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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 21x 21x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 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 { TestHelper, test } from "../../Common/TestHelper.js";
export class Client extends TestHelper {
async allTests(args) {
const out = this.getWriter();
out.write("testing configuration file escapes... ");
const props = new Map();
props.set("Foo\tBar", "3");
props.set("Foo\\tBar", "4");
props.set("Escape\\ Space", "2");
props.set("Prop1", "1");
props.set("Prop2", "2");
props.set("Prop3", "3");
props.set("My Prop1", "1");
props.set("My Prop2", "2");
props.set("My.Prop1", "a property");
props.set("My.Prop2", "a property");
props.set("My.Prop3", " a property ");
props.set("My.Prop4", " a property ");
props.set("My.Prop5", "a \\ property");
props.set("foo=bar", "1");
props.set("foo#bar", "2");
props.set("foo bar", "3");
props.set("A", "1");
props.set("B", "2 3 4");
props.set("C", "5=#6");
props.set("AServer", "\\\\server\\dir");
props.set("BServer", "\\server\\dir");
const properties = Ice.createProperties();
if (!TestHelper.isBrowser()) {
const fs = await import("fs");
const path = await import("path");
//
// We are running with NodeJS we load the properties file from the file system.
//
properties.parse(fs.readFileSync(path.join(args[4], "config", "escapes.cfg"), {
encoding: "utf8",
}));
for (const [key, value] of props) {
test(properties.getProperty(key) == value);
}
}
out.writeLine("ok");
{
out.write("testing property regexp pattern...");
const properties = Ice.createProperties();
properties.setProperty("Ice.Default.Locator.Context.Foo", "Bar");
const value = properties.getIceProperty("Ice.Default.Locator.Context.Foo");
test(value == "Bar");
out.writeLine("ok");
}
{
out.write("testing ice properties with set default values...");
const properties = Ice.createProperties();
const toStringMode = properties.getIceProperty("Ice.ToStringMode");
test(toStringMode == "Unicode");
const closeTimeout = properties.getIcePropertyAsInt("Ice.Connection.Client.CloseTimeout");
test(closeTimeout == 10);
const retryIntervals = properties.getIcePropertyAsList("Ice.RetryIntervals");
test(retryIntervals.length == 1);
test(retryIntervals[0] == "0");
out.writeLine("ok");
}
{
out.write("testing ice properties with unset default values...");
const properties = Ice.createProperties();
const stringValue = properties.getIceProperty("Ice.Default.Host");
test(stringValue == "");
const intValue = properties.getIcePropertyAsInt("Ice.Default.Host");
test(intValue == 0);
const listValue = properties.getIcePropertyAsList("Ice.Default.Host");
test(listValue.length == 0);
out.writeLine("ok");
}
{
out.write("testing that getting an unknown ice property throws an exception...");
const properties = Ice.createProperties();
try {
properties.getIceProperty("Ice.UnknownProperty");
test(false);
}
catch (ex) {
test(ex instanceof Ice.PropertyException);
}
out.writeLine("ok");
}
{
out.write("testing that setting an unknown ice property throws an exception...");
const properties = Ice.createProperties();
try {
properties.setProperty("Ice.UnknownProperty", "bar");
test(false);
}
catch (ex) {
test(ex instanceof Ice.PropertyException);
}
out.writeLine("ok");
}
{
const communicator = new Ice.Communicator(args);
try {
const properties = communicator.getProperties();
out.write("testing that creating an object adapter with unknown properties throws an exception...");
properties.setProperty("FooOA.Router", "router:tcp -h 127.0.0.1 -p 10000");
properties.setProperty("FooOA.UnknownProperty", "bar");
try {
await communicator.createObjectAdapter("FooOA");
test(false);
}
catch (ex) {
test(ex instanceof Ice.PropertyException);
}
out.writeLine("ok");
out.write("testing that creating a proxy with unknown properties throws an exception...");
properties.setProperty("FooProxy", "test:tcp -h 127.0.0.1 -p 10000");
properties.setProperty("FooProxy.UnknownProperty", "bar");
try {
communicator.propertyToProxy("FooProxy");
test(false);
}
catch (ex) {
test(ex instanceof Ice.PropertyException);
}
out.writeLine("ok");
communicator.shutdown();
}
finally {
await communicator.destroy();
}
}
{
out.write("testing that passing a property multiple times on the command line uses the last value... ");
const properties = Ice.createProperties(["--Ice.MessageSizeMax=10", "--Ice.MessageSizeMax=20"]);
test(properties.getIceProperty("Ice.MessageSizeMax") == "20");
out.writeLine("ok");
}
{
out.write("testing that trying to read a non-numeric value as an int throws... ");
const properties = Ice.createProperties();
try {
properties.setProperty("Foo", "bar");
properties.getPropertyAsInt("Foo");
test(false);
}
catch (ex) {
test(ex instanceof Ice.PropertyException);
}
out.writeLine("ok");
}
{
out.write("testing that the logger set in InitializationData takes precedence over Ice.LogFile... ");
const initData = new Ice.InitializationData();
initData.properties = Ice.createProperties();
initData.properties.setProperty("Ice.LogFile", "unused.log");
const logger = {
print: () => { },
trace: () => { },
warning: () => { },
error: () => { },
cloneWithPrefix: () => logger,
};
initData.logger = logger;
const communicator = new Ice.Communicator(initData);
try {
test(communicator.getLogger() === logger);
}
finally {
await communicator.destroy();
}
out.writeLine("ok");
}
}
async run(args) {
let communicator = null;
try {
[communicator, args] = this.initialize(args);
await this.allTests(args);
}
finally {
if (communicator) {
await communicator.destroy();
}
}
}
}
|