1 // 2 // Copyright (c) ZeroC, Inc. All rights reserved. 3 // 4 5 package test.Ice.operations; 6 7 import java.util.ArrayList; 8 import java.util.HashMap; 9 import java.util.List; 10 import java.util.Map; 11 import java.util.concurrent.CompletableFuture; 12 13 import com.zeroc.Ice.LocalException; 14 15 import test.Ice.operations.Test.*; 16 17 class TwowaysAMI 18 { test(boolean b)19 private static void test(boolean b) 20 { 21 if(!b) 22 { 23 new Throwable().printStackTrace(); 24 // 25 // Exceptions raised by callbacks are swallowed by CompletableFuture. 26 // 27 throw new RuntimeException(); 28 } 29 } 30 31 private static class Callback 32 { Callback()33 Callback() 34 { 35 _called = false; 36 } 37 check()38 public synchronized void check() 39 { 40 while(!_called) 41 { 42 try 43 { 44 wait(); 45 } 46 catch(InterruptedException ex) 47 { 48 } 49 } 50 51 _called = false; 52 } 53 called()54 public synchronized void called() 55 { 56 assert(!_called); 57 _called = true; 58 notify(); 59 } 60 61 private boolean _called; 62 } 63 twowaysAMI(test.TestHelper helper, MyClassPrx p)64 static void twowaysAMI(test.TestHelper helper, MyClassPrx p) 65 { 66 com.zeroc.Ice.Communicator communicator = helper.communicator(); 67 final boolean bluetooth = communicator.getProperties().getProperty("Ice.Default.Protocol").indexOf("bt") == 0; 68 69 { 70 Callback cb = new Callback(); 71 p.ice_pingAsync().whenComplete((result, ex) -> 72 { 73 test(ex == null); 74 cb.called(); 75 }); 76 cb.check(); 77 } 78 79 { 80 Callback cb = new Callback(); 81 p.ice_isAAsync(MyClass.ice_staticId()).whenComplete((result, ex) -> 82 { 83 test(ex == null); 84 test(result); 85 cb.called(); 86 }); 87 cb.check(); 88 } 89 90 { 91 Callback cb = new Callback(); 92 p.ice_idAsync().whenComplete((result, ex) -> 93 { 94 test(ex == null); 95 test(result.equals(MyDerivedClass.ice_staticId())); 96 cb.called(); 97 }); 98 cb.check(); 99 } 100 101 { 102 Callback cb = new Callback(); 103 p.ice_idsAsync().whenComplete((result, ex) -> 104 { 105 test(ex == null); 106 test(result.length == 3); 107 cb.called(); 108 }); 109 cb.check(); 110 } 111 112 { 113 p.opVoidAsync().join(); 114 } 115 116 { 117 Callback cb = new Callback(); 118 p.opVoidAsync().whenComplete((result, ex) -> 119 { 120 test(ex == null); 121 cb.called(); 122 }); 123 cb.check(); 124 } 125 126 { 127 Callback cb = new Callback(); 128 p.opByteAsync((byte)0xff, (byte)0x0f).whenComplete((result, ex) -> 129 { 130 test(ex == null); 131 test(result.p3 == (byte)0xf0); 132 test(result.returnValue == (byte)0xff); 133 cb.called(); 134 }); 135 cb.check(); 136 } 137 138 { 139 Callback cb = new Callback(); 140 p.opBoolAsync(true, false).whenComplete((result, ex) -> 141 { 142 test(ex == null); 143 test(result.p3); 144 test(!result.returnValue); 145 cb.called(); 146 }); 147 cb.check(); 148 } 149 150 { 151 Callback cb = new Callback(); 152 p.opShortIntLongAsync((short)10, 11, 12L).whenComplete((result, ex) -> 153 { 154 test(ex == null); 155 test(result.p4 == 10); 156 test(result.p5 == 11); 157 test(result.p6 == 12); 158 test(result.returnValue == 12); 159 cb.called(); 160 }); 161 cb.check(); 162 } 163 164 { 165 Callback cb = new Callback(); 166 p.opFloatDoubleAsync(3.14f, 1.1E10).whenComplete((result, ex) -> 167 { 168 test(ex == null); 169 test(result.p3 == 3.14f); 170 test(result.p4 == 1.1E10); 171 test(result.returnValue == 1.1E10); 172 cb.called(); 173 }); 174 cb.check(); 175 } 176 177 { 178 Callback cb = new Callback(); 179 p.opStringAsync("hello", "world").whenComplete((result, ex) -> 180 { 181 test(ex == null); 182 test(result.p3.equals("world hello")); 183 test(result.returnValue.equals("hello world")); 184 cb.called(); 185 }); 186 cb.check(); 187 } 188 189 { 190 Callback cb = new Callback(); 191 p.opMyEnumAsync(MyEnum.enum2).whenComplete((result, ex) -> 192 { 193 test(ex == null); 194 test(result.p2 == MyEnum.enum2); 195 test(result.returnValue == MyEnum.enum3); 196 cb.called(); 197 }); 198 cb.check(); 199 } 200 201 { 202 Callback cb = new Callback(); 203 p.opMyClassAsync(p).whenComplete((result, ex) -> 204 { 205 test(ex == null); 206 test(result.p2.ice_getIdentity().equals(com.zeroc.Ice.Util.stringToIdentity("test"))); 207 test(result.p3.ice_getIdentity().equals(com.zeroc.Ice.Util.stringToIdentity("noSuchIdentity"))); 208 test(result.returnValue.ice_getIdentity().equals(com.zeroc.Ice.Util.stringToIdentity("test"))); 209 // We can't do the callbacks below in connection serialization mode. 210 if(communicator.getProperties().getPropertyAsInt("Ice.ThreadPool.Client.Serialize") == 0) 211 { 212 result.returnValue.opVoid(); 213 result.p2.opVoid(); 214 try 215 { 216 result.p3.opVoid(); 217 test(false); 218 } 219 catch(com.zeroc.Ice.ObjectNotExistException e) 220 { 221 } 222 } 223 cb.called(); 224 }); 225 cb.check(); 226 } 227 228 { 229 Structure si1 = new Structure(); 230 si1.p = p; 231 si1.e = MyEnum.enum3; 232 si1.s = new AnotherStruct(); 233 si1.s.s = "abc"; 234 Structure si2 = new Structure(); 235 si2.p = null; 236 si2.e = MyEnum.enum2; 237 si2.s = new AnotherStruct(); 238 si2.s.s = "def"; 239 240 Callback cb = new Callback(); 241 p.opStructAsync(si1, si2).whenComplete((result, ex) -> 242 { 243 test(ex == null); 244 test(result.returnValue.p == null); 245 test(result.returnValue.e == MyEnum.enum2); 246 test(result.returnValue.s.s.equals("def")); 247 test(result.p3.e == MyEnum.enum3); 248 test(result.p3.s.s.equals("a new string")); 249 // We can't do the callbacks below in connection serialization mode. 250 if(communicator.getProperties().getPropertyAsInt("Ice.ThreadPool.Client.Serialize") == 0) 251 { 252 result.p3.p.opVoid(); 253 } 254 cb.called(); 255 }); 256 cb.check(); 257 } 258 259 { 260 final byte[] bsi1 = 261 { 262 (byte)0x01, 263 (byte)0x11, 264 (byte)0x12, 265 (byte)0x22 266 }; 267 final byte[] bsi2 = 268 { 269 (byte)0xf1, 270 (byte)0xf2, 271 (byte)0xf3, 272 (byte)0xf4 273 }; 274 275 Callback cb = new Callback(); 276 p.opByteSAsync(bsi1, bsi2).whenComplete((result, ex) -> 277 { 278 test(ex == null); 279 test(result.p3.length == 4); 280 test(result.p3[0] == (byte)0x22); 281 test(result.p3[1] == (byte)0x12); 282 test(result.p3[2] == (byte)0x11); 283 test(result.p3[3] == (byte)0x01); 284 test(result.returnValue.length == 8); 285 test(result.returnValue[0] == (byte)0x01); 286 test(result.returnValue[1] == (byte)0x11); 287 test(result.returnValue[2] == (byte)0x12); 288 test(result.returnValue[3] == (byte)0x22); 289 test(result.returnValue[4] == (byte)0xf1); 290 test(result.returnValue[5] == (byte)0xf2); 291 test(result.returnValue[6] == (byte)0xf3); 292 test(result.returnValue[7] == (byte)0xf4); 293 cb.called(); 294 }); 295 cb.check(); 296 } 297 298 { 299 final boolean[] bsi1 = { true, true, false }; 300 final boolean[] bsi2 = { false }; 301 302 Callback cb = new Callback(); 303 p.opBoolSAsync(bsi1, bsi2).whenComplete((result, ex) -> 304 { 305 test(ex == null); 306 test(result.p3.length == 4); 307 test(result.p3[0]); 308 test(result.p3[1]); 309 test(!result.p3[2]); 310 test(!result.p3[3]); 311 test(result.returnValue.length == 3); 312 test(!result.returnValue[0]); 313 test(result.returnValue[1]); 314 test(result.returnValue[2]); 315 cb.called(); 316 }); 317 cb.check(); 318 } 319 320 { 321 final short[] ssi = { 1, 2, 3 }; 322 final int[] isi = { 5, 6, 7, 8 }; 323 final long[] lsi = { 10, 30, 20 }; 324 325 Callback cb = new Callback(); 326 p.opShortIntLongSAsync(ssi, isi, lsi).whenComplete((result, ex) -> 327 { 328 test(ex == null); 329 test(result.p4.length == 3); 330 test(result.p4[0] == 1); 331 test(result.p4[1] == 2); 332 test(result.p4[2] == 3); 333 test(result.p5.length == 4); 334 test(result.p5[0] == 8); 335 test(result.p5[1] == 7); 336 test(result.p5[2] == 6); 337 test(result.p5[3] == 5); 338 test(result.p6.length == 6); 339 test(result.p6[0] == 10); 340 test(result.p6[1] == 30); 341 test(result.p6[2] == 20); 342 test(result.p6[3] == 10); 343 test(result.p6[4] == 30); 344 test(result.p6[5] == 20); 345 test(result.returnValue.length == 3); 346 test(result.returnValue[0] == 10); 347 test(result.returnValue[1] == 30); 348 test(result.returnValue[2] == 20); 349 cb.called(); 350 }); 351 cb.check(); 352 } 353 354 { 355 final float[] fsi = { 3.14f, 1.11f }; 356 final double[] dsi = { 1.1E10, 1.2E10, 1.3E10 }; 357 358 Callback cb = new Callback(); 359 p.opFloatDoubleSAsync(fsi, dsi).whenComplete((result, ex) -> 360 { 361 test(ex == null); 362 test(result.p3.length == 2); 363 test(result.p3[0] == 3.14f); 364 test(result.p3[1] == 1.11f); 365 test(result.p4.length == 3); 366 test(result.p4[0] == 1.3E10); 367 test(result.p4[1] == 1.2E10); 368 test(result.p4[2] == 1.1E10); 369 test(result.returnValue.length == 5); 370 test(result.returnValue[0] == 1.1E10); 371 test(result.returnValue[1] == 1.2E10); 372 test(result.returnValue[2] == 1.3E10); 373 test((float)result.returnValue[3] == 3.14f); 374 test((float)result.returnValue[4] == 1.11f); 375 cb.called(); 376 }); 377 cb.check(); 378 } 379 380 { 381 final String[] ssi1 = { "abc", "de", "fghi" }; 382 final String[] ssi2 = { "xyz" }; 383 384 Callback cb = new Callback(); 385 p.opStringSAsync(ssi1, ssi2).whenComplete((result, ex) -> 386 { 387 test(ex == null); 388 test(result.p3.length == 4); 389 test(result.p3[0].equals("abc")); 390 test(result.p3[1].equals("de")); 391 test(result.p3[2].equals("fghi")); 392 test(result.p3[3].equals("xyz")); 393 test(result.returnValue.length == 3); 394 test(result.returnValue[0].equals("fghi")); 395 test(result.returnValue[1].equals("de")); 396 test(result.returnValue[2].equals("abc")); 397 cb.called(); 398 }); 399 cb.check(); 400 } 401 402 { 403 final byte[][] bsi1 = 404 { 405 { (byte)0x01, (byte)0x11, (byte)0x12 }, 406 { (byte)0xff } 407 }; 408 final byte[][] bsi2 = 409 { 410 { (byte)0x0e }, 411 { (byte)0xf2, (byte)0xf1 } 412 }; 413 414 Callback cb = new Callback(); 415 p.opByteSSAsync(bsi1, bsi2).whenComplete((result, ex) -> 416 { 417 test(ex == null); 418 test(result.p3.length == 2); 419 test(result.p3[0].length == 1); 420 test(result.p3[0][0] == (byte)0xff); 421 test(result.p3[1].length == 3); 422 test(result.p3[1][0] == (byte)0x01); 423 test(result.p3[1][1] == (byte)0x11); 424 test(result.p3[1][2] == (byte)0x12); 425 test(result.returnValue.length == 4); 426 test(result.returnValue[0].length == 3); 427 test(result.returnValue[0][0] == (byte)0x01); 428 test(result.returnValue[0][1] == (byte)0x11); 429 test(result.returnValue[0][2] == (byte)0x12); 430 test(result.returnValue[1].length == 1); 431 test(result.returnValue[1][0] == (byte)0xff); 432 test(result.returnValue[2].length == 1); 433 test(result.returnValue[2][0] == (byte)0x0e); 434 test(result.returnValue[3].length == 2); 435 test(result.returnValue[3][0] == (byte)0xf2); 436 test(result.returnValue[3][1] == (byte)0xf1); 437 cb.called(); 438 }); 439 cb.check(); 440 } 441 442 { 443 final boolean[][] bsi1 = 444 { 445 { true }, 446 { false }, 447 { true, true} 448 }; 449 450 final boolean[][] bsi2 = 451 { 452 { false, false, true } 453 }; 454 455 Callback cb = new Callback(); 456 p.opBoolSSAsync(bsi1, bsi2).whenComplete((result, ex) -> 457 { 458 test(ex == null); 459 test(result.p3.length == 4); 460 test(result.p3[0].length == 1); 461 test(result.p3[0][0]); 462 test(result.p3[1].length == 1); 463 test(!result.p3[1][0]); 464 test(result.p3[2].length == 2); 465 test(result.p3[2][0]); 466 test(result.p3[2][1]); 467 test(result.p3[3].length == 3); 468 test(!result.p3[3][0]); 469 test(!result.p3[3][1]); 470 test(result.p3[3][2]); 471 test(result.returnValue.length == 3); 472 test(result.returnValue[0].length == 2); 473 test(result.returnValue[0][0]); 474 test(result.returnValue[0][1]); 475 test(result.returnValue[1].length == 1); 476 test(!result.returnValue[1][0]); 477 test(result.returnValue[2].length == 1); 478 test(result.returnValue[2][0]); 479 cb.called(); 480 }); 481 cb.check(); 482 } 483 484 { 485 final short[][] ssi= 486 { 487 {1, 2, 5}, 488 {13}, 489 {} 490 }; 491 final int[][] isi = 492 { 493 {24, 98}, 494 {42} 495 }; 496 final long[][] lsi = 497 { 498 {496, 1729}, 499 }; 500 501 Callback cb = new Callback(); 502 p.opShortIntLongSSAsync(ssi, isi, lsi).whenComplete((result, ex) -> 503 { 504 test(ex == null); 505 test(result.returnValue.length == 1); 506 test(result.returnValue[0].length == 2); 507 test(result.returnValue[0][0] == 496); 508 test(result.returnValue[0][1] == 1729); 509 test(result.p4.length == 3); 510 test(result.p4[0].length == 3); 511 test(result.p4[0][0] == 1); 512 test(result.p4[0][1] == 2); 513 test(result.p4[0][2] == 5); 514 test(result.p4[1].length == 1); 515 test(result.p4[1][0] == 13); 516 test(result.p4[2].length == 0); 517 test(result.p5.length == 2); 518 test(result.p5[0].length == 1); 519 test(result.p5[0][0] == 42); 520 test(result.p5[1].length == 2); 521 test(result.p5[1][0] == 24); 522 test(result.p5[1][1] == 98); 523 test(result.p6.length == 2); 524 test(result.p6[0].length == 2); 525 test(result.p6[0][0] == 496); 526 test(result.p6[0][1] == 1729); 527 test(result.p6[1].length == 2); 528 test(result.p6[1][0] == 496); 529 test(result.p6[1][1] == 1729); 530 cb.called(); 531 }); 532 cb.check(); 533 } 534 535 { 536 final float[][] fsi = 537 { 538 { 3.14f }, 539 { 1.11f }, 540 { }, 541 }; 542 final double[][] dsi = 543 { 544 { 1.1E10, 1.2E10, 1.3E10 } 545 }; 546 547 Callback cb = new Callback(); 548 p.opFloatDoubleSSAsync(fsi, dsi).whenComplete((result, ex) -> 549 { 550 test(ex == null); 551 test(result.p3.length == 3); 552 test(result.p3[0].length == 1); 553 test(result.p3[0][0] == 3.14f); 554 test(result.p3[1].length == 1); 555 test(result.p3[1][0] == 1.11f); 556 test(result.p3[2].length == 0); 557 test(result.p4.length == 1); 558 test(result.p4[0].length == 3); 559 test(result.p4[0][0] == 1.1E10); 560 test(result.p4[0][1] == 1.2E10); 561 test(result.p4[0][2] == 1.3E10); 562 test(result.returnValue.length == 2); 563 test(result.returnValue[0].length == 3); 564 test(result.returnValue[0][0] == 1.1E10); 565 test(result.returnValue[0][1] == 1.2E10); 566 test(result.returnValue[0][2] == 1.3E10); 567 test(result.returnValue[1].length == 3); 568 test(result.returnValue[1][0] == 1.1E10); 569 test(result.returnValue[1][1] == 1.2E10); 570 test(result.returnValue[1][2] == 1.3E10); 571 cb.called(); 572 }); 573 cb.check(); 574 } 575 576 { 577 final String[][] ssi1 = 578 { 579 { "abc" }, 580 { "de", "fghi" } 581 }; 582 final String[][] ssi2 = 583 { 584 { }, 585 { }, 586 { "xyz" } 587 }; 588 589 Callback cb = new Callback(); 590 p.opStringSSAsync(ssi1, ssi2).whenComplete((result, ex) -> 591 { 592 test(ex == null); 593 test(result.p3.length == 5); 594 test(result.p3[0].length == 1); 595 test(result.p3[0][0].equals("abc")); 596 test(result.p3[1].length == 2); 597 test(result.p3[1][0].equals("de")); 598 test(result.p3[1][1].equals("fghi")); 599 test(result.p3[2].length == 0); 600 test(result.p3[3].length == 0); 601 test(result.p3[4].length == 1); 602 test(result.p3[4][0].equals("xyz")); 603 test(result.returnValue.length == 3); 604 test(result.returnValue[0].length == 1); 605 test(result.returnValue[0][0].equals("xyz")); 606 test(result.returnValue[1].length == 0); 607 test(result.returnValue[2].length == 0); 608 cb.called(); 609 }); 610 cb.check(); 611 } 612 613 { 614 final String[][][] sssi1 = 615 { 616 { 617 { 618 "abc", "de" 619 }, 620 { 621 "xyz" 622 } 623 }, 624 { 625 { 626 "hello" 627 } 628 } 629 }; 630 631 final String[][][] sssi2 = 632 { 633 { 634 { 635 "", "" 636 }, 637 { 638 "abcd" 639 } 640 }, 641 { 642 { 643 "" 644 } 645 }, 646 { 647 } 648 }; 649 650 Callback cb = new Callback(); 651 p.opStringSSSAsync(sssi1, sssi2).whenComplete((result, ex) -> 652 { 653 test(ex == null); 654 test(result.p3.length == 5); 655 test(result.p3[0].length == 2); 656 test(result.p3[0][0].length == 2); 657 test(result.p3[0][1].length == 1); 658 test(result.p3[1].length == 1); 659 test(result.p3[1][0].length == 1); 660 test(result.p3[2].length == 2); 661 test(result.p3[2][0].length == 2); 662 test(result.p3[2][1].length == 1); 663 test(result.p3[3].length == 1); 664 test(result.p3[3][0].length == 1); 665 test(result.p3[4].length == 0); 666 test(result.p3[0][0][0].equals("abc")); 667 test(result.p3[0][0][1].equals("de")); 668 test(result.p3[0][1][0].equals("xyz")); 669 test(result.p3[1][0][0].equals("hello")); 670 test(result.p3[2][0][0].equals("")); 671 test(result.p3[2][0][1].equals("")); 672 test(result.p3[2][1][0].equals("abcd")); 673 test(result.p3[3][0][0].equals("")); 674 675 test(result.returnValue.length == 3); 676 test(result.returnValue[0].length == 0); 677 test(result.returnValue[1].length == 1); 678 test(result.returnValue[1][0].length == 1); 679 test(result.returnValue[2].length == 2); 680 test(result.returnValue[2][0].length == 2); 681 test(result.returnValue[2][1].length == 1); 682 test(result.returnValue[1][0][0].equals("")); 683 test(result.returnValue[2][0][0].equals("")); 684 test(result.returnValue[2][0][1].equals("")); 685 test(result.returnValue[2][1][0].equals("abcd")); 686 cb.called(); 687 }); 688 cb.check(); 689 } 690 691 { 692 java.util.Map<Byte, Boolean> di1 = new java.util.HashMap<>(); 693 di1.put((byte)10, Boolean.TRUE); 694 di1.put((byte)100, Boolean.FALSE); 695 java.util.Map<Byte, Boolean> di2 = new java.util.HashMap<>(); 696 di2.put((byte)10, Boolean.TRUE); 697 di2.put((byte)11, Boolean.FALSE); 698 di2.put((byte)101, Boolean.TRUE); 699 700 Callback cb = new Callback(); 701 p.opByteBoolDAsync(di1, di2).whenComplete((result, ex) -> 702 { 703 test(ex == null); 704 test(result.p3.equals(di1)); 705 test(result.returnValue.size() == 4); 706 test(result.returnValue.get((byte) 10)); 707 test(!result.returnValue.get((byte) 11)); 708 test(!result.returnValue.get((byte) 100)); 709 test(result.returnValue.get((byte) 101)); 710 cb.called(); 711 }); 712 cb.check(); 713 } 714 715 { 716 java.util.Map<Short, Integer> di1 = new java.util.HashMap<>(); 717 di1.put((short)110, -1); 718 di1.put((short)1100, 123123); 719 java.util.Map<Short, Integer> di2 = new java.util.HashMap<>(); 720 di2.put((short)110, -1); 721 di2.put((short)111, -100); 722 di2.put((short)1101, 0); 723 724 Callback cb = new Callback(); 725 p.opShortIntDAsync(di1, di2).whenComplete((result, ex) -> 726 { 727 test(ex == null); 728 test(result.p3.equals(di1)); 729 test(result.returnValue.size() == 4); 730 test(result.returnValue.get((short) 110) == -1); 731 test(result.returnValue.get((short) 111) == -100); 732 test(result.returnValue.get((short) 1100) == 123123); 733 test(result.returnValue.get((short) 1101) == 0); 734 cb.called(); 735 }); 736 cb.check(); 737 } 738 739 { 740 java.util.Map<Long, Float> di1 = new java.util.HashMap<>(); 741 di1.put(999999110L, -1.1f); 742 di1.put(999999111L, 123123.2f); 743 java.util.Map<Long, Float> di2 = new java.util.HashMap<>(); 744 di2.put(999999110L, -1.1f); 745 di2.put(999999120L, -100.4f); 746 di2.put(999999130L, 0.5f); 747 748 Callback cb = new Callback(); 749 p.opLongFloatDAsync(di1, di2).whenComplete((result, ex) -> 750 { 751 test(ex == null); 752 test(result.p3.equals(di1)); 753 test(result.returnValue.size() == 4); 754 test(result.returnValue.get(999999110L) == -1.1f); 755 test(result.returnValue.get(999999120L) == -100.4f); 756 test(result.returnValue.get(999999111L) == 123123.2f); 757 test(result.returnValue.get(999999130L) == 0.5f); 758 cb.called(); 759 }); 760 cb.check(); 761 } 762 763 { 764 java.util.Map<String, String> di1 = new java.util.HashMap<>(); 765 di1.put("foo", "abc -1.1"); 766 di1.put("bar", "abc 123123.2"); 767 java.util.Map<String, String> di2 = new java.util.HashMap<>(); 768 di2.put("foo", "abc -1.1"); 769 di2.put("FOO", "abc -100.4"); 770 di2.put("BAR", "abc 0.5"); 771 772 Callback cb = new Callback(); 773 p.opStringStringDAsync(di1, di2).whenComplete((result, ex) -> 774 { 775 test(ex == null); 776 test(result.p3.equals(di1)); 777 test(result.returnValue.size() == 4); 778 test(result.returnValue.get("foo").equals("abc -1.1")); 779 test(result.returnValue.get("FOO").equals("abc -100.4")); 780 test(result.returnValue.get("bar").equals("abc 123123.2")); 781 test(result.returnValue.get("BAR").equals("abc 0.5")); 782 cb.called(); 783 }); 784 cb.check(); 785 } 786 787 { 788 java.util.Map<String, MyEnum> di1 = new java.util.HashMap<>(); 789 di1.put("abc", MyEnum.enum1); 790 di1.put("", MyEnum.enum2); 791 java.util.Map<String, MyEnum> di2 = new java.util.HashMap<>(); 792 di2.put("abc", MyEnum.enum1); 793 di2.put("qwerty", MyEnum.enum3); 794 di2.put("Hello!!", MyEnum.enum2); 795 796 Callback cb = new Callback(); 797 p.opStringMyEnumDAsync(di1, di2).whenComplete((result, ex) -> 798 { 799 test(ex == null); 800 test(result.p3.equals(di1)); 801 test(result.returnValue.size() == 4); 802 test(result.returnValue.get("abc") == MyEnum.enum1); 803 test(result.returnValue.get("qwerty") == MyEnum.enum3); 804 test(result.returnValue.get("") == MyEnum.enum2); 805 test(result.returnValue.get("Hello!!") == MyEnum.enum2); 806 cb.called(); 807 }); 808 cb.check(); 809 } 810 811 { 812 java.util.Map<MyEnum, String> di1 = new java.util.HashMap<>(); 813 di1.put(MyEnum.enum1, "abc"); 814 java.util.Map<MyEnum, String> di2 = new java.util.HashMap<>(); 815 di2.put(MyEnum.enum2, "Hello!!"); 816 di2.put(MyEnum.enum3, "qwerty"); 817 818 Callback cb = new Callback(); 819 p.opMyEnumStringDAsync(di1, di2).whenComplete((result, ex) -> 820 { 821 test(ex == null); 822 test(result.p3.equals(di1)); 823 test(result.returnValue.size() == 3); 824 test(result.returnValue.get(MyEnum.enum1).equals("abc")); 825 test(result.returnValue.get(MyEnum.enum2).equals("Hello!!")); 826 test(result.returnValue.get(MyEnum.enum3).equals("qwerty")); 827 cb.called(); 828 }); 829 cb.check(); 830 } 831 832 { 833 MyStruct s11 = new MyStruct(1, 1); 834 MyStruct s12 = new MyStruct(1, 2); 835 java.util.Map<MyStruct, MyEnum> di1 = new java.util.HashMap<>(); 836 di1.put(s11, MyEnum.enum1); 837 di1.put(s12, MyEnum.enum2); 838 MyStruct s22 = new MyStruct(2, 2); 839 MyStruct s23 = new MyStruct(2, 3); 840 java.util.Map<MyStruct, MyEnum> di2 = new java.util.HashMap<>(); 841 di2.put(s11, MyEnum.enum1); 842 di2.put(s22, MyEnum.enum3); 843 di2.put(s23, MyEnum.enum2); 844 845 Callback cb = new Callback(); 846 p.opMyStructMyEnumDAsync(di1, di2).whenComplete((result, ex) -> 847 { 848 test(ex == null); 849 test(result.p3.equals(di1)); 850 test(result.returnValue.size() == 4); 851 test(result.returnValue.get(s11) == MyEnum.enum1); 852 test(result.returnValue.get(s12) == MyEnum.enum2); 853 test(result.returnValue.get(s22) == MyEnum.enum3); 854 test(result.returnValue.get(s23) == MyEnum.enum2); 855 cb.called(); 856 }); 857 cb.check(); 858 } 859 860 { 861 List<Map<Byte, Boolean>> dsi1 = new ArrayList<>(); 862 List<Map<Byte, Boolean>> dsi2 = new ArrayList<>(); 863 864 Map<Byte, Boolean> di1 = new HashMap<>(); 865 di1.put((byte) 10, Boolean.TRUE); 866 di1.put((byte) 100, Boolean.FALSE); 867 Map<Byte, Boolean> di2 = new HashMap<>(); 868 di2.put((byte) 10, Boolean.TRUE); 869 di2.put((byte) 11, Boolean.FALSE); 870 di2.put((byte) 101, Boolean.TRUE); 871 Map<Byte, Boolean> di3 = new HashMap<>(); 872 di3.put((byte) 100, Boolean.FALSE); 873 di3.put((byte) 101, Boolean.FALSE); 874 875 dsi1.add(di1); 876 dsi1.add(di2); 877 dsi2.add(di3); 878 879 Callback cb = new Callback(); 880 p.opByteBoolDSAsync(dsi1, dsi2).whenComplete((result, ex) -> 881 { 882 test(ex == null); 883 test(result.returnValue.size() == 2); 884 test(result.returnValue.get(0).size() == 3); 885 test(result.returnValue.get(0).get((byte) 10)); 886 test(!result.returnValue.get(0).get((byte) 11)); 887 test(result.returnValue.get(0).get((byte) 101)); 888 test(result.returnValue.get(1).size() == 2); 889 test(result.returnValue.get(1).get((byte) 10)); 890 test(!result.returnValue.get(1).get((byte) 100)); 891 892 test(result.p3.size() == 3); 893 test(result.p3.get(0).size() == 2); 894 test(!result.p3.get(0).get((byte) 100)); 895 test(!result.p3.get(0).get((byte) 101)); 896 test(result.p3.get(1).size() == 2); 897 test(result.p3.get(1).get((byte) 10)); 898 test(!result.p3.get(1).get((byte) 100)); 899 test(result.p3.get(2).size() == 3); 900 test(result.p3.get(2).get((byte) 10)); 901 test(!result.p3.get(2).get((byte) 11)); 902 test(result.p3.get(2).get((byte) 101)); 903 cb.called(); 904 }); 905 cb.check(); 906 } 907 908 { 909 List<Map<Short, Integer>> dsi1 = new ArrayList<>(); 910 List<Map<Short, Integer>> dsi2 = new ArrayList<>(); 911 912 Map<Short, Integer> di1 = new HashMap<>(); 913 di1.put((short) 110, -1); 914 di1.put((short) 1100, 123123); 915 Map<Short, Integer> di2 = new HashMap<>(); 916 di2.put((short) 110, -1); 917 di2.put((short) 111, -100); 918 di2.put((short) 1101, 0); 919 Map<Short, Integer> di3 = new HashMap<>(); 920 di3.put((short) 100, -1001); 921 922 dsi1.add(di1); 923 dsi1.add(di2); 924 dsi2.add(di3); 925 926 Callback cb = new Callback(); 927 p.opShortIntDSAsync(dsi1, dsi2).whenComplete((result, ex) -> 928 { 929 test(ex == null); 930 test(result.returnValue.size() == 2); 931 test(result.returnValue.get(0).size() == 3); 932 test(result.returnValue.get(0).get((short) 110) == -1); 933 test(result.returnValue.get(0).get((short) 111) == -100); 934 test(result.returnValue.get(0).get((short) 1101) == 0); 935 test(result.returnValue.get(1).size() == 2); 936 test(result.returnValue.get(1).get((short) 110) == -1); 937 test(result.returnValue.get(1).get((short) 1100) == 123123); 938 939 test(result.p3.size() == 3); 940 test(result.p3.get(0).size() == 1); 941 test(result.p3.get(0).get((short) 100) == -1001); 942 test(result.p3.get(1).size() == 2); 943 test(result.p3.get(1).get((short) 110) == -1); 944 test(result.p3.get(1).get((short) 1100) == 123123); 945 test(result.p3.get(2).size() == 3); 946 test(result.p3.get(2).get((short) 110) == -1); 947 test(result.p3.get(2).get((short) 111) == -100); 948 test(result.p3.get(2).get((short) 1101) == 0); 949 cb.called(); 950 }); 951 cb.check(); 952 } 953 954 { 955 List<Map<Long, Float>> dsi1 = new ArrayList<>(); 956 List<Map<Long, Float>> dsi2 = new ArrayList<>(); 957 958 Map<Long, Float> di1 = new HashMap<>(); 959 di1.put(999999110L, Float.valueOf((float)-1.1)); 960 di1.put(999999111L, Float.valueOf((float)123123.2)); 961 Map<Long, Float> di2 = new HashMap<>(); 962 di2.put(999999110L, Float.valueOf((float)-1.1)); 963 di2.put(999999120L, Float.valueOf((float)-100.4)); 964 di2.put(999999130L, Float.valueOf((float)0.5)); 965 Map<Long, Float> di3 = new HashMap<>(); 966 di3.put(999999140L, Float.valueOf((float)3.14)); 967 968 dsi1.add(di1); 969 dsi1.add(di2); 970 dsi2.add(di3); 971 972 Callback cb = new Callback(); 973 p.opLongFloatDSAsync(dsi1, dsi2).whenComplete((result, ex) -> 974 { 975 test(ex == null); 976 test(result.returnValue.size() == 2); 977 test(result.returnValue.get(0).size() == 3); 978 test(result.returnValue.get(0).get(999999110L) == -1.1f); 979 test(result.returnValue.get(0).get(999999120L) == -100.4f); 980 test(result.returnValue.get(0).get(999999130L) == 0.5f); 981 test(result.returnValue.get(1).size() == 2); 982 test(result.returnValue.get(1).get(999999110L) == -1.1f); 983 test(result.returnValue.get(1).get(999999111L) == 123123.2f); 984 985 test(result.p3.size() == 3); 986 test(result.p3.get(0).size() == 1); 987 test(result.p3.get(0).get(999999140L) == 3.14f); 988 test(result.p3.get(1).size() == 2); 989 test(result.p3.get(1).get(999999110L) == -1.1f); 990 test(result.p3.get(1).get(999999111L) == 123123.2f); 991 test(result.p3.get(2).size() == 3); 992 test(result.p3.get(2).get(999999110L) == -1.1f); 993 test(result.p3.get(2).get(999999120L) == -100.4f); 994 test(result.p3.get(2).get(999999130L) == 0.5f); 995 cb.called(); 996 }); 997 cb.check(); 998 } 999 1000 { 1001 List<Map<String, String>> dsi1 = new ArrayList<>(); 1002 List<Map<String, String>> dsi2 = new ArrayList<>(); 1003 1004 java.util.Map<String, String> di1 = new HashMap<>(); 1005 di1.put("foo", "abc -1.1"); 1006 di1.put("bar", "abc 123123.2"); 1007 java.util.Map<String, String> di2 = new HashMap<>(); 1008 di2.put("foo", "abc -1.1"); 1009 di2.put("FOO", "abc -100.4"); 1010 di2.put("BAR", "abc 0.5"); 1011 java.util.Map<String, String> di3 = new HashMap<>(); 1012 di3.put("f00", "ABC -3.14"); 1013 1014 dsi1.add(di1); 1015 dsi1.add(di2); 1016 dsi2.add(di3); 1017 1018 Callback cb = new Callback(); 1019 p.opStringStringDSAsync(dsi1, dsi2).whenComplete((result, ex) -> 1020 { 1021 test(ex == null); 1022 test(result.returnValue.size() == 2); 1023 test(result.returnValue.get(0).size() == 3); 1024 test(result.returnValue.get(0).get("foo").equals("abc -1.1")); 1025 test(result.returnValue.get(0).get("FOO").equals("abc -100.4")); 1026 test(result.returnValue.get(0).get("BAR").equals("abc 0.5")); 1027 test(result.returnValue.get(1).size() == 2); 1028 test(result.returnValue.get(1).get("foo").equals("abc -1.1")); 1029 test(result.returnValue.get(1).get("bar").equals("abc 123123.2")); 1030 1031 test(result.p3.size() == 3); 1032 test(result.p3.get(0).size() == 1); 1033 test(result.p3.get(0).get("f00").equals("ABC -3.14")); 1034 test(result.p3.get(1).size() == 2); 1035 test(result.p3.get(1).get("foo").equals("abc -1.1")); 1036 test(result.p3.get(1).get("bar").equals("abc 123123.2")); 1037 test(result.p3.get(2).size() == 3); 1038 test(result.p3.get(2).get("foo").equals("abc -1.1")); 1039 test(result.p3.get(2).get("FOO").equals("abc -100.4")); 1040 test(result.p3.get(2).get("BAR").equals("abc 0.5")); 1041 cb.called(); 1042 }); 1043 cb.check(); 1044 } 1045 1046 { 1047 List<Map<String, MyEnum>> dsi1 = new ArrayList<>(); 1048 List<Map<String, MyEnum>> dsi2 = new ArrayList<>(); 1049 1050 java.util.Map<String, MyEnum> di1 = new HashMap<>(); 1051 di1.put("abc", MyEnum.enum1); 1052 di1.put("", MyEnum.enum2); 1053 java.util.Map<String, MyEnum> di2 = new HashMap<>(); 1054 di2.put("abc", MyEnum.enum1); 1055 di2.put("qwerty", MyEnum.enum3); 1056 di2.put("Hello!!", MyEnum.enum2); 1057 java.util.Map<String, MyEnum> di3 = new HashMap<>(); 1058 di3.put("Goodbye", MyEnum.enum1); 1059 1060 dsi1.add(di1); 1061 dsi1.add(di2); 1062 dsi2.add(di3); 1063 1064 Callback cb = new Callback(); 1065 p.opStringMyEnumDSAsync(dsi1, dsi2).whenComplete((result, ex) -> 1066 { 1067 test(ex == null); 1068 test(result.returnValue.size() == 2); 1069 test(result.returnValue.get(0).size() == 3); 1070 test(result.returnValue.get(0).get("abc") == MyEnum.enum1); 1071 test(result.returnValue.get(0).get("qwerty") == MyEnum.enum3); 1072 test(result.returnValue.get(0).get("Hello!!") == MyEnum.enum2); 1073 test(result.returnValue.get(1).size() == 2); 1074 test(result.returnValue.get(1).get("abc") == MyEnum.enum1); 1075 test(result.returnValue.get(1).get("") == MyEnum.enum2); 1076 1077 test(result.p3.size() == 3); 1078 test(result.p3.get(0).size() == 1); 1079 test(result.p3.get(0).get("Goodbye") == MyEnum.enum1); 1080 test(result.p3.get(1).size() == 2); 1081 test(result.p3.get(1).get("abc") == MyEnum.enum1); 1082 test(result.p3.get(1).get("") == MyEnum.enum2); 1083 test(result.p3.get(2).size() == 3); 1084 test(result.p3.get(2).get("abc") == MyEnum.enum1); 1085 test(result.p3.get(2).get("qwerty") == MyEnum.enum3); 1086 test(result.p3.get(2).get("Hello!!") == MyEnum.enum2); 1087 cb.called(); 1088 }); 1089 cb.check(); 1090 } 1091 1092 { 1093 List<Map<MyEnum, String>> dsi1 = new ArrayList<>(); 1094 List<Map<MyEnum, String>> dsi2 = new ArrayList<>(); 1095 1096 java.util.Map<MyEnum, String> di1 = new HashMap<>(); 1097 di1.put(MyEnum.enum1, "abc"); 1098 java.util.Map<MyEnum, String> di2 = new HashMap<>(); 1099 di2.put(MyEnum.enum2, "Hello!!"); 1100 di2.put(MyEnum.enum3, "qwerty"); 1101 java.util.Map<MyEnum, String> di3 = new HashMap<>(); 1102 di3.put(MyEnum.enum1, "Goodbye"); 1103 1104 dsi1.add(di1); 1105 dsi1.add(di2); 1106 dsi2.add(di3); 1107 1108 Callback cb = new Callback(); 1109 p.opMyEnumStringDSAsync(dsi1, dsi2).whenComplete((result, ex) -> 1110 { 1111 test(ex == null); 1112 test(result.returnValue.size() == 2); 1113 test(result.returnValue.get(0).size() == 2); 1114 test(result.returnValue.get(0).get(MyEnum.enum2).equals("Hello!!")); 1115 test(result.returnValue.get(0).get(MyEnum.enum3).equals("qwerty")); 1116 test(result.returnValue.get(1).size() == 1); 1117 test(result.returnValue.get(1).get(MyEnum.enum1).equals("abc")); 1118 1119 test(result.p3.size() == 3); 1120 test(result.p3.get(0).size() == 1); 1121 test(result.p3.get(0).get(MyEnum.enum1).equals("Goodbye")); 1122 test(result.p3.get(1).size() == 1); 1123 test(result.p3.get(1).get(MyEnum.enum1).equals("abc")); 1124 test(result.p3.get(2).size() == 2); 1125 test(result.p3.get(2).get(MyEnum.enum2).equals("Hello!!")); 1126 test(result.p3.get(2).get(MyEnum.enum3).equals("qwerty")); 1127 cb.called(); 1128 }); 1129 cb.check(); 1130 } 1131 1132 { 1133 List<Map<MyStruct, MyEnum>> dsi1 = new ArrayList<>(); 1134 List<Map<MyStruct, MyEnum>> dsi2 = new ArrayList<>(); 1135 1136 MyStruct s11 = new MyStruct(1, 1); 1137 MyStruct s12 = new MyStruct(1, 2); 1138 java.util.Map<MyStruct, MyEnum> di1 = new HashMap<>(); 1139 di1.put(s11, MyEnum.enum1); 1140 di1.put(s12, MyEnum.enum2); 1141 1142 MyStruct s22 = new MyStruct(2, 2); 1143 MyStruct s23 = new MyStruct(2, 3); 1144 java.util.Map<MyStruct, MyEnum> di2 = new HashMap<>(); 1145 di2.put(s11, MyEnum.enum1); 1146 di2.put(s22, MyEnum.enum3); 1147 di2.put(s23, MyEnum.enum2); 1148 1149 java.util.Map<MyStruct, MyEnum> di3 = new HashMap<>(); 1150 di3.put(s23, MyEnum.enum3); 1151 1152 dsi1.add(di1); 1153 dsi1.add(di2); 1154 dsi2.add(di3); 1155 1156 Callback cb = new Callback(); 1157 p.opMyStructMyEnumDSAsync(dsi1, dsi2).whenComplete((result, ex) -> 1158 { 1159 test(ex == null); 1160 test(result.returnValue.size() == 2); 1161 test(result.returnValue.get(0).size() == 3); 1162 test(result.returnValue.get(0).get(s11) == MyEnum.enum1); 1163 test(result.returnValue.get(0).get(s22) == MyEnum.enum3); 1164 test(result.returnValue.get(0).get(s23) == MyEnum.enum2); 1165 test(result.returnValue.get(1).size() == 2); 1166 test(result.returnValue.get(1).get(s11) == MyEnum.enum1); 1167 test(result.returnValue.get(1).get(s12) == MyEnum.enum2); 1168 1169 test(result.p3.size() == 3); 1170 test(result.p3.get(0).size() == 1); 1171 test(result.p3.get(0).get(s23) == MyEnum.enum3); 1172 test(result.p3.get(1).size() == 2); 1173 test(result.p3.get(1).get(s11) == MyEnum.enum1); 1174 test(result.p3.get(1).get(s12) == MyEnum.enum2); 1175 test(result.p3.get(2).size() == 3); 1176 test(result.p3.get(2).get(s11) == MyEnum.enum1); 1177 test(result.p3.get(2).get(s22) == MyEnum.enum3); 1178 test(result.p3.get(2).get(s23) == MyEnum.enum2); 1179 cb.called(); 1180 }); 1181 cb.check(); 1182 } 1183 1184 { 1185 java.util.Map<Byte, byte[]> sdi1 = new java.util.HashMap<>(); 1186 java.util.Map<Byte, byte[]> sdi2 = new java.util.HashMap<>(); 1187 1188 final byte[] si1 = {(byte) 0x01, (byte) 0x11}; 1189 final byte[] si2 = {(byte) 0x12}; 1190 final byte[] si3 = {(byte) 0xf2, (byte) 0xf3}; 1191 1192 sdi1.put((byte) 0x01, si1); 1193 sdi1.put((byte) 0x22, si2); 1194 sdi2.put((byte) 0xf1, si3); 1195 1196 Callback cb = new Callback(); 1197 p.opByteByteSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1198 { 1199 test(ex == null); 1200 test(result.p3.size() == 1); 1201 test(result.p3.get((byte) 0xf1).length == 2); 1202 test(result.p3.get((byte) 0xf1)[0] == (byte) 0xf2); 1203 test(result.p3.get((byte) 0xf1)[1] == (byte) 0xf3); 1204 test(result.returnValue.size() == 3); 1205 test(result.returnValue.get((byte) 0x01).length == 2); 1206 test(result.returnValue.get((byte) 0x01)[0] == (byte) 0x01); 1207 test(result.returnValue.get((byte) 0x01)[1] == (byte) 0x11); 1208 test(result.returnValue.get((byte) 0x22).length == 1); 1209 test(result.returnValue.get((byte) 0x22)[0] == (byte) 0x12); 1210 test(result.returnValue.get((byte) 0xf1).length == 2); 1211 test(result.returnValue.get((byte) 0xf1)[0] == (byte) 0xf2); 1212 test(result.returnValue.get((byte) 0xf1)[1] == (byte) 0xf3); 1213 cb.called(); 1214 }); 1215 cb.check(); 1216 } 1217 1218 { 1219 java.util.Map<Boolean, boolean[]> sdi1 = new java.util.HashMap<>(); 1220 java.util.Map<Boolean, boolean[]> sdi2 = new java.util.HashMap<>(); 1221 1222 final boolean[] si1 = {true, false}; 1223 final boolean[] si2 = {false, true, true}; 1224 1225 sdi1.put(false, si1); 1226 sdi1.put(true, si2); 1227 sdi2.put(false, si1); 1228 1229 Callback cb = new Callback(); 1230 p.opBoolBoolSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1231 { 1232 test(ex == null); 1233 test(result.p3.size() == 1); 1234 test(result.p3.get(false).length == 2); 1235 test(result.p3.get(false)[0]); 1236 test(!result.p3.get(false)[1]); 1237 test(result.returnValue.size() == 2); 1238 test(result.returnValue.get(false).length == 2); 1239 test(result.returnValue.get(false)[0]); 1240 test(!result.returnValue.get(false)[1]); 1241 test(result.returnValue.get(true).length == 3); 1242 test(!result.returnValue.get(true)[0]); 1243 test(result.returnValue.get(true)[1]); 1244 test(result.returnValue.get(true)[2]); 1245 cb.called(); 1246 }); 1247 cb.check(); 1248 } 1249 1250 { 1251 java.util.Map<Short, short[]> sdi1 = new java.util.HashMap<>(); 1252 java.util.Map<Short, short[]> sdi2 = new java.util.HashMap<>(); 1253 1254 final short[] si1 = {1, 2, 3}; 1255 final short[] si2 = {4, 5}; 1256 final short[] si3 = {6, 7}; 1257 1258 sdi1.put((short) 1, si1); 1259 sdi1.put((short) 2, si2); 1260 sdi2.put((short) 4, si3); 1261 1262 Callback cb = new Callback(); 1263 p.opShortShortSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1264 { 1265 test(ex == null); 1266 test(result.p3.size() == 1); 1267 test(result.p3.get((short) 4).length == 2); 1268 test(result.p3.get((short) 4)[0] == 6); 1269 test(result.p3.get((short) 4)[1] == 7); 1270 test(result.returnValue.size() == 3); 1271 test(result.returnValue.get((short) 1).length == 3); 1272 test(result.returnValue.get((short) 1)[0] == 1); 1273 test(result.returnValue.get((short) 1)[1] == 2); 1274 test(result.returnValue.get((short) 1)[2] == 3); 1275 test(result.returnValue.get((short) 2).length == 2); 1276 test(result.returnValue.get((short) 2)[0] == 4); 1277 test(result.returnValue.get((short) 2)[1] == 5); 1278 test(result.returnValue.get((short) 4).length == 2); 1279 test(result.returnValue.get((short) 4)[0] == 6); 1280 test(result.returnValue.get((short) 4)[1] == 7); 1281 cb.called(); 1282 }); 1283 cb.check(); 1284 } 1285 1286 { 1287 java.util.Map<Integer, int[]> sdi1 = new java.util.HashMap<>(); 1288 java.util.Map<Integer, int[]> sdi2 = new java.util.HashMap<>(); 1289 1290 final int[] si1 = {100, 200, 300}; 1291 final int[] si2 = {400, 500}; 1292 final int[] si3 = {600, 700}; 1293 1294 sdi1.put(100, si1); 1295 sdi1.put(200, si2); 1296 sdi2.put(400, si3); 1297 1298 Callback cb = new Callback(); 1299 p.opIntIntSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1300 { 1301 test(ex == null); 1302 test(result.p3.size() == 1); 1303 test(result.p3.get(400).length == 2); 1304 test(result.p3.get(400)[0] == 600); 1305 test(result.p3.get(400)[1] == 700); 1306 test(result.returnValue.size() == 3); 1307 test(result.returnValue.get(100).length == 3); 1308 test(result.returnValue.get(100)[0] == 100); 1309 test(result.returnValue.get(100)[1] == 200); 1310 test(result.returnValue.get(100)[2] == 300); 1311 test(result.returnValue.get(200).length == 2); 1312 test(result.returnValue.get(200)[0] == 400); 1313 test(result.returnValue.get(200)[1] == 500); 1314 test(result.returnValue.get(400).length == 2); 1315 test(result.returnValue.get(400)[0] == 600); 1316 test(result.returnValue.get(400)[1] == 700); 1317 cb.called(); 1318 }); 1319 cb.check(); 1320 } 1321 1322 { 1323 java.util.Map<Long, long[]> sdi1 = new java.util.HashMap<>(); 1324 java.util.Map<Long, long[]> sdi2 = new java.util.HashMap<>(); 1325 1326 final long[] si1 = {999999110L, 999999111L, 999999110L}; 1327 final long[] si2 = {999999120L, 999999130L}; 1328 final long[] si3 = {999999110L, 999999120}; 1329 1330 sdi1.put(999999990L, si1); 1331 sdi1.put(999999991L, si2); 1332 sdi2.put(999999992L, si3); 1333 1334 Callback cb = new Callback(); 1335 p.opLongLongSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1336 { 1337 test(ex == null); 1338 test(result.p3.size() == 1); 1339 test(result.p3.get(999999992L).length == 2); 1340 test(result.p3.get(999999992L)[0] == 999999110L); 1341 test(result.p3.get(999999992L)[1] == 999999120); 1342 test(result.returnValue.size() == 3); 1343 test(result.returnValue.get(999999990L).length == 3); 1344 test(result.returnValue.get(999999990L)[0] == 999999110); 1345 test(result.returnValue.get(999999990L)[1] == 999999111); 1346 test(result.returnValue.get(999999990L)[2] == 999999110); 1347 test(result.returnValue.get(999999991L).length == 2); 1348 test(result.returnValue.get(999999991L)[0] == 999999120); 1349 test(result.returnValue.get(999999991L)[1] == 999999130); 1350 test(result.returnValue.get(999999992L).length == 2); 1351 test(result.returnValue.get(999999992L)[0] == 999999110); 1352 test(result.returnValue.get(999999992L)[1] == 999999120); 1353 cb.called(); 1354 }); 1355 cb.check(); 1356 } 1357 1358 { 1359 java.util.Map<String, float[]> sdi1 = new java.util.HashMap<>(); 1360 java.util.Map<String, float[]> sdi2 = new java.util.HashMap<>(); 1361 1362 final float[] si1 = {-1.1f, 123123.2f, 100.0f}; 1363 final float[] si2 = {42.24f, -1.61f}; 1364 final float[] si3 = {-3.14f, 3.14f}; 1365 1366 sdi1.put("abc", si1); 1367 sdi1.put("ABC", si2); 1368 sdi2.put("aBc", si3); 1369 1370 Callback cb = new Callback(); 1371 p.opStringFloatSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1372 { 1373 test(ex == null); 1374 test(result.p3.size() == 1); 1375 test(result.p3.get("aBc").length == 2); 1376 test(result.p3.get("aBc")[0] == -3.14f); 1377 test(result.p3.get("aBc")[1] == 3.14f); 1378 test(result.returnValue.size() == 3); 1379 test(result.returnValue.get("abc").length == 3); 1380 test(result.returnValue.get("abc")[0] == -1.1f); 1381 test(result.returnValue.get("abc")[1] == 123123.2f); 1382 test(result.returnValue.get("abc")[2] == 100.0f); 1383 test(result.returnValue.get("ABC").length == 2); 1384 test(result.returnValue.get("ABC")[0] == 42.24f); 1385 test(result.returnValue.get("ABC")[1] == -1.61f); 1386 test(result.returnValue.get("aBc").length == 2); 1387 test(result.returnValue.get("aBc")[0] == -3.14f); 1388 test(result.returnValue.get("aBc")[1] == 3.14f); 1389 cb.called(); 1390 }); 1391 cb.check(); 1392 } 1393 1394 { 1395 java.util.Map<String, double[]> sdi1 = new java.util.HashMap<>(); 1396 java.util.Map<String, double[]> sdi2 = new java.util.HashMap<>(); 1397 1398 double[] si1 = new double[]{1.1E10, 1.2E10, 1.3E10}; 1399 double[] si2 = new double[]{1.4E10, 1.5E10}; 1400 double[] si3 = new double[]{1.6E10, 1.7E10}; 1401 1402 sdi1.put("Hello!!", si1); 1403 sdi1.put("Goodbye", si2); 1404 sdi2.put("", si3); 1405 1406 Callback cb = new Callback(); 1407 p.opStringDoubleSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1408 { 1409 test(ex == null); 1410 test(result.p3.size() == 1); 1411 test(result.p3.get("").length == 2); 1412 test(result.p3.get("")[0] == 1.6E10); 1413 test(result.p3.get("")[1] == 1.7E10); 1414 test(result.returnValue.size()== 3); 1415 test(result.returnValue.get("Hello!!").length == 3); 1416 test(result.returnValue.get("Hello!!")[0] == 1.1E10); 1417 test(result.returnValue.get("Hello!!")[1] == 1.2E10); 1418 test(result.returnValue.get("Hello!!")[2] == 1.3E10); 1419 test(result.returnValue.get("Goodbye").length == 2); 1420 test(result.returnValue.get("Goodbye")[0] == 1.4E10); 1421 test(result.returnValue.get("Goodbye")[1] == 1.5E10); 1422 test(result.returnValue.get("").length== 2); 1423 test(result.returnValue.get("")[0] == 1.6E10); 1424 test(result.returnValue.get("")[1] == 1.7E10); 1425 cb.called(); 1426 }); 1427 cb.check(); 1428 } 1429 1430 { 1431 java.util.Map<String, String[]> sdi1 = new java.util.HashMap<>(); 1432 java.util.Map<String, String[]> sdi2 = new java.util.HashMap<>(); 1433 1434 String[] si1 = new String[] { "abc", "de", "fghi" }; 1435 String[] si2 = new String[] { "xyz", "or" }; 1436 String[] si3 = new String[] { "and", "xor" }; 1437 1438 sdi1.put("abc", si1); 1439 sdi1.put("def", si2); 1440 sdi2.put("ghi", si3); 1441 1442 Callback cb = new Callback(); 1443 p.opStringStringSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1444 { 1445 test(ex == null); 1446 test(result.p3.size() == 1); 1447 test(result.p3.get("ghi").length== 2); 1448 test(result.p3.get("ghi")[0].equals("and")); 1449 test(result.p3.get("ghi")[1].equals("xor")); 1450 test(result.returnValue.size()== 3); 1451 test(result.returnValue.get("abc").length == 3); 1452 test(result.returnValue.get("abc")[0].equals("abc")); 1453 test(result.returnValue.get("abc")[1].equals("de")); 1454 test(result.returnValue.get("abc")[2].equals("fghi")); 1455 test(result.returnValue.get("def").length == 2); 1456 test(result.returnValue.get("def")[0].equals("xyz")); 1457 test(result.returnValue.get("def")[1].equals("or")); 1458 test(result.returnValue.get("ghi").length == 2); 1459 test(result.returnValue.get("ghi")[0].equals("and")); 1460 test(result.returnValue.get("ghi")[1].equals("xor")); 1461 cb.called(); 1462 }); 1463 cb.check(); 1464 } 1465 1466 { 1467 java.util.Map<MyEnum, MyEnum[]> sdi1 = new java.util.HashMap<>(); 1468 java.util.Map<MyEnum, MyEnum[]> sdi2 = new java.util.HashMap<>(); 1469 1470 final MyEnum[] si1 = new MyEnum[] { MyEnum.enum1, MyEnum.enum1, MyEnum.enum2 }; 1471 final MyEnum[] si2 = new MyEnum[] { MyEnum.enum1, MyEnum.enum2 }; 1472 final MyEnum[] si3 = new MyEnum[] { MyEnum.enum3, MyEnum.enum3 }; 1473 1474 sdi1.put(MyEnum.enum3, si1); 1475 sdi1.put(MyEnum.enum2, si2); 1476 sdi2.put(MyEnum.enum1, si3); 1477 1478 Callback cb = new Callback(); 1479 p.opMyEnumMyEnumSDAsync(sdi1, sdi2).whenComplete((result, ex) -> 1480 { 1481 test(ex == null); 1482 test(result.p3.size() == 1); 1483 test(result.p3.get(MyEnum.enum1).length == 2); 1484 test(result.p3.get(MyEnum.enum1)[0] == MyEnum.enum3); 1485 test(result.p3.get(MyEnum.enum1)[1] == MyEnum.enum3); 1486 test(result.returnValue.size()== 3); 1487 test(result.returnValue.get(MyEnum.enum3).length == 3); 1488 test(result.returnValue.get(MyEnum.enum3)[0] == MyEnum.enum1); 1489 test(result.returnValue.get(MyEnum.enum3)[1] == MyEnum.enum1); 1490 test(result.returnValue.get(MyEnum.enum3)[2] == MyEnum.enum2); 1491 test(result.returnValue.get(MyEnum.enum2).length == 2); 1492 test(result.returnValue.get(MyEnum.enum2)[0] == MyEnum.enum1); 1493 test(result.returnValue.get(MyEnum.enum2)[1] == MyEnum.enum2); 1494 test(result.returnValue.get(MyEnum.enum1).length == 2); 1495 test(result.returnValue.get(MyEnum.enum1)[0] == MyEnum.enum3); 1496 test(result.returnValue.get(MyEnum.enum1)[1] == MyEnum.enum3); 1497 cb.called(); 1498 }); 1499 cb.check(); 1500 } 1501 1502 { 1503 int[] lengths = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; 1504 1505 for(int l : lengths) 1506 { 1507 int[] s = new int[l]; 1508 for(int i = 0; i < s.length; ++i) 1509 { 1510 s[i] = i; 1511 } 1512 Callback cb = new Callback(); 1513 p.opIntSAsync(s).whenComplete((result, ex) -> 1514 { 1515 test(ex == null); 1516 test(result.length == l); 1517 for(int j = 0; j < result.length; ++j) 1518 { 1519 test(result[j] == -j); 1520 } 1521 cb.called(); 1522 }); 1523 cb.check(); 1524 } 1525 } 1526 1527 { 1528 java.util.Map<String, String> ctx = new java.util.HashMap<>(); 1529 ctx.put("one", "ONE"); 1530 ctx.put("two", "TWO"); 1531 ctx.put("three", "THREE"); 1532 { 1533 test(p.ice_getContext().isEmpty()); 1534 java.util.Map<String, String> c = p.opContextAsync().join(); 1535 test(!c.equals(ctx)); 1536 } 1537 { 1538 test(p.ice_getContext().isEmpty()); 1539 java.util.Map<String, String> c = p.opContextAsync(ctx).join(); 1540 test(c.equals(ctx)); 1541 } 1542 MyClassPrx p2 = MyClassPrx.checkedCast(p.ice_context(ctx)); 1543 test(p2.ice_getContext().equals(ctx)); 1544 { 1545 java.util.Map<String, String> c = p2.opContextAsync().join(); 1546 test(c.equals(ctx)); 1547 } 1548 { 1549 java.util.Map<String, String> c = p2.opContextAsync(ctx).join(); 1550 test(c.equals(ctx)); 1551 } 1552 } 1553 1554 if(p.ice_getConnection() != null && !bluetooth) 1555 { 1556 // 1557 // Test implicit context propagation 1558 // 1559 1560 String[] impls = {"Shared", "PerThread"}; 1561 for(int i = 0; i < 2; i++) 1562 { 1563 com.zeroc.Ice.Properties properties = communicator.getProperties()._clone(); 1564 properties.setProperty("Ice.ImplicitContext", impls[i]); 1565 1566 try(com.zeroc.Ice.Communicator ic = helper.initialize(properties)) 1567 { 1568 java.util.Map<String, String> ctx = new java.util.HashMap<>(); 1569 ctx.put("one", "ONE"); 1570 ctx.put("two", "TWO"); 1571 ctx.put("three", "THREE"); 1572 1573 MyClassPrx p3 = 1574 MyClassPrx.uncheckedCast(ic.stringToProxy("test:" + helper.getTestEndpoint(properties, 0))); 1575 1576 ic.getImplicitContext().setContext(ctx); 1577 test(ic.getImplicitContext().getContext().equals(ctx)); 1578 { 1579 java.util.Map<String, String> c = p3.opContextAsync().join(); 1580 test(c.equals(ctx)); 1581 } 1582 1583 ic.getImplicitContext().put("zero", "ZERO"); 1584 1585 ctx = ic.getImplicitContext().getContext(); 1586 { 1587 java.util.Map<String, String> c = p3.opContextAsync().join(); 1588 test(c.equals(ctx)); 1589 } 1590 1591 java.util.Map<String, String> prxContext = new java.util.HashMap<>(); 1592 prxContext.put("one", "UN"); 1593 prxContext.put("four", "QUATRE"); 1594 1595 java.util.Map<String, String> combined = new java.util.HashMap<>(ctx); 1596 combined.putAll(prxContext); 1597 test(combined.get("one").equals("UN")); 1598 1599 p3 = p3.ice_context(prxContext); 1600 1601 ic.getImplicitContext().setContext(null); 1602 { 1603 java.util.Map<String, String> c = p3.opContextAsync().join(); 1604 test(c.equals(prxContext)); 1605 } 1606 1607 ic.getImplicitContext().setContext(ctx); 1608 { 1609 java.util.Map<String, String> c = p3.opContextAsync().join(); 1610 test(c.equals(combined)); 1611 } 1612 } 1613 } 1614 } 1615 1616 { 1617 double d = 1278312346.0 / 13.0; 1618 double[] ds = new double[5]; 1619 for(int i = 0; i < 5; i++) 1620 { 1621 ds[i] = d; 1622 } 1623 Callback cb = new Callback(); 1624 p.opDoubleMarshalingAsync(d, ds).whenComplete((result, ex) -> 1625 { 1626 test(ex == null); 1627 cb.called(); 1628 }); 1629 cb.check(); 1630 } 1631 1632 { 1633 Callback cb = new Callback(); 1634 p.opIdempotentAsync().whenComplete((result, ex) -> 1635 { 1636 test(ex == null); 1637 cb.called(); 1638 }); 1639 cb.check(); 1640 } 1641 1642 { 1643 Callback cb = new Callback(); 1644 p.opNonmutatingAsync().whenComplete((result, ex) -> 1645 { 1646 test(ex == null); 1647 cb.called(); 1648 }); 1649 cb.check(); 1650 } 1651 1652 { 1653 MyDerivedClassPrx derived = MyDerivedClassPrx.checkedCast(p); 1654 test(derived != null); 1655 Callback cb = new Callback(); 1656 derived.opDerivedAsync().whenComplete((result, ex) -> 1657 { 1658 test(ex == null); 1659 cb.called(); 1660 }); 1661 cb.check(); 1662 } 1663 1664 { 1665 Callback cb = new Callback(); 1666 p.opByte1Async((byte)0xFF).whenComplete((result, ex) -> 1667 { 1668 test(ex == null); 1669 test(result == (byte)0xFF); 1670 cb.called(); 1671 }); 1672 cb.check(); 1673 } 1674 1675 { 1676 Callback cb = new Callback(); 1677 p.opShort1Async((short)0x7FFF).whenComplete((result, ex) -> 1678 { 1679 test(ex == null); 1680 test(result == 0x7FFF); 1681 cb.called(); 1682 }); 1683 cb.check(); 1684 } 1685 1686 { 1687 Callback cb = new Callback(); 1688 p.opInt1Async(0x7FFFFFFF).whenComplete((result, ex) -> 1689 { 1690 test(ex == null); 1691 test(result == 0x7FFFFFFF); 1692 cb.called(); 1693 }); 1694 cb.check(); 1695 } 1696 1697 { 1698 Callback cb = new Callback(); 1699 p.opLong1Async(0x7FFFFFFF).whenComplete((result, ex) -> 1700 { 1701 test(ex == null); 1702 test(result == 0x7FFFFFFF); 1703 cb.called(); 1704 }); 1705 cb.check(); 1706 } 1707 1708 { 1709 Callback cb = new Callback(); 1710 p.opFloat1Async(1.0f).whenComplete((result, ex) -> 1711 { 1712 test(ex == null); 1713 test(result == 1.0f); 1714 cb.called(); 1715 }); 1716 cb.check(); 1717 } 1718 1719 { 1720 Callback cb = new Callback(); 1721 p.opDouble1Async(1.0).whenComplete((result, ex) -> 1722 { 1723 test(ex == null); 1724 test(result == 1.0); 1725 cb.called(); 1726 }); 1727 cb.check(); 1728 } 1729 1730 { 1731 Callback cb = new Callback(); 1732 p.opString1Async("opString1").whenComplete((result, ex) -> 1733 { 1734 test(ex == null); 1735 test(result.equals("opString1")); 1736 cb.called(); 1737 }); 1738 cb.check(); 1739 } 1740 1741 { 1742 Callback cb = new Callback(); 1743 p.opStringS1Async(null).whenComplete((result, ex) -> 1744 { 1745 test(ex == null); 1746 test(result.length == 0); 1747 cb.called(); 1748 }); 1749 cb.check(); 1750 } 1751 1752 { 1753 Callback cb = new Callback(); 1754 p.opByteBoolD1Async(null).whenComplete((result, ex) -> 1755 { 1756 test(ex == null); 1757 test(result.size() == 0); 1758 cb.called(); 1759 }); 1760 cb.check(); 1761 } 1762 } 1763 } 1764