1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: TestComponent.java,v $
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
;
81 private double _double
;
82 private String _string
= "";
83 private Object _xInterface
;
85 private Object _interface_sequence
[] = new Object
[0];
86 private ComplexTypes _complexTypes
= new ComplexTypes();
89 public int getLong_attr() throws com
.sun
.star
.uno
.RuntimeException
{
93 public void setLong_attr( int _long_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
97 public long getHyper_attr() throws com
.sun
.star
.uno
.RuntimeException
{
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
{
109 public void setFloat_attr( float _float_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
113 public double getDouble_attr() throws com
.sun
.star
.uno
.RuntimeException
{
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
{
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
{
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
{
141 public void setAny_attr(Object _any_attr
) throws com
.sun
.star
.uno
.RuntimeException
{
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
;
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
{
173 public ComplexTypes
complex_inout( /*INOUT*/ComplexTypes
[] aVal
) throws com
.sun
.star
.uno
.RuntimeException
{
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
{
191 public void setLong(/*IN*/int n
) throws com
.sun
.star
.uno
.RuntimeException
{
195 public long getHyper() throws com
.sun
.star
.uno
.RuntimeException
{
199 public void setHyper(/*IN*/long n
) throws com
.sun
.star
.uno
.RuntimeException
{
203 public float getFloat() throws com
.sun
.star
.uno
.RuntimeException
{
207 public void setFloat( /*IN*/float f
) throws com
.sun
.star
.uno
.RuntimeException
{
211 public double getDouble( ) throws com
.sun
.star
.uno
.RuntimeException
{
215 public void setDouble( /*IN*/double f
) throws com
.sun
.star
.uno
.RuntimeException
{
219 public String
getString( ) throws com
.sun
.star
.uno
.RuntimeException
{
223 public void setString( /*IN*/String s
) throws com
.sun
.star
.uno
.RuntimeException
{
227 public Object
getInterface( ) throws com
.sun
.star
.uno
.RuntimeException
{
231 public void setInterface( /*IN*/Object x
) throws com
.sun
.star
.uno
.RuntimeException
{
235 public Object
getAny( ) throws com
.sun
.star
.uno
.RuntimeException
{
239 public void setAny( /*IN*/java
.lang
.Object a
) throws com
.sun
.star
.uno
.RuntimeException
{
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
{
261 public void raiseRuntimeException( ) throws com
.sun
.star
.uno
.RuntimeException
{
262 throw new com
.sun
.star
.uno
.RuntimeException();
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
))
281 public String
[] getSupportedServiceNames() throws com
.sun
.star
.uno
.RuntimeException
{
282 return new String
[]{__serviceName
};
286 public Type
[] getTypes() throws com
.sun
.star
.uno
.RuntimeException
{
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
;
306 private short _short
;
307 private short _ushort
;
311 private long _uhyper
;
312 private float _float
;
313 private double _double
;
314 private String _string
;
315 private Object _xInterface
;
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
);
347 _bSequenceOfCallTestPassed
= true;
351 public void setValues(boolean bBool
,
366 TestElement testElements
[],
367 TestDataElements testDataElements
) throws com
.sun
.star
.uno
.RuntimeException
369 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".setValues:" + any
);
382 _testEnum
= testEnum
;
384 _xInterface
= xInterface
;
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]);
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 _xInterface
= io_xInterface
[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
,
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
);
460 o_ushort
[0] = _ushort
;
464 o_uhyper
[0] = _uhyper
;
466 o_double
[0] = _double
;
467 o_testEnum
[0] = _testEnum
;
468 o_string
[0] = _string
;
469 o_xInterface
[0] = _xInterface
;
471 o_testElements
[0] = _testElements
;
472 o_testDataElements
[0] = _testDataElements
;
474 return _testDataElements
;
478 public boolean getBool() throws com
.sun
.star
.uno
.RuntimeException
{
482 public void setBool(boolean bool
) throws com
.sun
.star
.uno
.RuntimeException
{
486 public byte getByte() throws com
.sun
.star
.uno
.RuntimeException
{
490 public void setByte(byte zbyte
) throws com
.sun
.star
.uno
.RuntimeException
{
494 public char getChar() throws com
.sun
.star
.uno
.RuntimeException
{
498 public void setChar(char zchar
) throws com
.sun
.star
.uno
.RuntimeException
{
502 public short getShort() throws com
.sun
.star
.uno
.RuntimeException
{
506 public void setShort(short zshort
) throws com
.sun
.star
.uno
.RuntimeException
{
510 public short getUShort() throws com
.sun
.star
.uno
.RuntimeException
{
514 public void setUShort(short ushort
) throws com
.sun
.star
.uno
.RuntimeException
{
518 public int getLong() throws com
.sun
.star
.uno
.RuntimeException
{
522 public void setLong(int zint
) throws com
.sun
.star
.uno
.RuntimeException
{
526 public int getULong() throws com
.sun
.star
.uno
.RuntimeException
{
530 public void setULong(int uint
) throws com
.sun
.star
.uno
.RuntimeException
{
534 public long getHyper() throws com
.sun
.star
.uno
.RuntimeException
{
538 public void setHyper(long hyper
) throws com
.sun
.star
.uno
.RuntimeException
{
542 public long getUHyper() throws com
.sun
.star
.uno
.RuntimeException
{
546 public void setUHyper(long uhyper
) throws com
.sun
.star
.uno
.RuntimeException
{
550 public float getFloat() throws com
.sun
.star
.uno
.RuntimeException
{
554 public void setFloat(float zfloat
) throws com
.sun
.star
.uno
.RuntimeException
{
558 public double getDouble() throws com
.sun
.star
.uno
.RuntimeException
{
562 public void setDouble(double zdouble
) throws com
.sun
.star
.uno
.RuntimeException
{
566 public TestEnum
getEnum() throws com
.sun
.star
.uno
.RuntimeException
{
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
{
578 public void setString(String string
) throws com
.sun
.star
.uno
.RuntimeException
{
582 public Object
getInterface() throws com
.sun
.star
.uno
.RuntimeException
{
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
);
596 public void setAny(Object any
) throws com
.sun
.star
.uno
.RuntimeException
{
597 if(DEBUG
) System
.err
.println("##### " + getClass().getName() + ".setAny:" + 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
;
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
;
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
{
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 );
690 Thread
.sleep(nWaitMUSEC
/ 10000);
692 catch(InterruptedException interruptedException
) {
693 throw new com
.sun
.star
.uno
.RuntimeException(interruptedException
.getMessage());
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 );
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
{
727 xCall
.callRecursivly(this , nToCall
);
731 public synchronized void startRecursiveCall(XRecursiveCall xCall
, int nToCall
) throws com
.sun
.star
.uno
.RuntimeException
{
735 xCall
.callRecursivly( this , nToCall
);
739 public XMulti
getMulti() {
740 return new XMulti() {
741 public double getatt1() {
745 public void setatt1(double value
) {
749 public int fn11(int arg
) {
753 public String
fn12(String arg
) {
757 public int fn21(int arg
) {
761 public String
fn22(String arg
) {
765 public double getatt3() {
769 public void setatt3(double value
) {
773 public int fn31(int arg
) {
777 public String
fn32(String arg
) {
785 public int fn41(int arg
) {
789 public int fn61(int arg
) {
793 public String
fn62(String arg
) {
797 public int fn71(int arg
) {
801 public String
fn72(String arg
) {
809 private double attribute1
= 0.0;
810 private double attribute3
= 0.0;
814 private static final class CheckFailed
extends Exception
{
815 CheckFailed(String message
) {
820 private static void checkEqual(int value
, int argument
)
823 if (argument
!= value
) {
824 throw new CheckFailed(value
+ " != " + argument
);
828 private static void checkEqual(double value
, double argument
)
831 if (argument
!= value
) {
832 throw new CheckFailed(value
+ " != " + argument
);
836 private static void checkEqual(String value
, String argument
)
839 if (!argument
.equals(value
)) {
840 throw new CheckFailed(value
+ " != " + argument
);
844 public String
testMulti(XMulti multi
) {
846 checkEqual(0.0, multi
.getatt1());
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());
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();
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
888 public int getRuntimeException()
889 throws com
.sun
.star
.uno
.RuntimeException
893 dothrow( new com
.sun
.star
.uno
.RuntimeException(
894 _string
, _xInterface
) );
897 catch (com
.sun
.star
.uno
.RuntimeException t
)
903 public void setRuntimeException(int _runtimeexception
) throws com
.sun
.star
.uno
.RuntimeException
{
904 throw new com
.sun
.star
.uno
.RuntimeException(_string
, _xInterface
);
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
))
925 public String
[] getSupportedServiceNames() throws com
.sun
.star
.uno
.RuntimeException
{
926 return new String
[]{__serviceName
};
930 public Type
[] getTypes() throws com
.sun
.star
.uno
.RuntimeException
{
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();
944 public boolean[] setSequenceBool( /*IN*/boolean[] aSeq
)
949 public char[] setSequenceChar( /*IN*/char[] aSeq
)
954 public byte[] setSequenceByte( /*IN*/byte[] aSeq
)
959 public short[] setSequenceShort( /*IN*/short[] aSeq
)
964 public short[] setSequenceUShort( /*IN*/short[] aSeq
)
969 public int[] setSequenceLong( /*IN*/int[] aSeq
)
974 public int[] setSequenceULong( /*IN*/int[] aSeq
)
979 public long[] setSequenceHyper( /*IN*/long[] aSeq
)
984 public long[] setSequenceUHyper( /*IN*/long[] aSeq
)
989 public float[] setSequenceFloat( /*IN*/float[] aSeq
)
994 public double[] setSequenceDouble( /*IN*/double[] aSeq
)
999 public TestEnum
[] setSequenceEnum( /*IN*/TestEnum
[] aSeq
)
1004 public String
[] setSequenceString( /*IN*/String
[] aSeq
)
1009 public java
.lang
.Object
[] setSequenceXInterface( /*IN*/java
.lang
.Object
[] aSeq
)
1014 public java
.lang
.Object
[] setSequenceAny( /*IN*/java
.lang
.Object
[] aSeq
)
1019 public TestElement
[] setSequenceStruct( /*IN*/TestElement
[] aSeq
)
1021 _testElements
= aSeq
;
1024 public int[][] setDim2( /*IN*/int[][] aSeq
)
1029 public int[][][] setDim3( /*IN*/int[][][] 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];
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
;
1087 aSeqDim2
[0] = arLong2
;
1088 aSeqDim3
[0] = arLong3
;
1091 public void testConstructorsService(XComponentContext context
)
1092 throws BadConstructorArguments
1094 Constructors
.create1(context
,
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
},
1115 new long[] { Long
.MIN_VALUE
},
1117 new float[] { 0.123f
},
1118 new double[] { 0.456 },
1120 new String
[] { "test" },
1121 new Type
[] { Type
.ANY
},
1122 new Boolean
[] { Boolean
.TRUE
},
1123 new boolean[][] { new boolean[] { true } },
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 },
1134 new TestPolyStruct(Boolean
.TRUE
),
1135 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
)),
1137 Constructors
.create2(context
, new Object
[] {
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)),
1151 new Any(Type
.BOOLEAN
, Boolean
.TRUE
),
1152 new boolean[] { true },
1153 new byte[] { Byte
.MIN_VALUE
},
1154 new short[] { Short
.MIN_VALUE
},
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 },
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 } },
1169 new Object
[] { new Any(Type
.BOOLEAN
, Boolean
.TRUE
) } },
1170 new TestEnum
[] { TestEnum
.TWO
},
1171 new TestStruct
[] { new TestStruct(10) },
1174 "[]test.testtools.bridgetest.TestPolyStruct<boolean>"),
1175 new TestPolyStruct
[] { new TestPolyStruct(Boolean
.TRUE
) }),
1177 new Type("[]test.testtools.bridgetest.TestPolyStruct<any>"),
1178 new TestPolyStruct
[] {
1179 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
))
1181 new XInterface
[] { null },
1186 "test.testtools.bridgetest.TestPolyStruct<boolean>"),
1187 new TestPolyStruct(Boolean
.TRUE
)),
1189 new Type("test.testtools.bridgetest.TestPolyStruct<any>"),
1190 new TestPolyStruct(new Any(Type
.BOOLEAN
, Boolean
.TRUE
))),
1192 Constructors2
.create1(
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>
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
,
1283 else if(implName
.equals(_PerformancTestObject
.class.getName()))
1284 xSingleServiceFactory
= FactoryHelper
.getServiceFactory(_PerformancTestObject
.class,
1285 _PerformancTestObject
.__serviceName
,
1289 return xSingleServiceFactory
;
1293 * Writes the service information into the given registry key.
1294 * This method is called by the <code>JavaLoader</code>
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
);