Version 7.1.7.1, tag libreoffice-7.1.7.1
[LibreOffice.git] / testtools / com / sun / star / comp / bridge / TestComponent.java
blob7d59de570591379505e52954b41677c5dafac1cc
1 /*
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";
70 private int _long;
71 private long _hyper;
72 private float _float;
73 private double _double;
74 private String _string = "";
75 private Object _xInterface;
76 private Object _any;
77 private Object _interface_sequence[] = new Object[0];
78 private ComplexTypes _complexTypes = new ComplexTypes();
80 // Attributes
81 public int getLong_attr() throws com.sun.star.uno.RuntimeException {
82 return _long;
85 public void setLong_attr( int _long_attr ) throws com.sun.star.uno.RuntimeException {
86 _long = _long_attr;
89 public long getHyper_attr() throws com.sun.star.uno.RuntimeException {
90 return _hyper;
93 public void setHyper_attr( long _hyper_attr ) throws com.sun.star.uno.RuntimeException {
94 _hyper = _hyper_attr;
97 public float getFloat_attr() throws com.sun.star.uno.RuntimeException {
98 return _float;
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 {
106 return _double;
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 {
114 return _string;
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 {
122 return _xInterface;
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 {
130 return _any;
133 public void setAny_attr(Object _any_attr ) throws com.sun.star.uno.RuntimeException {
134 _any = _any_attr;
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;
154 // Methods
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 {
162 return aVal;
165 public ComplexTypes complex_inout( /*INOUT*/ComplexTypes[] aVal ) throws com.sun.star.uno.RuntimeException {
166 return aVal[0];
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 {
180 return _long;
183 public void setLong(/*IN*/int n) throws com.sun.star.uno.RuntimeException {
184 _long = n;
187 public long getHyper() throws com.sun.star.uno.RuntimeException {
188 return _hyper;
191 public void setHyper(/*IN*/long n) throws com.sun.star.uno.RuntimeException {
192 _hyper = n;
195 public float getFloat() throws com.sun.star.uno.RuntimeException {
196 return _float;
199 public void setFloat( /*IN*/float f ) throws com.sun.star.uno.RuntimeException {
200 _float = f;
203 public double getDouble( ) throws com.sun.star.uno.RuntimeException {
204 return _double;
207 public void setDouble( /*IN*/double f ) throws com.sun.star.uno.RuntimeException {
208 _double = f;
211 public String getString( ) throws com.sun.star.uno.RuntimeException {
212 return _string;
215 public void setString( /*IN*/String s ) throws com.sun.star.uno.RuntimeException {
216 _string = s;
219 public Object getInterface( ) throws com.sun.star.uno.RuntimeException {
220 return _xInterface;
223 public void setInterface( /*IN*/Object x ) throws com.sun.star.uno.RuntimeException {
224 _xInterface = x;
227 public Object getAny( ) throws com.sun.star.uno.RuntimeException {
228 return _any;
231 public void setAny( /*IN*/java.lang.Object a ) throws com.sun.star.uno.RuntimeException {
232 _any = a;
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 {
250 _complexTypes = c;
253 public void raiseRuntimeException( ) throws com.sun.star.uno.RuntimeException {
254 throw new com.sun.star.uno.RuntimeException();
257 // XServiceInfo
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))
267 return true;
270 return false;
273 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
274 return new String[]{__serviceName};
277 // XTypeProvider
278 public Type[] getTypes() throws com.sun.star.uno.RuntimeException {
279 try {
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 {
288 return new byte[0];
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;
296 private char _char;
297 private byte _byte;
298 private short _short;
299 private short _ushort;
300 private int _long;
301 private int _ulong;
302 private long _hyper;
303 private long _uhyper;
304 private float _float;
305 private double _double;
306 private String _string;
307 private byte _byte2;
308 private short _short2;
309 private Object _xInterface;
310 private Object _any;
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);
339 _nLastCallId = 0;
340 _bFirstCall = true;
341 _bSequenceOfCallTestPassed = true;
345 public void setValues(boolean bBool,
346 char cChar,
347 byte nByte,
348 short nShort,
349 short nUShort,
350 int nLong,
351 int nULong,
352 long nHyper,
353 long nUHyper,
354 float fFloat,
355 double fDouble,
356 TestEnum testEnum,
357 String string,
358 byte nByte2,
359 short nShort2,
360 Object xInterface,
361 Object any,
362 TestElement testElements[],
363 TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException
365 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues:" + any);
367 _bool = bBool;
368 _char = cChar;
369 _byte = nByte;
370 _short = nShort;
371 _ushort = nUShort;
372 _long = nLong;
373 _ulong = nULong;
374 _hyper = nHyper;
375 _uhyper = nUHyper;
376 _float = fFloat;
377 _double = fDouble;
378 _testEnum = testEnum;
379 _string = string;
380 _byte2 = nByte2;
381 _short2 = nShort2;
382 _xInterface = xInterface;
383 _any = any;
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]);
412 _bool = io_bool[0];
413 _char = io_char[0];
414 _byte = io_byte[0];
415 _short = io_short[0];
416 _ushort = io_ushort[0];
417 _long = io_long[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];
428 _any = io_any[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,
443 /*OUT*/int[] o_long,
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);
460 o_bool[0] = _bool;
461 o_char[0] = _char;
462 o_byte[0] = _byte;
463 o_short[0] = _short;
464 o_ushort[0] = _ushort;
465 o_long[0] = _long;
466 o_ulong[0] = _ulong;
467 o_hyper[0] = _hyper;
468 o_uhyper[0] = _uhyper;
469 o_float[0] = _float;
470 o_double[0] = _double;
471 o_testEnum[0] = _testEnum;
472 o_string[0] = _string;
473 o_byte2[0] = _byte2;
474 o_short2[0] = _short2;
475 o_xInterface[0] = _xInterface;
476 o_any[0] = _any;
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 {
484 return i_Struct;
487 public MediumStruct echoMediumStruct( MediumStruct i_Struct) throws com.sun.star.uno.RuntimeException {
488 return i_Struct;
491 public BigStruct echoBigStruct( BigStruct i_Struct) throws com.sun.star.uno.RuntimeException {
492 return i_Struct;
495 public TwoFloats echoTwoFloats( TwoFloats i_Struct) throws com.sun.star.uno.RuntimeException {
496 return i_Struct;
499 public FourFloats echoFourFloats( FourFloats i_Struct) throws com.sun.star.uno.RuntimeException {
500 return i_Struct;
503 public MixedFloatAndInteger echoMixedFloatAndInteger( MixedFloatAndInteger i_Struct) throws com.sun.star.uno.RuntimeException {
504 return i_Struct;
507 public ThreeByteStruct echoThreeByteStruct( ThreeByteStruct i_Struct) throws com.sun.star.uno.RuntimeException {
508 return i_Struct;
511 public int testPPCAlignment( long l1, long l2, int i1, long l3, int i2 ) throws com.sun.star.uno.RuntimeException {
512 return i2;
515 public int testPPC64Alignment( double d1, double d2, double d3, int i1 ) throws com.sun.star.uno.RuntimeException {
516 return i1;
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;
523 // Attributes
524 public boolean getBool() throws com.sun.star.uno.RuntimeException {
525 return _bool;
528 public void setBool(boolean bool) throws com.sun.star.uno.RuntimeException {
529 _bool = bool;
532 public byte getByte() throws com.sun.star.uno.RuntimeException {
533 return _byte;
536 public void setByte(byte zbyte) throws com.sun.star.uno.RuntimeException {
537 _byte = zbyte;
540 public char getChar() throws com.sun.star.uno.RuntimeException {
541 return _char;
544 public void setChar(char zchar) throws com.sun.star.uno.RuntimeException {
545 _char = zchar;
548 public short getShort() throws com.sun.star.uno.RuntimeException {
549 return _short;
552 public void setShort(short zshort) throws com.sun.star.uno.RuntimeException {
553 _short = zshort;
556 public short getUShort() throws com.sun.star.uno.RuntimeException {
557 return _ushort;
560 public void setUShort(short ushort) throws com.sun.star.uno.RuntimeException {
561 _ushort = ushort;
564 public int getLong() throws com.sun.star.uno.RuntimeException {
565 return _long;
568 public void setLong(int zint) throws com.sun.star.uno.RuntimeException {
569 _long = zint;
572 public int getULong() throws com.sun.star.uno.RuntimeException {
573 return _ulong;
576 public void setULong(int uint) throws com.sun.star.uno.RuntimeException {
577 _ulong = uint;
580 public long getHyper() throws com.sun.star.uno.RuntimeException {
581 return _hyper;
584 public void setHyper(long hyper) throws com.sun.star.uno.RuntimeException {
585 _hyper = hyper;
588 public long getUHyper() throws com.sun.star.uno.RuntimeException {
589 return _uhyper;
592 public void setUHyper(long uhyper) throws com.sun.star.uno.RuntimeException {
593 _uhyper = uhyper;
596 public float getFloat() throws com.sun.star.uno.RuntimeException {
597 return _float;
600 public void setFloat(float zfloat) throws com.sun.star.uno.RuntimeException {
601 _float = zfloat;
604 public double getDouble() throws com.sun.star.uno.RuntimeException {
605 return _double;
608 public void setDouble(double zdouble) throws com.sun.star.uno.RuntimeException {
609 _double = zdouble;
612 public TestEnum getEnum() throws com.sun.star.uno.RuntimeException {
613 return _testEnum;
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 {
621 return _string;
624 public void setString(String string) throws com.sun.star.uno.RuntimeException {
625 _string = string;
628 public byte getByte2() throws com.sun.star.uno.RuntimeException {
629 return _byte2;
632 public void setByte2(byte zbyte) throws com.sun.star.uno.RuntimeException {
633 _byte2 = zbyte;
636 public short getShort2() throws com.sun.star.uno.RuntimeException {
637 return _short2;
640 public void setShort2(short zshort) throws com.sun.star.uno.RuntimeException {
641 _short2 = zshort;
644 public Object getInterface() throws com.sun.star.uno.RuntimeException {
645 return _xInterface;
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);
655 return _any;
658 public void setAny(Object any) throws com.sun.star.uno.RuntimeException {
659 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + any);
661 _any = 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;
694 return arg;
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;
705 arg2[0] = arg1;
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 {
745 return value;
748 public void call(int nCallId , int nWaitMUSEC) throws com.sun.star.uno.RuntimeException {
749 try {
750 Thread.sleep(nWaitMUSEC / 10000);
752 catch(InterruptedException interruptedException) {
753 throw new com.sun.star.uno.RuntimeException(interruptedException);
756 if(_bFirstCall)
757 _bFirstCall = false;
759 else
760 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
762 _nLastCallId = nCallId;
765 public void callOneway( int nCallId , int nWaitMUSEC ) throws com.sun.star.uno.RuntimeException {
766 try {
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 {
782 if(nToCall != 0)
784 nToCall --;
785 xCall.callRecursivly(this , nToCall);
789 public synchronized void startRecursiveCall(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException {
790 if(nToCall != 0)
792 nToCall --;
793 xCall.callRecursivly( this , nToCall );
797 public XMulti getMulti() {
798 return new XMulti() {
799 public double getatt1() {
800 return attribute1;
803 public void setatt1(double value) {
804 attribute1 = value;
807 public int fn11(int arg) {
808 return 11 * arg;
811 public String fn12(String arg) {
812 return "12" + arg;
815 public int fn21(int arg) {
816 return 21 * arg;
819 public String fn22(String arg) {
820 return "22" + arg;
823 public double getatt3() {
824 return attribute3;
827 public void setatt3(double value) {
828 attribute3 = value;
831 public int fn31(int arg) {
832 return 31 * arg;
835 public String fn32(String arg) {
836 return "32" + arg;
839 public int fn33() {
840 return 33;
843 public int fn41(int arg) {
844 return 41 * arg;
847 public int fn61(int arg) {
848 return 61 * arg;
851 public String fn62(String arg) {
852 return "62" + arg;
855 public int fn71(int arg) {
856 return 71 * arg;
859 public String fn72(String arg) {
860 return "72" + arg;
863 public int fn73() {
864 return 73;
867 private double attribute1 = 0.0;
868 private double attribute3 = 0.0;
872 private static final class CheckFailed extends Exception {
873 CheckFailed(String message) {
874 super(message);
878 private static void checkEqual(int value, int argument)
879 throws CheckFailed
881 if (argument != value) {
882 throw new CheckFailed(value + " != " + argument);
886 private static void checkEqual(double value, double argument)
887 throws CheckFailed
889 if (argument != value) {
890 throw new CheckFailed(value + " != " + argument);
894 private static void checkEqual(String value, String argument)
895 throws CheckFailed
897 if (!argument.equals(value)) {
898 throw new CheckFailed(value + " != " + argument);
902 public String testMulti(XMulti multi) {
903 try {
904 checkEqual(0.0, multi.getatt1());
905 multi.setatt1(0.1);
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());
912 multi.setatt3(0.3);
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();
926 return "";
929 // XBridgeTest
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
944 throw t;
946 public int getRuntimeException()
947 throws com.sun.star.uno.RuntimeException
949 dothrow( new com.sun.star.uno.RuntimeException(
950 _string, _xInterface ) );
951 return 0; // dummy
954 public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException {
955 throw new com.sun.star.uno.RuntimeException(_string, _xInterface);
960 // XServiceInfo
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))
970 return true;
973 return false;
976 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
977 return new String[]{__serviceName};
980 // XTypeProvider
981 public Type[] getTypes() throws com.sun.star.uno.RuntimeException {
982 try {
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 {
991 return new byte[0];
994 //XBridgeTest2
995 public boolean[] setSequenceBool( /*IN*/boolean[] aSeq )
997 arBool = aSeq;
998 return aSeq;
1000 public char[] setSequenceChar( /*IN*/char[] aSeq )
1002 arChar = aSeq;
1003 return aSeq;
1005 public byte[] setSequenceByte( /*IN*/byte[] aSeq )
1007 arByte = aSeq;
1008 return aSeq;
1010 public short[] setSequenceShort( /*IN*/short[] aSeq )
1012 arShort = aSeq;
1013 return aSeq;
1015 public short[] setSequenceUShort( /*IN*/short[] aSeq )
1017 arUShort = aSeq;
1018 return aSeq;
1020 public int[] setSequenceLong( /*IN*/int[] aSeq )
1022 arLong = aSeq;
1023 return aSeq;
1025 public int[] setSequenceULong( /*IN*/int[] aSeq )
1027 arULong = aSeq;
1028 return aSeq;
1030 public long[] setSequenceHyper( /*IN*/long[] aSeq )
1032 arHyper = aSeq;
1033 return aSeq;
1035 public long[] setSequenceUHyper( /*IN*/long[] aSeq )
1037 arUHyper = aSeq;
1038 return aSeq;
1040 public float[] setSequenceFloat( /*IN*/float[] aSeq )
1042 arFloat = aSeq;
1043 return aSeq;
1045 public double[] setSequenceDouble( /*IN*/double[] aSeq )
1047 arDouble = aSeq;
1048 return aSeq;
1050 public TestEnum[] setSequenceEnum( /*IN*/TestEnum[] aSeq )
1052 arEnum = aSeq;
1053 return aSeq;
1055 public String[] setSequenceString( /*IN*/String[] aSeq )
1057 arString = aSeq;
1058 return aSeq;
1060 public java.lang.Object[] setSequenceXInterface( /*IN*/java.lang.Object[] aSeq )
1062 arObject = aSeq;
1063 return aSeq;
1065 public java.lang.Object[] setSequenceAny( /*IN*/java.lang.Object[] aSeq )
1067 arAny = aSeq;
1068 return aSeq;
1070 public TestElement[] setSequenceStruct( /*IN*/TestElement[] aSeq )
1072 _testElements = aSeq;
1073 return aSeq;
1075 public int[][] setDim2( /*IN*/int[][] aSeq )
1077 arLong2 = aSeq;
1078 return aSeq;
1080 public int[][][] setDim3( /*IN*/int[][][] aSeq )
1082 arLong3 = aSeq;
1083 return 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];
1108 arAny = aSeqAny[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;
1137 aSeqAny[0] = arAny;
1138 aSeqDim2[0] = arLong2;
1139 aSeqDim3[0] = arLong3;
1142 public void testConstructorsService(XComponentContext context)
1143 throws BadConstructorArguments
1145 Constructors.create1(context,
1146 true,
1147 Byte.MIN_VALUE,
1148 Short.MIN_VALUE,
1149 (short) -1,
1150 Integer.MIN_VALUE,
1152 Long.MIN_VALUE,
1153 -1L,
1154 0.123f,
1155 0.456,
1156 'X',
1157 "test",
1158 Type.ANY,
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 },
1165 new int[] { -1 },
1166 new long[] { Long.MIN_VALUE },
1167 new long[] { -1L },
1168 new float[] { 0.123f },
1169 new double[] { 0.456 },
1170 new char[] { 'X' },
1171 new String[] { "test" },
1172 new Type[] { Type.ANY },
1173 new Boolean[] { Boolean.TRUE },
1174 new boolean[][] { new boolean[] { true } },
1175 new Object[][] {
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 },
1183 TestEnum.TWO,
1184 new TestStruct(10),
1185 new TestPolyStruct(Boolean.TRUE),
1186 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)),
1187 null);
1188 Constructors.create2(context, new Object[] {
1189 Boolean.TRUE,
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)),
1197 new Float(0.123f),
1198 new Double(0.456),
1199 new Character('X'),
1200 "test",
1201 Type.ANY,
1202 new Any(Type.BOOLEAN, Boolean.TRUE),
1203 new boolean[] { true },
1204 new byte[] { Byte.MIN_VALUE },
1205 new short[] { Short.MIN_VALUE },
1206 new Any(
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 },
1214 new char[] { 'X' },
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 } },
1219 new Object[][] {
1220 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } },
1221 new TestEnum[] { TestEnum.TWO },
1222 new TestStruct[] { new TestStruct(10) },
1223 new Any(
1224 new Type(
1225 "[]test.testtools.bridgetest.TestPolyStruct<boolean>"),
1226 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) }),
1227 new Any(
1228 new Type("[]test.testtools.bridgetest.TestPolyStruct<any>"),
1229 new TestPolyStruct[] {
1230 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))
1232 new XInterface[] { null },
1233 TestEnum.TWO,
1234 new TestStruct(10),
1235 new Any(
1236 new Type(
1237 "test.testtools.bridgetest.TestPolyStruct<boolean>"),
1238 new TestPolyStruct(Boolean.TRUE)),
1239 new Any(
1240 new Type("test.testtools.bridgetest.TestPolyStruct<any>"),
1241 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))),
1242 null });
1243 Constructors2.create1(
1244 context,
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>
1315 * <p>
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,
1331 multiFactory,
1332 regKey);
1334 else if(implName.equals(_PerformancTestObject.class.getName()))
1335 xSingleServiceFactory = FactoryHelper.getServiceFactory(_PerformancTestObject.class,
1336 _PerformancTestObject.__serviceName,
1337 multiFactory,
1338 regKey);
1340 return xSingleServiceFactory;