2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package com
.sun
.star
.comp
.bridge
;
21 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
23 import com
.sun
.star
.lang
.XServiceInfo
;
24 import com
.sun
.star
.lang
.XTypeProvider
;
26 import com
.sun
.star
.test
.performance
.ComplexTypes
;
27 import com
.sun
.star
.test
.performance
.XPerformanceTest
;
29 import test
.testtools
.bridgetest
.BadConstructorArguments
;
30 import test
.testtools
.bridgetest
.Constructors
;
31 import test
.testtools
.bridgetest
.Constructors2
;
32 import test
.testtools
.bridgetest
.TestDataElements
;
33 import test
.testtools
.bridgetest
.TestElement
;
34 import test
.testtools
.bridgetest
.TestEnum
;
35 import test
.testtools
.bridgetest
.TestPolyStruct
;
36 import test
.testtools
.bridgetest
.TestPolyStruct2
;
37 import test
.testtools
.bridgetest
.TestStruct
;
38 import test
.testtools
.bridgetest
.SmallStruct
;
39 import test
.testtools
.bridgetest
.MediumStruct
;
40 import test
.testtools
.bridgetest
.BigStruct
;
41 import test
.testtools
.bridgetest
.TwoFloats
;
42 import test
.testtools
.bridgetest
.FourFloats
;
43 import test
.testtools
.bridgetest
.MixedFloatAndInteger
;
44 import test
.testtools
.bridgetest
.ThreeByteStruct
;
45 import test
.testtools
.bridgetest
.XBridgeTest
;
46 import test
.testtools
.bridgetest
.XBridgeTest2
;
47 import test
.testtools
.bridgetest
.XCurrentContextChecker
;
48 import test
.testtools
.bridgetest
.XMulti
;
49 import test
.testtools
.bridgetest
.XRecursiveCall
;
52 import com
.sun
.star
.lang
.IllegalArgumentException
;
53 import com
.sun
.star
.lang
.XMultiServiceFactory
;
54 import com
.sun
.star
.lang
.XSingleServiceFactory
;
56 import com
.sun
.star
.registry
.XRegistryKey
;
58 import com
.sun
.star
.uno
.Any
;
59 import com
.sun
.star
.uno
.Type
;
60 import com
.sun
.star
.uno
.XComponentContext
;
61 import com
.sun
.star
.uno
.XInterface
;
63 @SuppressWarnings("unchecked")
64 public class TestComponent
{
65 public static final boolean DEBUG
= false;
67 public static class _PerformancTestObject
implements XPerformanceTest
, XServiceInfo
, XTypeProvider
{
68 private static final String __serviceName
= "com.sun.star.comp.benchmark.JavaTestObject";
73 private double _double
;
74 private String _string
= "";
75 private Object _xInterface
;
77 private Object _interface_sequence
[] = new Object
[0];
78 private ComplexTypes _complexTypes
= new ComplexTypes();
81 public int getLong_attr() throws com
.sun
.star
.uno
.RuntimeException
{
85 public void setLong_attr( int _long_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
89 public long getHyper_attr() throws com
.sun
.star
.uno
.RuntimeException
{
93 public void setHyper_attr( long _hyper_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
97 public float getFloat_attr() throws com
.sun
.star
.uno
.RuntimeException
{
101 public void setFloat_attr( float _float_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
102 _float
= _float_attr
;
105 public double getDouble_attr() throws com
.sun
.star
.uno
.RuntimeException
{
109 public void setDouble_attr( double _double_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
110 _double
= _double_attr
;
113 public String
getString_attr() throws com
.sun
.star
.uno
.RuntimeException
{
117 public void setString_attr( String _string_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
118 _string
= _string_attr
;
121 public Object
getInterface_attr() throws com
.sun
.star
.uno
.RuntimeException
{
125 public void setInterface_attr( java
.lang
.Object _interface_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
126 _xInterface
= _interface_attr
;
129 public Object
getAny_attr() throws com
.sun
.star
.uno
.RuntimeException
{
133 public void setAny_attr(Object _any_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
137 public Object
[] getSequence_attr() throws com
.sun
.star
.uno
.RuntimeException
{
138 return _interface_sequence
;
141 public void setSequence_attr(Object
[] _sequence_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
142 _interface_sequence
= _sequence_attr
;
145 public ComplexTypes
getStruct_attr() throws com
.sun
.star
.uno
.RuntimeException
{
146 return _complexTypes
;
149 public void setStruct_attr( ComplexTypes _struct_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
150 _complexTypes
= _struct_attr
;
155 public void async() throws com
.sun
.star
.uno
.RuntimeException
{
158 public void sync( ) throws com
.sun
.star
.uno
.RuntimeException
{
161 public ComplexTypes
complex_in( /*IN*/ComplexTypes aVal
) throws com
.sun
.star
.uno
.RuntimeException
{
165 public ComplexTypes
complex_inout( /*INOUT*/ComplexTypes
[] aVal
) throws com
.sun
.star
.uno
.RuntimeException
{
169 public void complex_oneway( /*IN*/ComplexTypes aVal
) throws com
.sun
.star
.uno
.RuntimeException
{
172 public void complex_noreturn( /*IN*/ComplexTypes aVal
) throws com
.sun
.star
.uno
.RuntimeException
{
175 public XPerformanceTest
createObject( ) throws com
.sun
.star
.uno
.RuntimeException
{
176 return new _PerformancTestObject();
179 public int getLong() throws com
.sun
.star
.uno
.RuntimeException
{
183 public void setLong(/*IN*/int n
) throws com
.sun
.star
.uno
.RuntimeException
{
187 public long getHyper() throws com
.sun
.star
.uno
.RuntimeException
{
191 public void setHyper(/*IN*/long n
) throws com
.sun
.star
.uno
.RuntimeException
{
195 public float getFloat() throws com
.sun
.star
.uno
.RuntimeException
{
199 public void setFloat( /*IN*/float f
) throws com
.sun
.star
.uno
.RuntimeException
{
203 public double getDouble( ) throws com
.sun
.star
.uno
.RuntimeException
{
207 public void setDouble( /*IN*/double f
) throws com
.sun
.star
.uno
.RuntimeException
{
211 public String
getString( ) throws com
.sun
.star
.uno
.RuntimeException
{
215 public void setString( /*IN*/String s
) throws com
.sun
.star
.uno
.RuntimeException
{
219 public Object
getInterface( ) throws com
.sun
.star
.uno
.RuntimeException
{
223 public void setInterface( /*IN*/Object x
) throws com
.sun
.star
.uno
.RuntimeException
{
227 public Object
getAny( ) throws com
.sun
.star
.uno
.RuntimeException
{
231 public void setAny( /*IN*/java
.lang
.Object a
) throws com
.sun
.star
.uno
.RuntimeException
{
235 public Object
[] getSequence( ) throws com
.sun
.star
.uno
.RuntimeException
{
236 return _interface_sequence
;
239 public void setSequence( /*IN*/Object
[] seq
) throws com
.sun
.star
.uno
.RuntimeException
{
240 if(DEBUG
) System
.err
.println("#### " + getClass().getName() + ".setSequence:" + seq
);
242 _interface_sequence
= seq
;
245 public ComplexTypes
getStruct( ) throws com
.sun
.star
.uno
.RuntimeException
{
246 return _complexTypes
;
249 public void setStruct( /*IN*/ComplexTypes c
) throws com
.sun
.star
.uno
.RuntimeException
{
253 public void raiseRuntimeException( ) throws com
.sun
.star
.uno
.RuntimeException
{
254 throw new com
.sun
.star
.uno
.RuntimeException();
258 public String
getImplementationName() throws com
.sun
.star
.uno
.RuntimeException
{
259 return __serviceName
;
262 public boolean supportsService(String rServiceName
) throws com
.sun
.star
.uno
.RuntimeException
{
263 String rSNL
[] = getSupportedServiceNames();
265 for(int nPos
= rSNL
.length
; (nPos
--) != 0;) {
266 if (rSNL
[nPos
].equals(rServiceName
))
273 public String
[] getSupportedServiceNames() throws com
.sun
.star
.uno
.RuntimeException
{
274 return new String
[]{__serviceName
};
278 public Type
[] getTypes() throws com
.sun
.star
.uno
.RuntimeException
{
280 return new Type
[]{new Type(XPerformanceTest
.class), new Type(XServiceInfo
.class), new Type(XTypeProvider
.class)};
282 catch(Exception exception
) {
283 throw new com
.sun
.star
.uno
.RuntimeException(exception
);
287 public byte[] getImplementationId() throws com
.sun
.star
.uno
.RuntimeException
{
292 public static class _TestObject
implements XBridgeTest2
, XRecursiveCall
, XServiceInfo
, XTypeProvider
{
293 private static final String __serviceName
= "com.sun.star.test.bridge.JavaTestObject";
295 private boolean _bool
;
298 private short _short
;
299 private short _ushort
;
303 private long _uhyper
;
304 private float _float
;
305 private double _double
;
306 private String _string
;
308 private short _short2
;
309 private Object _xInterface
;
311 private TestEnum _testEnum
= TestEnum
.TEST
;
312 private TestElement _testElements
[] = new TestElement
[0];
313 private TestDataElements _testDataElements
= new TestDataElements();
315 private int _nLastCallId
;
316 private boolean _bFirstCall
;
317 private boolean _bSequenceOfCallTestPassed
;
319 private boolean[] arBool
;
320 private char[] arChar
;
321 private byte[] arByte
;
322 private short[] arShort
;
323 private short[] arUShort
;
324 private int[] arLong
;
325 private int[] arULong
;
326 private long[] arHyper
;
327 private long[] arUHyper
;
328 private float[] arFloat
;
329 private double[] arDouble
;
330 private String
[] arString
;
331 private Object
[] arObject
;
332 private Object
[] arAny
;
333 private TestEnum
[] arEnum
;
334 private int[][] arLong2
;
335 private int[][][] arLong3
;
336 public _TestObject(XMultiServiceFactory xMultiServiceFactory
) {
337 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".<init> " + xMultiServiceFactory
);
341 _bSequenceOfCallTestPassed
= true;
345 public void setValues(boolean bBool
,
362 TestElement testElements
[],
363 TestDataElements testDataElements
) throws com
.sun
.star
.uno
.RuntimeException
365 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".setValues:" + any
);
378 _testEnum
= testEnum
;
382 _xInterface
= xInterface
;
384 _testElements
= testElements
;
385 _testDataElements
= testDataElements
;
390 public TestDataElements
setValues2(/*INOUT*/boolean[] io_bool
,
391 /*INOUT*/char[] io_char
,
392 /*INOUT*/byte[] io_byte
,
393 /*INOUT*/short[] io_short
,
394 /*INOUT*/short[] io_ushort
,
395 /*INOUT*/int[] io_long
,
396 /*INOUT*/int[] io_ulong
,
397 /*INOUT*/long[] io_hyper
,
398 /*INOUT*/long[] io_uhyper
,
399 /*INOUT*/float[] io_float
,
400 /*INOUT*/double[] io_double
,
401 /*INOUT*/TestEnum
[] io_testEnum
,
402 /*INOUT*/String
[] io_string
,
403 /*INOUT*/byte[] io_byte2
,
404 /*INOUT*/short[] io_short2
,
405 /*INOUT*/Object
[] io_xInterface
,
406 /*INOUT*/Object
[] io_any
,
407 /*INOUT*/TestElement
[][] io_testElements
,
408 /*INOUT*/TestDataElements
[] io_testDataElements
) throws com
.sun
.star
.uno
.RuntimeException
410 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".setValues2:" + io_any
[0]);
415 _short
= io_short
[0];
416 _ushort
= io_ushort
[0];
418 _ulong
= io_ulong
[0];
419 _hyper
= io_hyper
[0];
420 _uhyper
= io_uhyper
[0];
421 _float
= io_float
[0];
422 _double
= io_double
[0];
423 _testEnum
= io_testEnum
[0];
424 _string
= io_string
[0];
425 _byte2
= io_byte2
[0];
426 _short2
= io_short2
[0];
427 _xInterface
= io_xInterface
[0];
429 _testElements
= io_testElements
[0];
430 _testDataElements
= io_testDataElements
[0];
432 io_testElements
[ 0 ] =
433 new TestElement
[] { io_testElements
[ 0 ][ 1 ], io_testElements
[ 0 ][ 0 ] };
435 return _testDataElements
;
438 public TestDataElements
getValues(/*OUT*/boolean[] o_bool
,
439 /*OUT*/char[] o_char
,
440 /*OUT*/byte[] o_byte
,
441 /*OUT*/short[] o_short
,
442 /*OUT*/short[] o_ushort
,
444 /*OUT*/int[] o_ulong
,
445 /*OUT*/long[] o_hyper
,
446 /*OUT*/long[] o_uhyper
,
447 /*OUT*/float[] o_float
,
448 /*OUT*/double[] o_double
,
449 /*OUT*/TestEnum
[] o_testEnum
,
450 /*OUT*/String
[] o_string
,
451 /*OUT*/byte[] o_byte2
,
452 /*OUT*/short[] o_short2
,
453 /*OUT*/Object
[] o_xInterface
,
454 /*OUT*/Object
[] o_any
,
455 /*OUT*/TestElement
[][] o_testElements
,
456 /*OUT*/TestDataElements
[] o_testDataElements
) throws com
.sun
.star
.uno
.RuntimeException
458 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".getValues:" + _any
);
464 o_ushort
[0] = _ushort
;
468 o_uhyper
[0] = _uhyper
;
470 o_double
[0] = _double
;
471 o_testEnum
[0] = _testEnum
;
472 o_string
[0] = _string
;
474 o_short2
[0] = _short2
;
475 o_xInterface
[0] = _xInterface
;
477 o_testElements
[0] = _testElements
;
478 o_testDataElements
[0] = _testDataElements
;
480 return _testDataElements
;
483 public SmallStruct
echoSmallStruct( SmallStruct i_Struct
) throws com
.sun
.star
.uno
.RuntimeException
{
487 public MediumStruct
echoMediumStruct( MediumStruct i_Struct
) throws com
.sun
.star
.uno
.RuntimeException
{
491 public BigStruct
echoBigStruct( BigStruct i_Struct
) throws com
.sun
.star
.uno
.RuntimeException
{
495 public TwoFloats
echoTwoFloats( TwoFloats i_Struct
) throws com
.sun
.star
.uno
.RuntimeException
{
499 public FourFloats
echoFourFloats( FourFloats i_Struct
) throws com
.sun
.star
.uno
.RuntimeException
{
503 public MixedFloatAndInteger
echoMixedFloatAndInteger( MixedFloatAndInteger i_Struct
) throws com
.sun
.star
.uno
.RuntimeException
{
507 public ThreeByteStruct
echoThreeByteStruct( ThreeByteStruct i_Struct
) throws com
.sun
.star
.uno
.RuntimeException
{
511 public int testPPCAlignment( long l1
, long l2
, int i1
, long l3
, int i2
) throws com
.sun
.star
.uno
.RuntimeException
{
515 public int testPPC64Alignment( double d1
, double d2
, double d3
, int i1
) throws com
.sun
.star
.uno
.RuntimeException
{
519 public double testTenDoubles( double d1
, double d2
, double d3
, double d4
, double d5
, double d6
, double d7
, double d8
, double d9
, double d10
) {
520 return d1
+ d2
+ d3
+ d4
+ d5
+ d6
+ d7
+ d8
+ d9
+ d10
;
524 public boolean getBool() throws com
.sun
.star
.uno
.RuntimeException
{
528 public void setBool(boolean bool
) throws com
.sun
.star
.uno
.RuntimeException
{
532 public byte getByte() throws com
.sun
.star
.uno
.RuntimeException
{
536 public void setByte(byte zbyte
) throws com
.sun
.star
.uno
.RuntimeException
{
540 public char getChar() throws com
.sun
.star
.uno
.RuntimeException
{
544 public void setChar(char zchar
) throws com
.sun
.star
.uno
.RuntimeException
{
548 public short getShort() throws com
.sun
.star
.uno
.RuntimeException
{
552 public void setShort(short zshort
) throws com
.sun
.star
.uno
.RuntimeException
{
556 public short getUShort() throws com
.sun
.star
.uno
.RuntimeException
{
560 public void setUShort(short ushort
) throws com
.sun
.star
.uno
.RuntimeException
{
564 public int getLong() throws com
.sun
.star
.uno
.RuntimeException
{
568 public void setLong(int zint
) throws com
.sun
.star
.uno
.RuntimeException
{
572 public int getULong() throws com
.sun
.star
.uno
.RuntimeException
{
576 public void setULong(int uint
) throws com
.sun
.star
.uno
.RuntimeException
{
580 public long getHyper() throws com
.sun
.star
.uno
.RuntimeException
{
584 public void setHyper(long hyper
) throws com
.sun
.star
.uno
.RuntimeException
{
588 public long getUHyper() throws com
.sun
.star
.uno
.RuntimeException
{
592 public void setUHyper(long uhyper
) throws com
.sun
.star
.uno
.RuntimeException
{
596 public float getFloat() throws com
.sun
.star
.uno
.RuntimeException
{
600 public void setFloat(float zfloat
) throws com
.sun
.star
.uno
.RuntimeException
{
604 public double getDouble() throws com
.sun
.star
.uno
.RuntimeException
{
608 public void setDouble(double zdouble
) throws com
.sun
.star
.uno
.RuntimeException
{
612 public TestEnum
getEnum() throws com
.sun
.star
.uno
.RuntimeException
{
616 public void setEnum(TestEnum testEnum
) throws com
.sun
.star
.uno
.RuntimeException
{
617 _testEnum
= testEnum
;
620 public String
getString() throws com
.sun
.star
.uno
.RuntimeException
{
624 public void setString(String string
) throws com
.sun
.star
.uno
.RuntimeException
{
628 public byte getByte2() throws com
.sun
.star
.uno
.RuntimeException
{
632 public void setByte2(byte zbyte
) throws com
.sun
.star
.uno
.RuntimeException
{
636 public short getShort2() throws com
.sun
.star
.uno
.RuntimeException
{
640 public void setShort2(short zshort
) throws com
.sun
.star
.uno
.RuntimeException
{
644 public Object
getInterface() throws com
.sun
.star
.uno
.RuntimeException
{
648 public void setInterface(Object zinterface
) throws com
.sun
.star
.uno
.RuntimeException
{
649 _xInterface
= zinterface
;
652 public Object
getAny() throws com
.sun
.star
.uno
.RuntimeException
{
653 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".setAny:" + _any
);
658 public void setAny(Object any
) throws com
.sun
.star
.uno
.RuntimeException
{
659 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".setAny:" + any
);
664 public TestElement
[] getSequence() throws com
.sun
.star
.uno
.RuntimeException
{
665 return _testElements
;
668 public void setSequence(TestElement testElements
[]) throws com
.sun
.star
.uno
.RuntimeException
{
669 _testElements
= testElements
;
672 public TestDataElements
getStruct() throws com
.sun
.star
.uno
.RuntimeException
{
673 return _testDataElements
;
676 public void setStruct(TestDataElements testDataElements
) throws com
.sun
.star
.uno
.RuntimeException
{
677 _testDataElements
= testDataElements
;
680 public int getRaiseAttr1() {
681 throw new com
.sun
.star
.uno
.RuntimeException();
684 public void setRaiseAttr1(int n
) throws IllegalArgumentException
{
685 throw new IllegalArgumentException();
688 public int getRaiseAttr2() throws IllegalArgumentException
{
689 throw new IllegalArgumentException();
692 public TestPolyStruct
transportPolyBoolean(TestPolyStruct arg
) {
693 Boolean dummy
= (Boolean
) arg
.member
;
697 public void transportPolyHyper(TestPolyStruct
[] arg
) {
698 Long dummy
= (Long
) arg
[0].member
;
701 public void transportPolySequence(
702 TestPolyStruct arg1
, TestPolyStruct
[] arg2
)
704 Object
[] dummy
= (Object
[]) arg1
.member
;
708 public TestPolyStruct
getNullPolyLong() {
709 return new TestPolyStruct();
712 public TestPolyStruct
getNullPolyString() {
713 return new TestPolyStruct();
716 public TestPolyStruct
getNullPolyType() {
717 return new TestPolyStruct();
720 public TestPolyStruct
getNullPolyAny() {
721 return new TestPolyStruct();
724 public TestPolyStruct
getNullPolySequence() {
725 return new TestPolyStruct();
728 public TestPolyStruct
getNullPolyEnum() {
729 return new TestPolyStruct();
732 public TestPolyStruct
getNullPolyBadEnum() {
733 return new TestPolyStruct();
736 public TestPolyStruct
getNullPolyStruct() {
737 return new TestPolyStruct();
740 public TestPolyStruct
getNullPolyInterface() {
741 return new TestPolyStruct();
744 public Object
transportAny(Object value
) throws com
.sun
.star
.uno
.RuntimeException
{
748 public void call(int nCallId
, int nWaitMUSEC
) throws com
.sun
.star
.uno
.RuntimeException
{
750 Thread
.sleep(nWaitMUSEC
/ 10000);
752 catch(InterruptedException interruptedException
) {
753 throw new com
.sun
.star
.uno
.RuntimeException(interruptedException
);
760 _bSequenceOfCallTestPassed
= _bSequenceOfCallTestPassed
&& (nCallId
> _nLastCallId
);
762 _nLastCallId
= nCallId
;
765 public void callOneway( int nCallId
, int nWaitMUSEC
) throws com
.sun
.star
.uno
.RuntimeException
{
767 Thread
.sleep(nWaitMUSEC
/ 10000);
769 catch(InterruptedException interruptedException
) {
770 throw new com
.sun
.star
.uno
.RuntimeException(interruptedException
);
773 _bSequenceOfCallTestPassed
= _bSequenceOfCallTestPassed
&& (nCallId
> _nLastCallId
);
774 _nLastCallId
= nCallId
;
777 public boolean sequenceOfCallTestPassed() throws com
.sun
.star
.uno
.RuntimeException
{
778 return _bSequenceOfCallTestPassed
;
781 public synchronized void callRecursivly(XRecursiveCall xCall
, int nToCall
) throws com
.sun
.star
.uno
.RuntimeException
{
785 xCall
.callRecursivly(this , nToCall
);
789 public synchronized void startRecursiveCall(XRecursiveCall xCall
, int nToCall
) throws com
.sun
.star
.uno
.RuntimeException
{
793 xCall
.callRecursivly( this , nToCall
);
797 public XMulti
getMulti() {
798 return new XMulti() {
799 public double getatt1() {
803 public void setatt1(double value
) {
807 public int fn11(int arg
) {
811 public String
fn12(String arg
) {
815 public int fn21(int arg
) {
819 public String
fn22(String arg
) {
823 public double getatt3() {
827 public void setatt3(double value
) {
831 public int fn31(int arg
) {
835 public String
fn32(String arg
) {
843 public int fn41(int arg
) {
847 public int fn61(int arg
) {
851 public String
fn62(String arg
) {
855 public int fn71(int arg
) {
859 public String
fn72(String arg
) {
867 private double attribute1
= 0.0;
868 private double attribute3
= 0.0;
872 private static final class CheckFailed
extends Exception
{
873 CheckFailed(String message
) {
878 private static void checkEqual(int value
, int argument
)
881 if (argument
!= value
) {
882 throw new CheckFailed(value
+ " != " + argument
);
886 private static void checkEqual(double value
, double argument
)
889 if (argument
!= value
) {
890 throw new CheckFailed(value
+ " != " + argument
);
894 private static void checkEqual(String value
, String argument
)
897 if (!argument
.equals(value
)) {
898 throw new CheckFailed(value
+ " != " + argument
);
902 public String
testMulti(XMulti multi
) {
904 checkEqual(0.0, multi
.getatt1());
906 checkEqual(0.1, multi
.getatt1());
907 checkEqual(11 * 1, multi
.fn11(1));
908 checkEqual("12" + "abc", multi
.fn12("abc"));
909 checkEqual(21 * 2, multi
.fn21(2));
910 checkEqual("22" + "de", multi
.fn22("de"));
911 checkEqual(0.0, multi
.getatt3());
913 checkEqual(0.3, multi
.getatt3());
914 checkEqual(31 * 3, multi
.fn31(3));
915 checkEqual("32" + "f", multi
.fn32("f"));
916 checkEqual(33, multi
.fn33());
917 checkEqual(41 * 4, multi
.fn41(4));
918 checkEqual(61 * 6, multi
.fn61(6));
919 checkEqual("62", multi
.fn62(""));
920 checkEqual(71 * 7, multi
.fn71(7));
921 checkEqual("72" + "g", multi
.fn72("g"));
922 checkEqual(73, multi
.fn73());
923 } catch (CheckFailed f
) {
924 return f
.getMessage();
930 public TestDataElements
raiseException(short nArgumentPos
, String rMsg
, Object xContext
)
931 throws com
.sun
.star
.lang
.IllegalArgumentException
,
932 com
.sun
.star
.uno
.RuntimeException
934 throw new com
.sun
.star
.lang
.IllegalArgumentException(rMsg
, xContext
, nArgumentPos
);
937 public void raiseRuntimeExceptionOneway(String rMsg
, Object xContext
) throws com
.sun
.star
.uno
.RuntimeException
{
938 throw new com
.sun
.star
.uno
.RuntimeException(rMsg
, xContext
);
941 private void dothrow( com
.sun
.star
.uno
.RuntimeException t
)
942 throws com
.sun
.star
.uno
.RuntimeException
946 public int getRuntimeException()
947 throws com
.sun
.star
.uno
.RuntimeException
949 dothrow( new com
.sun
.star
.uno
.RuntimeException(
950 _string
, _xInterface
) );
954 public void setRuntimeException(int _runtimeexception
) throws com
.sun
.star
.uno
.RuntimeException
{
955 throw new com
.sun
.star
.uno
.RuntimeException(_string
, _xInterface
);
961 public String
getImplementationName() throws com
.sun
.star
.uno
.RuntimeException
{
962 return __serviceName
;
965 public boolean supportsService(String rServiceName
) throws com
.sun
.star
.uno
.RuntimeException
{
966 String rSNL
[] = getSupportedServiceNames();
968 for(int nPos
= rSNL
.length
; (nPos
--) != 0;) {
969 if (rSNL
[nPos
].equals(rServiceName
))
976 public String
[] getSupportedServiceNames() throws com
.sun
.star
.uno
.RuntimeException
{
977 return new String
[]{__serviceName
};
981 public Type
[] getTypes() throws com
.sun
.star
.uno
.RuntimeException
{
983 return new Type
[]{new Type(XBridgeTest
.class), new Type(XRecursiveCall
.class), new Type(XServiceInfo
.class), new Type(XTypeProvider
.class)};
985 catch(Exception exception
) {
986 throw new com
.sun
.star
.uno
.RuntimeException(exception
);
990 public byte[] getImplementationId() throws com
.sun
.star
.uno
.RuntimeException
{
995 public boolean[] setSequenceBool( /*IN*/boolean[] aSeq
)
1000 public char[] setSequenceChar( /*IN*/char[] aSeq
)
1005 public byte[] setSequenceByte( /*IN*/byte[] aSeq
)
1010 public short[] setSequenceShort( /*IN*/short[] aSeq
)
1015 public short[] setSequenceUShort( /*IN*/short[] aSeq
)
1020 public int[] setSequenceLong( /*IN*/int[] aSeq
)
1025 public int[] setSequenceULong( /*IN*/int[] aSeq
)
1030 public long[] setSequenceHyper( /*IN*/long[] aSeq
)
1035 public long[] setSequenceUHyper( /*IN*/long[] aSeq
)
1040 public float[] setSequenceFloat( /*IN*/float[] aSeq
)
1045 public double[] setSequenceDouble( /*IN*/double[] aSeq
)
1050 public TestEnum
[] setSequenceEnum( /*IN*/TestEnum
[] aSeq
)
1055 public String
[] setSequenceString( /*IN*/String
[] aSeq
)
1060 public java
.lang
.Object
[] setSequenceXInterface( /*IN*/java
.lang
.Object
[] aSeq
)
1065 public java
.lang
.Object
[] setSequenceAny( /*IN*/java
.lang
.Object
[] aSeq
)
1070 public TestElement
[] setSequenceStruct( /*IN*/TestElement
[] aSeq
)
1072 _testElements
= aSeq
;
1075 public int[][] setDim2( /*IN*/int[][] aSeq
)
1080 public int[][][] setDim3( /*IN*/int[][][] aSeq
)
1085 public void setSequencesInOut( /*INOUT*/boolean[][] aSeqBoolean
,
1086 /*INOUT*/char[][] aSeqChar
, /*INOUT*/byte[][] aSeqByte
,
1087 /*INOUT*/short[][] aSeqShort
, /*INOUT*/short[][] aSeqUShort
,
1088 /*INOUT*/int[][] aSeqLong
, /*INOUT*/int[][] aSeqULong
,
1089 /*INOUT*/long[][] aSeqHyper
, /*INOUT*/long[][] aSeqUHyper
,
1090 /*INOUT*/float[][] aSeqFloat
, /*INOUT*/double[][] aSeqDouble
,
1091 /*INOUT*/TestEnum
[][] aSeqEnum
, /*INOUT*/String
[][] aSeqString
,
1092 /*INOUT*/java
.lang
.Object
[][] aSeqXInterface
,
1093 /*INOUT*/java
.lang
.Object
[][] aSeqAny
,
1094 /*INOUT*/int[][][] aSeqDim2
, /*INOUT*/int[][][][] aSeqDim3
)
1096 arBool
= aSeqBoolean
[0];
1097 arChar
= aSeqChar
[0];
1098 arByte
= aSeqByte
[0];
1099 arShort
= aSeqShort
[0];
1100 arUShort
= aSeqUShort
[0];
1101 arLong
= aSeqLong
[0];
1102 arULong
= aSeqULong
[0];
1103 arFloat
= aSeqFloat
[0];
1104 arDouble
= aSeqDouble
[0];
1105 arEnum
= aSeqEnum
[0];
1106 arString
= aSeqString
[0];
1107 arObject
= aSeqXInterface
[0];
1109 arLong2
= aSeqDim2
[0];
1110 arLong3
= aSeqDim3
[0];
1112 public void setSequencesOut( /*OUT*/boolean[][] aSeqBoolean
, /*OUT*/char[][] aSeqChar
,
1113 /*OUT*/byte[][] aSeqByte
, /*OUT*/short[][] aSeqShort
,
1114 /*OUT*/short[][] aSeqUShort
, /*OUT*/int[][] aSeqLong
,
1115 /*OUT*/int[][] aSeqULong
, /*OUT*/long[][] aSeqHyper
,
1116 /*OUT*/long[][] aSeqUHyper
, /*OUT*/float[][] aSeqFloat
,
1117 /*OUT*/double[][] aSeqDouble
, /*OUT*/TestEnum
[][] aSeqEnum
,
1118 /*OUT*/String
[][] aSeqString
,
1119 /*OUT*/java
.lang
.Object
[][] aSeqXInterface
,
1120 /*OUT*/java
.lang
.Object
[][] aSeqAny
, /*OUT*/int[][][] aSeqDim2
,
1121 /*OUT*/int[][][][] aSeqDim3
)
1123 aSeqBoolean
[0] = arBool
;
1124 aSeqChar
[0] = arChar
;
1125 aSeqByte
[0] = arByte
;
1126 aSeqShort
[0] = arShort
;
1127 aSeqUShort
[0] = arUShort
;
1128 aSeqLong
[0] = arLong
;
1129 aSeqULong
[0] = arULong
;
1130 aSeqHyper
[0] = arHyper
;
1131 aSeqUHyper
[0] = arUHyper
;
1132 aSeqFloat
[0] = arFloat
;
1133 aSeqDouble
[0] = arDouble
;
1134 aSeqEnum
[0] = arEnum
;
1135 aSeqString
[0] = arString
;
1136 aSeqXInterface
[0] = arObject
;
1138 aSeqDim2
[0] = arLong2
;
1139 aSeqDim3
[0] = arLong3
;
1142 public void testConstructorsService(XComponentContext context
)
1143 throws BadConstructorArguments
1145 Constructors
.create1(context
,
1159 new Any(Type
.BOOLEAN
, Boolean
.TRUE
),
1160 new boolean[] { true },
1161 new byte[] { Byte
.MIN_VALUE
},
1162 new short[] { Short
.MIN_VALUE
},
1163 new short[] { (short) -1 },
1164 new int[] { Integer
.MIN_VALUE
},
1166 new long[] { Long
.MIN_VALUE
},
1168 new float[] { 0.123f
},
1169 new double[] { 0.456 },
1171 new String
[] { "test" },
1172 new Type
[] { Type
.ANY
},
1173 new Boolean
[] { Boolean
.TRUE
},
1174 new boolean[][] { new boolean[] { true } },
1176 new Object
[] { new Any(Type
.BOOLEAN
, Boolean
.TRUE
) } },
1177 new TestEnum
[] { TestEnum
.TWO
},
1178 new TestStruct
[] { new TestStruct(10) },
1179 new TestPolyStruct
[] { new TestPolyStruct(Boolean
.TRUE
) },
1180 new TestPolyStruct
[] {
1181 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
)) },
1182 new Object
[] { null },
1185 new TestPolyStruct(Boolean
.TRUE
),
1186 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
)),
1188 Constructors
.create2(context
, new Object
[] {
1190 Byte
.valueOf(Byte
.MIN_VALUE
),
1191 Short
.valueOf(Short
.MIN_VALUE
),
1192 new Any(Type
.UNSIGNED_SHORT
, Short
.valueOf((short) -1)),
1193 Integer
.valueOf(Integer
.MIN_VALUE
),
1194 new Any(Type
.UNSIGNED_LONG
, Integer
.valueOf(-1)),
1195 Long
.valueOf(Long
.MIN_VALUE
),
1196 new Any(Type
.UNSIGNED_HYPER
, Long
.valueOf(-1L)),
1202 new Any(Type
.BOOLEAN
, Boolean
.TRUE
),
1203 new boolean[] { true },
1204 new byte[] { Byte
.MIN_VALUE
},
1205 new short[] { Short
.MIN_VALUE
},
1207 new Type("[]unsigned short"), new short[] { (short) -1 }),
1208 new int[] { Integer
.MIN_VALUE
},
1209 new Any(new Type("[]unsigned long"), new int[] { -1 }),
1210 new long[] { Long
.MIN_VALUE
},
1211 new Any(new Type("[]unsigned hyper"), new long[] { -1L }),
1212 new float[] { 0.123f
},
1213 new double[] { 0.456 },
1215 new String
[] { "test" },
1216 new Type
[] { Type
.ANY
},
1217 new Any(new Type("[]any"), new Boolean
[] { Boolean
.TRUE
}),
1218 new boolean[][] { new boolean[] { true } },
1220 new Object
[] { new Any(Type
.BOOLEAN
, Boolean
.TRUE
) } },
1221 new TestEnum
[] { TestEnum
.TWO
},
1222 new TestStruct
[] { new TestStruct(10) },
1225 "[]test.testtools.bridgetest.TestPolyStruct<boolean>"),
1226 new TestPolyStruct
[] { new TestPolyStruct(Boolean
.TRUE
) }),
1228 new Type("[]test.testtools.bridgetest.TestPolyStruct<any>"),
1229 new TestPolyStruct
[] {
1230 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
))
1232 new XInterface
[] { null },
1237 "test.testtools.bridgetest.TestPolyStruct<boolean>"),
1238 new TestPolyStruct(Boolean
.TRUE
)),
1240 new Type("test.testtools.bridgetest.TestPolyStruct<any>"),
1241 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
))),
1243 Constructors2
.create1(
1245 new TestPolyStruct(Type
.LONG
),
1246 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
)),
1247 new TestPolyStruct(Boolean
.TRUE
),
1248 new TestPolyStruct(Byte
.valueOf(Byte
.MIN_VALUE
)),
1249 new TestPolyStruct(Short
.valueOf(Short
.MIN_VALUE
)),
1250 new TestPolyStruct(Integer
.valueOf(Integer
.MIN_VALUE
)),
1251 new TestPolyStruct(Long
.valueOf(Long
.MIN_VALUE
)),
1252 new TestPolyStruct(new Character('X')),
1253 new TestPolyStruct("test"),
1254 new TestPolyStruct(new Float(0.123f
)),
1255 new TestPolyStruct(new Double(0.456)),
1256 new TestPolyStruct(new com
.sun
.star
.lib
.uno
.helper
.ComponentBase()),
1257 new TestPolyStruct(new com
.sun
.star
.lib
.uno
.helper
.ComponentBase()),
1258 new TestPolyStruct(TestEnum
.TWO
),
1259 new TestPolyStruct(new TestPolyStruct2(new Character('X'),
1260 new Any(Type
.BOOLEAN
, Boolean
.TRUE
))),
1261 new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2(
1262 new Character('X'), new Any(Type
.BOOLEAN
, Boolean
.TRUE
)), "test")),
1263 new TestPolyStruct2("test", new TestPolyStruct2(new Character('X'),
1264 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
)))),
1265 new TestPolyStruct2( new TestPolyStruct2(new Character('X'),
1266 new Any(Type
.BOOLEAN
, Boolean
.TRUE
)), new TestPolyStruct(new Character('X'))),
1267 new TestPolyStruct(new Type
[] { Type
.LONG
}),
1268 new TestPolyStruct(new Any
[] { new Any(Type
.BOOLEAN
, Boolean
.TRUE
) }),
1269 new TestPolyStruct(new boolean[] {true}),
1270 new TestPolyStruct(new byte[] {Byte
.MIN_VALUE
}),
1271 new TestPolyStruct(new short[] {Short
.MIN_VALUE
}),
1272 new TestPolyStruct(new int[] {Integer
.MIN_VALUE
}),
1273 new TestPolyStruct(new long[] {Long
.MIN_VALUE
}),
1274 new TestPolyStruct(new char[] {'X'}),
1275 new TestPolyStruct(new String
[] {"test"}),
1276 new TestPolyStruct(new float[] {0.123f
}),
1277 new TestPolyStruct(new double[] {0.456d
}),
1278 new TestPolyStruct(new Object
[] {new com
.sun
.star
.lib
.uno
.helper
.ComponentBase()}),
1279 new TestPolyStruct(new com
.sun
.star
.lang
.XComponent
[] {new com
.sun
.star
.lib
.uno
.helper
.ComponentBase()}),
1280 new TestPolyStruct(new TestEnum
[] {TestEnum
.TWO
}),
1281 new TestPolyStruct(new TestPolyStruct2
[] {new TestPolyStruct2(
1282 new Character('X'), new Any
[] {new Any(Type
.BOOLEAN
, Boolean
.TRUE
)})}),
1283 new TestPolyStruct(new TestPolyStruct2
[] {new TestPolyStruct2(
1284 new TestPolyStruct(new Character('X')), new Any
[] {new Any(Type
.BOOLEAN
, Boolean
.TRUE
)})}),
1285 new TestPolyStruct(new int[][] { new int[] {Integer
.MIN_VALUE
} }),
1286 new TestPolyStruct
[]{ new TestPolyStruct(Integer
.valueOf(Integer
.MIN_VALUE
))},
1287 new TestPolyStruct
[]{new TestPolyStruct(new TestPolyStruct2(
1288 new Character('X'), new Any(Type
.BOOLEAN
, Boolean
.TRUE
)))},
1289 new TestPolyStruct
[]{new TestPolyStruct(new TestPolyStruct2(
1290 new TestPolyStruct2(new Character('X'), new Any(Type
.BOOLEAN
, Boolean
.TRUE
)), "test"))},
1291 new TestPolyStruct2
[]{new TestPolyStruct2("test", new TestPolyStruct2(
1292 new Character('X'), new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
))))},
1293 new TestPolyStruct2
[]{new TestPolyStruct2(new TestPolyStruct2(new Character('X'), new Any(
1294 Type
.BOOLEAN
, Boolean
.TRUE
)),new TestPolyStruct(new Character('X')))},
1295 new TestPolyStruct
[][]{new TestPolyStruct
[]{new TestPolyStruct(new Character('X'))}},
1296 new TestPolyStruct
[][]{new TestPolyStruct
[]{
1297 new TestPolyStruct(new TestPolyStruct2(new Character('X'), new Any(Type
.BOOLEAN
, Boolean
.TRUE
)))}},
1298 new TestPolyStruct
[][]{new TestPolyStruct
[] {new TestPolyStruct(new TestPolyStruct2(
1299 new TestPolyStruct2(new Character('X'),new Any(Type
.BOOLEAN
, Boolean
.TRUE
)), "test"))}},
1300 new TestPolyStruct2
[][]{new TestPolyStruct2
[]{new TestPolyStruct2(
1301 "test", new TestPolyStruct2(new Character('X'),new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
))))}},
1302 new TestPolyStruct2
[][]{new TestPolyStruct2
[]{new TestPolyStruct2(
1303 new TestPolyStruct2(new Character('X'),new Any(Type
.BOOLEAN
, Boolean
.TRUE
)),
1304 new TestPolyStruct(new Character('X')))}});
1307 public XCurrentContextChecker
getCurrentContextChecker() {
1308 return new CurrentContextChecker();
1313 * Gives a factory for creating the service.
1314 * This method is called by the <code>JavaLoader</code>
1316 * @return returns a <code>XSingleServiceFactory</code> for creating the component
1317 * @param implName the name of the implementation for which a service is desired
1318 * @param multiFactory the service manager to be uses if needed
1319 * @param regKey the registryKey
1320 * @see com.sun.star.comp.loader.JavaLoader
1322 public static XSingleServiceFactory
__getServiceFactory(String implName
,
1323 XMultiServiceFactory multiFactory
,
1324 XRegistryKey regKey
)
1326 XSingleServiceFactory xSingleServiceFactory
= null;
1328 if(implName
.equals(_TestObject
.class.getName()))
1329 xSingleServiceFactory
= FactoryHelper
.getServiceFactory(_TestObject
.class,
1330 _TestObject
.__serviceName
,
1334 else if(implName
.equals(_PerformancTestObject
.class.getName()))
1335 xSingleServiceFactory
= FactoryHelper
.getServiceFactory(_PerformancTestObject
.class,
1336 _PerformancTestObject
.__serviceName
,
1340 return xSingleServiceFactory
;