All files / test/Ice/proxy Client.js

93.86% Statements 888/946
21.05% Branches 4/19
100% Functions 2/2
93.86% Lines 888/946

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 9471x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                   1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x             1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x       1x 1x 1x 1x       1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                       1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
// Copyright (c) ZeroC, Inc.
import { Ice } from "@zeroc/ice";
import { Test } from "./Test.js";
import { TestHelper, test } from "../../Common/TestHelper.js";
export class Client extends TestHelper {
    async allTests() {
        class TestError extends Error {
        }
        const communicator = this.communicator();
        const out = this.getWriter();
        const defaultProtocol = communicator.getProperties().getIceProperty("Ice.Default.Protocol");
        const base = new Ice.ObjectPrx(communicator, `test:${this.getTestEndpoint()}`);
        out.write("testing stringToProxy... ");
        let b1 = communicator.stringToProxy("test");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getAdapterId().length === 0 &&
            b1.ice_getFacet().length === 0);
        b1 = communicator.stringToProxy("test ");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet().length === 0);
        b1 = communicator.stringToProxy(" test ");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet().length === 0);
        b1 = communicator.stringToProxy(" test");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet().length === 0);
        b1 = communicator.stringToProxy("'test -f facet'");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test -f facet" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet().length === 0);
        try {
            b1 = communicator.stringToProxy("\"test -f facet'");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        b1 = communicator.stringToProxy('"test -f facet"');
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test -f facet" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet().length === 0);
        b1 = communicator.stringToProxy('"test -f facet@test"');
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test -f facet@test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet().length === 0);
        b1 = communicator.stringToProxy('"test -f facet@test @test"');
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test -f facet@test @test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet().length === 0);
        try {
            b1 = communicator.stringToProxy("test test");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        b1 = communicator.stringToProxy("test\\040test");
        test(b1 !== null && b1.ice_getIdentity().name === "test test" && b1.ice_getIdentity().category.length === 0);
        try {
            b1 = communicator.stringToProxy("test\\777");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        b1 = communicator.stringToProxy("test\\40test");
        test(b1 !== null && b1.ice_getIdentity().name === "test test");
        // Test some octal and hex corner cases.
        b1 = communicator.stringToProxy("test\\4test");
        test(b1 !== null && b1.ice_getIdentity().name === "test\x04test");
        b1 = communicator.stringToProxy("test\\04test");
        test(b1 !== null && b1.ice_getIdentity().name === "test\x04test");
        b1 = communicator.stringToProxy("test\\004test");
        test(b1 !== null && b1.ice_getIdentity().name === "test\x04test");
        b1 = communicator.stringToProxy("test\\1114test");
        test(b1 !== null && b1.ice_getIdentity().name === "test\x494test");
        b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test\b\f\n\r\t'\"\\test" &&
            b1.ice_getIdentity().category.length === 0);
        b1 = communicator.stringToProxy("category/test");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category === "category" &&
            b1.ice_getAdapterId().length === 0);
        b1 = communicator.stringToProxy('test:tcp --sourceAddress "::1"');
        test(b1 !== null && b1.equals(communicator.stringToProxy(b1.toString())));
        b1 = communicator.stringToProxy("");
        test(b1 === null);
        b1 = communicator.stringToProxy('""');
        test(b1 === null);
        try {
            b1 = communicator.stringToProxy('"" test'); // Invalid trailing characters.
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            b1 = communicator.stringToProxy("test:"); // Missing endpoint.
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        b1 = communicator.stringToProxy("test@adapter");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getAdapterId() === "adapter");
        try {
            b1 = communicator.stringToProxy("id@adapter test");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        b1 = communicator.stringToProxy("category/test@adapter");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category === "category" &&
            b1.ice_getAdapterId() === "adapter");
        b1 = communicator.stringToProxy("category/test@adapter:" + defaultProtocol);
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category === "category" &&
            b1.ice_getAdapterId() === "adapter:" + defaultProtocol);
        b1 = communicator.stringToProxy("'category 1/test'@adapter");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category === "category 1" &&
            b1.ice_getAdapterId() === "adapter");
        b1 = communicator.stringToProxy("'category/test 1'@adapter");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test 1" &&
            b1.ice_getIdentity().category === "category" &&
            b1.ice_getAdapterId() === "adapter");
        b1 = communicator.stringToProxy("'category/test'@'adapter 1'");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category === "category" &&
            b1.ice_getAdapterId() === "adapter 1");
        b1 = communicator.stringToProxy('"category \\/test@foo/test"@adapter');
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category === "category /test@foo" &&
            b1.ice_getAdapterId() === "adapter");
        b1 = communicator.stringToProxy('"category \\/test@foo/test"@"adapter:' + defaultProtocol + '"');
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category === "category /test@foo" &&
            b1.ice_getAdapterId() === "adapter:" + defaultProtocol);
        b1 = communicator.stringToProxy("id -f facet");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "id" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet");
        b1 = communicator.stringToProxy("id -f 'facet x'");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "id" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet x");
        b1 = communicator.stringToProxy('id -f "facet x"');
        test(b1 !== null &&
            b1.ice_getIdentity().name === "id" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet x");
        try {
            b1 = communicator.stringToProxy('id -f "facet x');
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            b1 = communicator.stringToProxy("id -f 'facet x");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        b1 = communicator.stringToProxy("test -f facet:" + defaultProtocol);
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet" &&
            b1.ice_getAdapterId().length === 0);
        b1 = communicator.stringToProxy('test -f "facet:' + defaultProtocol + '"');
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet:" + defaultProtocol &&
            b1.ice_getAdapterId().length === 0);
        b1 = communicator.stringToProxy("test -f facet@test");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet" &&
            b1.ice_getAdapterId() === "test");
        b1 = communicator.stringToProxy("test -f 'facet@test'");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet@test" &&
            b1.ice_getAdapterId().length === 0);
        b1 = communicator.stringToProxy("test -f 'facet@test'@test");
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getFacet() === "facet@test" &&
            b1.ice_getAdapterId() === "test");
        try {
            b1 = communicator.stringToProxy("test -f facet@test @test");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        b1 = communicator.stringToProxy("test");
        test(b1 !== null && b1.ice_isTwoway());
        b1 = communicator.stringToProxy("test -t");
        test(b1 !== null && b1.ice_isTwoway());
        b1 = communicator.stringToProxy("test -o");
        test(b1 !== null && b1.ice_isOneway());
        b1 = communicator.stringToProxy("test -O");
        test(b1 !== null && b1.ice_isBatchOneway());
        // We can still parse -d and -D even if JavaScript doesn't support Datagram invocations.
        b1 = communicator.stringToProxy("test -d");
        b1 = communicator.stringToProxy("test -D");
        b1 = communicator.stringToProxy("test -s"); // does nothing
        test(b1 !== null && b1.ice_getEncodingVersion().equals(Ice.Encoding_1_1));
        b1 = communicator.stringToProxy("test -e 1.0");
        test(b1 !== null && b1.ice_getEncodingVersion().major === 1 && b1.ice_getEncodingVersion().minor === 0);
        b1 = communicator.stringToProxy("test -e 6.5");
        test(b1 !== null && b1.ice_getEncodingVersion().major === 6 && b1.ice_getEncodingVersion().minor === 5);
        b1 = communicator.stringToProxy("test -p 1.0 -e 1.0");
        test(b1 !== null && b1.toString() === "test -e 1.0");
        b1 = communicator.stringToProxy("test -p 6.5 -e 1.0");
        test(b1 !== null && b1.toString() === "test -p 6.5 -e 1.0");
        try {
            b1 = communicator.stringToProxy("test:" + defaultProtocol + "@adapterId");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            b1 = communicator.stringToProxy("test::" + defaultProtocol);
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        //
        // Test for bug ICE-5543: escaped escapes in stringToIdentity
        //
        let id = new Ice.Identity("test", ",X2QNUAzSBcJ_e$AV;E\\");
        let id2 = Ice.stringToIdentity(Ice.identityToString(id));
        test(id.equals(id2));
        id = new Ice.Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\");
        id2 = Ice.stringToIdentity(Ice.identityToString(id));
        test(id.equals(id2));
        id = new Ice.Identity("/test", "cat/");
        let idStr = Ice.identityToString(id);
        test(idStr === "cat\\//\\/test");
        id2 = Ice.stringToIdentity(idStr);
        test(id.equals(id2));
        // Input string with various pitfalls
        // id = Ice.stringToIdentity("\\342\\x82\\254\\60\\x9\\60\\");
        // test(id.name === "€0\t0\\" && id.category.isEmpty());
        try {
            // Illegal character < 32
            id = Ice.stringToIdentity("xx\x01FooBar");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Illegal surrogate
            id = Ice.stringToIdentity("xx\\ud911");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        // Testing bytes 127 (\x7F) and €
        id = new Ice.Identity("test", "\x7F€");
        idStr = Ice.identityToString(id, Ice.ToStringMode.Unicode);
        test(idStr === "\\u007f€/test");
        id2 = Ice.stringToIdentity(idStr);
        test(id.equals(id2));
        test(Ice.identityToString(id) === idStr);
        idStr = Ice.identityToString(id, Ice.ToStringMode.ASCII);
        test(idStr === "\\u007f\\u20ac/test");
        id2 = Ice.stringToIdentity(idStr);
        test(id.equals(id2));
        idStr = Ice.identityToString(id, Ice.ToStringMode.Compat);
        test(idStr === "\\177\\342\\202\\254/test");
        id2 = Ice.stringToIdentity(idStr);
        test(id.equals(id2));
        id2 = Ice.stringToIdentity(communicator.identityToString(id));
        test(id.equals(id2));
        // More unicode characters
        id = new Ice.Identity("banana \x0e-\ud83c\udf4c\u20ac\u00a2\u0024", "greek \ud800\udd6a");
        idStr = Ice.identityToString(id, Ice.ToStringMode.Unicode);
        test(idStr === "greek \ud800\udd6a/banana \\u000e-\ud83c\udf4c\u20ac\u00a2$");
        id2 = Ice.stringToIdentity(idStr);
        test(id.equals(id2));
        idStr = Ice.identityToString(id, Ice.ToStringMode.ASCII);
        test(idStr === "greek \\U0001016a/banana \\u000e-\\U0001f34c\\u20ac\\u00a2$");
        id2 = Ice.stringToIdentity(idStr);
        test(id.equals(id2));
        idStr = Ice.identityToString(id, Ice.ToStringMode.Compat);
        test(idStr === "greek \\360\\220\\205\\252/banana \\016-\\360\\237\\215\\214\\342\\202\\254\\302\\242$");
        id2 = Ice.stringToIdentity(idStr);
        test(id.equals(id2));
        //
        // Test proxies with duplicated endpoint option.
        //
        const goodBase = "hello:default -h host1 -p 4061 --sourceAddress 127.0.0.1";
        test(communicator.stringToProxy(goodBase) !== null);
        const dupOptions = [" -h host2", " -p 4062", " --sourceAddress 10.0.0.1"];
        for (const opt of dupOptions) {
            try {
                communicator.stringToProxy(goodBase + opt);
                test(false);
            }
            catch (ex) {
                test(ex instanceof Ice.ParseException, ex);
            }
        }
        out.writeLine("ok");
        out.write("testing propertyToProxy... ");
        const prop = communicator.getProperties();
        const propertyPrefix = "Foo.Proxy";
        prop.setProperty(propertyPrefix, `test:${this.getTestEndpoint()}`);
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null &&
            b1.ice_getIdentity().name === "test" &&
            b1.ice_getIdentity().category.length === 0 &&
            b1.ice_getAdapterId().length === 0 &&
            b1.ice_getFacet().length === 0);
        let property = propertyPrefix + ".Locator";
        test(b1.ice_getLocator() === null);
        prop.setProperty(property, "locator:default -p 10000");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getLocator()?.ice_getIdentity().name === "locator");
        prop.setProperty(property, "");
        property = propertyPrefix + ".LocatorCacheTimeout";
        test(b1.ice_getLocatorCacheTimeout() === -1);
        prop.setProperty(property, "1");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getLocatorCacheTimeout() === 1);
        prop.setProperty(property, "");
        // Now retest with an indirect proxy.
        prop.setProperty(propertyPrefix, "test");
        property = propertyPrefix + ".Locator";
        prop.setProperty(property, "locator:default -p 10000");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getLocator()?.ice_getIdentity().name === "locator");
        prop.setProperty(property, "");
        property = propertyPrefix + ".LocatorCacheTimeout";
        test(b1.ice_getLocatorCacheTimeout() === -1);
        prop.setProperty(property, "1");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getLocatorCacheTimeout() === 1);
        prop.setProperty(property, "");
        prop.setProperty(propertyPrefix, `test:${this.getTestEndpoint()}`);
        property = propertyPrefix + ".Router";
        test(b1.ice_getRouter() === null);
        prop.setProperty(property, "router:default -p 10000");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getRouter()?.ice_getIdentity().name === "router");
        prop.setProperty(property, "");
        property = propertyPrefix + ".ConnectionCached";
        test(b1.ice_isConnectionCached());
        prop.setProperty(property, "0");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && !b1.ice_isConnectionCached());
        prop.setProperty(property, "");
        property = propertyPrefix + ".InvocationTimeout";
        test(b1.ice_getInvocationTimeout() == -1);
        prop.setProperty(property, "1000");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getInvocationTimeout() == 1000);
        prop.setProperty(property, "");
        property = propertyPrefix + ".EndpointSelection";
        test(b1.ice_getEndpointSelection() === Ice.EndpointSelectionType.Random);
        prop.setProperty(property, "Random");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getEndpointSelection() === Ice.EndpointSelectionType.Random);
        prop.setProperty(property, "Ordered");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getEndpointSelection() === Ice.EndpointSelectionType.Ordered);
        prop.setProperty(property, "");
        property = propertyPrefix + ".Context.c1";
        test(!b1.ice_getContext().has("c1"));
        prop.setProperty(property, "TEST");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getContext().get("c1") == "TEST");
        property = propertyPrefix + ".Context.c2";
        test(!b1.ice_getContext().has("c2"));
        prop.setProperty(property, "TEST");
        b1 = communicator.propertyToProxy(propertyPrefix);
        test(b1 !== null && b1.ice_getContext().get("c2") == "TEST");
        prop.setProperty(propertyPrefix + ".Context.c1", "");
        prop.setProperty(propertyPrefix + ".Context.c2", "");
        out.writeLine("ok");
        out.write("testing proxyToProperty... ");
        b1 = new Ice.ObjectPrx(communicator, "test");
        b1 = b1.ice_connectionCached(true);
        b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered);
        b1 = b1.ice_locatorCacheTimeout(100);
        b1 = b1.ice_invocationTimeout(1234);
        b1 = b1.ice_encodingVersion(new Ice.EncodingVersion(1, 0));
        let router = new Ice.RouterPrx(communicator, "router");
        router = router.ice_connectionCached(true);
        router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random);
        router = router.ice_locatorCacheTimeout(200);
        router = router.ice_invocationTimeout(1500);
        let locator = new Ice.LocatorPrx(communicator, "locator");
        locator = locator.ice_connectionCached(false);
        locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random);
        locator = locator.ice_locatorCacheTimeout(300);
        locator = locator.ice_invocationTimeout(1500);
        locator = locator.ice_router(Ice.RouterPrx.uncheckedCast(router));
        b1 = b1.ice_locator(Ice.LocatorPrx.uncheckedCast(locator));
        const proxyProps = communicator.proxyToProperty(b1, "Test");
        test(proxyProps.size === 15);
        test(proxyProps.get("Test") === "test -e 1.0");
        test(proxyProps.get("Test.ConnectionCached") === "1");
        test(proxyProps.get("Test.EndpointSelection") === "Ordered");
        test(proxyProps.get("Test.LocatorCacheTimeout") === "100");
        test(proxyProps.get("Test.InvocationTimeout") === "1234");
        test(proxyProps.get("Test.Locator") === "locator");
        test(proxyProps.get("Test.Locator.ConnectionCached") === "0");
        test(proxyProps.get("Test.Locator.EndpointSelection") === "Random");
        test(proxyProps.get("Test.Locator.LocatorCacheTimeout") === "300");
        test(proxyProps.get("Test.Locator.InvocationTimeout") === "1500");
        test(proxyProps.get("Test.Locator.Router") === "router");
        test(proxyProps.get("Test.Locator.Router.ConnectionCached") === "1");
        test(proxyProps.get("Test.Locator.Router.EndpointSelection") === "Random");
        test(proxyProps.get("Test.Locator.Router.LocatorCacheTimeout") === "200");
        test(proxyProps.get("Test.Locator.Router.InvocationTimeout") === "1500");
        out.writeLine("ok");
        out.write("testing ice_getCommunicator... ");
        test(base.ice_getCommunicator() === communicator);
        out.writeLine("ok");
        out.write("testing proxy methods... ");
        test(communicator.identityToString(base.ice_identity(Ice.stringToIdentity("other")).ice_getIdentity()) ===
            "other");
        test(Ice.identityToString(base.ice_identity(Ice.stringToIdentity("other")).ice_getIdentity()) === "other");
        test(base.ice_facet("facet").ice_getFacet() === "facet");
        test(base.ice_adapterId("id").ice_getAdapterId() === "id");
        test(base.ice_twoway().ice_isTwoway());
        test(base.ice_oneway().ice_isOneway());
        test(base.ice_batchOneway().ice_isBatchOneway());
        test(base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion().equals(Ice.Encoding_1_0));
        test(base.ice_encodingVersion(Ice.Encoding_1_1).ice_getEncodingVersion().equals(Ice.Encoding_1_1));
        test(!base.ice_encodingVersion(Ice.Encoding_1_0).ice_getEncodingVersion().equals(Ice.Encoding_1_1));
        try {
            base.ice_invocationTimeout(0);
            test(false);
        }
        catch (ex) {
            test(!(ex instanceof TestError), ex);
        }
        try {
            base.ice_invocationTimeout(-1);
        }
        catch (ex) {
            test(false, ex);
        }
        try {
            base.ice_invocationTimeout(-2);
            test(false);
        }
        catch (ex) {
            test(!(ex instanceof TestError), ex);
        }
        try {
            base.ice_locatorCacheTimeout(0);
        }
        catch (ex) {
            test(false, ex);
        }
        try {
            base.ice_locatorCacheTimeout(-1);
        }
        catch (ex) {
            test(false, ex);
        }
        try {
            base.ice_locatorCacheTimeout(-2);
            test(false);
        }
        catch (ex) {
            test(!(ex instanceof TestError), ex);
        }
        out.writeLine("ok");
        out.write("testing proxy comparison... ");
        test(new Ice.ObjectPrx(communicator, "foo").equals(new Ice.ObjectPrx(communicator, "foo")));
        test(!new Ice.ObjectPrx(communicator, "foo").equals(new Ice.ObjectPrx(communicator, "foo2")));
        const compObj = new Ice.ObjectPrx(communicator, "foo");
        test(compObj.ice_facet("facet").equals(compObj.ice_facet("facet")));
        test(!compObj.ice_facet("facet").equals(compObj.ice_facet("facet1")));
        test(compObj.ice_oneway().equals(compObj.ice_oneway()));
        test(!compObj.ice_oneway().equals(compObj.ice_twoway()));
        test(compObj.ice_connectionCached(true).equals(compObj.ice_connectionCached(true)));
        test(!compObj.ice_connectionCached(false).equals(compObj.ice_connectionCached(true)));
        test(compObj
            .ice_endpointSelection(Ice.EndpointSelectionType.Random)
            .equals(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random)));
        test(!compObj
            .ice_endpointSelection(Ice.EndpointSelectionType.Random)
            .equals(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)));
        test(compObj.ice_connectionId("id2").equals(compObj.ice_connectionId("id2")));
        test(!compObj.ice_connectionId("id1").equals(compObj.ice_connectionId("id2")));
        test(compObj.ice_connectionId("id1").ice_getConnectionId() === "id1");
        test(compObj.ice_connectionId("id2").ice_getConnectionId() === "id2");
        const loc1 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000"));
        const loc2 = Ice.LocatorPrx.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000"));
        test(compObj.ice_locator(null).equals(compObj.ice_locator(null)));
        test(compObj.ice_locator(loc1).equals(compObj.ice_locator(loc1)));
        test(!compObj.ice_locator(loc1).equals(compObj.ice_locator(null)));
        test(!compObj.ice_locator(null).equals(compObj.ice_locator(loc2)));
        test(!compObj.ice_locator(loc1).equals(compObj.ice_locator(loc2)));
        const rtr1 = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("rtr1:default -p 10000"));
        const rtr2 = Ice.RouterPrx.uncheckedCast(communicator.stringToProxy("rtr2:default -p 10000"));
        test(compObj.ice_router(null).equals(compObj.ice_router(null)));
        test(compObj.ice_router(rtr1).equals(compObj.ice_router(rtr1)));
        test(!compObj.ice_router(rtr1).equals(compObj.ice_router(null)));
        test(!compObj.ice_router(null).equals(compObj.ice_router(rtr2)));
        test(!compObj.ice_router(rtr1).equals(compObj.ice_router(rtr2)));
        const ctx1 = new Map();
        ctx1.set("ctx1", "v1");
        const ctx2 = new Map();
        ctx2.set("ctx2", "v2");
        test(compObj.ice_context(null).equals(compObj.ice_context(null)));
        test(compObj.ice_context(ctx1).equals(compObj.ice_context(ctx1)));
        test(!compObj.ice_context(ctx1).equals(compObj.ice_context(null)));
        test(!compObj.ice_context(null).equals(compObj.ice_context(ctx2)));
        test(!compObj.ice_context(ctx1).equals(compObj.ice_context(ctx2)));
        let compObj1 = new Ice.ObjectPrx(communicator, "foo:" + defaultProtocol + " -h 127.0.0.1 -p 10000");
        let compObj2 = new Ice.ObjectPrx(communicator, "foo:" + defaultProtocol + " -h 127.0.0.1 -p 10001");
        test(!compObj1.equals(compObj2));
        compObj1 = new Ice.ObjectPrx(communicator, "foo@MyAdapter1");
        compObj2 = new Ice.ObjectPrx(communicator, "foo@MyAdapter2");
        test(!compObj1.equals(compObj2));
        test(compObj1.ice_locatorCacheTimeout(20).equals(compObj1.ice_locatorCacheTimeout(20)));
        test(!compObj1.ice_locatorCacheTimeout(10).equals(compObj1.ice_locatorCacheTimeout(20)));
        test(compObj1.ice_invocationTimeout(20).equals(compObj1.ice_invocationTimeout(20)));
        test(!compObj1.ice_invocationTimeout(10).equals(compObj1.ice_invocationTimeout(20)));
        compObj1 = new Ice.ObjectPrx(communicator, "foo:" + defaultProtocol + " -h 127.0.0.1 -p 1000");
        compObj2 = new Ice.ObjectPrx(communicator, "foo@MyAdapter1");
        test(!compObj1.equals(compObj2));
        const endpts1 = new Ice.ObjectPrx(communicator, `foo:${defaultProtocol} -h 127.0.0.1 -p 10000`).ice_getEndpoints();
        const endpts2 = new Ice.ObjectPrx(communicator, `foo:${defaultProtocol} -h 127.0.0.1 -p 10001`).ice_getEndpoints();
        test(!endpts1[0].equals(endpts2[0]));
        let compObj3 = new Ice.ObjectPrx(communicator, `foo:${defaultProtocol}`);
        compObj3 = compObj3.ice_endpoints(endpts1);
        const endpts3 = compObj3.ice_getEndpoints();
        test(endpts1[0].equals(endpts3[0]));
        test(compObj1.ice_encodingVersion(Ice.Encoding_1_0).equals(compObj1.ice_encodingVersion(Ice.Encoding_1_0)));
        test(!compObj1.ice_encodingVersion(Ice.Encoding_1_0).equals(compObj1.ice_encodingVersion(Ice.Encoding_1_1)));
        const baseConnection = await base.ice_getConnection();
        if (baseConnection !== null) {
            const baseConnection2 = await base.ice_connectionId("base2").ice_getConnection();
            compObj1 = compObj1.ice_fixed(baseConnection);
            compObj2 = compObj2.ice_fixed(baseConnection2);
            test(!compObj1.equals(compObj2));
        }
        out.writeLine("ok");
        out.write("testing checked cast... ");
        const cl = await Test.MyClassPrx.checkedCast(base);
        test(cl !== null);
        let derived = await Test.MyDerivedClassPrx.checkedCast(cl);
        test(derived !== null);
        test(cl.equals(base));
        test(derived.equals(base));
        test(cl.equals(derived));
        try {
            await Test.MyDerivedClassPrx.checkedCast(cl, "facet");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.FacetNotExistException);
        }
        out.writeLine("ok");
        out.write("testing checked cast with context... ");
        let c = await cl.getContext();
        test(c === null || c.size == 0);
        c = new Map();
        c.set("one", "hello");
        c.set("two", "world");
        const clc = await Test.MyClassPrx.checkedCast(base, undefined, c);
        const c2 = await clc.getContext();
        test(Ice.MapUtil.equals(c, c2));
        out.writeLine("ok");
        out.write("testing ice_fixed... ");
        {
            const connection = await cl.ice_getConnection();
            if (connection !== null) {
                test(!cl.ice_isFixed());
                test(cl.ice_fixed(connection).ice_isFixed());
                await cl.ice_fixed(connection).getContext();
                test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet");
                test(cl.ice_oneway().ice_fixed(connection).ice_isOneway());
                const ctx = new Map();
                ctx.set("one", "hello");
                ctx.set("two", "world");
                test(cl.ice_fixed(connection).ice_getContext().size == 0);
                test(cl.ice_context(ctx).ice_fixed(connection).ice_getContext().size == 2);
                test(cl.ice_fixed(connection).ice_getInvocationTimeout() == -1);
                test(cl.ice_invocationTimeout(10).ice_fixed(connection).ice_getInvocationTimeout() == 10);
                test((await cl.ice_fixed(connection).ice_getConnection()) == connection);
                test((await cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection()) == connection);
                const fixedConnection = await cl.ice_connectionId("ice_fixed").ice_getConnection();
                test((await cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection()) == fixedConnection);
            }
            else {
                try {
                    cl.ice_fixed(connection);
                    test(false);
                }
                catch {
                    // Expected with null connection.
                }
            }
        }
        out.writeLine("ok");
        out.write("testing encoding versioning... ");
        let ref20 = `test -e 2.0:${this.getTestEndpoint()}`;
        let cl20 = new Test.MyClassPrx(communicator, ref20);
        try {
            await cl20.ice_ping();
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.MarshalException, ex);
        }
        let ref13 = `test -e 1.3:${this.getTestEndpoint()}`;
        let cl13 = new Test.MyClassPrx(communicator, ref13);
        try {
            await cl13.ice_ping();
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.MarshalException, ex);
        }
        let ref10 = `test -e 1.0:${this.getTestEndpoint()}`;
        let cl10 = new Test.MyClassPrx(communicator, ref10);
        await cl10.ice_ping();
        await cl10.ice_encodingVersion(Ice.Encoding_1_0).ice_ping();
        await cl.ice_encodingVersion(Ice.Encoding_1_0).ice_ping();
        out.writeLine("ok");
        out.write("testing protocol versioning... ");
        ref20 = `test -p 2.0:${this.getTestEndpoint()}`;
        cl20 = new Test.MyClassPrx(communicator, ref20);
        try {
            await cl20.ice_ping();
            test(false);
        }
        catch (ex) {
            // Server 2.0 proxy doesn't support 1.0 version.
            test(ex instanceof Ice.FeatureNotSupportedException, ex);
        }
        ref13 = `test -p 1.3:${this.getTestEndpoint()}`;
        cl13 = new Test.MyClassPrx(communicator, ref13);
        try {
            await cl13.ice_ping();
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.FeatureNotSupportedException, ex);
        }
        ref10 = `test -p 1.0:${this.getTestEndpoint()}`;
        cl10 = new Test.MyClassPrx(communicator, ref10);
        await cl10.ice_ping();
        out.writeLine("ok");
        out.write("testing opaque endpoints... ");
        try {
            // Invalid -x option
            communicator.stringToProxy("id:opaque -t 99 -v abc -x abc");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Missing -t and -v
            communicator.stringToProxy("id:opaque");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Repeated -t
            communicator.stringToProxy("id:opaque -t 1 -t 1 -v abc");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Repeated -v
            communicator.stringToProxy("id:opaque -t 1 -v abc -v abc");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Missing -t
            communicator.stringToProxy("id:opaque -v abc");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Missing -v
            communicator.stringToProxy("id:opaque -t 1");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Missing arg for -t
            communicator.stringToProxy("id:opaque -t -v abc");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Missing arg for -v
            communicator.stringToProxy("id:opaque -t 1 -v");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Not a number for -t
            communicator.stringToProxy("id:opaque -t x -v abc");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // < 0 for -t
            communicator.stringToProxy("id:opaque -t -1 -v abc");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        try {
            // Invalid char for -v
            communicator.stringToProxy("id:opaque -t 99 -v x?c");
            test(false);
        }
        catch (ex) {
            test(ex instanceof Ice.ParseException, ex);
        }
        // Legal TCP endpoint expressed as opaque endpoint
        let p1 = new Ice.ObjectPrx(communicator, "test -e 1.1:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==");
        let pstr = communicator.proxyToString(p1);
        test(pstr === "test:tcp -h 127.0.0.1 -p 12010 -t 10000");
        // Legal WS endpoint expressed as opaque endpoint
        p1 = new Ice.ObjectPrx(communicator, "test -e 1.1:opaque -t 4 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAAA=");
        pstr = communicator.proxyToString(p1);
        test(pstr === "test:ws -h 127.0.0.1 -p 12010 -t 10000");
        // Opaque endpoint encoded with 1.1 encoding.
        let p2 = new Ice.ObjectPrx(communicator, "test:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==");
        test(communicator.proxyToString(p2) === "test:tcp -h 127.0.0.1 -p 12010 -t 10000");
        p2 = new Ice.ObjectPrx(communicator, "test:opaque -e 1.1 -t 4 -v CTEyNy4wLjAuMeouAAAQJwAAAAA=");
        test(communicator.proxyToString(p2) === "test:ws -h 127.0.0.1 -p 12010 -t 10000");
        const ref = `test:${this.getTestEndpoint()}`;
        const ssl = communicator.getProperties().getIceProperty("Ice.Default.Protocol") === "ssl";
        // TODO: p1 contains 127.0.0.1 - OK to invoke?
        //   if(!ssl)
        //   {
        //       p1.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping();
        //   }
        // Two legal TCP endpoints expressed as opaque endpoints
        p1 = new Ice.ObjectPrx(communicator, "test -e 1.0:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMusuAAAQJwAAAA==");
        pstr = communicator.proxyToString(p1);
        test(pstr === "test -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000");
        p1 = new Ice.ObjectPrx(communicator, "test -e 1.0:opaque -t 4 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAAA=:opaque -t 4 -e 1.0 -v CTEyNy4wLjAuMusuAAAQJwAAAAA=");
        pstr = communicator.proxyToString(p1);
        test(pstr === "test -e 1.0:ws -h 127.0.0.1 -p 12010 -t 10000:ws -h 127.0.0.2 -p 12011 -t 10000");
        //
        // Test that an SSL endpoint and a nonsense endpoint get
        // written back out as an opaque endpoint.
        //
        p1 = new Ice.ObjectPrx(communicator, "test -e 1.0:opaque -e 1.0 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch");
        pstr = communicator.proxyToString(p1);
        test(pstr === "test -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch");
        //
        // Try to invoke on the SSL endpoint to verify that we get a
        // NoEndpointException (or ConnectFailedException when
        // running with SSL).
        //
        try {
            await p1.ice_encodingVersion(Ice.Encoding_1_0).ice_ping();
            test(false);
        }
        catch (ex) {
            if (ex instanceof Ice.NoEndpointException) {
                test(!ssl);
            }
            else if (ex instanceof Ice.ConnectFailedException) {
                test(ssl);
            }
            else {
                throw ex;
            }
        }
        //
        // Test that the proxy with an SSL endpoint and a nonsense
        // endpoint (which the server doesn't understand either) can
        // be sent over the wire and returned by the server without
        // losing the opaque endpoints.
        //
        derived = new Test.MyDerivedClassPrx(communicator, `test -e 1.0:${this.getTestEndpoint()}`);
        p2 = (await derived.echo(p1));
        pstr = communicator.proxyToString(p2);
        test(pstr === "test -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch");
        let p = new Ice.ObjectPrx(communicator, `test:${this.getTestEndpoint()}`);
        if (defaultProtocol === "tcp") {
            test(p.ice_getEndpoints()[0].getInfo() instanceof Ice.TCPEndpointInfo);
        }
        else if (defaultProtocol === "ws" || defaultProtocol === "wss") {
            test(p.ice_getEndpoints()[0].getInfo() instanceof Ice.WSEndpointInfo);
        }
        let con = await p.ice_getConnection();
        if (defaultProtocol === "tcp") {
            test(con.getInfo() instanceof Ice.TCPConnectionInfo);
        }
        else if (defaultProtocol === "ws" || defaultProtocol === "wss") {
            test(con.getInfo() instanceof Ice.WSConnectionInfo);
        }
        // The first endpoint is a non connectable and should be automatically skipped.
        p = TestHelper.isBrowser()
            ? new Ice.ObjectPrx(communicator, `test:${this.getTestEndpoint("tcp")}:${this.getTestEndpoint()}`)
            : new Ice.ObjectPrx(communicator, `test:${this.getTestEndpoint("ws")}:${this.getTestEndpoint()}`);
        p = p.ice_endpointSelection(Ice.EndpointSelectionType.Ordered);
        await p.ice_ping();
        out.writeLine("ok");
        out.write("testing proxyToString... ");
        b1 = new Ice.ObjectPrx(communicator, ref);
        let b2 = new Ice.ObjectPrx(communicator, communicator.proxyToString(b1));
        test(b1.equals(b2));
        con = await b1.ice_getConnection();
        b2 = con.createProxy(Ice.stringToIdentity("fixed"));
        const str = communicator.proxyToString(b2);
        test(b2.toString() === str);
        const str2 = b1.ice_identity(b2.ice_getIdentity()).toString();
        // Verify that the stringified fixed proxy is the same as a regular stringified proxy
        // but without endpoints
        test(str2.startsWith(str));
        test(str2.charAt(str.length) === ":");
        out.writeLine("ok");
        if (defaultProtocol === "ws" || defaultProtocol === "wss") {
            out.write("testing ping invalid WS proxies... ");
            //
            // Invocation in a WS or WSS proxy that has not hostname set
            // will fail creating the WebSocket object.
            //
            const communicator2 = new Ice.Communicator();
            const invalid = new Ice.ObjectPrx(communicator2, `test:${this.getTestEndpoint()}`);
            try {
                await invalid.ice_ping();
                test(false);
            }
            catch {
                // expected
            }
            finally {
                await communicator2.destroy();
            }
            out.writeLine("ok");
        }
        out.write("testing communicator shutdown/destroy... ");
        {
            const c = new Ice.Communicator();
            c.shutdown();
            test(c.isShutdown());
            await c.waitForShutdown();
            await c.destroy();
            c.shutdown();
            test(c.isShutdown());
            await c.waitForShutdown();
            await c.destroy();
        }
        out.writeLine("ok");
        out.write("testing proxy hierarchy... ");
        let cPrx = new Test.CPrx(communicator, `c:${this.getTestEndpoint()}`);
        const aPrx = await cPrx.opA(cPrx);
        test(cPrx.equals(aPrx));
        const bPrx = await cPrx.opB(cPrx);
        test(cPrx.equals(bPrx));
        cPrx = (await cPrx.opC(cPrx));
        let s = new Test.S();
        s.a = cPrx;
        s.b = cPrx;
        s = await cPrx.opS(s);
        test(s.a !== null);
        test(s.a.equals(cPrx));
        test(s.b !== null);
        test(s.b.equals(cPrx));
        out.writeLine("ok");
        derived = new Test.MyDerivedClassPrx(communicator, `test:${this.getTestEndpoint()}`);
        await derived.shutdown();
    }
    async run(args) {
        let communicator = null;
        try {
            [communicator] = this.initialize(args);
            await this.allTests();
        }
        finally {
            if (communicator) {
                await communicator.destroy();
            }
        }
    }
}