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 12 import com.zeroc.Ice.*; 13 14 import test.Ice.operations.Test.*; 15 16 class Twoways 17 { test(boolean b)18 private static void test(boolean b) 19 { 20 if(!b) 21 { 22 throw new RuntimeException(); 23 } 24 } 25 26 static class PerThreadContextInvokeThread extends Thread 27 { PerThreadContextInvokeThread(MyClassPrx proxy)28 public PerThreadContextInvokeThread(MyClassPrx proxy) 29 { 30 _proxy = proxy; 31 } 32 33 @Override run()34 public void run() 35 { 36 java.util.Map<String, String> ctx = _proxy.ice_getCommunicator().getImplicitContext().getContext(); 37 test(ctx.isEmpty()); 38 ctx.put("one", "ONE"); 39 _proxy.ice_getCommunicator().getImplicitContext().setContext(ctx); 40 test(_proxy.opContext().equals(ctx)); 41 } 42 43 final private MyClassPrx _proxy; 44 } 45 twoways(test.TestHelper helper, MyClassPrx p)46 static void twoways(test.TestHelper helper, MyClassPrx p) 47 { 48 Communicator communicator = helper.communicator(); 49 final boolean bluetooth = communicator.getProperties().getProperty("Ice.Default.Protocol").indexOf("bt") == 0; 50 51 String[] literals = p.opStringLiterals(); 52 53 test(s0.value.equals("\\") && 54 s0.value.equals(sw0.value) && 55 s0.value.equals(literals[0]) && 56 s0.value.equals(literals[11])); 57 58 test(s1.value.equals("A") && 59 s1.value.equals(sw1.value) && 60 s1.value.equals(literals[1]) && 61 s1.value.equals(literals[12])); 62 63 test(s2.value.equals("Ice") && 64 s2.value.equals(sw2.value) && 65 s2.value.equals(literals[2]) && 66 s2.value.equals(literals[13])); 67 68 test(s3.value.equals("A21") && 69 s3.value.equals(sw3.value) && 70 s3.value.equals(literals[3]) && 71 s3.value.equals(literals[14])); 72 73 test(s4.value.equals("\\u0041 \\U00000041") && 74 s4.value.equals(sw4.value) && 75 s4.value.equals(literals[4]) && 76 s4.value.equals(literals[15])); 77 78 test(s5.value.equals("\u00FF") && 79 s5.value.equals(sw5.value) && 80 s5.value.equals(literals[5]) && 81 s5.value.equals(literals[16])); 82 83 test(s6.value.equals("\u03FF") && 84 s6.value.equals(sw6.value) && 85 s6.value.equals(literals[6]) && 86 s6.value.equals(literals[17])); 87 88 test(s7.value.equals("\u05F0") && 89 s7.value.equals(sw7.value) && 90 s7.value.equals(literals[7]) && 91 s7.value.equals(literals[18])); 92 93 test(s8.value.equals("\uD800\uDC00") && 94 s8.value.equals(sw8.value) && 95 s8.value.equals(literals[8]) && 96 s8.value.equals(literals[19])); 97 98 test(s9.value.equals("\uD83C\uDF4C") && 99 s9.value.equals(sw9.value) && 100 s9.value.equals(literals[9]) && 101 s9.value.equals(literals[20])); 102 103 test(s10.value.equals("\u0DA7") && 104 s10.value.equals(sw10.value) && 105 s10.value.equals(literals[10]) && 106 s10.value.equals(literals[21])); 107 108 test(ss0.value.equals("\'\"\u003f\\\u0007\b\f\n\r\t\u000b\6") && 109 ss0.value.equals(ss1.value) && 110 ss0.value.equals(ss2.value) && 111 ss0.value.equals(literals[22]) && 112 ss0.value.equals(literals[23]) && 113 ss0.value.equals(literals[24])); 114 115 test(ss3.value.equals("\\\\U\\u\\") && 116 ss3.value.equals(literals[25])); 117 118 test(ss4.value.equals("\\A\\") && 119 ss4.value.equals(literals[26])); 120 121 test(ss5.value.equals("\\u0041\\") && 122 ss5.value.equals(literals[27])); 123 124 test(su0.value.equals(su1.value) && 125 su0.value.equals(su2.value) && 126 su0.value.equals(literals[28]) && 127 su0.value.equals(literals[29]) && 128 su0.value.equals(literals[30])); 129 130 p.ice_ping(); 131 132 test(p.ice_isA(MyClass.ice_staticId())); 133 134 test(p.ice_id().equals(MyDerivedClass.ice_staticId())); 135 136 test(MyDerivedClassPrx.ice_staticId().equals(MyDerivedClass.ice_staticId())); 137 test(ObjectPrx.ice_staticId().equals(com.zeroc.Ice.Object.ice_staticId())); 138 test(LocatorPrx.ice_staticId().equals(Locator.ice_staticId())); 139 140 { 141 String[] ids = p.ice_ids(); 142 test(ids.length == 3); 143 test(ids[0].equals("::Ice::Object")); 144 test(ids[1].equals("::Test::MyClass")); 145 test(ids[2].equals("::Test::MyDerivedClass")); 146 } 147 148 { 149 p.opVoid(); 150 } 151 152 { 153 MyClass.OpByteResult r = p.opByte((byte) 0xff, (byte) 0x0f); 154 test(r.p3 == (byte) 0xf0); 155 test(r.returnValue == (byte) 0xff); 156 } 157 158 { 159 MyClass.OpBoolResult r = p.opBool(true, false); 160 test(r.p3); 161 test(!r.returnValue); 162 } 163 164 { 165 MyClass.OpShortIntLongResult r = p.opShortIntLong((short) 10, 11, 12L); 166 test(r.p4 == 10); 167 test(r.p5 == 11); 168 test(r.p6 == 12); 169 test(r.returnValue == 12L); 170 171 r = p.opShortIntLong(Short.MIN_VALUE, Integer.MIN_VALUE, Long.MIN_VALUE); 172 test(r.p4 == Short.MIN_VALUE); 173 test(r.p5 == Integer.MIN_VALUE); 174 test(r.p6 == Long.MIN_VALUE); 175 test(r.returnValue == Long.MIN_VALUE); 176 177 r = p.opShortIntLong(Short.MAX_VALUE, Integer.MAX_VALUE, Long.MAX_VALUE); 178 test(r.p4 == Short.MAX_VALUE); 179 test(r.p5 == Integer.MAX_VALUE); 180 test(r.p6 == Long.MAX_VALUE); 181 test(r.returnValue == Long.MAX_VALUE); 182 } 183 184 { 185 MyClass.OpFloatDoubleResult r = p.opFloatDouble(3.14f, 1.1E10); 186 test(r.p3 == 3.14f); 187 test(r.p4 == 1.1E10); 188 test(r.returnValue == 1.1E10); 189 190 r = p.opFloatDouble(Float.MIN_VALUE, Double.MIN_VALUE); 191 test(r.p3 == Float.MIN_VALUE); 192 test(r.p4 == Double.MIN_VALUE); 193 test(r.returnValue == Double.MIN_VALUE); 194 195 r = p.opFloatDouble(Float.MAX_VALUE, Double.MAX_VALUE); 196 test(r.p3 == Float.MAX_VALUE); 197 test(r.p4 == Double.MAX_VALUE); 198 test(r.returnValue == Double.MAX_VALUE); 199 } 200 201 { 202 MyClass.OpStringResult r = p.opString("hello", "world"); 203 test(r.p3.equals("world hello")); 204 test(r.returnValue.equals("hello world")); 205 } 206 207 { 208 MyClass.OpMyEnumResult r = p.opMyEnum(MyEnum.enum2); 209 test(r.p2 == MyEnum.enum2); 210 test(r.returnValue == MyEnum.enum3); 211 212 // 213 // Test marshalling of null enum (first enum value is 214 // marshalled in this case). 215 // 216 r = p.opMyEnum(null); 217 test(r.p2 == MyEnum.enum1); 218 test(r.returnValue == MyEnum.enum3); 219 } 220 221 { 222 MyClass.OpMyClassResult r = p.opMyClass(p); 223 test(Util.proxyIdentityAndFacetCompare(r.p2, p) == 0); 224 test(Util.proxyIdentityAndFacetCompare(r.p3, p) != 0); 225 test(Util.proxyIdentityAndFacetCompare(r.returnValue, p) == 0); 226 test(r.p2.ice_getIdentity().equals(com.zeroc.Ice.Util.stringToIdentity("test"))); 227 test(r.p3.ice_getIdentity().equals(com.zeroc.Ice.Util.stringToIdentity("noSuchIdentity"))); 228 test(r.returnValue.ice_getIdentity().equals(com.zeroc.Ice.Util.stringToIdentity("test"))); 229 r.returnValue.opVoid(); 230 r.p2.opVoid(); 231 try 232 { 233 r.p3.opVoid(); 234 test(false); 235 } 236 catch(ObjectNotExistException ex) 237 { 238 } 239 240 r = p.opMyClass(null); 241 test(r.p2 == null); 242 test(r.p3 != null); 243 test(Util.proxyIdentityAndFacetCompare(r.returnValue, p) == 0); 244 r.returnValue.opVoid(); 245 } 246 247 { 248 Structure si1 = new Structure(); 249 si1.p = p; 250 si1.e = MyEnum.enum3; 251 si1.s = new AnotherStruct(); 252 si1.s.s = "abc"; 253 Structure si2 = new Structure(); 254 si2.p = null; 255 si2.e = MyEnum.enum2; 256 si2.s = new AnotherStruct(); 257 si2.s.s = "def"; 258 259 MyClass.OpStructResult r = p.opStruct(si1, si2); 260 test(r.returnValue.p == null); 261 test(r.returnValue.e == MyEnum.enum2); 262 test(r.returnValue.s.s.equals("def")); 263 test(r.p3.p.equals(p)); 264 test(r.p3.e == MyEnum.enum3); 265 test(r.p3.s.s.equals("a new string")); 266 r.p3.p.opVoid(); 267 268 // 269 // Test marshalling of null structs and structs with default member values. 270 // 271 si1 = new Structure(); 272 si2 = null; 273 274 r = p.opStruct(si1, si2); 275 test(r.returnValue.p == null); 276 test(r.returnValue.e == MyEnum.enum1); 277 test(r.returnValue.s.s.equals("")); 278 test(r.p3.p == null); 279 test(r.p3.e == MyEnum.enum1); 280 test(r.p3.s.s.equals("a new string")); 281 } 282 283 { 284 final byte[] bsi1 = 285 { 286 (byte) 0x01, 287 (byte) 0x11, 288 (byte) 0x12, 289 (byte) 0x22 290 }; 291 final byte[] bsi2 = 292 { 293 (byte) 0xf1, 294 (byte) 0xf2, 295 (byte) 0xf3, 296 (byte) 0xf4 297 }; 298 299 MyClass.OpByteSResult r = p.opByteS(bsi1, bsi2); 300 test(r.p3.length == 4); 301 test(r.p3[0] == (byte) 0x22); 302 test(r.p3[1] == (byte) 0x12); 303 test(r.p3[2] == (byte) 0x11); 304 test(r.p3[3] == (byte) 0x01); 305 test(r.returnValue.length == 8); 306 test(r.returnValue[0] == (byte) 0x01); 307 test(r.returnValue[1] == (byte) 0x11); 308 test(r.returnValue[2] == (byte) 0x12); 309 test(r.returnValue[3] == (byte) 0x22); 310 test(r.returnValue[4] == (byte) 0xf1); 311 test(r.returnValue[5] == (byte) 0xf2); 312 test(r.returnValue[6] == (byte) 0xf3); 313 test(r.returnValue[7] == (byte) 0xf4); 314 } 315 316 { 317 final boolean[] bsi1 = {true, true, false}; 318 final boolean[] bsi2 = {false}; 319 320 MyClass.OpBoolSResult r = p.opBoolS(bsi1, bsi2); 321 test(r.p3.length == 4); 322 test(r.p3[0]); 323 test(r.p3[1]); 324 test(!r.p3[2]); 325 test(!r.p3[3]); 326 test(r.returnValue.length == 3); 327 test(!r.returnValue[0]); 328 test(r.returnValue[1]); 329 test(r.returnValue[2]); 330 } 331 332 { 333 final short[] ssi = {1, 2, 3}; 334 final int[] isi = {5, 6, 7, 8}; 335 final long[] lsi = {10, 30, 20}; 336 337 MyClass.OpShortIntLongSResult r = p.opShortIntLongS(ssi, isi, lsi); 338 test(r.p4.length == 3); 339 test(r.p4[0] == 1); 340 test(r.p4[1] == 2); 341 test(r.p4[2] == 3); 342 test(r.p5.length == 4); 343 test(r.p5[0] == 8); 344 test(r.p5[1] == 7); 345 test(r.p5[2] == 6); 346 test(r.p5[3] == 5); 347 test(r.p6.length == 6); 348 test(r.p6[0] == 10); 349 test(r.p6[1] == 30); 350 test(r.p6[2] == 20); 351 test(r.p6[3] == 10); 352 test(r.p6[4] == 30); 353 test(r.p6[5] == 20); 354 test(r.returnValue.length == 3); 355 test(r.returnValue[0] == 10); 356 test(r.returnValue[1] == 30); 357 test(r.returnValue[2] == 20); 358 } 359 360 { 361 final float[] fsi = {3.14f, 1.11f}; 362 final double[] dsi = {1.1E10, 1.2E10, 1.3E10}; 363 364 MyClass.OpFloatDoubleSResult r = p.opFloatDoubleS(fsi, dsi); 365 test(r.p3.length == 2); 366 test(r.p3[0] == 3.14f); 367 test(r.p3[1] == 1.11f); 368 test(r.p4.length == 3); 369 test(r.p4[0] == 1.3E10); 370 test(r.p4[1] == 1.2E10); 371 test(r.p4[2] == 1.1E10); 372 test(r.returnValue.length == 5); 373 test(r.returnValue[0] == 1.1E10); 374 test(r.returnValue[1] == 1.2E10); 375 test(r.returnValue[2] == 1.3E10); 376 test((float) r.returnValue[3] == 3.14f); 377 test((float) r.returnValue[4] == 1.11f); 378 } 379 380 { 381 final String[] ssi1 = {"abc", "de", "fghi"}; 382 final String[] ssi2 = {"xyz"}; 383 384 MyClass.OpStringSResult r = p.opStringS(ssi1, ssi2); 385 test(r.p3.length == 4); 386 test(r.p3[0].equals("abc")); 387 test(r.p3[1].equals("de")); 388 test(r.p3[2].equals("fghi")); 389 test(r.p3[3].equals("xyz")); 390 test(r.returnValue.length == 3); 391 test(r.returnValue[0].equals("fghi")); 392 test(r.returnValue[1].equals("de")); 393 test(r.returnValue[2].equals("abc")); 394 } 395 396 { 397 final byte[][] bsi1 = 398 { 399 {(byte) 0x01, (byte) 0x11, (byte) 0x12}, 400 {(byte) 0xff} 401 }; 402 final byte[][] bsi2 = 403 { 404 {(byte) 0x0e}, 405 {(byte) 0xf2, (byte) 0xf1} 406 }; 407 408 MyClass.OpByteSSResult r = p.opByteSS(bsi1, bsi2); 409 test(r.p3.length == 2); 410 test(r.p3[0].length == 1); 411 test(r.p3[0][0] == (byte) 0xff); 412 test(r.p3[1].length == 3); 413 test(r.p3[1][0] == (byte) 0x01); 414 test(r.p3[1][1] == (byte) 0x11); 415 test(r.p3[1][2] == (byte) 0x12); 416 test(r.returnValue.length == 4); 417 test(r.returnValue[0].length == 3); 418 test(r.returnValue[0][0] == (byte) 0x01); 419 test(r.returnValue[0][1] == (byte) 0x11); 420 test(r.returnValue[0][2] == (byte) 0x12); 421 test(r.returnValue[1].length == 1); 422 test(r.returnValue[1][0] == (byte) 0xff); 423 test(r.returnValue[2].length == 1); 424 test(r.returnValue[2][0] == (byte) 0x0e); 425 test(r.returnValue[3].length == 2); 426 test(r.returnValue[3][0] == (byte) 0xf2); 427 test(r.returnValue[3][1] == (byte) 0xf1); 428 } 429 430 { 431 final boolean[][] bsi1 = 432 { 433 {true}, 434 {false}, 435 {true, true} 436 }; 437 438 final boolean[][] bsi2 = 439 { 440 {false, false, true} 441 }; 442 443 MyClass.OpBoolSSResult r = p.opBoolSS(bsi1, bsi2); 444 test(r.p3.length == 4); 445 test(r.p3[0].length == 1); 446 test(r.p3[0][0]); 447 test(r.p3[1].length == 1); 448 test(!r.p3[1][0]); 449 test(r.p3[2].length == 2); 450 test(r.p3[2][0]); 451 test(r.p3[2][1]); 452 test(r.p3[3].length == 3); 453 test(!r.p3[3][0]); 454 test(!r.p3[3][1]); 455 test(r.p3[3][2]); 456 test(r.returnValue.length == 3); 457 test(r.returnValue[0].length == 2); 458 test(r.returnValue[0][0]); 459 test(r.returnValue[0][1]); 460 test(r.returnValue[1].length == 1); 461 test(!r.returnValue[1][0]); 462 test(r.returnValue[2].length == 1); 463 test(r.returnValue[2][0]); 464 } 465 466 { 467 final short[][] ssi = 468 { 469 {1, 2, 5}, 470 {13}, 471 {} 472 }; 473 final int[][] isi = 474 { 475 {24, 98}, 476 {42} 477 }; 478 final long[][] lsi = 479 { 480 {496, 1729}, 481 }; 482 483 MyClass.OpShortIntLongSSResult r = p.opShortIntLongSS(ssi, isi, lsi); 484 test(r.returnValue.length == 1); 485 test(r.returnValue[0].length == 2); 486 test(r.returnValue[0][0] == 496); 487 test(r.returnValue[0][1] == 1729); 488 test(r.p4.length == 3); 489 test(r.p4[0].length == 3); 490 test(r.p4[0][0] == 1); 491 test(r.p4[0][1] == 2); 492 test(r.p4[0][2] == 5); 493 test(r.p4[1].length == 1); 494 test(r.p4[1][0] == 13); 495 test(r.p4[2].length == 0); 496 test(r.p5.length == 2); 497 test(r.p5[0].length == 1); 498 test(r.p5[0][0] == 42); 499 test(r.p5[1].length == 2); 500 test(r.p5[1][0] == 24); 501 test(r.p5[1][1] == 98); 502 test(r.p6.length == 2); 503 test(r.p6[0].length == 2); 504 test(r.p6[0][0] == 496); 505 test(r.p6[0][1] == 1729); 506 test(r.p6[1].length == 2); 507 test(r.p6[1][0] == 496); 508 test(r.p6[1][1] == 1729); 509 } 510 511 { 512 final float[][] fsi = 513 { 514 {3.14f}, 515 {1.11f}, 516 {}, 517 }; 518 final double[][] dsi = 519 { 520 {1.1E10, 1.2E10, 1.3E10} 521 }; 522 523 MyClass.OpFloatDoubleSSResult r = p.opFloatDoubleSS(fsi, dsi); 524 test(r.p3.length == 3); 525 test(r.p3[0].length == 1); 526 test(r.p3[0][0] == 3.14f); 527 test(r.p3[1].length == 1); 528 test(r.p3[1][0] == 1.11f); 529 test(r.p3[2].length == 0); 530 test(r.p4.length == 1); 531 test(r.p4[0].length == 3); 532 test(r.p4[0][0] == 1.1E10); 533 test(r.p4[0][1] == 1.2E10); 534 test(r.p4[0][2] == 1.3E10); 535 test(r.returnValue.length == 2); 536 test(r.returnValue[0].length == 3); 537 test(r.returnValue[0][0] == 1.1E10); 538 test(r.returnValue[0][1] == 1.2E10); 539 test(r.returnValue[0][2] == 1.3E10); 540 test(r.returnValue[1].length == 3); 541 test(r.returnValue[1][0] == 1.1E10); 542 test(r.returnValue[1][1] == 1.2E10); 543 test(r.returnValue[1][2] == 1.3E10); 544 } 545 546 { 547 final String[][] ssi1 = 548 { 549 {"abc"}, 550 {"de", "fghi"} 551 }; 552 final String[][] ssi2 = 553 { 554 {}, 555 {}, 556 {"xyz"} 557 }; 558 559 MyClass.OpStringSSResult r = p.opStringSS(ssi1, ssi2); 560 test(r.p3.length == 5); 561 test(r.p3[0].length == 1); 562 test(r.p3[0][0].equals("abc")); 563 test(r.p3[1].length == 2); 564 test(r.p3[1][0].equals("de")); 565 test(r.p3[1][1].equals("fghi")); 566 test(r.p3[2].length == 0); 567 test(r.p3[3].length == 0); 568 test(r.p3[4].length == 1); 569 test(r.p3[4][0].equals("xyz")); 570 test(r.returnValue.length == 3); 571 test(r.returnValue[0].length == 1); 572 test(r.returnValue[0][0].equals("xyz")); 573 test(r.returnValue[1].length == 0); 574 test(r.returnValue[2].length == 0); 575 } 576 577 { 578 final String[][][] sssi1 = 579 { 580 { 581 { 582 "abc", "de" 583 }, 584 { 585 "xyz" 586 } 587 }, 588 { 589 { 590 "hello" 591 } 592 } 593 }; 594 595 final String[][][] sssi2 = 596 { 597 { 598 { 599 "", "" 600 }, 601 { 602 "abcd" 603 } 604 }, 605 { 606 { 607 "" 608 } 609 }, 610 { 611 } 612 }; 613 614 MyClass.OpStringSSSResult r = p.opStringSSS(sssi1, sssi2); 615 test(r.p3.length == 5); 616 test(r.p3[0].length == 2); 617 test(r.p3[0][0].length == 2); 618 test(r.p3[0][1].length == 1); 619 test(r.p3[1].length == 1); 620 test(r.p3[1][0].length == 1); 621 test(r.p3[2].length == 2); 622 test(r.p3[2][0].length == 2); 623 test(r.p3[2][1].length == 1); 624 test(r.p3[3].length == 1); 625 test(r.p3[3][0].length == 1); 626 test(r.p3[4].length == 0); 627 test(r.p3[0][0][0].equals("abc")); 628 test(r.p3[0][0][1].equals("de")); 629 test(r.p3[0][1][0].equals("xyz")); 630 test(r.p3[1][0][0].equals("hello")); 631 test(r.p3[2][0][0].equals("")); 632 test(r.p3[2][0][1].equals("")); 633 test(r.p3[2][1][0].equals("abcd")); 634 test(r.p3[3][0][0].equals("")); 635 636 test(r.returnValue.length == 3); 637 test(r.returnValue[0].length == 0); 638 test(r.returnValue[1].length == 1); 639 test(r.returnValue[1][0].length == 1); 640 test(r.returnValue[2].length == 2); 641 test(r.returnValue[2][0].length == 2); 642 test(r.returnValue[2][1].length == 1); 643 test(r.returnValue[1][0][0].equals("")); 644 test(r.returnValue[2][0][0].equals("")); 645 test(r.returnValue[2][0][1].equals("")); 646 test(r.returnValue[2][1][0].equals("abcd")); 647 } 648 649 { 650 Map<Byte, Boolean> di1 = new HashMap<>(); 651 di1.put((byte) 10, Boolean.TRUE); 652 di1.put((byte) 100, Boolean.FALSE); 653 Map<Byte, Boolean> di2 = new HashMap<>(); 654 di2.put((byte) 10, Boolean.TRUE); 655 di2.put((byte) 11, Boolean.FALSE); 656 di2.put((byte) 101, Boolean.TRUE); 657 658 MyClass.OpByteBoolDResult r = p.opByteBoolD(di1, di2); 659 660 test(r.p3.equals(di1)); 661 test(r.returnValue.size() == 4); 662 test(r.returnValue.get((byte) 10)); 663 test(!r.returnValue.get((byte) 11)); 664 test(!r.returnValue.get((byte) 100)); 665 test(r.returnValue.get((byte) 101)); 666 } 667 668 { 669 Map<Short, Integer> di1 = new HashMap<>(); 670 di1.put((short) 110, -1); 671 di1.put((short) 1100, 123123); 672 Map<Short, Integer> di2 = new HashMap<>(); 673 di2.put((short) 110, -1); 674 di2.put((short) 111, -100); 675 di2.put((short) 1101, 0); 676 677 MyClass.OpShortIntDResult r = p.opShortIntD(di1, di2); 678 679 test(r.p3.equals(di1)); 680 test(r.returnValue.size() == 4); 681 test(r.returnValue.get((short) 110) == -1); 682 test(r.returnValue.get((short) 111) == -100); 683 test(r.returnValue.get((short) 1100) == 123123); 684 test(r.returnValue.get((short) 1101) == 0); 685 } 686 687 { 688 Map<Long, Float> di1 = new HashMap<>(); 689 di1.put(999999110L, -1.1f); 690 di1.put(999999111L, 123123.2f); 691 Map<Long, Float> di2 = new HashMap<>(); 692 di2.put(999999110L, -1.1f); 693 di2.put(999999120L, -100.4f); 694 di2.put(999999130L, 0.5f); 695 696 MyClass.OpLongFloatDResult r = p.opLongFloatD(di1, di2); 697 698 test(r.p3.equals(di1)); 699 test(r.returnValue.size() == 4); 700 test(r.returnValue.get(999999110L) == -1.1f); 701 test(r.returnValue.get(999999120L) == -100.4f); 702 test(r.returnValue.get(999999111L) == 123123.2f); 703 test(r.returnValue.get(999999130L) == 0.5f); 704 } 705 706 { 707 Map<String, String> di1 = new HashMap<>(); 708 di1.put("foo", "abc -1.1"); 709 di1.put("bar", "abc 123123.2"); 710 Map<String, String> di2 = new HashMap<>(); 711 di2.put("foo", "abc -1.1"); 712 di2.put("FOO", "abc -100.4"); 713 di2.put("BAR", "abc 0.5"); 714 715 MyClass.OpStringStringDResult r = p.opStringStringD(di1, di2); 716 717 test(r.p3.equals(di1)); 718 test(r.returnValue.size() == 4); 719 test(r.returnValue.get("foo").equals("abc -1.1")); 720 test(r.returnValue.get("FOO").equals("abc -100.4")); 721 test(r.returnValue.get("bar").equals("abc 123123.2")); 722 test(r.returnValue.get("BAR").equals("abc 0.5")); 723 } 724 725 { 726 Map<String, MyEnum> di1 = new HashMap<>(); 727 di1.put("abc", MyEnum.enum1); 728 di1.put("", MyEnum.enum2); 729 Map<String, MyEnum> di2 = new HashMap<>(); 730 di2.put("abc", MyEnum.enum1); 731 di2.put("qwerty", MyEnum.enum3); 732 di2.put("Hello!!", MyEnum.enum2); 733 734 MyClass.OpStringMyEnumDResult r = p.opStringMyEnumD(di1, di2); 735 736 test(r.p3.equals(di1)); 737 test(r.returnValue.size() == 4); 738 test(r.returnValue.get("abc") == MyEnum.enum1); 739 test(r.returnValue.get("qwerty") == MyEnum.enum3); 740 test(r.returnValue.get("") == MyEnum.enum2); 741 test(r.returnValue.get("Hello!!") == MyEnum.enum2); 742 } 743 744 { 745 Map<MyEnum, String> di1 = new HashMap<>(); 746 di1.put(MyEnum.enum1, "abc"); 747 Map<MyEnum, String> di2 = new HashMap<>(); 748 di2.put(MyEnum.enum2, "Hello!!"); 749 di2.put(MyEnum.enum3, "qwerty"); 750 751 MyClass.OpMyEnumStringDResult r = p.opMyEnumStringD(di1, di2); 752 753 test(r.p3.equals(di1)); 754 test(r.returnValue.size() == 3); 755 test(r.returnValue.get(MyEnum.enum1).equals("abc")); 756 test(r.returnValue.get(MyEnum.enum2).equals("Hello!!")); 757 test(r.returnValue.get(MyEnum.enum3).equals("qwerty")); 758 } 759 760 { 761 MyStruct s11 = new MyStruct(1, 1); 762 MyStruct s12 = new MyStruct(1, 2); 763 Map<MyStruct, MyEnum> di1 = new HashMap<>(); 764 di1.put(s11, MyEnum.enum1); 765 di1.put(s12, MyEnum.enum2); 766 767 MyStruct s22 = new MyStruct(2, 2); 768 MyStruct s23 = new MyStruct(2, 3); 769 Map<MyStruct, MyEnum> di2 = new HashMap<>(); 770 di2.put(s11, MyEnum.enum1); 771 di2.put(s22, MyEnum.enum3); 772 di2.put(s23, MyEnum.enum2); 773 774 MyClass.OpMyStructMyEnumDResult r = p.opMyStructMyEnumD(di1, di2); 775 776 test(r.p3.equals(di1)); 777 test(r.returnValue.size() == 4); 778 test(r.returnValue.get(s11) == MyEnum.enum1); 779 test(r.returnValue.get(s12) == MyEnum.enum2); 780 test(r.returnValue.get(s22) == MyEnum.enum3); 781 test(r.returnValue.get(s23) == MyEnum.enum2); 782 } 783 784 { 785 List<Map<Byte, Boolean>> dsi1 = new ArrayList<>(); 786 List<Map<Byte, Boolean>> dsi2 = new ArrayList<>(); 787 788 Map<Byte, Boolean> di1 = new HashMap<>(); 789 di1.put((byte) 10, Boolean.TRUE); 790 di1.put((byte) 100, Boolean.FALSE); 791 Map<Byte, Boolean> di2 = new HashMap<>(); 792 di2.put((byte) 10, Boolean.TRUE); 793 di2.put((byte) 11, Boolean.FALSE); 794 di2.put((byte) 101, Boolean.TRUE); 795 Map<Byte, Boolean> di3 = new HashMap<>(); 796 di3.put((byte) 100, Boolean.FALSE); 797 di3.put((byte) 101, Boolean.FALSE); 798 799 dsi1.add(di1); 800 dsi1.add(di2); 801 dsi2.add(di3); 802 803 MyClass.OpByteBoolDSResult r = p.opByteBoolDS(dsi1, dsi2); 804 805 test(r.returnValue.size() == 2); 806 test(r.returnValue.get(0).size() == 3); 807 test(r.returnValue.get(0).get((byte) 10)); 808 test(!r.returnValue.get(0).get((byte) 11)); 809 test(r.returnValue.get(0).get((byte) 101)); 810 test(r.returnValue.get(1).size() == 2); 811 test(r.returnValue.get(1).get((byte) 10)); 812 test(!r.returnValue.get(1).get((byte) 100)); 813 814 test(r.p3.size() == 3); 815 test(r.p3.get(0).size() == 2); 816 test(!r.p3.get(0).get((byte) 100)); 817 test(!r.p3.get(0).get((byte) 101)); 818 test(r.p3.get(1).size() == 2); 819 test(r.p3.get(1).get((byte) 10)); 820 test(!r.p3.get(1).get((byte) 100)); 821 test(r.p3.get(2).size() == 3); 822 test(r.p3.get(2).get((byte) 10)); 823 test(!r.p3.get(2).get((byte) 11)); 824 test(r.p3.get(2).get((byte) 101)); 825 } 826 827 { 828 List<Map<Short, Integer>> dsi1 = new ArrayList<>(); 829 List<Map<Short, Integer>> dsi2 = new ArrayList<>(); 830 831 Map<Short, Integer> di1 = new HashMap<>(); 832 di1.put((short) 110, -1); 833 di1.put((short) 1100, 123123); 834 Map<Short, Integer> di2 = new HashMap<>(); 835 di2.put((short) 110, -1); 836 di2.put((short) 111, -100); 837 di2.put((short) 1101, 0); 838 Map<Short, Integer> di3 = new HashMap<>(); 839 di3.put((short) 100, -1001); 840 841 dsi1.add(di1); 842 dsi1.add(di2); 843 dsi2.add(di3); 844 845 MyClass.OpShortIntDSResult r = p.opShortIntDS(dsi1, dsi2); 846 847 test(r.returnValue.size() == 2); 848 test(r.returnValue.get(0).size() == 3); 849 test(r.returnValue.get(0).get((short) 110) == -1); 850 test(r.returnValue.get(0).get((short) 111) == -100); 851 test(r.returnValue.get(0).get((short) 1101) == 0); 852 test(r.returnValue.get(1).size() == 2); 853 test(r.returnValue.get(1).get((short) 110) == -1); 854 test(r.returnValue.get(1).get((short) 1100) == 123123); 855 856 test(r.p3.size() == 3); 857 test(r.p3.get(0).size() == 1); 858 test(r.p3.get(0).get((short) 100) == -1001); 859 test(r.p3.get(1).size() == 2); 860 test(r.p3.get(1).get((short) 110) == -1); 861 test(r.p3.get(1).get((short) 1100) == 123123); 862 test(r.p3.get(2).size() == 3); 863 test(r.p3.get(2).get((short) 110) == -1); 864 test(r.p3.get(2).get((short) 111) == -100); 865 test(r.p3.get(2).get((short) 1101) == 0); 866 } 867 868 { 869 List<Map<Long, Float>> dsi1 = new ArrayList<>(); 870 List<Map<Long, Float>> dsi2 = new ArrayList<>(); 871 872 Map<Long, Float> di1 = new HashMap<>(); 873 di1.put(999999110L, Float.valueOf((float)-1.1)); 874 di1.put(999999111L, Float.valueOf((float)123123.2)); 875 Map<Long, Float> di2 = new HashMap<>(); 876 di2.put(999999110L, Float.valueOf((float)-1.1)); 877 di2.put(999999120L, Float.valueOf((float)-100.4)); 878 di2.put(999999130L, Float.valueOf((float)0.5)); 879 Map<Long, Float> di3 = new HashMap<>(); 880 di3.put(999999140L, Float.valueOf((float)3.14)); 881 882 dsi1.add(di1); 883 dsi1.add(di2); 884 dsi2.add(di3); 885 886 MyClass.OpLongFloatDSResult r = p.opLongFloatDS(dsi1, dsi2); 887 888 test(r.returnValue.size() == 2); 889 test(r.returnValue.get(0).size() == 3); 890 test(r.returnValue.get(0).get(999999110L) == -1.1f); 891 test(r.returnValue.get(0).get(999999120L) == -100.4f); 892 test(r.returnValue.get(0).get(999999130L) == 0.5f); 893 test(r.returnValue.get(1).size() == 2); 894 test(r.returnValue.get(1).get(999999110L) == -1.1f); 895 test(r.returnValue.get(1).get(999999111L) == 123123.2f); 896 897 test(r.p3.size() == 3); 898 test(r.p3.get(0).size() == 1); 899 test(r.p3.get(0).get(999999140L) == 3.14f); 900 test(r.p3.get(1).size() == 2); 901 test(r.p3.get(1).get(999999110L) == -1.1f); 902 test(r.p3.get(1).get(999999111L) == 123123.2f); 903 test(r.p3.get(2).size() == 3); 904 test(r.p3.get(2).get(999999110L) == -1.1f); 905 test(r.p3.get(2).get(999999120L) == -100.4f); 906 test(r.p3.get(2).get(999999130L) == 0.5f); 907 } 908 909 { 910 List<Map<String, String>> dsi1 = new ArrayList<>(); 911 List<Map<String, String>> dsi2 = new ArrayList<>(); 912 913 java.util.Map<String, String> di1 = new HashMap<>(); 914 di1.put("foo", "abc -1.1"); 915 di1.put("bar", "abc 123123.2"); 916 java.util.Map<String, String> di2 = new HashMap<>(); 917 di2.put("foo", "abc -1.1"); 918 di2.put("FOO", "abc -100.4"); 919 di2.put("BAR", "abc 0.5"); 920 java.util.Map<String, String> di3 = new HashMap<>(); 921 di3.put("f00", "ABC -3.14"); 922 923 dsi1.add(di1); 924 dsi1.add(di2); 925 dsi2.add(di3); 926 927 MyClass.OpStringStringDSResult r = p.opStringStringDS(dsi1, dsi2); 928 929 test(r.returnValue.size() == 2); 930 test(r.returnValue.get(0).size() == 3); 931 test(r.returnValue.get(0).get("foo").equals("abc -1.1")); 932 test(r.returnValue.get(0).get("FOO").equals("abc -100.4")); 933 test(r.returnValue.get(0).get("BAR").equals("abc 0.5")); 934 test(r.returnValue.get(1).size() == 2); 935 test(r.returnValue.get(1).get("foo").equals("abc -1.1")); 936 test(r.returnValue.get(1).get("bar").equals("abc 123123.2")); 937 938 test(r.p3.size() == 3); 939 test(r.p3.get(0).size() == 1); 940 test(r.p3.get(0).get("f00").equals("ABC -3.14")); 941 test(r.p3.get(1).size() == 2); 942 test(r.p3.get(1).get("foo").equals("abc -1.1")); 943 test(r.p3.get(1).get("bar").equals("abc 123123.2")); 944 test(r.p3.get(2).size() == 3); 945 test(r.p3.get(2).get("foo").equals("abc -1.1")); 946 test(r.p3.get(2).get("FOO").equals("abc -100.4")); 947 test(r.p3.get(2).get("BAR").equals("abc 0.5")); 948 } 949 950 { 951 List<Map<String, MyEnum>> dsi1 = new ArrayList<>(); 952 List<Map<String, MyEnum>> dsi2 = new ArrayList<>(); 953 954 java.util.Map<String, MyEnum> di1 = new HashMap<>(); 955 di1.put("abc", MyEnum.enum1); 956 di1.put("", MyEnum.enum2); 957 java.util.Map<String, MyEnum> di2 = new HashMap<>(); 958 di2.put("abc", MyEnum.enum1); 959 di2.put("qwerty", MyEnum.enum3); 960 di2.put("Hello!!", MyEnum.enum2); 961 java.util.Map<String, MyEnum> di3 = new HashMap<>(); 962 di3.put("Goodbye", MyEnum.enum1); 963 964 dsi1.add(di1); 965 dsi1.add(di2); 966 dsi2.add(di3); 967 968 MyClass.OpStringMyEnumDSResult r = p.opStringMyEnumDS(dsi1, dsi2); 969 970 test(r.returnValue.size() == 2); 971 test(r.returnValue.get(0).size() == 3); 972 test(r.returnValue.get(0).get("abc") == MyEnum.enum1); 973 test(r.returnValue.get(0).get("qwerty") == MyEnum.enum3); 974 test(r.returnValue.get(0).get("Hello!!") == MyEnum.enum2); 975 test(r.returnValue.get(1).size() == 2); 976 test(r.returnValue.get(1).get("abc") == MyEnum.enum1); 977 test(r.returnValue.get(1).get("") == MyEnum.enum2); 978 979 test(r.p3.size() == 3); 980 test(r.p3.get(0).size() == 1); 981 test(r.p3.get(0).get("Goodbye") == MyEnum.enum1); 982 test(r.p3.get(1).size() == 2); 983 test(r.p3.get(1).get("abc") == MyEnum.enum1); 984 test(r.p3.get(1).get("") == MyEnum.enum2); 985 test(r.p3.get(2).size() == 3); 986 test(r.p3.get(2).get("abc") == MyEnum.enum1); 987 test(r.p3.get(2).get("qwerty") == MyEnum.enum3); 988 test(r.p3.get(2).get("Hello!!") == MyEnum.enum2); 989 } 990 991 { 992 List<Map<MyEnum, String>> dsi1 = new ArrayList<>(); 993 List<Map<MyEnum, String>> dsi2 = new ArrayList<>(); 994 995 java.util.Map<MyEnum, String> di1 = new HashMap<>(); 996 di1.put(MyEnum.enum1, "abc"); 997 java.util.Map<MyEnum, String> di2 = new HashMap<>(); 998 di2.put(MyEnum.enum2, "Hello!!"); 999 di2.put(MyEnum.enum3, "qwerty"); 1000 java.util.Map<MyEnum, String> di3 = new HashMap<>(); 1001 di3.put(MyEnum.enum1, "Goodbye"); 1002 1003 dsi1.add(di1); 1004 dsi1.add(di2); 1005 dsi2.add(di3); 1006 1007 MyClass.OpMyEnumStringDSResult r = p.opMyEnumStringDS(dsi1, dsi2); 1008 1009 test(r.returnValue.size() == 2); 1010 test(r.returnValue.get(0).size() == 2); 1011 test(r.returnValue.get(0).get(MyEnum.enum2).equals("Hello!!")); 1012 test(r.returnValue.get(0).get(MyEnum.enum3).equals("qwerty")); 1013 test(r.returnValue.get(1).size() == 1); 1014 test(r.returnValue.get(1).get(MyEnum.enum1).equals("abc")); 1015 1016 test(r.p3.size() == 3); 1017 test(r.p3.get(0).size() == 1); 1018 test(r.p3.get(0).get(MyEnum.enum1).equals("Goodbye")); 1019 test(r.p3.get(1).size() == 1); 1020 test(r.p3.get(1).get(MyEnum.enum1).equals("abc")); 1021 test(r.p3.get(2).size() == 2); 1022 test(r.p3.get(2).get(MyEnum.enum2).equals("Hello!!")); 1023 test(r.p3.get(2).get(MyEnum.enum3).equals("qwerty")); 1024 } 1025 1026 { 1027 List<Map<MyStruct, MyEnum>> dsi1 = new ArrayList<>(); 1028 List<Map<MyStruct, MyEnum>> dsi2 = new ArrayList<>(); 1029 1030 MyStruct s11 = new MyStruct(1, 1); 1031 MyStruct s12 = new MyStruct(1, 2); 1032 java.util.Map<MyStruct, MyEnum> di1 = new HashMap<>(); 1033 di1.put(s11, MyEnum.enum1); 1034 di1.put(s12, MyEnum.enum2); 1035 1036 MyStruct s22 = new MyStruct(2, 2); 1037 MyStruct s23 = new MyStruct(2, 3); 1038 java.util.Map<MyStruct, MyEnum> di2 = new HashMap<>(); 1039 di2.put(s11, MyEnum.enum1); 1040 di2.put(s22, MyEnum.enum3); 1041 di2.put(s23, MyEnum.enum2); 1042 1043 java.util.Map<MyStruct, MyEnum> di3 = new HashMap<>(); 1044 di3.put(s23, MyEnum.enum3); 1045 1046 dsi1.add(di1); 1047 dsi1.add(di2); 1048 dsi2.add(di3); 1049 1050 MyClass.OpMyStructMyEnumDSResult r = p.opMyStructMyEnumDS(dsi1, dsi2); 1051 1052 test(r.returnValue.size() == 2); 1053 test(r.returnValue.get(0).size() == 3); 1054 test(r.returnValue.get(0).get(s11) == MyEnum.enum1); 1055 test(r.returnValue.get(0).get(s22) == MyEnum.enum3); 1056 test(r.returnValue.get(0).get(s23) == MyEnum.enum2); 1057 test(r.returnValue.get(1).size() == 2); 1058 test(r.returnValue.get(1).get(s11) == MyEnum.enum1); 1059 test(r.returnValue.get(1).get(s12) == MyEnum.enum2); 1060 1061 test(r.p3.size() == 3); 1062 test(r.p3.get(0).size() == 1); 1063 test(r.p3.get(0).get(s23) == MyEnum.enum3); 1064 test(r.p3.get(1).size() == 2); 1065 test(r.p3.get(1).get(s11) == MyEnum.enum1); 1066 test(r.p3.get(1).get(s12) == MyEnum.enum2); 1067 test(r.p3.get(2).size() == 3); 1068 test(r.p3.get(2).get(s11) == MyEnum.enum1); 1069 test(r.p3.get(2).get(s22) == MyEnum.enum3); 1070 test(r.p3.get(2).get(s23) == MyEnum.enum2); 1071 } 1072 1073 { 1074 java.util.Map<Byte, byte[]> sdi1 = new java.util.HashMap<>(); 1075 java.util.Map<Byte, byte[]> sdi2 = new java.util.HashMap<>(); 1076 1077 final byte[] si1 = {(byte) 0x01, (byte) 0x11}; 1078 final byte[] si2 = {(byte) 0x12}; 1079 final byte[] si3 = {(byte) 0xf2, (byte) 0xf3}; 1080 1081 sdi1.put((byte) 0x01, si1); 1082 sdi1.put((byte) 0x22, si2); 1083 sdi2.put((byte) 0xf1, si3); 1084 1085 MyClass.OpByteByteSDResult r = p.opByteByteSD(sdi1, sdi2); 1086 1087 test(r.p3.size() == 1); 1088 test(r.p3.get((byte) 0xf1).length == 2); 1089 test(r.p3.get((byte) 0xf1)[0] == (byte) 0xf2); 1090 test(r.p3.get((byte) 0xf1)[1] == (byte) 0xf3); 1091 test(r.returnValue.size() == 3); 1092 test(r.returnValue.get((byte) 0x01).length == 2); 1093 test(r.returnValue.get((byte) 0x01)[0] == (byte) 0x01); 1094 test(r.returnValue.get((byte) 0x01)[1] == (byte) 0x11); 1095 test(r.returnValue.get((byte) 0x22).length == 1); 1096 test(r.returnValue.get((byte) 0x22)[0] == (byte) 0x12); 1097 test(r.returnValue.get((byte) 0xf1).length == 2); 1098 test(r.returnValue.get((byte) 0xf1)[0] == (byte) 0xf2); 1099 test(r.returnValue.get((byte) 0xf1)[1] == (byte) 0xf3); 1100 } 1101 1102 { 1103 java.util.Map<Boolean, boolean[]> sdi1 = new java.util.HashMap<>(); 1104 java.util.Map<Boolean, boolean[]> sdi2 = new java.util.HashMap<>(); 1105 1106 final boolean[] si1 = {true, false}; 1107 final boolean[] si2 = {false, true, true}; 1108 1109 sdi1.put(false, si1); 1110 sdi1.put(true, si2); 1111 sdi2.put(false, si1); 1112 1113 MyClass.OpBoolBoolSDResult r = p.opBoolBoolSD(sdi1, sdi2); 1114 1115 test(r.p3.size() == 1); 1116 test(r.p3.get(false).length == 2); 1117 test(r.p3.get(false)[0]); 1118 test(!r.p3.get(false)[1]); 1119 test(r.returnValue.size() == 2); 1120 test(r.returnValue.get(false).length == 2); 1121 test(r.returnValue.get(false)[0]); 1122 test(!r.returnValue.get(false)[1]); 1123 test(r.returnValue.get(true).length == 3); 1124 test(!r.returnValue.get(true)[0]); 1125 test(r.returnValue.get(true)[1]); 1126 test(r.returnValue.get(true)[2]); 1127 } 1128 1129 { 1130 java.util.Map<Short, short[]> sdi1 = new java.util.HashMap<>(); 1131 java.util.Map<Short, short[]> sdi2 = new java.util.HashMap<>(); 1132 1133 final short[] si1 = {1, 2, 3}; 1134 final short[] si2 = {4, 5}; 1135 final short[] si3 = {6, 7}; 1136 1137 sdi1.put((short) 1, si1); 1138 sdi1.put((short) 2, si2); 1139 sdi2.put((short) 4, si3); 1140 1141 MyClass.OpShortShortSDResult r = p.opShortShortSD(sdi1, sdi2); 1142 1143 test(r.p3.size() == 1); 1144 test(r.p3.get((short) 4).length == 2); 1145 test(r.p3.get((short) 4)[0] == 6); 1146 test(r.p3.get((short) 4)[1] == 7); 1147 test(r.returnValue.size() == 3); 1148 test(r.returnValue.get((short) 1).length == 3); 1149 test(r.returnValue.get((short) 1)[0] == 1); 1150 test(r.returnValue.get((short) 1)[1] == 2); 1151 test(r.returnValue.get((short) 1)[2] == 3); 1152 test(r.returnValue.get((short) 2).length == 2); 1153 test(r.returnValue.get((short) 2)[0] == 4); 1154 test(r.returnValue.get((short) 2)[1] == 5); 1155 test(r.returnValue.get((short) 4).length == 2); 1156 test(r.returnValue.get((short) 4)[0] == 6); 1157 test(r.returnValue.get((short) 4)[1] == 7); 1158 } 1159 1160 { 1161 java.util.Map<Integer, int[]> sdi1 = new java.util.HashMap<>(); 1162 java.util.Map<Integer, int[]> sdi2 = new java.util.HashMap<>(); 1163 1164 final int[] si1 = {100, 200, 300}; 1165 final int[] si2 = {400, 500}; 1166 final int[] si3 = {600, 700}; 1167 1168 sdi1.put(100, si1); 1169 sdi1.put(200, si2); 1170 sdi2.put(400, si3); 1171 1172 MyClass.OpIntIntSDResult r = p.opIntIntSD(sdi1, sdi2); 1173 1174 test(r.p3.size() == 1); 1175 test(r.p3.get(400).length == 2); 1176 test(r.p3.get(400)[0] == 600); 1177 test(r.p3.get(400)[1] == 700); 1178 test(r.returnValue.size() == 3); 1179 test(r.returnValue.get(100).length == 3); 1180 test(r.returnValue.get(100)[0] == 100); 1181 test(r.returnValue.get(100)[1] == 200); 1182 test(r.returnValue.get(100)[2] == 300); 1183 test(r.returnValue.get(200).length == 2); 1184 test(r.returnValue.get(200)[0] == 400); 1185 test(r.returnValue.get(200)[1] == 500); 1186 test(r.returnValue.get(400).length == 2); 1187 test(r.returnValue.get(400)[0] == 600); 1188 test(r.returnValue.get(400)[1] == 700); 1189 } 1190 1191 { 1192 java.util.Map<Long, long[]> sdi1 = new java.util.HashMap<>(); 1193 java.util.Map<Long, long[]> sdi2 = new java.util.HashMap<>(); 1194 1195 final long[] si1 = {999999110L, 999999111L, 999999110L}; 1196 final long[] si2 = {999999120L, 999999130L}; 1197 final long[] si3 = {999999110L, 999999120L}; 1198 1199 sdi1.put(999999990L, si1); 1200 sdi1.put(999999991L, si2); 1201 sdi2.put(999999992L, si3); 1202 1203 MyClass.OpLongLongSDResult r = p.opLongLongSD(sdi1, sdi2); 1204 1205 test(r.p3.size() == 1); 1206 test(r.p3.get(999999992L).length == 2); 1207 test(r.p3.get(999999992L)[0] == 999999110L); 1208 test(r.p3.get(999999992L)[1] == 999999120L); 1209 test(r.returnValue.size() == 3); 1210 test(r.returnValue.get(999999990L).length == 3); 1211 test(r.returnValue.get(999999990L)[0] == 999999110L); 1212 test(r.returnValue.get(999999990L)[1] == 999999111L); 1213 test(r.returnValue.get(999999990L)[2] == 999999110L); 1214 test(r.returnValue.get(999999991L).length == 2); 1215 test(r.returnValue.get(999999991L)[0] == 999999120L); 1216 test(r.returnValue.get(999999991L)[1] == 999999130L); 1217 test(r.returnValue.get(999999992L).length == 2); 1218 test(r.returnValue.get(999999992L)[0] == 999999110L); 1219 test(r.returnValue.get(999999992L)[1] == 999999120L); 1220 } 1221 1222 { 1223 java.util.Map<String, float[]> sdi1 = new java.util.HashMap<>(); 1224 java.util.Map<String, float[]> sdi2 = new java.util.HashMap<>(); 1225 1226 final float[] si1 = {-1.1f, 123123.2f, 100.0f}; 1227 final float[] si2 = {42.24f, -1.61f}; 1228 final float[] si3 = {-3.14f, 3.14f}; 1229 1230 sdi1.put("abc", si1); 1231 sdi1.put("ABC", si2); 1232 sdi2.put("aBc", si3); 1233 1234 MyClass.OpStringFloatSDResult r = p.opStringFloatSD(sdi1, sdi2); 1235 1236 test(r.p3.size() == 1); 1237 test(r.p3.get("aBc").length == 2); 1238 test(r.p3.get("aBc")[0] == -3.14f); 1239 test(r.p3.get("aBc")[1] == 3.14f); 1240 test(r.returnValue.size() == 3); 1241 test(r.returnValue.get("abc").length == 3); 1242 test(r.returnValue.get("abc")[0] == -1.1f); 1243 test(r.returnValue.get("abc")[1] == 123123.2f); 1244 test(r.returnValue.get("abc")[2] == 100.0f); 1245 test(r.returnValue.get("ABC").length == 2); 1246 test(r.returnValue.get("ABC")[0] == 42.24f); 1247 test(r.returnValue.get("ABC")[1] == -1.61f); 1248 test(r.returnValue.get("aBc").length == 2); 1249 test(r.returnValue.get("aBc")[0] == -3.14f); 1250 test(r.returnValue.get("aBc")[1] == 3.14f); 1251 } 1252 1253 { 1254 java.util.Map<String, double[]> sdi1 = new java.util.HashMap<>(); 1255 java.util.Map<String, double[]> sdi2 = new java.util.HashMap<>(); 1256 1257 double[] si1 = new double[] { 1.1E10, 1.2E10, 1.3E10 }; 1258 double[] si2 = new double[] { 1.4E10, 1.5E10 }; 1259 double[] si3 = new double[] { 1.6E10, 1.7E10 }; 1260 1261 sdi1.put("Hello!!", si1); 1262 sdi1.put("Goodbye", si2); 1263 sdi2.put("", si3); 1264 1265 MyClass.OpStringDoubleSDResult r = p.opStringDoubleSD(sdi1, sdi2); 1266 1267 test(r.p3.size() == 1); 1268 test(r.p3.get("").length == 2); 1269 test(r.p3.get("")[0] == 1.6E10); 1270 test(r.p3.get("")[1] == 1.7E10); 1271 test(r.returnValue.size()== 3); 1272 test(r.returnValue.get("Hello!!").length == 3); 1273 test(r.returnValue.get("Hello!!")[0] == 1.1E10); 1274 test(r.returnValue.get("Hello!!")[1] == 1.2E10); 1275 test(r.returnValue.get("Hello!!")[2] == 1.3E10); 1276 test(r.returnValue.get("Goodbye").length == 2); 1277 test(r.returnValue.get("Goodbye")[0] == 1.4E10); 1278 test(r.returnValue.get("Goodbye")[1] == 1.5E10); 1279 test(r.returnValue.get("").length== 2); 1280 test(r.returnValue.get("")[0] == 1.6E10); 1281 test(r.returnValue.get("")[1] == 1.7E10); 1282 } 1283 1284 { 1285 java.util.Map<String, String[]> sdi1 = new java.util.HashMap<String, String[]>(); 1286 java.util.Map<String, String[]> sdi2 = new java.util.HashMap<String, String[]>(); 1287 1288 String[] si1 = new String[] { "abc", "de", "fghi" }; 1289 String[] si2 = new String[] { "xyz", "or" }; 1290 String[] si3 = new String[] { "and", "xor" }; 1291 1292 sdi1.put("abc", si1); 1293 sdi1.put("def", si2); 1294 sdi2.put("ghi", si3); 1295 1296 MyClass.OpStringStringSDResult r = p.opStringStringSD(sdi1, sdi2); 1297 1298 test(r.p3.size() == 1); 1299 test(r.p3.get("ghi").length== 2); 1300 test(r.p3.get("ghi")[0].equals("and")); 1301 test(r.p3.get("ghi")[1].equals("xor")); 1302 test(r.returnValue.size()== 3); 1303 test(r.returnValue.get("abc").length == 3); 1304 test(r.returnValue.get("abc")[0].equals("abc")); 1305 test(r.returnValue.get("abc")[1].equals("de")); 1306 test(r.returnValue.get("abc")[2].equals("fghi")); 1307 test(r.returnValue.get("def").length == 2); 1308 test(r.returnValue.get("def")[0].equals("xyz")); 1309 test(r.returnValue.get("def")[1].equals("or")); 1310 test(r.returnValue.get("ghi").length == 2); 1311 test(r.returnValue.get("ghi")[0].equals("and")); 1312 test(r.returnValue.get("ghi")[1].equals("xor")); 1313 } 1314 1315 { 1316 java.util.Map<MyEnum, MyEnum[]> sdi1 = new java.util.HashMap<>(); 1317 java.util.Map<MyEnum, MyEnum[]> sdi2 = new java.util.HashMap<>(); 1318 1319 final MyEnum[] si1 = new MyEnum[] { MyEnum.enum1, MyEnum.enum1, MyEnum.enum2 }; 1320 final MyEnum[] si2 = new MyEnum[] { MyEnum.enum1, MyEnum.enum2 }; 1321 final MyEnum[] si3 = new MyEnum[] { MyEnum.enum3, MyEnum.enum3 }; 1322 1323 sdi1.put(MyEnum.enum3, si1); 1324 sdi1.put(MyEnum.enum2, si2); 1325 sdi2.put(MyEnum.enum1, si3); 1326 1327 MyClass.OpMyEnumMyEnumSDResult r = p.opMyEnumMyEnumSD(sdi1, sdi2); 1328 1329 test(r.p3.size() == 1); 1330 test(r.p3.get(MyEnum.enum1).length == 2); 1331 test(r.p3.get(MyEnum.enum1)[0] == MyEnum.enum3); 1332 test(r.p3.get(MyEnum.enum1)[1] == MyEnum.enum3); 1333 test(r.returnValue.size()== 3); 1334 test(r.returnValue.get(MyEnum.enum3).length == 3); 1335 test(r.returnValue.get(MyEnum.enum3)[0] == MyEnum.enum1); 1336 test(r.returnValue.get(MyEnum.enum3)[1] == MyEnum.enum1); 1337 test(r.returnValue.get(MyEnum.enum3)[2] == MyEnum.enum2); 1338 test(r.returnValue.get(MyEnum.enum2).length == 2); 1339 test(r.returnValue.get(MyEnum.enum2)[0] == MyEnum.enum1); 1340 test(r.returnValue.get(MyEnum.enum2)[1] == MyEnum.enum2); 1341 test(r.returnValue.get(MyEnum.enum1).length == 2); 1342 test(r.returnValue.get(MyEnum.enum1)[0] == MyEnum.enum3); 1343 test(r.returnValue.get(MyEnum.enum1)[1] == MyEnum.enum3); 1344 } 1345 1346 { 1347 int[] lengths = {0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000}; 1348 1349 for(int l : lengths) 1350 { 1351 int[] s = new int[l]; 1352 for(int i = 0; i < l; ++i) 1353 { 1354 s[i] = i; 1355 } 1356 int[] r = p.opIntS(s); 1357 test(r.length == l); 1358 for(int j = 0; j < r.length; ++j) 1359 { 1360 test(r[j] == -j); 1361 } 1362 } 1363 } 1364 1365 { 1366 Map<String, String> ctx = new HashMap<>(); 1367 ctx.put("one", "ONE"); 1368 ctx.put("two", "TWO"); 1369 ctx.put("three", "THREE"); 1370 { 1371 test(p.ice_getContext().isEmpty()); 1372 Map<String, String> r = p.opContext(); 1373 test(!r.equals(ctx)); 1374 } 1375 { 1376 Map<String, String> r = p.opContext(ctx); 1377 test(p.ice_getContext().isEmpty()); 1378 test(r.equals(ctx)); 1379 } 1380 { 1381 MyClassPrx p2 = MyClassPrx.checkedCast(p.ice_context(ctx)); 1382 test(p2.ice_getContext().equals(ctx)); 1383 Map<String, String> r = p2.opContext(); 1384 test(r.equals(ctx)); 1385 r = p2.opContext(ctx); 1386 test(r.equals(ctx)); 1387 } 1388 } 1389 1390 if(p.ice_getConnection() != null && !bluetooth) 1391 { 1392 // 1393 // Test implicit context propagation 1394 // 1395 1396 String[] impls = {"Shared", "PerThread"}; 1397 for(int i = 0; i < 2; i++) 1398 { 1399 com.zeroc.Ice.Properties properties = communicator.getProperties()._clone(); 1400 properties.setProperty("Ice.ImplicitContext", impls[i]); 1401 1402 try(Communicator ic = helper.initialize(properties)) 1403 { 1404 1405 Map<String, String> ctx = new HashMap<>(); 1406 ctx.put("one", "ONE"); 1407 ctx.put("two", "TWO"); 1408 ctx.put("three", "THREE"); 1409 1410 MyClassPrx p3 = 1411 MyClassPrx.uncheckedCast(ic.stringToProxy("test:" + helper.getTestEndpoint(properties, 0))); 1412 1413 ic.getImplicitContext().setContext(ctx); 1414 test(ic.getImplicitContext().getContext().equals(ctx)); 1415 test(p3.opContext().equals(ctx)); 1416 1417 test(!ic.getImplicitContext().containsKey("zero")); 1418 String r = ic.getImplicitContext().put("zero", "ZERO"); 1419 test(r.equals("")); 1420 test(ic.getImplicitContext().containsKey("zero")); 1421 test(ic.getImplicitContext().get("zero").equals("ZERO")); 1422 1423 ctx = ic.getImplicitContext().getContext(); 1424 test(p3.opContext().equals(ctx)); 1425 1426 Map<String, String> prxContext = new HashMap<>(); 1427 prxContext.put("one", "UN"); 1428 prxContext.put("four", "QUATRE"); 1429 1430 Map<String, String> combined = new HashMap<>(ctx); 1431 combined.putAll(prxContext); 1432 test(combined.get("one").equals("UN")); 1433 1434 p3 = p3.ice_context(prxContext); 1435 1436 ic.getImplicitContext().setContext(null); 1437 test(p3.opContext().equals(prxContext)); 1438 1439 ic.getImplicitContext().setContext(ctx); 1440 test(p3.opContext().equals(combined)); 1441 1442 test(ic.getImplicitContext().remove("one").equals("ONE")); 1443 1444 if(impls[i].equals("PerThread")) 1445 { 1446 Thread thread = new PerThreadContextInvokeThread(p3.ice_context(null)); 1447 thread.start(); 1448 try 1449 { 1450 thread.join(); 1451 } 1452 catch(InterruptedException ex) 1453 { 1454 } 1455 } 1456 } 1457 } 1458 } 1459 1460 { 1461 double d = 1278312346.0 / 13.0; 1462 double[] ds = new double[5]; 1463 for(int i = 0; i < 5; i++) 1464 { 1465 ds[i] = d; 1466 } 1467 p.opDoubleMarshaling(d, ds); 1468 } 1469 1470 p.opIdempotent(); 1471 1472 p.opNonmutating(); 1473 1474 test(p.opByte1((byte)0xFF) == (byte)0xFF); 1475 test(p.opShort1((short)0x7FFF) == (short)0x7FFF); 1476 test(p.opInt1(0x7FFFFFFF) == 0x7FFFFFFF); 1477 //test(p.opLong1(0x7FFFFFFFFFFFFFFF) == 0x7FFFFFFFFFFFFFFF); 1478 test(p.opFloat1(1.0f) == 1.0f); 1479 test(p.opDouble1(1.0d) == 1.0d); 1480 test(p.opString1("opString1").equals("opString1")); 1481 test(p.opStringS1(null).length == 0); 1482 test(p.opByteBoolD1(null).size() == 0); 1483 test(p.opStringS2(null).length == 0); 1484 test(p.opByteBoolD2(null).size() == 0); 1485 1486 MyDerivedClassPrx d = MyDerivedClassPrx.uncheckedCast(p); 1487 MyStruct1 s = new MyStruct1(); 1488 s.tesT = "Test.MyStruct1.s"; 1489 s.myClass = null; 1490 s.myStruct1 = "Test.MyStruct1.myStruct1"; 1491 s = d.opMyStruct1(s); 1492 test(s.tesT.equals("Test.MyStruct1.s")); 1493 test(s.myClass == null); 1494 test(s.myStruct1.equals("Test.MyStruct1.myStruct1")); 1495 MyClass1 c = new MyClass1(); 1496 c.tesT = "Test.MyClass1.testT"; 1497 c.myClass = null; 1498 c.myClass1 = "Test.MyClass1.myClass1"; 1499 c = d.opMyClass1(c); 1500 test(c.tesT.equals("Test.MyClass1.testT")); 1501 test(c.myClass == null); 1502 test(c.myClass1.equals("Test.MyClass1.myClass1")); 1503 1504 { 1505 Structure p1 = p.opMStruct1(); 1506 p1.e = MyEnum.enum3; 1507 MyClass.OpMStruct2Result r = p.opMStruct2(p1); 1508 test(r.p2.e == p1.e && r.returnValue.e == p1.e); 1509 } 1510 1511 { 1512 p.opMSeq1(); 1513 1514 String[] p1 = new String[1]; 1515 p1[0] = "test"; 1516 MyClass.OpMSeq2Result r = p.opMSeq2(p1); 1517 test(java.util.Arrays.equals(r.p2, p1) && java.util.Arrays.equals(r.returnValue, p1)); 1518 } 1519 1520 { 1521 p.opMDict1(); 1522 1523 java.util.Map<String, String> p1 = new java.util.HashMap<>(); 1524 p1.put("test", "test"); 1525 MyClass.OpMDict2Result r = p.opMDict2(p1); 1526 test(r.p2.equals(p1) && r.returnValue.equals(p1)); 1527 } 1528 } 1529 } 1530