1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 package com.sun.star.comp.bridge; 29 30 import com.sun.star.comp.loader.FactoryHelper; 31 32 import com.sun.star.lang.XServiceInfo; 33 import com.sun.star.lang.XTypeProvider; 34 35 import com.sun.star.test.performance.ComplexTypes; 36 import com.sun.star.test.performance.XPerformanceTest; 37 38 import test.testtools.bridgetest.BadConstructorArguments; 39 import test.testtools.bridgetest.Constructors; 40 import test.testtools.bridgetest.Constructors2; 41 import test.testtools.bridgetest.TestDataElements; 42 import test.testtools.bridgetest.TestElement; 43 import test.testtools.bridgetest.TestEnum; 44 import test.testtools.bridgetest.TestPolyStruct; 45 import test.testtools.bridgetest.TestPolyStruct2; 46 import test.testtools.bridgetest.TestStruct; 47 import test.testtools.bridgetest.SmallStruct; 48 import test.testtools.bridgetest.MediumStruct; 49 import test.testtools.bridgetest.BigStruct; 50 import test.testtools.bridgetest.AllFloats; 51 import test.testtools.bridgetest.XBridgeTest; 52 import test.testtools.bridgetest.XBridgeTest2; 53 import test.testtools.bridgetest.XCurrentContextChecker; 54 import test.testtools.bridgetest.XMulti; 55 import test.testtools.bridgetest.XRecursiveCall; 56 57 58 import com.sun.star.lang.IllegalArgumentException; 59 import com.sun.star.lang.XMultiServiceFactory; 60 import com.sun.star.lang.XSingleServiceFactory; 61 62 import com.sun.star.registry.XRegistryKey; 63 64 import com.sun.star.uno.Any; 65 import com.sun.star.uno.Type; 66 import com.sun.star.uno.XComponentContext; 67 import com.sun.star.uno.XInterface; 68 69 public class TestComponent { 70 static public final boolean DEBUG = false; 71 72 static public class _PerformancTestObject implements XPerformanceTest, XServiceInfo, XTypeProvider { 73 static private final String __serviceName = "com.sun.star.comp.benchmark.JavaTestObject"; 74 75 private boolean _bool; 76 private char _char; 77 private byte _byte; 78 private short _short; 79 private int _long; 80 private int _ulong; 81 private long _hyper; 82 private float _float; 83 private double _double; 84 private String _string = ""; 85 private Object _xInterface; 86 private Object _any; 87 private Object _interface_sequence[] = new Object[0]; 88 private ComplexTypes _complexTypes = new ComplexTypes(); 89 90 // Attributes 91 public int getLong_attr() throws com.sun.star.uno.RuntimeException { 92 return _long; 93 } 94 95 public void setLong_attr( int _long_attr ) throws com.sun.star.uno.RuntimeException { 96 _long = _long_attr; 97 } 98 99 public long getHyper_attr() throws com.sun.star.uno.RuntimeException { 100 return _hyper; 101 } 102 103 public void setHyper_attr( long _hyper_attr ) throws com.sun.star.uno.RuntimeException { 104 _hyper = _hyper_attr; 105 } 106 107 public float getFloat_attr() throws com.sun.star.uno.RuntimeException { 108 return _float; 109 } 110 111 public void setFloat_attr( float _float_attr ) throws com.sun.star.uno.RuntimeException { 112 _float = _float; 113 } 114 115 public double getDouble_attr() throws com.sun.star.uno.RuntimeException { 116 return _double; 117 } 118 119 public void setDouble_attr( double _double_attr ) throws com.sun.star.uno.RuntimeException { 120 _double = _double_attr; 121 } 122 123 public String getString_attr() throws com.sun.star.uno.RuntimeException { 124 return _string; 125 } 126 127 public void setString_attr( String _string_attr ) throws com.sun.star.uno.RuntimeException { 128 _string = _string_attr; 129 } 130 131 public Object getInterface_attr() throws com.sun.star.uno.RuntimeException { 132 return _xInterface; 133 } 134 135 public void setInterface_attr( java.lang.Object _interface_attr ) throws com.sun.star.uno.RuntimeException { 136 _xInterface = _interface_attr; 137 } 138 139 public Object getAny_attr() throws com.sun.star.uno.RuntimeException { 140 return _any; 141 } 142 143 public void setAny_attr(Object _any_attr ) throws com.sun.star.uno.RuntimeException { 144 _any = _any_attr; 145 } 146 147 public Object[] getSequence_attr() throws com.sun.star.uno.RuntimeException { 148 return _interface_sequence; 149 } 150 151 public void setSequence_attr(Object[] _sequence_attr ) throws com.sun.star.uno.RuntimeException { 152 _interface_sequence = _sequence_attr; 153 } 154 155 public ComplexTypes getStruct_attr() throws com.sun.star.uno.RuntimeException { 156 return _complexTypes; 157 } 158 159 public void setStruct_attr( ComplexTypes _struct_attr ) throws com.sun.star.uno.RuntimeException { 160 _complexTypes = _struct_attr; 161 } 162 163 164 // Methods 165 public void async() throws com.sun.star.uno.RuntimeException { 166 } 167 168 public void sync( ) throws com.sun.star.uno.RuntimeException { 169 } 170 171 public ComplexTypes complex_in( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException { 172 return aVal; 173 } 174 175 public ComplexTypes complex_inout( /*INOUT*/ComplexTypes[] aVal ) throws com.sun.star.uno.RuntimeException { 176 return aVal[0]; 177 } 178 179 public void complex_oneway( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException { 180 } 181 182 public void complex_noreturn( /*IN*/ComplexTypes aVal ) throws com.sun.star.uno.RuntimeException { 183 } 184 185 public XPerformanceTest createObject( ) throws com.sun.star.uno.RuntimeException { 186 return new _PerformancTestObject(); 187 } 188 189 public int getLong() throws com.sun.star.uno.RuntimeException { 190 return _long; 191 } 192 193 public void setLong(/*IN*/int n) throws com.sun.star.uno.RuntimeException { 194 _long = n; 195 } 196 197 public long getHyper() throws com.sun.star.uno.RuntimeException { 198 return _hyper; 199 } 200 201 public void setHyper(/*IN*/long n) throws com.sun.star.uno.RuntimeException { 202 _hyper = n; 203 } 204 205 public float getFloat() throws com.sun.star.uno.RuntimeException { 206 return _float; 207 } 208 209 public void setFloat( /*IN*/float f ) throws com.sun.star.uno.RuntimeException { 210 _float = f; 211 } 212 213 public double getDouble( ) throws com.sun.star.uno.RuntimeException { 214 return _double; 215 } 216 217 public void setDouble( /*IN*/double f ) throws com.sun.star.uno.RuntimeException { 218 _double = f; 219 } 220 221 public String getString( ) throws com.sun.star.uno.RuntimeException { 222 return _string; 223 } 224 225 public void setString( /*IN*/String s ) throws com.sun.star.uno.RuntimeException { 226 _string = s; 227 } 228 229 public Object getInterface( ) throws com.sun.star.uno.RuntimeException { 230 return _xInterface; 231 } 232 233 public void setInterface( /*IN*/Object x ) throws com.sun.star.uno.RuntimeException { 234 _xInterface = x; 235 } 236 237 public Object getAny( ) throws com.sun.star.uno.RuntimeException { 238 return _any; 239 } 240 241 public void setAny( /*IN*/java.lang.Object a ) throws com.sun.star.uno.RuntimeException { 242 _any = a; 243 } 244 245 public Object[] getSequence( ) throws com.sun.star.uno.RuntimeException { 246 return _interface_sequence; 247 } 248 249 public void setSequence( /*IN*/Object[] seq ) throws com.sun.star.uno.RuntimeException { 250 if(DEBUG) System.err.println("#### " + getClass().getName() + ".setSequence:" + seq); 251 252 _interface_sequence = seq; 253 } 254 255 public ComplexTypes getStruct( ) throws com.sun.star.uno.RuntimeException { 256 return _complexTypes; 257 } 258 259 public void setStruct( /*IN*/ComplexTypes c ) throws com.sun.star.uno.RuntimeException { 260 _complexTypes = c; 261 } 262 263 public void raiseRuntimeException( ) throws com.sun.star.uno.RuntimeException { 264 throw new com.sun.star.uno.RuntimeException(); 265 } 266 267 // XServiceInfo 268 public String getImplementationName() throws com.sun.star.uno.RuntimeException { 269 return __serviceName; 270 } 271 272 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException { 273 String rSNL[] = getSupportedServiceNames(); 274 275 for(int nPos = rSNL.length; (nPos--) != 0;) { 276 if (rSNL[nPos].equals(rServiceName)) 277 return true; 278 } 279 280 return false; 281 } 282 283 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException { 284 return new String[]{__serviceName}; 285 } 286 287 // XTypeProvider 288 public Type[] getTypes() throws com.sun.star.uno.RuntimeException { 289 try { 290 return new Type[]{new Type(XPerformanceTest.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)}; 291 } 292 catch(Exception exception) { 293 throw new com.sun.star.uno.RuntimeException(exception.getMessage()); 294 } 295 } 296 297 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException { 298 return toString().getBytes(); 299 } 300 } 301 302 static public class _TestObject implements XBridgeTest2, XRecursiveCall, XServiceInfo, XTypeProvider { 303 static private final String __serviceName = "com.sun.star.test.bridge.JavaTestObject"; 304 305 private boolean _bool; 306 private char _char; 307 private byte _byte; 308 private short _short; 309 private short _ushort; 310 private int _long; 311 private int _ulong; 312 private long _hyper; 313 private long _uhyper; 314 private float _float; 315 private double _double; 316 private String _string; 317 private Object _xInterface; 318 private Object _any; 319 private TestEnum _testEnum = TestEnum.TEST; 320 private TestElement _testElements[] = new TestElement[0]; 321 private TestDataElements _testDataElements = new TestDataElements(); 322 323 private int _nLastCallId; 324 private boolean _bFirstCall; 325 private boolean _bSequenceOfCallTestPassed; 326 327 private boolean[] arBool; 328 private char[] arChar; 329 private byte[] arByte; 330 private short[] arShort; 331 private short[] arUShort; 332 private int[] arLong; 333 private int[] arULong; 334 private long[] arHyper; 335 private long[] arUHyper; 336 private float[] arFloat; 337 private double[] arDouble; 338 private String[] arString; 339 private Object[] arObject; 340 private Object[] arAny; 341 private TestEnum[] arEnum; 342 private int[][] arLong2; 343 private int[][][] arLong3; 344 public _TestObject(XMultiServiceFactory xMultiServiceFactory) { 345 if(DEBUG) System.err.println("##### " + getClass().getName() + ".<init> " + xMultiServiceFactory); 346 347 _nLastCallId = 0; 348 _bFirstCall = true; 349 _bSequenceOfCallTestPassed = true; 350 } 351 352 353 public void setValues(boolean bBool, 354 char cChar, 355 byte nByte, 356 short nShort, 357 short nUShort, 358 int nLong, 359 int nULong, 360 long nHyper, 361 long nUHyper, 362 float fFloat, 363 double fDouble, 364 TestEnum testEnum, 365 String string, 366 Object xInterface, 367 Object any, 368 TestElement testElements[], 369 TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException 370 { 371 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues:" + any); 372 373 _bool = bBool; 374 _char = cChar; 375 _byte = nByte; 376 _short = nShort; 377 _ushort = nUShort; 378 _long = nLong; 379 _ulong = nULong; 380 _hyper = nHyper; 381 _uhyper = nUHyper; 382 _float = fFloat; 383 _double = fDouble; 384 _testEnum = testEnum; 385 _string = string; 386 _xInterface = xInterface; 387 _any = any; 388 _testElements = testElements; 389 _testDataElements = testDataElements; 390 } 391 392 393 394 public TestDataElements setValues2(/*INOUT*/boolean[] io_bool, 395 /*INOUT*/char[] io_char, 396 /*INOUT*/byte[] io_byte, 397 /*INOUT*/short[] io_short, 398 /*INOUT*/short[] io_ushort, 399 /*INOUT*/int[] io_long, 400 /*INOUT*/int[] io_ulong, 401 /*INOUT*/long[] io_hyper, 402 /*INOUT*/long[] io_uhyper, 403 /*INOUT*/float[] io_float, 404 /*INOUT*/double[] io_double, 405 /*INOUT*/TestEnum[] io_testEnum, 406 /*INOUT*/String[] io_string, 407 /*INOUT*/Object[] io_xInterface, 408 /*INOUT*/Object[] io_any, 409 /*INOUT*/TestElement[][] io_testElements, 410 /*INOUT*/TestDataElements[] io_testDataElements) throws com.sun.star.uno.RuntimeException 411 { 412 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setValues2:" + io_any[0]); 413 414 _bool = io_bool[0]; 415 _char = io_char[0]; 416 _byte = io_byte[0]; 417 _short = io_short[0]; 418 _ushort = io_ushort[0]; 419 _long = io_long[0]; 420 _ulong = io_ulong[0]; 421 _hyper = io_hyper[0]; 422 _uhyper = io_uhyper[0]; 423 _float = io_float[0]; 424 _double = io_double[0]; 425 _testEnum = io_testEnum[0]; 426 _string = io_string[0]; 427 _xInterface = io_xInterface[0]; 428 _any = io_any[0]; 429 _testElements = io_testElements[0]; 430 _testDataElements = io_testDataElements[0]; 431 432 io_testElements[ 0 ] = 433 new TestElement [] { io_testElements[ 0 ][ 1 ], io_testElements[ 0 ][ 0 ] }; 434 435 return _testDataElements; 436 } 437 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*/Object[] o_xInterface, 452 /*OUT*/Object[] o_any, 453 /*OUT*/TestElement[][] o_testElements, 454 /*OUT*/TestDataElements[] o_testDataElements) throws com.sun.star.uno.RuntimeException 455 { 456 if(DEBUG) System.err.println("##### " + getClass().getName() + ".getValues:" + _any); 457 458 o_bool[0] = _bool; 459 o_char[0] = _char; 460 o_byte[0] = _byte; 461 o_short[0] = _short; 462 o_ushort[0] = _ushort; 463 o_long[0] = _long; 464 o_ulong[0] = _ulong; 465 o_hyper[0] = _hyper; 466 o_uhyper[0] = _uhyper; 467 o_float[0] = _float; 468 o_double[0] = _double; 469 o_testEnum[0] = _testEnum; 470 o_string[0] = _string; 471 o_xInterface[0] = _xInterface; 472 o_any[0] = _any; 473 o_testElements[0] = _testElements; 474 o_testDataElements[0] = _testDataElements; 475 476 return _testDataElements; 477 } 478 479 public SmallStruct echoSmallStruct( SmallStruct i_Struct) throws com.sun.star.uno.RuntimeException { 480 return i_Struct; 481 } 482 483 public MediumStruct echoMediumStruct( MediumStruct i_Struct) throws com.sun.star.uno.RuntimeException { 484 return i_Struct; 485 } 486 487 public BigStruct echoBigStruct( BigStruct i_Struct) throws com.sun.star.uno.RuntimeException { 488 return i_Struct; 489 } 490 491 public AllFloats echoAllFloats( AllFloats i_Struct) throws com.sun.star.uno.RuntimeException { 492 return i_Struct; 493 } 494 495 public int testPPCAlignment( long l1, long l2, int i1, long l3, int i2 ) throws com.sun.star.uno.RuntimeException { 496 return i2; 497 } 498 499 // Attributes 500 public boolean getBool() throws com.sun.star.uno.RuntimeException { 501 return _bool; 502 } 503 504 public void setBool(boolean bool) throws com.sun.star.uno.RuntimeException { 505 _bool = bool; 506 } 507 508 public byte getByte() throws com.sun.star.uno.RuntimeException { 509 return _byte; 510 } 511 512 public void setByte(byte zbyte) throws com.sun.star.uno.RuntimeException { 513 _byte = zbyte; 514 } 515 516 public char getChar() throws com.sun.star.uno.RuntimeException { 517 return _char; 518 } 519 520 public void setChar(char zchar) throws com.sun.star.uno.RuntimeException { 521 _char = zchar; 522 } 523 524 public short getShort() throws com.sun.star.uno.RuntimeException { 525 return _short; 526 } 527 528 public void setShort(short zshort) throws com.sun.star.uno.RuntimeException { 529 _short = zshort; 530 } 531 532 public short getUShort() throws com.sun.star.uno.RuntimeException { 533 return _ushort; 534 } 535 536 public void setUShort(short ushort) throws com.sun.star.uno.RuntimeException { 537 _ushort = ushort; 538 } 539 540 public int getLong() throws com.sun.star.uno.RuntimeException { 541 return _long; 542 } 543 544 public void setLong(int zint) throws com.sun.star.uno.RuntimeException { 545 _long = zint; 546 } 547 548 public int getULong() throws com.sun.star.uno.RuntimeException { 549 return _ulong; 550 } 551 552 public void setULong(int uint) throws com.sun.star.uno.RuntimeException { 553 _ulong = uint; 554 } 555 556 public long getHyper() throws com.sun.star.uno.RuntimeException { 557 return _hyper; 558 } 559 560 public void setHyper(long hyper) throws com.sun.star.uno.RuntimeException { 561 _hyper = hyper; 562 } 563 564 public long getUHyper() throws com.sun.star.uno.RuntimeException { 565 return _uhyper; 566 } 567 568 public void setUHyper(long uhyper) throws com.sun.star.uno.RuntimeException { 569 _uhyper = uhyper; 570 } 571 572 public float getFloat() throws com.sun.star.uno.RuntimeException { 573 return _float; 574 } 575 576 public void setFloat(float zfloat) throws com.sun.star.uno.RuntimeException { 577 _float = zfloat; 578 } 579 580 public double getDouble() throws com.sun.star.uno.RuntimeException { 581 return _double; 582 } 583 584 public void setDouble(double zdouble) throws com.sun.star.uno.RuntimeException { 585 _double = zdouble; 586 } 587 588 public TestEnum getEnum() throws com.sun.star.uno.RuntimeException { 589 return _testEnum; 590 } 591 592 public void setEnum(TestEnum testEnum) throws com.sun.star.uno.RuntimeException { 593 _testEnum = testEnum; 594 } 595 596 public String getString() throws com.sun.star.uno.RuntimeException { 597 return _string; 598 } 599 600 public void setString(String string) throws com.sun.star.uno.RuntimeException { 601 _string = string; 602 } 603 604 public Object getInterface() throws com.sun.star.uno.RuntimeException { 605 return _xInterface; 606 } 607 608 public void setInterface(Object zinterface) throws com.sun.star.uno.RuntimeException { 609 _xInterface = zinterface; 610 } 611 612 public Object getAny() throws com.sun.star.uno.RuntimeException { 613 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + _any); 614 615 return _any; 616 } 617 618 public void setAny(Object any) throws com.sun.star.uno.RuntimeException { 619 if(DEBUG) System.err.println("##### " + getClass().getName() + ".setAny:" + any); 620 621 _any = any; 622 } 623 624 public TestElement[] getSequence() throws com.sun.star.uno.RuntimeException { 625 return _testElements; 626 } 627 628 public void setSequence(TestElement testElements[]) throws com.sun.star.uno.RuntimeException { 629 _testElements = testElements; 630 } 631 632 public TestDataElements getStruct() throws com.sun.star.uno.RuntimeException { 633 return _testDataElements; 634 } 635 636 public void setStruct(TestDataElements testDataElements) throws com.sun.star.uno.RuntimeException { 637 _testDataElements = testDataElements; 638 } 639 640 public int getRaiseAttr1() { 641 throw new com.sun.star.uno.RuntimeException(); 642 } 643 644 public void setRaiseAttr1(int n) throws IllegalArgumentException { 645 throw new IllegalArgumentException(); 646 } 647 648 public int getRaiseAttr2() throws IllegalArgumentException { 649 throw new IllegalArgumentException(); 650 } 651 652 public TestPolyStruct transportPolyBoolean(TestPolyStruct arg) { 653 Boolean dummy = (Boolean) arg.member; 654 return arg; 655 } 656 657 public void transportPolyHyper(TestPolyStruct[] arg) { 658 Long dummy = (Long) arg[0].member; 659 } 660 661 public void transportPolySequence( 662 TestPolyStruct arg1, TestPolyStruct[] arg2) 663 { 664 Object[] dummy = (Object[]) arg1.member; 665 arg2[0] = arg1; 666 } 667 668 public TestPolyStruct getNullPolyLong() { 669 return new TestPolyStruct(); 670 } 671 672 public TestPolyStruct getNullPolyString() { 673 return new TestPolyStruct(); 674 } 675 676 public TestPolyStruct getNullPolyType() { 677 return new TestPolyStruct(); 678 } 679 680 public TestPolyStruct getNullPolyAny() { 681 return new TestPolyStruct(); 682 } 683 684 public TestPolyStruct getNullPolySequence() { 685 return new TestPolyStruct(); 686 } 687 688 public TestPolyStruct getNullPolyEnum() { 689 return new TestPolyStruct(); 690 } 691 692 public TestPolyStruct getNullPolyBadEnum() { 693 return new TestPolyStruct(); 694 } 695 696 public TestPolyStruct getNullPolyStruct() { 697 return new TestPolyStruct(); 698 } 699 700 public TestPolyStruct getNullPolyInterface() { 701 return new TestPolyStruct(); 702 } 703 704 public Object transportAny(Object value) throws com.sun.star.uno.RuntimeException { 705 return value; 706 } 707 708 public void call(int nCallId , int nWaitMUSEC) throws com.sun.star.uno.RuntimeException { 709 // TimeValue value = { nWaitMUSEC / 1000000 , nWaitMUSEC * 1000 }; 710 // osl_waitThread( &value ); 711 try { 712 Thread.sleep(nWaitMUSEC / 10000); 713 } 714 catch(InterruptedException interruptedException) { 715 throw new com.sun.star.uno.RuntimeException(interruptedException.getMessage()); 716 } 717 718 if(_bFirstCall) 719 _bFirstCall = false; 720 721 else 722 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId); 723 724 _nLastCallId = nCallId; 725 } 726 727 public void callOneway( int nCallId , int nWaitMUSEC ) throws com.sun.star.uno.RuntimeException { 728 // TimeValue value = { nWaitMUSEC / 1000000 , nWaitMUSEC * 1000 }; 729 // osl_waitThread( &value ); 730 try { 731 Thread.sleep(nWaitMUSEC / 10000); 732 } 733 catch(InterruptedException interruptedException) { 734 throw new com.sun.star.uno.RuntimeException(interruptedException.getMessage()); 735 } 736 737 _bSequenceOfCallTestPassed = _bSequenceOfCallTestPassed && (nCallId > _nLastCallId); 738 _nLastCallId = nCallId; 739 } 740 741 public boolean sequenceOfCallTestPassed() throws com.sun.star.uno.RuntimeException { 742 return _bSequenceOfCallTestPassed; 743 } 744 745 public synchronized void callRecursivly(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException { 746 if(nToCall != 0) 747 { 748 nToCall --; 749 xCall.callRecursivly(this , nToCall); 750 } 751 } 752 753 public synchronized void startRecursiveCall(XRecursiveCall xCall, int nToCall) throws com.sun.star.uno.RuntimeException { 754 if(nToCall != 0) 755 { 756 nToCall --; 757 xCall.callRecursivly( this , nToCall ); 758 } 759 } 760 761 public XMulti getMulti() { 762 return new XMulti() { 763 public double getatt1() { 764 return attribute1; 765 } 766 767 public void setatt1(double value) { 768 attribute1 = value; 769 } 770 771 public int fn11(int arg) { 772 return 11 * arg; 773 } 774 775 public String fn12(String arg) { 776 return "12" + arg; 777 } 778 779 public int fn21(int arg) { 780 return 21 * arg; 781 } 782 783 public String fn22(String arg) { 784 return "22" + arg; 785 } 786 787 public double getatt3() { 788 return attribute3; 789 } 790 791 public void setatt3(double value) { 792 attribute3 = value; 793 } 794 795 public int fn31(int arg) { 796 return 31 * arg; 797 } 798 799 public String fn32(String arg) { 800 return "32" + arg; 801 } 802 803 public int fn33() { 804 return 33; 805 } 806 807 public int fn41(int arg) { 808 return 41 * arg; 809 } 810 811 public int fn61(int arg) { 812 return 61 * arg; 813 } 814 815 public String fn62(String arg) { 816 return "62" + arg; 817 } 818 819 public int fn71(int arg) { 820 return 71 * arg; 821 } 822 823 public String fn72(String arg) { 824 return "72" + arg; 825 } 826 827 public int fn73() { 828 return 73; 829 } 830 831 private double attribute1 = 0.0; 832 private double attribute3 = 0.0; 833 }; 834 } 835 836 private static final class CheckFailed extends Exception { 837 CheckFailed(String message) { 838 super(message); 839 } 840 } 841 842 private static void checkEqual(int value, int argument) 843 throws CheckFailed 844 { 845 if (argument != value) { 846 throw new CheckFailed(value + " != " + argument); 847 } 848 } 849 850 private static void checkEqual(double value, double argument) 851 throws CheckFailed 852 { 853 if (argument != value) { 854 throw new CheckFailed(value + " != " + argument); 855 } 856 } 857 858 private static void checkEqual(String value, String argument) 859 throws CheckFailed 860 { 861 if (!argument.equals(value)) { 862 throw new CheckFailed(value + " != " + argument); 863 } 864 } 865 866 public String testMulti(XMulti multi) { 867 try { 868 checkEqual(0.0, multi.getatt1()); 869 multi.setatt1(0.1); 870 checkEqual(0.1, multi.getatt1()); 871 checkEqual(11 * 1, multi.fn11(1)); 872 checkEqual("12" + "abc", multi.fn12("abc")); 873 checkEqual(21 * 2, multi.fn21(2)); 874 checkEqual("22" + "de", multi.fn22("de")); 875 checkEqual(0.0, multi.getatt3()); 876 multi.setatt3(0.3); 877 checkEqual(0.3, multi.getatt3()); 878 checkEqual(31 * 3, multi.fn31(3)); 879 checkEqual("32" + "f", multi.fn32("f")); 880 checkEqual(33, multi.fn33()); 881 checkEqual(41 * 4, multi.fn41(4)); 882 checkEqual(61 * 6, multi.fn61(6)); 883 checkEqual("62" + "", multi.fn62("")); 884 checkEqual(71 * 7, multi.fn71(7)); 885 checkEqual("72" + "g", multi.fn72("g")); 886 checkEqual(73, multi.fn73()); 887 } catch (CheckFailed f) { 888 return f.getMessage(); 889 } 890 return ""; 891 } 892 893 // XBridgeTest 894 public TestDataElements raiseException(short nArgumentPos, String rMsg, Object xContext) 895 throws com.sun.star.lang.IllegalArgumentException, 896 com.sun.star.uno.RuntimeException 897 { 898 throw new com.sun.star.lang.IllegalArgumentException(rMsg, xContext, nArgumentPos); 899 } 900 901 public void raiseRuntimeExceptionOneway(String rMsg, Object xContext) throws com.sun.star.uno.RuntimeException { 902 throw new com.sun.star.uno.RuntimeException(rMsg, xContext); 903 } 904 905 private void dothrow( com.sun.star.uno.RuntimeException t ) 906 throws com.sun.star.uno.RuntimeException 907 { 908 throw t; 909 } 910 public int getRuntimeException() 911 throws com.sun.star.uno.RuntimeException 912 { 913 try 914 { 915 dothrow( new com.sun.star.uno.RuntimeException( 916 _string, _xInterface ) ); 917 return 0; // dummy 918 } 919 catch (com.sun.star.uno.RuntimeException t) 920 { 921 throw t; 922 } 923 } 924 925 public void setRuntimeException(int _runtimeexception) throws com.sun.star.uno.RuntimeException { 926 throw new com.sun.star.uno.RuntimeException(_string, _xInterface); 927 } 928 929 930 931 // XServiceInfo 932 public String getImplementationName() throws com.sun.star.uno.RuntimeException { 933 return __serviceName; 934 } 935 936 public boolean supportsService(String rServiceName) throws com.sun.star.uno.RuntimeException { 937 String rSNL[] = getSupportedServiceNames(); 938 939 for(int nPos = rSNL.length; (nPos--) != 0;) { 940 if (rSNL[nPos].equals(rServiceName)) 941 return true; 942 } 943 944 return false; 945 } 946 947 public String [] getSupportedServiceNames() throws com.sun.star.uno.RuntimeException { 948 return new String[]{__serviceName}; 949 } 950 951 // XTypeProvider 952 public Type[] getTypes() throws com.sun.star.uno.RuntimeException { 953 try { 954 return new Type[]{new Type(XBridgeTest.class), new Type(XRecursiveCall.class), new Type(XServiceInfo.class), new Type(XTypeProvider.class)}; 955 } 956 catch(Exception exception) { 957 throw new com.sun.star.uno.RuntimeException(exception.getMessage()); 958 } 959 } 960 961 public byte[] getImplementationId() throws com.sun.star.uno.RuntimeException { 962 return toString().getBytes(); 963 } 964 965 //XBridgeTest2 966 public boolean[] setSequenceBool( /*IN*/boolean[] aSeq ) 967 { 968 arBool = aSeq; 969 return aSeq; 970 } 971 public char[] setSequenceChar( /*IN*/char[] aSeq ) 972 { 973 arChar = aSeq; 974 return aSeq; 975 } 976 public byte[] setSequenceByte( /*IN*/byte[] aSeq ) 977 { 978 arByte = aSeq; 979 return aSeq; 980 } 981 public short[] setSequenceShort( /*IN*/short[] aSeq ) 982 { 983 arShort = aSeq; 984 return aSeq; 985 } 986 public short[] setSequenceUShort( /*IN*/short[] aSeq ) 987 { 988 arUShort = aSeq; 989 return aSeq; 990 } 991 public int[] setSequenceLong( /*IN*/int[] aSeq ) 992 { 993 arLong = aSeq; 994 return aSeq; 995 } 996 public int[] setSequenceULong( /*IN*/int[] aSeq ) 997 { 998 arULong = aSeq; 999 return aSeq; 1000 } 1001 public long[] setSequenceHyper( /*IN*/long[] aSeq ) 1002 { 1003 arHyper = aSeq; 1004 return aSeq; 1005 } 1006 public long[] setSequenceUHyper( /*IN*/long[] aSeq ) 1007 { 1008 arUHyper = aSeq; 1009 return aSeq; 1010 } 1011 public float[] setSequenceFloat( /*IN*/float[] aSeq ) 1012 { 1013 arFloat = aSeq; 1014 return aSeq; 1015 } 1016 public double[] setSequenceDouble( /*IN*/double[] aSeq ) 1017 { 1018 arDouble = aSeq; 1019 return aSeq; 1020 } 1021 public TestEnum[] setSequenceEnum( /*IN*/TestEnum[] aSeq ) 1022 { 1023 arEnum = aSeq; 1024 return aSeq; 1025 } 1026 public String[] setSequenceString( /*IN*/String[] aSeq ) 1027 { 1028 arString = aSeq; 1029 return aSeq; 1030 } 1031 public java.lang.Object[] setSequenceXInterface( /*IN*/java.lang.Object[] aSeq ) 1032 { 1033 arObject = aSeq; 1034 return aSeq; 1035 } 1036 public java.lang.Object[] setSequenceAny( /*IN*/java.lang.Object[] aSeq ) 1037 { 1038 arAny = aSeq; 1039 return aSeq; 1040 } 1041 public TestElement[] setSequenceStruct( /*IN*/TestElement[] aSeq ) 1042 { 1043 _testElements = aSeq; 1044 return aSeq; 1045 } 1046 public int[][] setDim2( /*IN*/int[][] aSeq ) 1047 { 1048 arLong2 = aSeq; 1049 return aSeq; 1050 } 1051 public int[][][] setDim3( /*IN*/int[][][] aSeq ) 1052 { 1053 arLong3 = aSeq; 1054 return aSeq; 1055 } 1056 public void setSequencesInOut( /*INOUT*/boolean[][] aSeqBoolean, 1057 /*INOUT*/char[][] aSeqChar, /*INOUT*/byte[][] aSeqByte, 1058 /*INOUT*/short[][] aSeqShort, /*INOUT*/short[][] aSeqUShort, 1059 /*INOUT*/int[][] aSeqLong, /*INOUT*/int[][] aSeqULong, 1060 /*INOUT*/long[][] aSeqHyper, /*INOUT*/long[][] aSeqUHyper, 1061 /*INOUT*/float[][] aSeqFloat, /*INOUT*/double[][] aSeqDouble, 1062 /*INOUT*/TestEnum[][] aSeqEnum, /*INOUT*/String[][] aSeqString, 1063 /*INOUT*/java.lang.Object[][] aSeqXInterface, 1064 /*INOUT*/java.lang.Object[][] aSeqAny, 1065 /*INOUT*/int[][][] aSeqDim2, /*INOUT*/int[][][][] aSeqDim3 ) 1066 { 1067 arBool = aSeqBoolean[0]; 1068 arChar = aSeqChar[0]; 1069 arByte = aSeqByte[0]; 1070 arShort = aSeqShort[0]; 1071 arUShort = aSeqUShort[0]; 1072 arLong = aSeqLong[0]; 1073 arULong = aSeqULong[0]; 1074 arFloat = aSeqFloat[0]; 1075 arDouble = aSeqDouble[0]; 1076 arEnum = aSeqEnum[0]; 1077 arString = aSeqString[0]; 1078 arObject = aSeqXInterface[0]; 1079 arAny = aSeqAny[0]; 1080 arLong2 = aSeqDim2[0]; 1081 arLong3 = aSeqDim3[0]; 1082 } 1083 public void setSequencesOut( /*OUT*/boolean[][] aSeqBoolean, /*OUT*/char[][] aSeqChar, 1084 /*OUT*/byte[][] aSeqByte, /*OUT*/short[][] aSeqShort, 1085 /*OUT*/short[][] aSeqUShort, /*OUT*/int[][] aSeqLong, 1086 /*OUT*/int[][] aSeqULong, /*OUT*/long[][] aSeqHyper, 1087 /*OUT*/long[][] aSeqUHyper, /*OUT*/float[][] aSeqFloat, 1088 /*OUT*/double[][] aSeqDouble, /*OUT*/TestEnum[][] aSeqEnum, 1089 /*OUT*/String[][] aSeqString, 1090 /*OUT*/java.lang.Object[][] aSeqXInterface, 1091 /*OUT*/java.lang.Object[][] aSeqAny, /*OUT*/int[][][] aSeqDim2, 1092 /*OUT*/int[][][][] aSeqDim3 ) 1093 { 1094 aSeqBoolean[0] = arBool; 1095 aSeqChar[0] = arChar; 1096 aSeqByte[0] = arByte; 1097 aSeqShort[0] = arShort; 1098 aSeqUShort[0] = arUShort; 1099 aSeqLong[0] = arLong; 1100 aSeqULong[0] = arULong; 1101 aSeqHyper[0] = arHyper; 1102 aSeqUHyper[0] = arUHyper; 1103 aSeqFloat[0] = arFloat; 1104 aSeqDouble[0] = arDouble; 1105 aSeqEnum[0] = arEnum; 1106 aSeqString[0] = arString; 1107 aSeqXInterface[0] = arObject; 1108 aSeqAny[0] = arAny; 1109 aSeqDim2[0] = arLong2; 1110 aSeqDim3[0] = arLong3; 1111 } 1112 1113 public void testConstructorsService(XComponentContext context) 1114 throws BadConstructorArguments 1115 { 1116 Constructors.create1(context, 1117 true, 1118 Byte.MIN_VALUE, 1119 Short.MIN_VALUE, 1120 (short) -1, 1121 Integer.MIN_VALUE, 1122 -1, 1123 Long.MIN_VALUE, 1124 -1L, 1125 0.123f, 1126 0.456, 1127 'X', 1128 "test", 1129 Type.ANY, 1130 new Any(Type.BOOLEAN, Boolean.TRUE), 1131 new boolean[] { true }, 1132 new byte[] { Byte.MIN_VALUE }, 1133 new short[] { Short.MIN_VALUE }, 1134 new short[] { (short) -1 }, 1135 new int[] { Integer.MIN_VALUE }, 1136 new int[] { -1 }, 1137 new long[] { Long.MIN_VALUE }, 1138 new long[] { -1L }, 1139 new float[] { 0.123f }, 1140 new double[] { 0.456 }, 1141 new char[] { 'X' }, 1142 new String[] { "test" }, 1143 new Type[] { Type.ANY }, 1144 new Boolean[] { Boolean.TRUE }, 1145 new boolean[][] { new boolean[] { true } }, 1146 new Object[][] { 1147 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } }, 1148 new TestEnum[] { TestEnum.TWO }, 1149 new TestStruct[] { new TestStruct(10) }, 1150 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) }, 1151 new TestPolyStruct[] { 1152 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)) }, 1153 new Object[] { null }, 1154 TestEnum.TWO, 1155 new TestStruct(10), 1156 new TestPolyStruct(Boolean.TRUE), 1157 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)), 1158 null); 1159 Constructors.create2(context, new Object[] { 1160 Boolean.TRUE, 1161 new Byte(Byte.MIN_VALUE), 1162 new Short(Short.MIN_VALUE), 1163 new Any(Type.UNSIGNED_SHORT, new Short((short) -1)), 1164 new Integer(Integer.MIN_VALUE), 1165 new Any(Type.UNSIGNED_LONG, new Integer(-1)), 1166 new Long(Long.MIN_VALUE), 1167 new Any(Type.UNSIGNED_HYPER, new Long(-1L)), 1168 new Float(0.123f), 1169 new Double(0.456), 1170 new Character('X'), 1171 "test", 1172 Type.ANY, 1173 new Any(Type.BOOLEAN, Boolean.TRUE), 1174 new boolean[] { true }, 1175 new byte[] { Byte.MIN_VALUE }, 1176 new short[] { Short.MIN_VALUE }, 1177 new Any( 1178 new Type("[]unsigned short"), new short[] { (short) -1 }), 1179 new int[] { Integer.MIN_VALUE }, 1180 new Any(new Type("[]unsigned long"), new int[] { -1 }), 1181 new long[] { Long.MIN_VALUE }, 1182 new Any(new Type("[]unsigned hyper"), new long[] { -1L }), 1183 new float[] { 0.123f }, 1184 new double[] { 0.456 }, 1185 new char[] { 'X' }, 1186 new String[] { "test" }, 1187 new Type[] { Type.ANY }, 1188 new Any(new Type("[]any"), new Boolean[] { Boolean.TRUE }), 1189 new boolean[][] { new boolean[] { true } }, 1190 new Object[][] { 1191 new Object[] { new Any(Type.BOOLEAN, Boolean.TRUE) } }, 1192 new TestEnum[] { TestEnum.TWO }, 1193 new TestStruct[] { new TestStruct(10) }, 1194 new Any( 1195 new Type( 1196 "[]test.testtools.bridgetest.TestPolyStruct<boolean>"), 1197 new TestPolyStruct[] { new TestPolyStruct(Boolean.TRUE) }), 1198 new Any( 1199 new Type("[]test.testtools.bridgetest.TestPolyStruct<any>"), 1200 new TestPolyStruct[] { 1201 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)) 1202 }), 1203 new XInterface[] { null }, 1204 TestEnum.TWO, 1205 new TestStruct(10), 1206 new Any( 1207 new Type( 1208 "test.testtools.bridgetest.TestPolyStruct<boolean>"), 1209 new TestPolyStruct(Boolean.TRUE)), 1210 new Any( 1211 new Type("test.testtools.bridgetest.TestPolyStruct<any>"), 1212 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))), 1213 null }); 1214 Constructors2.create1( 1215 context, 1216 new TestPolyStruct(Type.LONG), 1217 new TestPolyStruct(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 Integer(Integer.MIN_VALUE)), 1222 new TestPolyStruct(new Long(Long.MIN_VALUE)), 1223 new TestPolyStruct(new Character('X')), 1224 new TestPolyStruct("test"), 1225 new TestPolyStruct(new Float(0.123f)), 1226 new TestPolyStruct(new Double(0.456)), 1227 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()), 1228 new TestPolyStruct(new com.sun.star.lib.uno.helper.ComponentBase()), 1229 new TestPolyStruct(TestEnum.TWO), 1230 new TestPolyStruct(new TestPolyStruct2(new Character('X'), 1231 new Any(Type.BOOLEAN, Boolean.TRUE))), 1232 new TestPolyStruct(new TestPolyStruct2(new TestPolyStruct2( 1233 new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test")), 1234 new TestPolyStruct2("test", new TestPolyStruct2(new Character('X'), 1235 new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE)))), 1236 new TestPolyStruct2( new TestPolyStruct2(new Character('X'), 1237 new Any(Type.BOOLEAN, Boolean.TRUE)), new TestPolyStruct(new Character('X'))), 1238 new TestPolyStruct(new Type[] { Type.LONG}), 1239 new TestPolyStruct(new Any[] { new Any(Type.BOOLEAN, Boolean.TRUE) }), 1240 new TestPolyStruct(new boolean[] {true}), 1241 new TestPolyStruct(new byte[] {Byte.MIN_VALUE}), 1242 new TestPolyStruct(new short[] {Short.MIN_VALUE}), 1243 new TestPolyStruct(new int[] {Integer.MIN_VALUE}), 1244 new TestPolyStruct(new long[] {Long.MIN_VALUE}), 1245 new TestPolyStruct(new char[] {'X'}), 1246 new TestPolyStruct(new String[] {"test"}), 1247 new TestPolyStruct(new float[] {0.123f}), 1248 new TestPolyStruct(new double[] {0.456d}), 1249 new TestPolyStruct(new Object[] {new com.sun.star.lib.uno.helper.ComponentBase()}), 1250 new TestPolyStruct(new com.sun.star.lang.XComponent[] {new com.sun.star.lib.uno.helper.ComponentBase()}), 1251 new TestPolyStruct(new TestEnum[] {TestEnum.TWO}), 1252 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2( 1253 new Character('X'), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}), 1254 new TestPolyStruct(new TestPolyStruct2[] {new TestPolyStruct2( 1255 new TestPolyStruct(new Character('X')), new Any[] {new Any(Type.BOOLEAN, Boolean.TRUE)})}), 1256 new TestPolyStruct(new int[][] { new int[] {Integer.MIN_VALUE} }), 1257 new TestPolyStruct[]{ new TestPolyStruct(new Integer(Integer.MIN_VALUE))}, 1258 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2( 1259 new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))}, 1260 new TestPolyStruct[]{new TestPolyStruct(new TestPolyStruct2( 1261 new TestPolyStruct2(new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))}, 1262 new TestPolyStruct2[]{new TestPolyStruct2("test", new TestPolyStruct2( 1263 new Character('X'), new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))}, 1264 new TestPolyStruct2[]{new TestPolyStruct2(new TestPolyStruct2(new Character('X'), new Any( 1265 Type.BOOLEAN, Boolean.TRUE)),new TestPolyStruct(new Character('X')))}, 1266 new TestPolyStruct[][]{new TestPolyStruct[]{new TestPolyStruct(new Character('X'))}}, 1267 new TestPolyStruct[][]{new TestPolyStruct[]{ 1268 new TestPolyStruct(new TestPolyStruct2(new Character('X'), new Any(Type.BOOLEAN, Boolean.TRUE)))}}, 1269 new TestPolyStruct[][]{new TestPolyStruct[] {new TestPolyStruct(new TestPolyStruct2( 1270 new TestPolyStruct2(new Character('X'),new Any(Type.BOOLEAN, Boolean.TRUE)), "test"))}}, 1271 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2( 1272 "test", new TestPolyStruct2(new Character('X'),new TestPolyStruct(new Any(Type.BOOLEAN, Boolean.TRUE))))}}, 1273 new TestPolyStruct2[][]{new TestPolyStruct2[]{new TestPolyStruct2( 1274 new TestPolyStruct2(new Character('X'),new Any(Type.BOOLEAN, Boolean.TRUE)), 1275 new TestPolyStruct(new Character('X')))}}); 1276 } 1277 1278 public XCurrentContextChecker getCurrentContextChecker() { 1279 return new CurrentContextChecker(); 1280 } 1281 } 1282 1283 /** 1284 * Gives a factory for creating the service. 1285 * This method is called by the <code>JavaLoader</code> 1286 * <p> 1287 * @return returns a <code>XSingleServiceFactory</code> for creating the component 1288 * @param implName the name of the implementation for which a service is desired 1289 * @param multiFactory the service manager to be uses if needed 1290 * @param regKey the registryKey 1291 * @see com.sun.star.comp.loader.JavaLoader 1292 */ 1293 public static XSingleServiceFactory __getServiceFactory(String implName, 1294 XMultiServiceFactory multiFactory, 1295 XRegistryKey regKey) 1296 { 1297 XSingleServiceFactory xSingleServiceFactory = null; 1298 1299 if(implName.equals(_TestObject.class.getName())) 1300 xSingleServiceFactory = FactoryHelper.getServiceFactory(_TestObject.class, 1301 _TestObject.__serviceName, 1302 multiFactory, 1303 regKey); 1304 1305 else if(implName.equals(_PerformancTestObject.class.getName())) 1306 xSingleServiceFactory = FactoryHelper.getServiceFactory(_PerformancTestObject.class, 1307 _PerformancTestObject.__serviceName, 1308 multiFactory, 1309 regKey); 1310 1311 return xSingleServiceFactory; 1312 } 1313 } 1314