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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 5x 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 { TestHelper, test } from "../../Common/TestHelper.js";
import { Test } from "./Test.js";
import { MyObjectI } from "./MyObjectI.js";
export class Client extends TestHelper {
async allTests(echo) {
const communicator = this.communicator();
const adapter = await communicator.createObjectAdapter("");
await echo.setConnection();
echo.ice_getCachedConnection().setAdapter(adapter);
const out = this.getWriter();
const servant = new MyObjectI();
adapter.addDefaultServant(servant, "foo");
out.write("testing single category... ");
test(adapter.findDefaultServant("foo") === servant);
test(adapter.findDefaultServant("bar") === null);
const names = ["foo", "bar", "x", "y", "abcdefg"];
let prx;
for (const name of names) {
prx = new Test.MyObjectPrx(communicator, `foo/${name}:${this.getTestEndpoint()}`);
await prx.ice_ping();
test((await prx.getName()) == name);
}
prx = new Test.MyObjectPrx(communicator, `foo/ObjectNotExist:${this.getTestEndpoint()}`);
try {
await prx.ice_ping();
test(false);
}
catch (ex) {
test(ex instanceof Ice.ObjectNotExistException);
}
try {
await prx.getName();
test(false);
}
catch (ex) {
test(ex instanceof Ice.ObjectNotExistException);
}
prx = new Test.MyObjectPrx(communicator, `foo/FacetNotExist:${this.getTestEndpoint()}`);
try {
await prx.ice_ping();
test(false);
}
catch (ex) {
test(ex instanceof Ice.FacetNotExistException);
}
try {
await prx.getName();
test(false);
}
catch (ex) {
test(ex instanceof Ice.FacetNotExistException);
}
for (const name of names) {
prx = new Test.MyObjectPrx(communicator, `bar/${name}:${this.getTestEndpoint()}`);
try {
await prx.ice_ping();
test(false);
}
catch (ex) {
test(ex instanceof Ice.ObjectNotExistException);
}
try {
await prx.getName();
test(false);
}
catch (ex) {
test(ex instanceof Ice.ObjectNotExistException);
}
}
adapter.removeDefaultServant("foo");
prx = new Test.MyObjectPrx(communicator, `foo/x:${this.getTestEndpoint()}`);
try {
await prx.ice_ping();
test(false);
}
catch (ex) {
test(ex instanceof Ice.ObjectNotExistException);
}
out.writeLine("ok");
out.write("testing default category... ");
adapter.addDefaultServant(servant, "");
test(adapter.findDefaultServant("bar") === null);
test(adapter.findDefaultServant("") == servant);
for (const name of names) {
prx = new Test.MyObjectPrx(communicator, `bar/${name}:${this.getTestEndpoint()}`);
await prx.ice_ping();
test((await prx.getName()) == name);
}
out.writeLine("ok");
}
async run(args) {
let communicator = null;
let echo = null;
try {
[communicator, args] = this.initialize(args);
echo = new Test.EchoPrx(communicator, `__echo:${this.getTestEndpoint()}`);
await this.allTests(echo);
}
finally {
if (echo) {
try {
await echo.shutdown();
}
catch {
// Ignore shutdown exceptions
}
}
if (communicator) {
await communicator.destroy();
}
}
}
}
|