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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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";
import { DI, FI, HI, EmptyI } from "./TestI.js";
export class Server extends TestHelper {
async run(args) {
let communicator = null;
let echo = null;
try {
[communicator] = this.initialize(args);
const out = this.getWriter();
echo = new Test.EchoPrx(communicator, `__echo:${this.getTestEndpoint()}`);
out.write("testing facet registration exceptions... ");
let adapter = await communicator.createObjectAdapter("");
const obj = new EmptyI();
adapter.add(obj, Ice.stringToIdentity("d"));
adapter.addFacet(obj, Ice.stringToIdentity("d"), "facetABCD");
try {
adapter.addFacet(obj, Ice.stringToIdentity("d"), "facetABCD");
test(false);
}
catch (ex) {
test(ex instanceof Ice.AlreadyRegisteredException);
}
adapter.removeFacet(Ice.stringToIdentity("d"), "facetABCD");
try {
adapter.removeFacet(Ice.stringToIdentity("d"), "facetABCD");
test(false);
}
catch (ex) {
test(ex instanceof Ice.NotRegisteredException);
}
out.writeLine("ok");
out.write("testing removeAllFacets... ");
const obj1 = new EmptyI();
const obj2 = new EmptyI();
adapter.addFacet(obj1, Ice.stringToIdentity("id1"), "f1");
adapter.addFacet(obj2, Ice.stringToIdentity("id1"), "f2");
const obj3 = new EmptyI();
adapter.addFacet(obj1, Ice.stringToIdentity("id2"), "f1");
adapter.addFacet(obj2, Ice.stringToIdentity("id2"), "f2");
adapter.addFacet(obj3, Ice.stringToIdentity("id2"), "");
let fm = adapter.removeAllFacets(Ice.stringToIdentity("id1"));
test(fm.size === 2);
test(fm.get("f1") === obj1);
test(fm.get("f2") === obj2);
try {
adapter.removeAllFacets(Ice.stringToIdentity("id1"));
test(false);
}
catch (ex) {
test(ex instanceof Ice.NotRegisteredException);
}
fm = adapter.removeAllFacets(Ice.stringToIdentity("id2"));
test(fm.size == 3);
test(fm.get("f1") === obj1);
test(fm.get("f2") === obj2);
test(fm.get("") === obj3);
out.writeLine("ok");
adapter.destroy();
adapter = await communicator.createObjectAdapter("");
const di = new DI();
adapter.add(di, Ice.stringToIdentity("d"));
adapter.addFacet(di, Ice.stringToIdentity("d"), "facetABCD");
const fi = new FI();
adapter.addFacet(fi, Ice.stringToIdentity("d"), "facetEF");
const hi = new HI();
adapter.addFacet(hi, Ice.stringToIdentity("d"), "facetGH");
await echo.setConnection();
echo.ice_getCachedConnection().setAdapter(adapter);
this.serverReady();
await communicator.waitForShutdown();
}
finally {
if (echo) {
await echo.shutdown();
}
if (communicator) {
await communicator.destroy();
}
}
}
}
|