Update ooo320-m1
[ooovba.git] / testtools / com / sun / star / comp / bridge / TestComponent.java
blob0834884c45c2ce9c1e36952aefc7d8c25a4301cf
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TestComponent.java,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 package com.sun.star.comp.bridge;
33 import com.sun.star.comp.loader.FactoryHelper;
35 import com.sun.star.lang.XServiceInfo;
36 import com.sun.star.lang.XTypeProvider;
38 import com.sun.star.test.performance.ComplexTypes;
39 import com.sun.star.test.performance.XPerformanceTest;
41 import test.testtools.bridgetest.BadConstructorArguments;
42 import test.testtools.bridgetest.Constructors;
43 import test.testtools.bridgetest.Constructors2;
44 import test.testtools.bridgetest.TestDataElements;
45 import test.testtools.bridgetest.TestElement;
46 import test.testtools.bridgetest.TestEnum;
47 import test.testtools.bridgetest.TestPolyStruct;
48 import test.testtools.bridgetest.TestPolyStruct2;
49 import test.testtools.bridgetest.TestStruct;
50 import test.testtools.bridgetest.XBridgeTest;
51 import test.testtools.bridgetest.XBridgeTest2;
52 import test.testtools.bridgetest.XCurrentContextChecker;
53 import test.testtools.bridgetest.XMulti;
54 import test.testtools.bridgetest.XRecursiveCall;
56 import com.sun.star.lang.IllegalArgumentException;
57 import com.sun.star.lang.XMultiServiceFactory;
58 import com.sun.star.lang.XSingleServiceFactory;
60 import com.sun.star.registry.XRegistryKey;
62 import com.sun.star.uno.Any;
63 import com.sun.star.uno.Type;
64 import com.sun.star.uno.XComponentContext;
65 import com.sun.star.uno.XInterface;
67 public class TestComponent {
68 static public final boolean DEBUG = false;
70 static public class _PerformancTestObject implements XPerformanceTest, XServiceInfo, XTypeProvider {
71 static private final String __serviceName = "com.sun.star.comp.benchmark.JavaTestObject";
73 private boolean _bool;
74 private char _char;
75 private byte _byte;
76 private short _short;
77 private int _long;
78 private int _ulong;
79 private long _hyper;
80 private float _float;
81 private double _double;
82 private String _string = "";
83 private Object _xInterface;
84 private Object _any;
85 private Object _interface_sequence[] = new Object[0];
86 private ComplexTypes _complexTypes = new ComplexTypes();
88 // Attributes
89 public int getLong_attr() throws com.sun.star.uno.RuntimeException {
90 return _long;
93 public void setLong_attr( int _long_attr ) throws com.sun.star.uno.RuntimeException {
94 _long = _long_attr;
97 public long getHyper_attr() throws com.sun.star.uno.RuntimeException {
98 return _hyper;
101 public void setHyper_attr( long _hyper_attr ) throws com.sun.star.uno.RuntimeException {
102 _hyper = _hyper_attr;
105 public float getFloat_attr() throws com.sun.star.uno.RuntimeException {
106 return _float;
109 public void setFloat_attr( float _float_attr ) throws com.sun.star.uno.RuntimeException {
110 _float = _float;
113 public double getDouble_attr() throws com.sun.star.uno.RuntimeException {
114 return _double;
117 public void setDouble_attr( double _double_attr ) throws com.sun.star.uno.RuntimeException {
118 _double = _double_attr;
121 public String getString_attr() throws com.sun.star.uno.RuntimeException {
122 return _string;
125 public void setString_attr( String _string_attr ) throws com.sun.star.uno.RuntimeException {
126 _string = _string_attr;
129 public Object getInterface_attr() throws com.sun.star.uno.RuntimeException {
130 return _xInterface;
133 public void setInterface_attr( java.lang.Object _interface_attr ) throws com.sun.star.uno.RuntimeException {
134 _xInterface = _interface_attr;
137 public Object getAny_attr() throws com.sun.star.uno.RuntimeException {
138 return _any;
141 public void setAny_attr(Object _any_attr ) throws com.sun.star.uno.RuntimeException {
142 _any = _any_attr;
145 public Object[] getSequence_attr() throws com.sun.star.uno.RuntimeException {
146 return _interface_sequence;
149 public void setSequence_attr(Object[] _sequence_attr ) throws com.sun.star.uno.RuntimeException {
150 _interface_sequence = _sequence_attr;
153 public ComplexTypes getStruct_attr() throws com.sun.star.uno.RuntimeException {
154 return _complexTypes;
157 public void setStruct_attr( ComplexTypes _struct_attr ) throws com.sun.star.uno.RuntimeException {
158 _complexTypes = _struct_attr;
162 // Methods
163 public void async() throws com.sun.star.uno.RuntimeException {
166 public void sync( ) throws com.sun.star.uno.RuntimeException {
169 public ComplexTypes complex_in( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException {
170 return aVal;
173 public ComplexTypes complex_inout( /*INOUT*/ComplexTypes[] aVal ) throws com.sun.star.uno.RuntimeException {
174 return aVal[0];
177 public void complex_oneway( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException {
180 public void complex_noreturn( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException {
183 public XPerformanceTest createObject( ) throws com.sun.star.uno.RuntimeException {
184 return new _PerformancTestObject();
187 public int getLong() throws com.sun.star.uno.RuntimeException {
188 return _long;
191 public void setLong(/*IN*/int n) throws com.sun.star.uno.RuntimeException {
192 _long = n;
195 public long getHyper() throws com.sun.star.uno.RuntimeException {
196 return _hyper;
199 public void setHyper(/*IN*/long n) throws com.sun.star.uno.RuntimeException {
200 _hyper = n;
203 public float getFloat() throws com.sun.star.uno.RuntimeException {
204 return _float;
207 public void setFloat( /*IN*/float f ) throws com.sun.star.uno.RuntimeException {
208 _float = f;
211 public double getDouble( ) throws com.sun.star.uno.RuntimeException {
212 return _double;
215 public void setDouble( /*IN*/double f ) throws com.sun.star.uno.RuntimeException {
216 _double = f;
219 public String getString( ) throws com.sun.star.uno.RuntimeException {
220 return _string;
223 public void setString( /*IN*/String s ) throws com.sun.star.uno.RuntimeException {
224 _string = s;
227 public Object getInterface( ) throws com.sun.star.uno.RuntimeException {
228 return _xInterface;
231 public void setInterface( /*IN*/Object x ) throws com.sun.star.uno.RuntimeException {
232 _xInterface = x;
235 public Object getAny( ) throws com.sun.star.uno.RuntimeException {
236 return _any;
239 public void setAny( /*IN*/java.lang.Object a ) throws com.sun.star.uno.RuntimeException {
240 _any = a;
243 public Object[] getSequence( ) throws com.sun.star.uno.RuntimeException {
244 return _interface_sequence;
247 public void setSequence( /*IN*/Object[] seq ) throws com.sun.star.uno.RuntimeException {
248 if(DEBUG) System.err.println("#### " + getClass().getName() + ".setSequence:" + seq);
250 _interface_sequence = seq;
253 public ComplexTypes getStruct( ) throws com.sun.star.uno.RuntimeException {
254 return _complexTypes;
257 public void setStruct( /*IN*/ComplexTypes c ) throws com.sun.star.uno.RuntimeException {
258 _complexTypes = c;
261 public void raiseRuntimeException( ) throws com.sun.star.uno.RuntimeException {
262 throw new com.sun.star.uno.RuntimeException();
265 // XServiceInfo
266 public String getImplementationName() throws com.sun.star.uno.RuntimeException {
267 return __serviceName;
270 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException {
271 String rSNL[] = getSupportedServiceNames();
273 for(int nPos = rSNL.length; (nPos--) != 0;) {
274 if (rSNL[nPos].equals(rServiceName))
275 return true;
278 return false;
281 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
282 return new String[]{__serviceName};
285 // XTypeProvider
286 public Type[] getTypes() throws com.sun.star.uno.RuntimeException {
287 try {
288 return new Type[]{new Type(XPerformanceTest.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)};
290 catch(Exception exception) {
291 throw new com.sun.star.uno.RuntimeException(exception.getMessage());
295 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException {
296 return toString().getBytes();
300 static public class _TestObject implements XBridgeTest2, XRecursiveCall, XServiceInfo, XTypeProvider {
301 static private final String __serviceName = "com.sun.star.test.bridge.JavaTestObject";
303 private boolean _bool;
304 private char _char;
305 private byte _byte;
306 private short _short;
307 private short _ushort;
308 private int _long;
309 private int _ulong;
310 private long _hyper;
311 private long _uhyper;
312 private float _float;
313 private double _double;
314 private String _string;
315 private Object _xInterface;
316 private Object _any;
317 private TestEnum _testEnum = TestEnum.TEST;
318 private TestElement _testElements[] = new TestElement[0];
319 private TestDataElements _testDataElements = new TestDataElements();
321 private int _nLastCallId;
322 private boolean _bFirstCall;
323 private boolean _bSequenceOfCallTestPassed;
325 private boolean[] arBool;
326 private char[] arChar;
327 private byte[] arByte;
328 private short[] arShort;
329 private short[] arUShort;
330 private int[] arLong;
331 private int[] arULong;
332 private long[] arHyper;
333 private long[] arUHyper;
334 private float[] arFloat;
335 private double[] arDouble;
336 private String[] arString;
337 private Object[] arObject;
338 private Object[] arAny;
339 private TestEnum[] arEnum;
340 private int[][] arLong2;
341 private int[][][] arLong3;
342 public _TestObject(XMultiServiceFactory xMultiServiceFactory) {
343 if(DEBUG) System.err.println("##### " + getClass().getName() + ".<init> " + xMultiServiceFactory);
345 _nLastCallId = 0;
346 _bFirstCall = true;
347 _bSequenceOfCallTestPassed = true;
351 public void setValues(boolean bBool,
352 char cChar,
353 byte nByte,
354 short nShort,
355 short nUShort,
356 int nLong,
357 int nULong,
358 long nHyper,
359 long nUHyper,
360 float fFloat,
361 double fDouble,
362 TestEnum testEnum,
363 String string,
364 Object xInterface,
365 Object any,
366 TestElement testElements[],
367 TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException
369 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues:" + any);
371 _bool = bBool;
372 _char = cChar;
373 _byte = nByte;
374 _short = nShort;
375 _ushort = nUShort;
376 _long = nLong;
377 _ulong = nULong;
378 _hyper = nHyper;
379 _uhyper = nUHyper;
380 _float = fFloat;
381 _double = fDouble;
382 _testEnum = testEnum;
383 _string = string;
384 _xInterface = xInterface;
385 _any = any;
386 _testElements = testElements;
387 _testDataElements = testDataElements;
392 public TestDataElements setValues2(/*INOUT*/boolean[] io_bool,
393 /*INOUT*/char[] io_char,
394 /*INOUT*/byte[] io_byte,
395 /*INOUT*/short[] io_short,
396 /*INOUT*/short[] io_ushort,
397 /*INOUT*/int[] io_long,
398 /*INOUT*/int[] io_ulong,
399 /*INOUT*/long[] io_hyper,
400 /*INOUT*/long[] io_uhyper,
401 /*INOUT*/float[] io_float,
402 /*INOUT*/double[] io_double,
403 /*INOUT*/TestEnum[] io_testEnum,
404 /*INOUT*/String[] io_string,
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 _xInterface = io_xInterface[0];
426 _any = io_any[0];
427 _testElements = io_testElements[0];
428 _testDataElements = io_testDataElements[0];
430 io_testElements[ 0 ] =
431 new TestElement [] { io_testElements[ 0 ][ 1 ], io_testElements[ 0 ][ 0 ] };
433 return _testDataElements;
436 public TestDataElements getValues(/*OUT*/boolean[] o_bool,
437 /*OUT*/char[] o_char,
438 /*OUT*/byte[] o_byte,
439 /*OUT*/short[] o_short,
440 /*OUT*/short[] o_ushort,
441 /*OUT*/int[] o_long,
442 /*OUT*/int[] o_ulong,
443 /*OUT*/long[] o_hyper,
444 /*OUT*/long[] o_uhyper,
445 /*OUT*/float[] o_float,
446 /*OUT*/double[] o_double,
447 /*OUT*/TestEnum[] o_testEnum,
448 /*OUT*/String[] o_string,
449 /*OUT*/Object[] o_xInterface,
450 /*OUT*/Object[] o_any,
451 /*OUT*/TestElement[][] o_testElements,
452 /*OUT*/TestDataElements[] o_testDataElements) throws com.sun.star.uno.RuntimeException
454 if(DEBUG) System.err.println("##### " + getClass().getName() + ".getValues:" + _any);
456 o_bool[0] = _bool;
457 o_char[0] = _char;
458 o_byte[0] = _byte;
459 o_short[0] = _short;
460 o_ushort[0] = _ushort;
461 o_long[0] = _long;
462 o_ulong[0] = _ulong;
463 o_hyper[0] = _hyper;
464 o_uhyper[0] = _uhyper;
465 o_float[0] = _float;
466 o_double[0] = _double;
467 o_testEnum[0] = _testEnum;
468 o_string[0] = _string;
469 o_xInterface[0] = _xInterface;
470 o_any[0] = _any;
471 o_testElements[0] = _testElements;
472 o_testDataElements[0] = _testDataElements;
474 return _testDataElements;
477 // Attributes
478 public boolean getBool() throws com.sun.star.uno.RuntimeException {
479 return _bool;
482 public void setBool(boolean bool) throws com.sun.star.uno.RuntimeException {
483 _bool = bool;
486 public byte getByte() throws com.sun.star.uno.RuntimeException {
487 return _byte;
490 public void setByte(byte zbyte) throws com.sun.star.uno.RuntimeException {
491 _byte = zbyte;
494 public char getChar() throws com.sun.star.uno.RuntimeException {
495 return _char;
498 public void setChar(char zchar) throws com.sun.star.uno.RuntimeException {
499 _char = zchar;
502 public short getShort() throws com.sun.star.uno.RuntimeException {
503 return _short;
506 public void setShort(short zshort) throws com.sun.star.uno.RuntimeException {
507 _short = zshort;
510 public short getUShort() throws com.sun.star.uno.RuntimeException {
511 return _ushort;
514 public void setUShort(short ushort) throws com.sun.star.uno.RuntimeException {
515 _ushort = ushort;
518 public int getLong() throws com.sun.star.uno.RuntimeException {
519 return _long;
522 public void setLong(int zint) throws com.sun.star.uno.RuntimeException {
523 _long = zint;
526 public int getULong() throws com.sun.star.uno.RuntimeException {
527 return _ulong;
530 public void setULong(int uint) throws com.sun.star.uno.RuntimeException {
531 _ulong = uint;
534 public long getHyper() throws com.sun.star.uno.RuntimeException {
535 return _hyper;
538 public void setHyper(long hyper) throws com.sun.star.uno.RuntimeException {
539 _hyper = hyper;
542 public long getUHyper() throws com.sun.star.uno.RuntimeException {
543 return _uhyper;
546 public void setUHyper(long uhyper) throws com.sun.star.uno.RuntimeException {
547 _uhyper = uhyper;
550 public float getFloat() throws com.sun.star.uno.RuntimeException {
551 return _float;
554 public void setFloat(float zfloat) throws com.sun.star.uno.RuntimeException {
555 _float = zfloat;
558 public double getDouble() throws com.sun.star.uno.RuntimeException {
559 return _double;
562 public void setDouble(double zdouble) throws com.sun.star.uno.RuntimeException {
563 _double = zdouble;
566 public TestEnum getEnum() throws com.sun.star.uno.RuntimeException {
567 return _testEnum;
570 public void setEnum(TestEnum testEnum) throws com.sun.star.uno.RuntimeException {
571 _testEnum = testEnum;
574 public String getString() throws com.sun.star.uno.RuntimeException {
575 return _string;
578 public void setString(String string) throws com.sun.star.uno.RuntimeException {
579 _string = string;
582 public Object getInterface() throws com.sun.star.uno.RuntimeException {
583 return _xInterface;
586 public void setInterface(Object zinterface) throws com.sun.star.uno.RuntimeException {
587 _xInterface = zinterface;
590 public Object getAny() throws com.sun.star.uno.RuntimeException {
591 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + _any);
593 return _any;
596 public void setAny(Object any) throws com.sun.star.uno.RuntimeException {
597 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + any);
599 _any = any;
602 public TestElement[] getSequence() throws com.sun.star.uno.RuntimeException {
603 return _testElements;
606 public void setSequence(TestElement testElements[]) throws com.sun.star.uno.RuntimeException {
607 _testElements = testElements;
610 public TestDataElements getStruct() throws com.sun.star.uno.RuntimeException {
611 return _testDataElements;
614 public void setStruct(TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException {
615 _testDataElements = testDataElements;
618 public int getRaiseAttr1() {
619 throw new com.sun.star.uno.RuntimeException();
622 public void setRaiseAttr1(int n) throws IllegalArgumentException {
623 throw new IllegalArgumentException();
626 public int getRaiseAttr2() throws IllegalArgumentException {
627 throw new IllegalArgumentException();
630 public TestPolyStruct transportPolyBoolean(TestPolyStruct arg) {
631 Boolean dummy = (Boolean) arg.member;
632 return arg;
635 public void transportPolyHyper(TestPolyStruct[] arg) {
636 Long dummy = (Long) arg[0].member;
639 public void transportPolySequence(
640 TestPolyStruct arg1, TestPolyStruct[] arg2)
642 Object[] dummy = (Object[]) arg1.member;
643 arg2[0] = arg1;
646 public TestPolyStruct getNullPolyLong() {
647 return new TestPolyStruct();
650 public TestPolyStruct getNullPolyString() {
651 return new TestPolyStruct();
654 public TestPolyStruct getNullPolyType() {
655 return new TestPolyStruct();
658 public TestPolyStruct getNullPolyAny() {
659 return new TestPolyStruct();
662 public TestPolyStruct getNullPolySequence() {
663 return new TestPolyStruct();
666 public TestPolyStruct getNullPolyEnum() {
667 return new TestPolyStruct();
670 public TestPolyStruct getNullPolyBadEnum() {
671 return new TestPolyStruct();
674 public TestPolyStruct getNullPolyStruct() {
675 return new TestPolyStruct();
678 public TestPolyStruct getNullPolyInterface() {
679 return new TestPolyStruct();
682 public Object transportAny(Object value) throws com.sun.star.uno.RuntimeException {
683 return value;
686 public void call(int nCallId , int nWaitMUSEC) throws com.sun.star.uno.RuntimeException {
687 // TimeValue value = { nWaitMUSEC / 1000000 , nWaitMUSEC * 1000 };
688 // osl_waitThread( &value );
689 try {
690 Thread.sleep(nWaitMUSEC / 10000);
692 catch(InterruptedException interruptedException) {
693 throw new com.sun.star.uno.RuntimeException(interruptedException.getMessage());
696 if(_bFirstCall)
697 _bFirstCall = false;
699 else
700 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
702 _nLastCallId = nCallId;
705 public void callOneway( int nCallId , int nWaitMUSEC ) throws com.sun.star.uno.RuntimeException {
706 // TimeValue value = { nWaitMUSEC / 1000000 , nWaitMUSEC * 1000 };
707 // osl_waitThread( &value );
708 try {
709 Thread.sleep(nWaitMUSEC / 10000);
711 catch(InterruptedException interruptedException) {
712 throw new com.sun.star.uno.RuntimeException(interruptedException.getMessage());
715 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId);
716 _nLastCallId = nCallId;
719 public boolean sequenceOfCallTestPassed() throws com.sun.star.uno.RuntimeException {
720 return _bSequenceOfCallTestPassed;
723 public synchronized void callRecursivly(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException {
724 if(nToCall != 0)
726 nToCall --;
727 xCall.callRecursivly(this , nToCall);
731 public synchronized void startRecursiveCall(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException {
732 if(nToCall != 0)
734 nToCall --;
735 xCall.callRecursivly( this , nToCall );
739 public XMulti getMulti() {
740 return new XMulti() {
741 public double getatt1() {
742 return attribute1;
745 public void setatt1(double value) {
746 attribute1 = value;
749 public int fn11(int arg) {
750 return 11 * arg;
753 public String fn12(String arg) {
754 return "12" + arg;
757 public int fn21(int arg) {
758 return 21 * arg;
761 public String fn22(String arg) {
762 return "22" + arg;
765 public double getatt3() {
766 return attribute3;
769 public void setatt3(double value) {
770 attribute3 = value;
773 public int fn31(int arg) {
774 return 31 * arg;
777 public String fn32(String arg) {
778 return "32" + arg;
781 public int fn33() {
782 return 33;
785 public int fn41(int arg) {
786 return 41 * arg;
789 public int fn61(int arg) {
790 return 61 * arg;
793 public String fn62(String arg) {
794 return "62" + arg;
797 public int fn71(int arg) {
798 return 71 * arg;
801 public String fn72(String arg) {
802 return "72" + arg;
805 public int fn73() {
806 return 73;
809 private double attribute1 = 0.0;
810 private double attribute3 = 0.0;
814 private static final class CheckFailed extends Exception {
815 CheckFailed(String message) {
816 super(message);
820 private static void checkEqual(int value, int argument)
821 throws CheckFailed
823 if (argument != value) {
824 throw new CheckFailed(value + " != " + argument);
828 private static void checkEqual(double value, double argument)
829 throws CheckFailed
831 if (argument != value) {
832 throw new CheckFailed(value + " != " + argument);
836 private static void checkEqual(String value, String argument)
837 throws CheckFailed
839 if (!argument.equals(value)) {
840 throw new CheckFailed(value + " != " + argument);
844 public String testMulti(XMulti multi) {
845 try {
846 checkEqual(0.0, multi.getatt1());
847 multi.setatt1(0.1);
848 checkEqual(0.1, multi.getatt1());
849 checkEqual(11 * 1, multi.fn11(1));
850 checkEqual("12" + "abc", multi.fn12("abc"));
851 checkEqual(21 * 2, multi.fn21(2));
852 checkEqual("22" + "de", multi.fn22("de"));
853 checkEqual(0.0, multi.getatt3());
854 multi.setatt3(0.3);
855 checkEqual(0.3, multi.getatt3());
856 checkEqual(31 * 3, multi.fn31(3));
857 checkEqual("32" + "f", multi.fn32("f"));
858 checkEqual(33, multi.fn33());
859 checkEqual(41 * 4, multi.fn41(4));
860 checkEqual(61 * 6, multi.fn61(6));
861 checkEqual("62" + "", multi.fn62(""));
862 checkEqual(71 * 7, multi.fn71(7));
863 checkEqual("72" + "g", multi.fn72("g"));
864 checkEqual(73, multi.fn73());
865 } catch (CheckFailed f) {
866 return f.getMessage();
868 return "";
871 // XBridgeTest
872 public TestDataElements raiseException(short nArgumentPos, String rMsg, Object xContext)
873 throws com.sun.star.lang.IllegalArgumentException,
874 com.sun.star.uno.RuntimeException
876 throw new com.sun.star.lang.IllegalArgumentException(rMsg, xContext, nArgumentPos);
879 public void raiseRuntimeExceptionOneway(String rMsg, Object xContext) throws com.sun.star.uno.RuntimeException {
880 throw new com.sun.star.uno.RuntimeException(rMsg, xContext);
883 private void dothrow( com.sun.star.uno.RuntimeException t )
884 throws com.sun.star.uno.RuntimeException
886 throw t;
888 public int getRuntimeException()
889 throws com.sun.star.uno.RuntimeException
893 dothrow( new com.sun.star.uno.RuntimeException(
894 _string, _xInterface ) );
895 return 0; // dummy
897 catch (com.sun.star.uno.RuntimeException t)
899 throw t;
903 public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException {
904 throw new com.sun.star.uno.RuntimeException(_string, _xInterface);
909 // XServiceInfo
910 public String getImplementationName() throws com.sun.star.uno.RuntimeException {
911 return __serviceName;
914 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException {
915 String rSNL[] = getSupportedServiceNames();
917 for(int nPos = rSNL.length; (nPos--) != 0;) {
918 if (rSNL[nPos].equals(rServiceName))
919 return true;
922 return false;
925 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException {
926 return new String[]{__serviceName};
929 // XTypeProvider
930 public Type[] getTypes() throws com.sun.star.uno.RuntimeException {
931 try {
932 return new Type[]{new Type(XBridgeTest.class), new Type(XRecursiveCall.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)};
934 catch(Exception exception) {
935 throw new com.sun.star.uno.RuntimeException(exception.getMessage());
939 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException {
940 return toString().getBytes();
943 //XBridgeTest2
944 public boolean[] setSequenceBool( /*IN*/boolean[] aSeq )
946 arBool = aSeq;
947 return aSeq;
949 public char[] setSequenceChar( /*IN*/char[] aSeq )
951 arChar = aSeq;
952 return aSeq;
954 public byte[] setSequenceByte( /*IN*/byte[] aSeq )
956 arByte = aSeq;
957 return aSeq;
959 public short[] setSequenceShort( /*IN*/short[] aSeq )
961 arShort = aSeq;
962 return aSeq;
964 public short[] setSequenceUShort( /*IN*/short[] aSeq )
966 arUShort = aSeq;
967 return aSeq;
969 public int[] setSequenceLong( /*IN*/int[] aSeq )
971 arLong = aSeq;
972 return aSeq;
974 public int[] setSequenceULong( /*IN*/int[] aSeq )
976 arULong = aSeq;
977 return aSeq;
979 public long[] setSequenceHyper( /*IN*/long[] aSeq )
981 arHyper = aSeq;
982 return aSeq;
984 public long[] setSequenceUHyper( /*IN*/long[] aSeq )
986 arUHyper = aSeq;
987 return aSeq;
989 public float[] setSequenceFloat( /*IN*/float[] aSeq )
991 arFloat = aSeq;
992 return aSeq;
994 public double[] setSequenceDouble( /*IN*/double[] aSeq )
996 arDouble = aSeq;
997 return aSeq;
999 public TestEnum[] setSequenceEnum( /*IN*/TestEnum[] aSeq )
1001 arEnum = aSeq;
1002 return aSeq;
1004 public String[] setSequenceString( /*IN*/String[] aSeq )
1006 arString = aSeq;
1007 return aSeq;
1009 public java.lang.Object[] setSequenceXInterface( /*IN*/java.lang.Object[] aSeq )
1011 arObject = aSeq;
1012 return aSeq;
1014 public java.lang.Object[] setSequenceAny( /*IN*/java.lang.Object[] aSeq )
1016 arAny = aSeq;
1017 return aSeq;
1019 public TestElement[] setSequenceStruct( /*IN*/TestElement[] aSeq )
1021 _testElements = aSeq;
1022 return aSeq;
1024 public int[][] setDim2( /*IN*/int[][] aSeq )
1026 arLong2 = aSeq;
1027 return aSeq;
1029 public int[][][] setDim3( /*IN*/int[][][] aSeq )
1031 arLong3 = aSeq;
1032 return aSeq;
1034 public void setSequencesInOut( /*INOUT*/boolean[][] aSeqBoolean,
1035 /*INOUT*/char[][] aSeqChar, /*INOUT*/byte[][] aSeqByte,
1036 /*INOUT*/short[][] aSeqShort, /*INOUT*/short[][] aSeqUShort,
1037 /*INOUT*/int[][] aSeqLong, /*INOUT*/int[][] aSeqULong,
1038 /*INOUT*/long[][] aSeqHyper, /*INOUT*/long[][] aSeqUHyper,
1039 /*INOUT*/float[][] aSeqFloat, /*INOUT*/double[][] aSeqDouble,
1040 /*INOUT*/TestEnum[][] aSeqEnum, /*INOUT*/String[][] aSeqString,
1041 /*INOUT*/java.lang.Object[][] aSeqXInterface,
1042 /*INOUT*/java.lang.Object[][] aSeqAny,
1043 /*INOUT*/int[][][] aSeqDim2, /*INOUT*/int[][][][] aSeqDim3 )
1045 arBool = aSeqBoolean[0];
1046 arChar = aSeqChar[0];
1047 arByte = aSeqByte[0];
1048 arShort = aSeqShort[0];
1049 arUShort = aSeqUShort[0];
1050 arLong = aSeqLong[0];
1051 arULong = aSeqULong[0];
1052 arFloat = aSeqFloat[0];
1053 arDouble = aSeqDouble[0];
1054 arEnum = aSeqEnum[0];
1055 arString = aSeqString[0];
1056 arObject = aSeqXInterface[0];
1057 arAny = aSeqAny[0];
1058 arLong2 = aSeqDim2[0];
1059 arLong3 = aSeqDim3[0];
1061 public void setSequencesOut( /*OUT*/boolean[][] aSeqBoolean, /*OUT*/char[][] aSeqChar,
1062 /*OUT*/byte[][] aSeqByte, /*OUT*/short[][] aSeqShort,
1063 /*OUT*/short[][] aSeqUShort, /*OUT*/int[][] aSeqLong,
1064 /*OUT*/int[][] aSeqULong, /*OUT*/long[][] aSeqHyper,
1065 /*OUT*/long[][] aSeqUHyper, /*OUT*/float[][] aSeqFloat,
1066 /*OUT*/double[][] aSeqDouble, /*OUT*/TestEnum[][] aSeqEnum,
1067 /*OUT*/String[][] aSeqString,
1068 /*OUT*/java.lang.Object[][] aSeqXInterface,
1069 /*OUT*/java.lang.Object[][] aSeqAny, /*OUT*/int[][][] aSeqDim2,
1070 /*OUT*/int[][][][] aSeqDim3 )
1072 aSeqBoolean[0] = arBool;
1073 aSeqChar[0] = arChar;
1074 aSeqByte[0] = arByte;
1075 aSeqShort[0] = arShort;
1076 aSeqUShort[0] = arUShort;
1077 aSeqLong[0] = arLong;
1078 aSeqULong[0] = arULong;
1079 aSeqHyper[0] = arHyper;
1080 aSeqUHyper[0] = arUHyper;
1081 aSeqFloat[0] = arFloat;
1082 aSeqDouble[0] = arDouble;
1083 aSeqEnum[0] = arEnum;
1084 aSeqString[0] = arString;
1085 aSeqXInterface[0] = arObject;
1086 aSeqAny[0] = arAny;
1087 aSeqDim2[0] = arLong2;
1088 aSeqDim3[0] = arLong3;
1091 public void testConstructorsService(XComponentContext context)
1092 throws BadConstructorArguments
1094 Constructors.create1(context,
1095 true,
1096 Byte.MIN_VALUE,
1097 Short.MIN_VALUE,
1098 (short) -1,
1099 Integer.MIN_VALUE,
1101 Long.MIN_VALUE,
1102 -1L,
1103 0.123f,
1104 0.456,
1105 'X',
1106 "test",
1107 Type.ANY,
1108 new Any(Type.BOOLEAN, Boolean.TRUE),
1109 new boolean[] { true },
1110 new byte[] { Byte.MIN_VALUE },
1111 new short[] { Short.MIN_VALUE },
1112 new short[] { (short) -1 },
1113 new int[] { Integer.MIN_VALUE },
1114 new int[] { -1 },
1115 new long[] { Long.MIN_VALUE },
1116 new long[] { -1L },
1117 new float[] { 0.123f },
1118 new double[] { 0.456 },
1119 new char[] { 'X' },
1120 new String[] { "test" },
1121 new Type[] { Type.ANY },
1122 new Boolean[] { Boolean.TRUE },
1123 new boolean[][] { new boolean[] { true } },
1124 new Object[][] {
1125 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } },
1126 new TestEnum[] { TestEnum.TWO },
1127 new TestStruct[] { new TestStruct(10) },
1128 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) },
1129 new TestPolyStruct[] {
1130 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)) },
1131 new Object[] { null },
1132 TestEnum.TWO,
1133 new TestStruct(10),
1134 new TestPolyStruct(Boolean.TRUE),
1135 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)),
1136 null);
1137 Constructors.create2(context, new Object[] {
1138 Boolean.TRUE,
1139 new Byte(Byte.MIN_VALUE),
1140 new Short(Short.MIN_VALUE),
1141 new Any(Type.UNSIGNED_SHORT, new Short((short) -1)),
1142 new Integer(Integer.MIN_VALUE),
1143 new Any(Type.UNSIGNED_LONG, new Integer(-1)),
1144 new Long(Long.MIN_VALUE),
1145 new Any(Type.UNSIGNED_HYPER, new Long(-1L)),
1146 new Float(0.123f),
1147 new Double(0.456),
1148 new Character('X'),
1149 "test",
1150 Type.ANY,
1151 new Any(Type.BOOLEAN, Boolean.TRUE),
1152 new boolean[] { true },
1153 new byte[] { Byte.MIN_VALUE },
1154 new short[] { Short.MIN_VALUE },
1155 new Any(
1156 new Type("[]unsigned short"), new short[] { (short) -1 }),
1157 new int[] { Integer.MIN_VALUE },
1158 new Any(new Type("[]unsigned long"), new int[] { -1 }),
1159 new long[] { Long.MIN_VALUE },
1160 new Any(new Type("[]unsigned hyper"), new long[] { -1L }),
1161 new float[] { 0.123f },
1162 new double[] { 0.456 },
1163 new char[] { 'X' },
1164 new String[] { "test" },
1165 new Type[] { Type.ANY },
1166 new Any(new Type("[]any"), new Boolean[] { Boolean.TRUE }),
1167 new boolean[][] { new boolean[] { true } },
1168 new Object[][] {
1169 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } },
1170 new TestEnum[] { TestEnum.TWO },
1171 new TestStruct[] { new TestStruct(10) },
1172 new Any(
1173 new Type(
1174 "[]test.testtools.bridgetest.TestPolyStruct<boolean>"),
1175 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) }),
1176 new Any(
1177 new Type("[]test.testtools.bridgetest.TestPolyStruct<any>"),
1178 new TestPolyStruct[] {
1179 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))
1181 new XInterface[] { null },
1182 TestEnum.TWO,
1183 new TestStruct(10),
1184 new Any(
1185 new Type(
1186 "test.testtools.bridgetest.TestPolyStruct<boolean>"),
1187 new TestPolyStruct(Boolean.TRUE)),
1188 new Any(
1189 new Type("test.testtools.bridgetest.TestPolyStruct<any>"),
1190 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))),
1191 null });
1192 Constructors2.create1(
1193 context,
1194 new TestPolyStruct(Type.LONG),
1195 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)),
1196 new TestPolyStruct(new Boolean(true)),
1197 new TestPolyStruct(new Byte(Byte.MIN_VALUE)),
1198 new TestPolyStruct(new Short(Short.MIN_VALUE)),
1199 new TestPolyStruct(new Integer(Integer.MIN_VALUE)),
1200 new TestPolyStruct(new Long(Long.MIN_VALUE)),
1201 new TestPolyStruct(new Character('X')),
1202 new TestPolyStruct("test"),
1203 new TestPolyStruct(new Float(0.123f)),
1204 new TestPolyStruct(new Double(0.456)),
1205 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()),
1206 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()),
1207 new TestPolyStruct(TestEnum.TWO),
1208 new TestPolyStruct(new TestPolyStruct2(new Character('X'),
1209 new Any(Type.BOOLEAN, Boolean.TRUE))),
1210 new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2(
1211 new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test")),
1212 new TestPolyStruct2("test", new TestPolyStruct2(new Character('X'),
1213 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)))),
1214 new TestPolyStruct2( new TestPolyStruct2(new Character('X'),
1215 new Any(Type.BOOLEAN, Boolean.TRUE)), new TestPolyStruct(new Character('X'))),
1216 new TestPolyStruct(new Type[] { Type.LONG}),
1217 new TestPolyStruct(new Any[] { new Any(Type.BOOLEAN, Boolean.TRUE) }),
1218 new TestPolyStruct(new boolean[] {true}),
1219 new TestPolyStruct(new byte[] {Byte.MIN_VALUE}),
1220 new TestPolyStruct(new short[] {Short.MIN_VALUE}),
1221 new TestPolyStruct(new int[] {Integer.MIN_VALUE}),
1222 new TestPolyStruct(new long[] {Long.MIN_VALUE}),
1223 new TestPolyStruct(new char[] {'X'}),
1224 new TestPolyStruct(new String[] {"test"}),
1225 new TestPolyStruct(new float[] {0.123f}),
1226 new TestPolyStruct(new double[] {0.456d}),
1227 new TestPolyStruct(new Object[] {new com.sun.star.lib.uno.helper.ComponentBase()}),
1228 new TestPolyStruct(new com.sun.star.lang.XComponent[] {new com.sun.star.lib.uno.helper.ComponentBase()}),
1229 new TestPolyStruct(new TestEnum[] {TestEnum.TWO}),
1230 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2(
1231 new Character('X'), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}),
1232 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2(
1233 new TestPolyStruct(new Character('X')), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}),
1234 new TestPolyStruct(new int[][] { new int[] {Integer.MIN_VALUE} }),
1235 new TestPolyStruct[]{ new TestPolyStruct(new Integer(Integer.MIN_VALUE))},
1236 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(
1237 new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))},
1238 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2(
1239 new TestPolyStruct2(new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))},
1240 new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2(
1241 new Character('X'), new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))},
1242 new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2(new Character('X'), new Any(
1243 Type.BOOLEAN, Boolean.TRUE)),new TestPolyStruct(new Character('X')))},
1244 new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(new Character('X'))}},
1245 new TestPolyStruct[][]{new TestPolyStruct[]{
1246 new TestPolyStruct(new TestPolyStruct2(new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))}},
1247 new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2(
1248 new TestPolyStruct2(new Character('X'),new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))}},
1249 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(
1250 "test", new TestPolyStruct2(new Character('X'),new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))}},
1251 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2(
1252 new TestPolyStruct2(new Character('X'),new Any(Type.BOOLEAN, Boolean.TRUE)),
1253 new TestPolyStruct(new Character('X')))}});
1256 public XCurrentContextChecker getCurrentContextChecker() {
1257 return new CurrentContextChecker();
1262 * Gives a factory for creating the service.
1263 * This method is called by the <code>JavaLoader</code>
1264 * <p>
1265 * @return returns a <code>XSingleServiceFactory</code> for creating the component
1266 * @param implName the name of the implementation for which a service is desired
1267 * @param multiFactory the service manager to be uses if needed
1268 * @param regKey the registryKey
1269 * @see com.sun.star.comp.loader.JavaLoader
1271 public static XSingleServiceFactory __getServiceFactory(String implName,
1272 XMultiServiceFactory multiFactory,
1273 XRegistryKey regKey)
1275 XSingleServiceFactory xSingleServiceFactory = null;
1277 if(implName.equals(_TestObject.class.getName()))
1278 xSingleServiceFactory = FactoryHelper.getServiceFactory(_TestObject.class,
1279 _TestObject.__serviceName,
1280 multiFactory,
1281 regKey);
1283 else if(implName.equals(_PerformancTestObject.class.getName()))
1284 xSingleServiceFactory = FactoryHelper.getServiceFactory(_PerformancTestObject.class,
1285 _PerformancTestObject.__serviceName,
1286 multiFactory,
1287 regKey);
1289 return xSingleServiceFactory;
1293 * Writes the service information into the given registry key.
1294 * This method is called by the <code>JavaLoader</code>
1295 * <p>
1296 * @return returns true if the operation succeeded
1297 * @param regKey the registryKey
1298 * @see com.sun.star.comp.loader.JavaLoader
1300 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
1301 boolean result = true;
1303 result = result & FactoryHelper.writeRegistryServiceInfo(_TestObject.class.getName(), _TestObject.__serviceName, regKey);
1304 result = result & FactoryHelper.writeRegistryServiceInfo(_PerformancTestObject.class.getName(),
1305 _PerformancTestObject.__serviceName, regKey);
1307 return result;