internal ServerManagerI(ServerLocatorRegistry registry, Ice.InitializationData initData, TestCommon.Application app) { _registry = registry; _communicators = new ArrayList(); _initData = initData; _app = app; _initData.properties.setProperty("TestAdapter.AdapterId", "TestAdapter"); _initData.properties.setProperty("TestAdapter.ReplicaGroupId", "ReplicatedAdapter"); _initData.properties.setProperty("TestAdapter2.AdapterId", "TestAdapter2"); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); string @ref = "communicator:" + app.getTestEndpoint(0); RemoteCommunicatorPrx com = RemoteCommunicatorPrxHelper.uncheckedCast(communicator.stringToProxy(@ref)); List <TestCase> tests = new List <TestCase>(); tests.Add(new InvocationHeartbeatTest(com)); tests.Add(new InvocationHeartbeatOnHoldTest(com)); tests.Add(new InvocationNoHeartbeatTest(com)); tests.Add(new InvocationHeartbeatCloseOnIdleTest(com)); tests.Add(new CloseOnIdleTest(com)); tests.Add(new CloseOnInvocationTest(com)); tests.Add(new CloseOnIdleAndInvocationTest(com)); tests.Add(new ForcefulCloseOnIdleAndInvocationTest(com)); tests.Add(new HeartbeatOnIdleTest(com)); tests.Add(new HeartbeatAlwaysTest(com)); tests.Add(new HeartbeatManualTest(com)); tests.Add(new SetACMTest(com)); foreach (TestCase test in tests) { test.init(); } foreach (TestCase test in tests) { test.start(); } foreach (TestCase test in tests) { test.join(); } foreach (TestCase test in tests) { test.destroy(); } Console.Out.Write("shutting down... "); Console.Out.Flush(); com.shutdown(); Console.WriteLine("ok"); }
public static ThrowerPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); { Write("testing object adapter registration exceptions... "); Ice.ObjectAdapter first; try { first = communicator.createObjectAdapter("TestAdapter0"); } catch (Ice.InitializationException) { // Expected } communicator.getProperties().setProperty("TestAdapter0.Endpoints", "default"); first = communicator.createObjectAdapter("TestAdapter0"); try { communicator.createObjectAdapter("TestAdapter0"); test(false); } catch (Ice.AlreadyRegisteredException) { // Expected. } try { Ice.ObjectAdapter second = communicator.createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011"); test(false); // // Quell mono error that variable second isn't used. // second.deactivate(); } catch (Ice.AlreadyRegisteredException) { // Expected } first.deactivate(); WriteLine("ok"); } { Write("testing servant registration exceptions... "); communicator.getProperties().setProperty("TestAdapter1.Endpoints", "default"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter1"); Ice.Object obj = new EmptyI(); adapter.add(obj, Ice.Util.stringToIdentity("x")); try { adapter.add(obj, Ice.Util.stringToIdentity("x")); test(false); } catch (Ice.AlreadyRegisteredException) { } try { adapter.add(obj, Ice.Util.stringToIdentity("")); test(false); } catch (Ice.IllegalIdentityException e) { test(e.id.name.Equals("")); } try { adapter.add(null, Ice.Util.stringToIdentity("x")); test(false); } catch (Ice.IllegalServantException) { } adapter.remove(Ice.Util.stringToIdentity("x")); try { adapter.remove(Ice.Util.stringToIdentity("x")); test(false); } catch (Ice.NotRegisteredException) { } adapter.deactivate(); WriteLine("ok"); } { Write("testing servant locator registration exceptions... "); communicator.getProperties().setProperty("TestAdapter2.Endpoints", "default"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter2"); Ice.ServantLocator loc = new ServantLocatorI(); adapter.addServantLocator(loc, "x"); try { adapter.addServantLocator(loc, "x"); test(false); } catch (Ice.AlreadyRegisteredException) { } adapter.deactivate(); WriteLine("ok"); } { Write("testing object factory registration exception... "); communicator.getValueFactoryManager().add(_ => { return(null); }, "::x"); try { communicator.getValueFactoryManager().add(_ => { return(null); }, "::x"); test(false); } catch (Ice.AlreadyRegisteredException) { } WriteLine("ok"); } Write("testing stringToProxy... "); Flush(); String @ref = "thrower:" + app.getTestEndpoint(0); Ice.ObjectPrx @base = communicator.stringToProxy(@ref); test(@base != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); ThrowerPrx thrower = ThrowerPrxHelper.checkedCast(@base); test(thrower != null); test(thrower.Equals(@base)); WriteLine("ok"); Write("catching exact types... "); Flush(); try { thrower.throwAasA(1); test(false); } catch (A ex) { test(ex.aMem == 1); } catch (Exception ex) { System.Console.WriteLine(ex); test(false); } try { thrower.throwAorDasAorD(1); test(false); } catch (A ex) { test(ex.aMem == 1); } catch (Exception) { test(false); } try { thrower.throwAorDasAorD(-1); test(false); } catch (D ex) { test(ex.dMem == -1); } catch (Exception) { test(false); } try { thrower.throwBasB(1, 2); test(false); } catch (B ex) { test(ex.aMem == 1); test(ex.bMem == 2); } catch (Exception) { test(false); } try { thrower.throwCasC(1, 2, 3); test(false); } catch (C ex) { test(ex.aMem == 1); test(ex.bMem == 2); test(ex.cMem == 3); } catch (Exception) { test(false); } WriteLine("ok"); Write("catching base types... "); Flush(); try { thrower.throwBasB(1, 2); test(false); } catch (A ex) { test(ex.aMem == 1); } catch (Exception) { test(false); } try { thrower.throwCasC(1, 2, 3); test(false); } catch (B ex) { test(ex.aMem == 1); test(ex.bMem == 2); } catch (Exception) { test(false); } WriteLine("ok"); Write("catching derived types... "); Flush(); try { thrower.throwBasA(1, 2); test(false); } catch (B ex) { test(ex.aMem == 1); test(ex.bMem == 2); } catch (Exception) { test(false); } try { thrower.throwCasA(1, 2, 3); test(false); } catch (C ex) { test(ex.aMem == 1); test(ex.bMem == 2); test(ex.cMem == 3); } catch (Exception) { test(false); } try { thrower.throwCasB(1, 2, 3); test(false); } catch (C ex) { test(ex.aMem == 1); test(ex.bMem == 2); test(ex.cMem == 3); } catch (Exception) { test(false); } WriteLine("ok"); if (thrower.supportsUndeclaredExceptions()) { Write("catching unknown user exception... "); Flush(); try { thrower.throwUndeclaredA(1); test(false); } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } try { thrower.throwUndeclaredB(1, 2); test(false); } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } try { thrower.throwUndeclaredC(1, 2, 3); test(false); } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } WriteLine("ok"); } if (thrower.ice_getConnection() != null) { Write("testing memory limit marshal exception..."); Flush(); try { thrower.throwMemoryLimitException(null); test(false); } catch (Ice.MemoryLimitException) { } catch (Exception) { test(false); } try { thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB test(false); } catch (Ice.ConnectionLostException) { } catch (Ice.UnknownLocalException) { // Expected with JS bidir server } catch (Exception) { test(false); } try { ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast( communicator.stringToProxy("thrower:" + app.getTestEndpoint(1))); try { thrower2.throwMemoryLimitException(new byte[2 * 1024 * 1024]); // 2MB (no limits) } catch (Ice.MemoryLimitException) { } ThrowerPrx thrower3 = ThrowerPrxHelper.uncheckedCast( communicator.stringToProxy("thrower:" + app.getTestEndpoint(2))); try { thrower3.throwMemoryLimitException(new byte[1024]); // 1KB limit test(false); } catch (Ice.ConnectionLostException) { } } catch (Ice.ConnectionRefusedException) { // Expected with JS bidir server } WriteLine("ok"); } Write("catching object not exist exception... "); Flush(); { Ice.Identity id = Ice.Util.stringToIdentity("does not exist"); try { ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id)); thrower2.ice_ping(); test(false); } catch (Ice.ObjectNotExistException ex) { test(ex.id.Equals(id)); } catch (Exception) { test(false); } } WriteLine("ok"); Write("catching facet not exist exception... "); Flush(); try { ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet"); try { thrower2.ice_ping(); test(false); } catch (Ice.FacetNotExistException ex) { test(ex.facet.Equals("no such facet")); } } catch (Exception) { test(false); } WriteLine("ok"); Write("catching operation not exist exception... "); Flush(); try { WrongOperationPrx thrower2 = WrongOperationPrxHelper.uncheckedCast(thrower); thrower2.noSuchOperation(); test(false); } catch (Ice.OperationNotExistException ex) { test(ex.operation.Equals("noSuchOperation")); } catch (Exception) { test(false); } WriteLine("ok"); Write("catching unknown local exception... "); Flush(); try { thrower.throwLocalException(); test(false); } catch (Ice.UnknownLocalException) { } catch (Exception) { test(false); } try { thrower.throwLocalExceptionIdempotent(); test(false); } catch (Ice.UnknownLocalException) { } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } WriteLine("ok"); Write("catching unknown non-Ice exception... "); Flush(); try { thrower.throwNonIceException(); test(false); } catch (Ice.UnknownException) { } catch (System.Exception) { test(false); } WriteLine("ok"); Write("testing asynchronous exceptions... "); Flush(); try { thrower.throwAfterResponse(); } catch (Exception) { test(false); } try { thrower.throwAfterException(); test(false); } catch (A) { } catch (Exception) { test(false); } WriteLine("ok"); Write("catching exact types with AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwAasA(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { test(exc is A); A ex = exc as A; test(ex.aMem == 1); cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwAorDasAorD(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (A ex) { test(ex.aMem == 1); } catch (D ex) { test(ex.dMem == -1); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwAorDasAorD(-1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (A ex) { test(ex.aMem == 1); } catch (D ex) { test(ex.dMem == -1); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwBasB(1, 2).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (B ex) { test(ex.aMem == 1); test(ex.bMem == 2); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwCasC(1, 2, 3).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (C ex) { test(ex.aMem == 1); test(ex.bMem == 2); test(ex.cMem == 3); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching derived types with new AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwBasA(1, 2).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (B ex) { test(ex.aMem == 1); test(ex.bMem == 2); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwCasA(1, 2, 3).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (C ex) { test(ex.aMem == 1); test(ex.bMem == 2); test(ex.cMem == 3); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwCasB(1, 2, 3).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (C ex) { test(ex.aMem == 1); test(ex.bMem == 2); test(ex.cMem == 3); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); if (thrower.supportsUndeclaredExceptions()) { Write("catching unknown user exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwUndeclaredA(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwUndeclaredB(1, 2).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwUndeclaredC(1, 2, 3).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); } Write("catching object not exist exception with new AMI mapping... "); Flush(); { Ice.Identity id = Ice.Util.stringToIdentity("does not exist"); ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id)); Callback cb = new Callback(); thrower2.begin_throwAasA(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.ObjectNotExistException ex) { test(ex.id.Equals(id)); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching facet not exist exception with new AMI mapping... "); Flush(); { ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet"); Callback cb = new Callback(); thrower2.begin_throwAasA(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.FacetNotExistException ex) { test(ex.facet.Equals("no such facet")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching operation not exist exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); WrongOperationPrx thrower4 = WrongOperationPrxHelper.uncheckedCast(thrower); thrower4.begin_noSuchOperation().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.OperationNotExistException ex) { test(ex.operation.Equals("noSuchOperation")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching unknown local exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwLocalException().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownLocalException) { } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwLocalExceptionIdempotent().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownLocalException) { } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching unknown non-Ice exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwNonIceException().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); if (thrower.supportsUndeclaredExceptions()) { Write("catching unknown user exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwUndeclaredA(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwUndeclaredB(1, 2).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwUndeclaredC(1, 2, 3).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownUserException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); } Write("catching object not exist exception with new AMI mapping... "); Flush(); { Ice.Identity id = Ice.Util.stringToIdentity("does not exist"); ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id)); Callback cb = new Callback(); thrower2.begin_throwAasA(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.ObjectNotExistException ex) { test(ex.id.Equals(id)); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching facet not exist exception with new AMI mapping... "); Flush(); { ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet"); Callback cb = new Callback(); thrower2.begin_throwAasA(1).whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.FacetNotExistException ex) { test(ex.facet.Equals("no such facet")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching operation not exist exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); WrongOperationPrx thrower4 = WrongOperationPrxHelper.uncheckedCast(thrower); thrower4.begin_noSuchOperation().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.OperationNotExistException ex) { test(ex.operation.Equals("noSuchOperation")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching unknown local exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwLocalException().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownLocalException) { } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } { Callback cb = new Callback(); thrower.begin_throwLocalExceptionIdempotent().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownLocalException) { } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); Write("catching unknown non-Ice exception with new AMI mapping... "); Flush(); { Callback cb = new Callback(); thrower.begin_throwNonIceException().whenCompleted( () => { test(false); }, (Ice.Exception exc) => { try { throw exc; } catch (Ice.UnknownException) { } catch (Exception) { test(false); } cb.called(); }); cb.check(); } WriteLine("ok"); return(thrower); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); string @ref = "communicator:" + app.getTestEndpoint(0); RemoteCommunicatorPrx com = RemoteCommunicatorPrxHelper.uncheckedCast(communicator.stringToProxy(@ref)); System.Random rand = new System.Random(unchecked ((int)System.DateTime.Now.Ticks)); Write("testing binding with single endpoint... "); Flush(); { RemoteObjectAdapterPrx adapter = com.createObjectAdapter("Adapter", "default"); TestIntfPrx test1 = adapter.getTestIntf(); TestIntfPrx test2 = adapter.getTestIntf(); test(test1.ice_getConnection() == test2.ice_getConnection()); test1.ice_ping(); test2.ice_ping(); com.deactivateObjectAdapter(adapter); TestIntfPrx test3 = TestIntfPrxHelper.uncheckedCast(test1); test(test3.ice_getConnection() == test1.ice_getConnection()); test(test3.ice_getConnection() == test2.ice_getConnection()); try { test3.ice_ping(); test(false); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } } WriteLine("ok"); Write("testing binding with multiple endpoints... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter11", "default")); adapters.Add(com.createObjectAdapter("Adapter12", "default")); adapters.Add(com.createObjectAdapter("Adapter13", "default")); // // Ensure that when a connection is opened it's reused for new // proxies and that all endpoints are eventually tried. // List <string> names = new List <string>(); names.Add("Adapter11"); names.Add("Adapter12"); names.Add("Adapter13"); while (names.Count > 0) { List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test1.ice_ping(); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Ensure that the proxy correctly caches the connection (we // always send the request over the same connection.) // { foreach (RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_ping(); } TestIntfPrx t = createTestIntfPrx(adapters); string name = t.getAdapterName(); int nRetry = 10; int i; for (i = 0; i < nRetry && t.getAdapterName().Equals(name); i++) { ; } test(i == nRetry); foreach (RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapters. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("Adapter12"); names.Add("Adapter13"); while (names.Count > 0) { List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(test1.getAdapterName()); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapter. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); TestIntfPrx obj = createTestIntfPrx(adapters); test(obj.getAdapterName().Equals("Adapter12")); deactivate(com, adapters); } WriteLine("ok"); Write("testing binding with multiple random endpoints... "); Flush(); { RemoteObjectAdapterPrx[] adapters = new RemoteObjectAdapterPrx[5]; adapters[0] = com.createObjectAdapter("AdapterRandom11", "default"); adapters[1] = com.createObjectAdapter("AdapterRandom12", "default"); adapters[2] = com.createObjectAdapter("AdapterRandom13", "default"); adapters[3] = com.createObjectAdapter("AdapterRandom14", "default"); adapters[4] = com.createObjectAdapter("AdapterRandom15", "default"); int count = 20; int adapterCount = adapters.Length; while (--count > 0) { TestIntfPrx[] proxies; if (count == 1) { com.deactivateObjectAdapter(adapters[4]); --adapterCount; } proxies = new TestIntfPrx[10]; int i; for (i = 0; i < proxies.Length; ++i) { RemoteObjectAdapterPrx[] adpts = new RemoteObjectAdapterPrx[rand.Next(adapters.Length)]; if (adpts.Length == 0) { adpts = new RemoteObjectAdapterPrx[1]; } for (int j = 0; j < adpts.Length; ++j) { adpts[j] = adapters[rand.Next(adapters.Length)]; } proxies[i] = createTestIntfPrx(new List <RemoteObjectAdapterPrx>(adpts)); } for (i = 0; i < proxies.Length; i++) { proxies[i].begin_getAdapterName(); } for (i = 0; i < proxies.Length; i++) { try { proxies[i].ice_ping(); } catch (Ice.LocalException) { } } List <Ice.Connection> connections = new List <Ice.Connection>(); for (i = 0; i < proxies.Length; i++) { if (proxies[i].ice_getCachedConnection() != null) { if (!connections.Contains(proxies[i].ice_getCachedConnection())) { connections.Add(proxies[i].ice_getCachedConnection()); } } } test(connections.Count <= adapterCount); foreach (RemoteObjectAdapterPrx a in adapters) { try { a.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } catch (Ice.LocalException) { // Expected if adapter is down. } } } } WriteLine("ok"); Write("testing binding with multiple endpoints and AMI... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("AdapterAMI11", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI12", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI13", "default")); // // Ensure that when a connection is opened it's reused for new // proxies and that all endpoints are eventually tried. // List <string> names = new List <string>(); names.Add("AdapterAMI11"); names.Add("AdapterAMI12"); names.Add("AdapterAMI13"); while (names.Count > 0) { List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test1.ice_ping(); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Ensure that the proxy correctly caches the connection (we // always send the request over the same connection.) // { foreach (RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_ping(); } TestIntfPrx t = createTestIntfPrx(adapters); string name = getAdapterNameWithAMI(t); int nRetry = 10; int i; for (i = 0; i < nRetry && getAdapterNameWithAMI(t).Equals(name); i++) { ; } test(i == nRetry); foreach (RemoteObjectAdapterPrx adpt in adapters) { adpt.getTestIntf().ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapters. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("AdapterAMI12"); names.Add("AdapterAMI13"); while (names.Count > 0) { List <RemoteObjectAdapterPrx> adpts = new List <RemoteObjectAdapterPrx>(adapters); TestIntfPrx test1 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test2 = createTestIntfPrx(adpts); shuffle(ref adpts); TestIntfPrx test3 = createTestIntfPrx(adpts); test(test1.ice_getConnection() == test2.ice_getConnection()); test(test2.ice_getConnection() == test3.ice_getConnection()); names.Remove(getAdapterNameWithAMI(test1)); test1.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } // // Deactivate an adapter and ensure that we can still // establish the connection to the remaining adapter. // com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); TestIntfPrx obj = createTestIntfPrx(adapters); test(getAdapterNameWithAMI(obj).Equals("AdapterAMI12")); deactivate(com, adapters); } WriteLine("ok"); Write("testing random endpoint selection... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter21", "default")); adapters.Add(com.createObjectAdapter("Adapter22", "default")); adapters.Add(com.createObjectAdapter("Adapter23", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); List <string> names = new List <string>(); names.Add("Adapter21"); names.Add("Adapter22"); names.Add("Adapter23"); while (names.Count > 0) { names.Remove(obj.getAdapterName()); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Random)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); names.Add("Adapter21"); names.Add("Adapter22"); names.Add("Adapter23"); while (names.Count > 0) { names.Remove(obj.getAdapterName()); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } deactivate(com, adapters); } WriteLine("ok"); Write("testing ordered endpoint selection... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter31", "default")); adapters.Add(com.createObjectAdapter("Adapter32", "default")); adapters.Add(com.createObjectAdapter("Adapter33", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); int nRetry = 3; int i; // // Ensure that endpoints are tried in order by deactiving the adapters // one after the other. // for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter31"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter32"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter33"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); try { obj.getAdapterName(); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("Adapter36", endpoints[2].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter36"); i++) { ; } test(i == nRetry); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.Add(com.createObjectAdapter("Adapter35", endpoints[1].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter35"); i++) { ; } test(i == nRetry); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); adapters.Add(com.createObjectAdapter("Adapter34", endpoints[0].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter34"); i++) { ; } test(i == nRetry); deactivate(com, adapters); } WriteLine("ok"); Write("testing per request binding with single endpoint... "); Flush(); { RemoteObjectAdapterPrx adapter = com.createObjectAdapter("Adapter41", "default"); TestIntfPrx test1 = TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false)); TestIntfPrx test2 = TestIntfPrxHelper.uncheckedCast(adapter.getTestIntf().ice_connectionCached(false)); test(!test1.ice_isConnectionCached()); test(!test2.ice_isConnectionCached()); test(test1.ice_getConnection() != null && test2.ice_getConnection() != null); test(test1.ice_getConnection() == test2.ice_getConnection()); test1.ice_ping(); com.deactivateObjectAdapter(adapter); TestIntfPrx test3 = TestIntfPrxHelper.uncheckedCast(test1); try { test(test3.ice_getConnection() == test1.ice_getConnection()); test(false); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } } WriteLine("ok"); Write("testing per request binding with multiple endpoints... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter51", "default")); adapters.Add(com.createObjectAdapter("Adapter52", "default")); adapters.Add(com.createObjectAdapter("Adapter53", "default")); TestIntfPrx obj = TestIntfPrxHelper.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); List <string> names = new List <string>(); names.Add("Adapter51"); names.Add("Adapter52"); names.Add("Adapter53"); while (names.Count > 0) { names.Remove(obj.getAdapterName()); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("Adapter52"); names.Add("Adapter53"); while (names.Count > 0) { names.Remove(obj.getAdapterName()); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); test(obj.getAdapterName().Equals("Adapter52")); deactivate(com, adapters); } WriteLine("ok"); Write("testing per request binding with multiple endpoints and AMI... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("AdapterAMI51", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI52", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI53", "default")); TestIntfPrx obj = TestIntfPrxHelper.uncheckedCast(createTestIntfPrx(adapters).ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); List <string> names = new List <string>(); names.Add("AdapterAMI51"); names.Add("AdapterAMI52"); names.Add("AdapterAMI53"); while (names.Count > 0) { names.Remove(getAdapterNameWithAMI(obj)); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); names.Add("AdapterAMI52"); names.Add("AdapterAMI53"); while (names.Count > 0) { names.Remove(getAdapterNameWithAMI(obj)); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); test(getAdapterNameWithAMI(obj).Equals("AdapterAMI52")); deactivate(com, adapters); } WriteLine("ok"); Write("testing per request binding and ordered endpoint selection... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter61", "default")); adapters.Add(com.createObjectAdapter("Adapter62", "default")); adapters.Add(com.createObjectAdapter("Adapter63", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); int nRetry = 3; int i; // // Ensure that endpoints are tried in order by deactiving the adapters // one after the other. // for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter61"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter62"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter63"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); try { obj.getAdapterName(); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("Adapter66", endpoints[2].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter66"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("Adapter65", endpoints[1].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter65"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("Adapter64", endpoints[0].ToString())); for (i = 0; i < nRetry && obj.getAdapterName().Equals("Adapter64"); i++) { ; } test(i == nRetry); deactivate(com, adapters); } WriteLine("ok"); Write("testing per request binding and ordered endpoint selection and AMI... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("AdapterAMI61", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI62", "default")); adapters.Add(com.createObjectAdapter("AdapterAMI63", "default")); TestIntfPrx obj = createTestIntfPrx(adapters); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered)); test(obj.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); obj = TestIntfPrxHelper.uncheckedCast(obj.ice_connectionCached(false)); test(!obj.ice_isConnectionCached()); int nRetry = 3; int i; // // Ensure that endpoints are tried in order by deactiving the adapters // one after the other. // for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI61"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI62"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI63"); i++) { ; } test(i == nRetry); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[2]); try { obj.getAdapterName(); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } Ice.Endpoint[] endpoints = obj.ice_getEndpoints(); adapters.Clear(); // // Now, re-activate the adapters with the same endpoints in the opposite // order. // adapters.Add(com.createObjectAdapter("AdapterAMI66", endpoints[2].ToString())); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI66"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("AdapterAMI65", endpoints[1].ToString())); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI65"); i++) { ; } test(i == nRetry); adapters.Add(com.createObjectAdapter("AdapterAMI64", endpoints[0].ToString())); for (i = 0; i < nRetry && getAdapterNameWithAMI(obj).Equals("AdapterAMI64"); i++) { ; } test(i == nRetry); deactivate(com, adapters); } WriteLine("ok"); Write("testing endpoint mode filtering... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter71", "default")); adapters.Add(com.createObjectAdapter("Adapter72", "udp")); TestIntfPrx obj = createTestIntfPrx(adapters); test(obj.getAdapterName().Equals("Adapter71")); TestIntfPrx testUDP = TestIntfPrxHelper.uncheckedCast(obj.ice_datagram()); test(obj.ice_getConnection() != testUDP.ice_getConnection()); try { testUDP.getAdapterName(); } catch (System.ArgumentException) { } } WriteLine("ok"); if (communicator.getProperties().getProperty("Ice.Plugin.IceSSL").Length > 0) { Write("testing unsecure vs. secure endpoints... "); Flush(); { List <RemoteObjectAdapterPrx> adapters = new List <RemoteObjectAdapterPrx>(); adapters.Add(com.createObjectAdapter("Adapter81", "ssl")); adapters.Add(com.createObjectAdapter("Adapter82", "tcp")); TestIntfPrx obj = createTestIntfPrx(adapters); int i; for (i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter82")); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } TestIntfPrx testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true)); test(testSecure.ice_isSecure()); testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(false)); test(!testSecure.ice_isSecure()); testSecure = TestIntfPrxHelper.uncheckedCast(obj.ice_secure(true)); test(testSecure.ice_isSecure()); test(obj.ice_getConnection() != testSecure.ice_getConnection()); com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[1]); for (i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter81")); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.createObjectAdapter("Adapter83", (obj.ice_getEndpoints()[1]).ToString()); // Reactive tcp OA. for (i = 0; i < 5; i++) { test(obj.getAdapterName().Equals("Adapter83")); obj.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } com.deactivateObjectAdapter((RemoteObjectAdapterPrx)adapters[0]); try { testSecure.ice_ping(); test(false); } catch (Ice.ConnectFailedException) { } catch (Ice.ConnectTimeoutException) { } deactivate(com, adapters); } WriteLine("ok"); } { Write("testing ipv4 & ipv6 connections... "); Flush(); Ice.Properties ipv4 = Ice.Util.createProperties(); ipv4.setProperty("Ice.IPv4", "1"); ipv4.setProperty("Ice.IPv6", "0"); ipv4.setProperty("Adapter.Endpoints", "tcp -h localhost"); Ice.Properties ipv6 = Ice.Util.createProperties(); ipv6.setProperty("Ice.IPv4", "0"); ipv6.setProperty("Ice.IPv6", "1"); ipv6.setProperty("Adapter.Endpoints", "tcp -h localhost"); Ice.Properties bothPreferIPv4 = Ice.Util.createProperties(); bothPreferIPv4.setProperty("Ice.IPv4", "1"); bothPreferIPv4.setProperty("Ice.IPv6", "1"); bothPreferIPv4.setProperty("Ice.PreferIPv6Address", "0"); bothPreferIPv4.setProperty("Adapter.Endpoints", "tcp -h localhost"); Ice.Properties bothPreferIPv6 = Ice.Util.createProperties(); bothPreferIPv6.setProperty("Ice.IPv4", "1"); bothPreferIPv6.setProperty("Ice.IPv6", "1"); bothPreferIPv6.setProperty("Ice.PreferIPv6Address", "1"); bothPreferIPv6.setProperty("Adapter.Endpoints", "tcp -h localhost"); List <Ice.Properties> clientProps = new List <Ice.Properties>(); clientProps.Add(ipv4); clientProps.Add(ipv6); clientProps.Add(bothPreferIPv4); clientProps.Add(bothPreferIPv6); string endpoint = "tcp -p " + app.getTestPort(2).ToString(); Ice.Properties anyipv4 = ipv4.ice_clone_(); anyipv4.setProperty("Adapter.Endpoints", endpoint); anyipv4.setProperty("Adapter.PublishedEndpoints", endpoint + " -h 127.0.0.1"); Ice.Properties anyipv6 = ipv6.ice_clone_(); anyipv6.setProperty("Adapter.Endpoints", endpoint); anyipv6.setProperty("Adapter.PublishedEndpoints", endpoint + " -h \".1\""); Ice.Properties anyboth = Ice.Util.createProperties(); anyboth.setProperty("Ice.IPv4", "1"); anyboth.setProperty("Ice.IPv6", "1"); anyboth.setProperty("Adapter.Endpoints", endpoint); anyboth.setProperty("Adapter.PublishedEndpoints", endpoint + " -h \"::1\":" + endpoint + " -h 127.0.0.1"); Ice.Properties localipv4 = ipv4.ice_clone_(); localipv4.setProperty("Adapter.Endpoints", "tcp -h 127.0.0.1"); Ice.Properties localipv6 = ipv6.ice_clone_(); localipv6.setProperty("Adapter.Endpoints", "tcp -h \"::1\""); List <Ice.Properties> serverProps = new List <Ice.Properties>(clientProps); serverProps.Add(anyipv4); serverProps.Add(anyipv6); serverProps.Add(anyboth); serverProps.Add(localipv4); serverProps.Add(localipv6); bool ipv6NotSupported = false; foreach (Ice.Properties p in serverProps) { Ice.InitializationData serverInitData = new Ice.InitializationData(); serverInitData.properties = p; Ice.Communicator serverCommunicator = Ice.Util.initialize(serverInitData); Ice.ObjectAdapter oa; try { oa = serverCommunicator.createObjectAdapter("Adapter"); oa.activate(); } catch (Ice.DNSException) { serverCommunicator.destroy(); continue; // IP version not supported. } catch (Ice.SocketException) { if (p == ipv6) { ipv6NotSupported = true; } serverCommunicator.destroy(); continue; // IP version not supported. } Ice.ObjectPrx prx = oa.createProxy(Ice.Util.stringToIdentity("dummy")); try { prx.ice_collocationOptimized(false).ice_ping(); } catch (Ice.LocalException) { serverCommunicator.destroy(); continue; // IP version not supported. } string strPrx = prx.ToString(); foreach (Ice.Properties q in clientProps) { Ice.InitializationData clientInitData = new Ice.InitializationData(); clientInitData.properties = q; Ice.Communicator clientCommunicator = Ice.Util.initialize(clientInitData); prx = clientCommunicator.stringToProxy(strPrx); try { prx.ice_ping(); test(false); } catch (Ice.ObjectNotExistException) { // Expected, no object registered. } catch (Ice.DNSException) { // Expected if no IPv4 or IPv6 address is // associated to localhost or if trying to connect // to an any endpoint with the wrong IP version, // e.g.: resolving an IPv4 address when only IPv6 // is enabled fails with a DNS exception. } catch (Ice.SocketException) { test((p == ipv4 && q == ipv6) || (p == ipv6 && q == ipv4) || (p == bothPreferIPv4 && q == ipv6) || (p == bothPreferIPv6 && q == ipv4) || (p == bothPreferIPv6 && q == ipv6 && ipv6NotSupported) || (p == anyipv4 && q == ipv6) || (p == anyipv6 && q == ipv4) || (p == localipv4 && q == ipv6) || (p == localipv6 && q == ipv4) || (p == ipv6 && q == bothPreferIPv4) || (p == ipv6 && q == bothPreferIPv6) || (p == bothPreferIPv6 && q == ipv6)); } clientCommunicator.destroy(); } serverCommunicator.destroy(); } WriteLine("ok"); } com.shutdown(); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); String @ref = "hold:" + app.getTestEndpoint(0); Ice.ObjectPrx @base = communicator.stringToProxy(@ref); test(@base != null); String refSerialized = "hold:" + app.getTestEndpoint(1); Ice.ObjectPrx baseSerialized = communicator.stringToProxy(refSerialized); test(baseSerialized != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); HoldPrx hold = HoldPrxHelper.checkedCast(@base); HoldPrx holdOneway = HoldPrxHelper.uncheckedCast(@base.ice_oneway()); test(hold != null); test(hold.Equals(@base)); HoldPrx holdSerialized = HoldPrxHelper.checkedCast(baseSerialized); HoldPrx holdSerializedOneway = HoldPrxHelper.uncheckedCast(baseSerialized.ice_oneway()); test(holdSerialized != null); test(holdSerialized.Equals(baseSerialized)); WriteLine("ok"); Write("changing state between active and hold rapidly... "); Flush(); for (int i = 0; i < 100; ++i) { hold.putOnHold(0); } for (int i = 0; i < 100; ++i) { holdOneway.putOnHold(0); } for (int i = 0; i < 100; ++i) { holdSerialized.putOnHold(0); } for (int i = 0; i < 100; ++i) { holdSerializedOneway.putOnHold(0); } WriteLine("ok"); Write("testing without serialize mode... "); Flush(); System.Random rand = new System.Random(); { Condition cond = new Condition(true); int value = 0; Ice.AsyncResult result = null; while (cond.value()) { SetCB cb = new SetCB(cond, value); result = hold.begin_set(++value, value < 500 ? rand.Next(5) : 0).whenCompleted(cb.response, cb.exception); if (value % 100 == 0) { result.waitForSent(); } if (value > 100000) { // Don't continue, it's possible that out-of-order dispatch doesn't occur // after 100000 iterations and we don't want the test to last for too long // when this occurs. break; } } test(value > 100000 || !cond.value()); result.waitForSent(); } WriteLine("ok"); Write("testing with serialize mode... "); Flush(); { Condition cond = new Condition(true); int value = 0; Ice.AsyncResult result = null; while (value < 3000 && cond.value()) { SetCB cb = new SetCB(cond, value); result = holdSerialized.begin_set(++value, 0).whenCompleted(cb.response, cb.exception); if (value % 100 == 0) { result.waitForSent(); } } result.waitForCompleted(); test(cond.value()); for (int i = 0; i < 10000; ++i) { holdSerializedOneway.setOneway(value + 1, value); ++value; if ((i % 100) == 0) { holdSerializedOneway.putOnHold(1); } } } WriteLine("ok"); Write("testing serialization... "); Flush(); { int value = 0; holdSerialized.set(value, 0); Ice.AsyncResult result = null; for (int i = 0; i < 10000; ++i) { // Create a new proxy for each request result = ((HoldPrx)holdSerialized.ice_oneway()).begin_setOneway(value + 1, value); ++value; if ((i % 100) == 0) { result.waitForSent(); holdSerialized.ice_ping(); // Ensure everything's dispatched. holdSerialized.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); } } result.waitForCompleted(); } WriteLine("ok"); Write("testing waitForHold... "); Flush(); { hold.waitForHold(); hold.waitForHold(); for (int i = 0; i < 1000; ++i) { holdOneway.ice_ping(); if ((i % 20) == 0) { hold.putOnHold(0); } } hold.putOnHold(-1); hold.ice_ping(); hold.putOnHold(-1); hold.ice_ping(); } WriteLine("ok"); Write("changing state to hold and shutting down server... "); Flush(); hold.shutdown(); WriteLine("ok"); }
public RemoteCommunicatorI(TestCommon.Application app) { _app = app; }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing proxy endpoint information... "); Flush(); { Ice.ObjectPrx p1 = communicator.stringToProxy( "test -t:default -h tcphost -p 10000 -t 1200 -z --sourceAddress 10.10.10.10:" + "udp -h udphost -p 10001 --interface eth0 --ttl 5 --sourceAddress 10.10.10.10:" + "opaque -e 1.8 -t 100 -v ABCD"); Ice.Endpoint[] endps = p1.ice_getEndpoints(); Ice.EndpointInfo info = endps[0].getInfo(); Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(info); test(tcpEndpoint.host.Equals("tcphost")); test(tcpEndpoint.port == 10000); test(tcpEndpoint.sourceAddress.Equals("10.10.10.10")); test(tcpEndpoint.timeout == 1200); test(tcpEndpoint.compress); test(!tcpEndpoint.datagram()); test(tcpEndpoint.type() == Ice.TCPEndpointType.value && !tcpEndpoint.secure() || tcpEndpoint.type() == Ice.SSLEndpointType.value && tcpEndpoint.secure() || tcpEndpoint.type() == Ice.WSEndpointType.value && !tcpEndpoint.secure() || tcpEndpoint.type() == Ice.WSSEndpointType.value && tcpEndpoint.secure()); test(tcpEndpoint.type() == Ice.TCPEndpointType.value && info is Ice.TCPEndpointInfo || tcpEndpoint.type() == Ice.SSLEndpointType.value && info is IceSSL.EndpointInfo || tcpEndpoint.type() == Ice.WSEndpointType.value && info is Ice.WSEndpointInfo || tcpEndpoint.type() == Ice.WSSEndpointType.value && info is Ice.WSEndpointInfo); Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endps[1].getInfo(); test(udpEndpoint.host.Equals("udphost")); test(udpEndpoint.port == 10001); test(udpEndpoint.mcastInterface.Equals("eth0")); test(udpEndpoint.mcastTtl == 5); test(udpEndpoint.sourceAddress.Equals("10.10.10.10")); test(udpEndpoint.timeout == -1); test(!udpEndpoint.compress); test(!udpEndpoint.secure()); test(udpEndpoint.datagram()); test(udpEndpoint.type() == 3); Ice.OpaqueEndpointInfo opaqueEndpoint = (Ice.OpaqueEndpointInfo)endps[2].getInfo(); test(opaqueEndpoint.rawBytes.Length > 0); test(opaqueEndpoint.rawEncoding.Equals(new Ice.EncodingVersion(1, 8))); } WriteLine("ok"); Ice.ObjectAdapter adapter; Write("test object adapter endpoint information... "); Flush(); { string host = communicator.getProperties().getPropertyAsInt("Ice.IPv6") != 0 ? "::1" : "127.0.0.1"; communicator.getProperties().setProperty("TestAdapter.Endpoints", "tcp -h \"" + host + "\" -t 15000:udp -h \"" + host + "\""); adapter = communicator.createObjectAdapter("TestAdapter"); Ice.Endpoint[] endpoints = adapter.getEndpoints(); test(endpoints.Length == 2); Ice.Endpoint[] publishedEndpoints = adapter.getPublishedEndpoints(); test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints)); Ice.TCPEndpointInfo tcpEndpoint = getTCPEndpointInfo(endpoints[0].getInfo()); test(tcpEndpoint.type() == Ice.TCPEndpointType.value || tcpEndpoint.type() == Ice.SSLEndpointType.value || tcpEndpoint.type() == Ice.WSEndpointType.value || tcpEndpoint.type() == Ice.WSSEndpointType.value); test(tcpEndpoint.host.Equals(host)); test(tcpEndpoint.port > 0); test(tcpEndpoint.timeout == 15000); Ice.UDPEndpointInfo udpEndpoint = (Ice.UDPEndpointInfo)endpoints[1].getInfo(); test(udpEndpoint.host.Equals(host)); test(udpEndpoint.datagram()); test(udpEndpoint.port > 0); endpoints = new Ice.Endpoint[] { endpoints[0] }; test(endpoints.Length == 1); adapter.setPublishedEndpoints(endpoints); publishedEndpoints = adapter.getPublishedEndpoints(); test(IceUtilInternal.Arrays.Equals(endpoints, publishedEndpoints)); adapter.destroy(); int port = app.getTestPort(1); communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -h * -p " + port); communicator.getProperties().setProperty("TestAdapter.PublishedEndpoints", app.getTestEndpoint(1)); adapter = communicator.createObjectAdapter("TestAdapter"); endpoints = adapter.getEndpoints(); test(endpoints.Length >= 1); publishedEndpoints = adapter.getPublishedEndpoints(); test(publishedEndpoints.Length == 1); foreach (Ice.Endpoint endpoint in endpoints) { tcpEndpoint = getTCPEndpointInfo(endpoint.getInfo()); test(tcpEndpoint.port == port); } tcpEndpoint = getTCPEndpointInfo(publishedEndpoints[0].getInfo()); test(tcpEndpoint.host.Equals("127.0.0.1")); test(tcpEndpoint.port == port); adapter.destroy(); } WriteLine("ok"); int endpointPort = app.getTestPort(0); Ice.ObjectPrx @base = communicator.stringToProxy("test:" + app.getTestEndpoint(0) + ":" + app.getTestEndpoint(0, "udp")); TestIntfPrx testIntf = TestIntfPrxHelper.checkedCast(@base); string defaultHost = communicator.getProperties().getProperty("Ice.Default.Host"); Write("test connection endpoint information... "); Flush(); { Ice.EndpointInfo info = @base.ice_getConnection().getEndpoint().getInfo(); Ice.TCPEndpointInfo tcpinfo = getTCPEndpointInfo(info); test(tcpinfo.port == endpointPort); test(!tcpinfo.compress); test(tcpinfo.host.Equals(defaultHost)); Dictionary <string, string> ctx = testIntf.getEndpointInfoAsContext(); test(ctx["host"].Equals(tcpinfo.host)); test(ctx["compress"].Equals("false")); int port = System.Int32.Parse(ctx["port"]); test(port > 0); info = @base.ice_datagram().ice_getConnection().getEndpoint().getInfo(); Ice.UDPEndpointInfo udp = (Ice.UDPEndpointInfo)info; test(udp.port == endpointPort); test(udp.host.Equals(defaultHost)); } WriteLine("ok"); Write("testing connection information... "); Flush(); { Ice.Connection connection = @base.ice_getConnection(); connection.setBufferSize(1024, 2048); Ice.ConnectionInfo info = connection.getInfo(); Ice.TCPConnectionInfo ipInfo = getTCPConnectionInfo(info); test(!info.incoming); test(info.adapterName.Length == 0); test(ipInfo.remotePort == endpointPort); test(ipInfo.localPort > 0); if (defaultHost.Equals("127.0.0.1")) { test(ipInfo.localAddress.Equals(defaultHost)); test(ipInfo.remoteAddress.Equals(defaultHost)); } test(ipInfo.rcvSize >= 1024); test(ipInfo.sndSize >= 2048); Dictionary <string, string> ctx = testIntf.getConnectionInfoAsContext(); test(ctx["incoming"].Equals("true")); test(ctx["adapterName"].Equals("TestAdapter")); test(ctx["remoteAddress"].Equals(ipInfo.localAddress)); test(ctx["localAddress"].Equals(ipInfo.remoteAddress)); test(ctx["remotePort"].Equals(ipInfo.localPort.ToString())); test(ctx["localPort"].Equals(ipInfo.remotePort.ToString())); if (@base.ice_getConnection().type().Equals("ws") || @base.ice_getConnection().type().Equals("wss")) { Dictionary <string, string> headers = ((Ice.WSConnectionInfo)info).headers; test(headers["Upgrade"].Equals("websocket")); test(headers["Connection"].Equals("Upgrade")); test(headers["Sec-WebSocket-Protocol"].Equals("ice.zeroc.com")); test(headers["Sec-WebSocket-Accept"] != null); test(ctx["ws.Upgrade"].Equals("websocket")); test(ctx["ws.Connection"].Equals("Upgrade")); test(ctx["ws.Sec-WebSocket-Protocol"].Equals("ice.zeroc.com")); test(ctx["ws.Sec-WebSocket-Version"].Equals("13")); test(ctx["ws.Sec-WebSocket-Key"] != null); } connection = @base.ice_datagram().ice_getConnection(); connection.setBufferSize(2048, 1024); Ice.UDPConnectionInfo udpInfo = (Ice.UDPConnectionInfo)connection.getInfo(); test(!udpInfo.incoming); test(udpInfo.adapterName.Length == 0); test(udpInfo.localPort > 0); test(udpInfo.remotePort == endpointPort); if (defaultHost.Equals("127.0.0.1")) { test(udpInfo.remoteAddress.Equals(defaultHost)); test(udpInfo.localAddress.Equals(defaultHost)); } test(udpInfo.rcvSize >= 2048); test(udpInfo.sndSize >= 1024); } WriteLine("ok"); testIntf.shutdown(); communicator.shutdown(); communicator.waitForShutdown(); }
public static Test.BackgroundPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); string sref = "background:" + app.getTestEndpoint(0); Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); BackgroundPrx background = BackgroundPrxHelper.uncheckedCast(obj); sref = "backgroundController:" + app.getTestEndpoint(1, "tcp"); obj = communicator.stringToProxy(sref); test(obj != null); BackgroundControllerPrx backgroundController = BackgroundControllerPrxHelper.uncheckedCast(obj); Configuration configuration = Configuration.getInstance(); Console.Write("testing connect... "); Console.Out.Flush(); { connectTests(configuration, background); } Console.Out.WriteLine("ok"); Console.Write("testing initialization... "); Console.Out.Flush(); { initializeTests(configuration, background, backgroundController); } Console.Out.WriteLine("ok"); Console.Write("testing connection validation... "); Console.Out.Flush(); { validationTests(configuration, background, backgroundController); } Console.Out.WriteLine("ok"); Console.Write("testing read/write... "); Console.Out.Flush(); { readWriteTests(configuration, background, backgroundController); } Console.Out.WriteLine("ok"); Console.Write("testing locator... "); Console.Out.Flush(); { Ice.LocatorPrx locator; obj = communicator.stringToProxy("locator:" + app.getTestEndpoint(0)).ice_invocationTimeout(250); locator = Ice.LocatorPrxHelper.uncheckedCast(obj); obj = communicator.stringToProxy("background@Test").ice_locator(locator).ice_oneway(); backgroundController.pauseCall("findAdapterById"); try { obj.ice_ping(); test(false); } catch (Ice.TimeoutException) { } backgroundController.resumeCall("findAdapterById"); obj = communicator.stringToProxy("locator:" + app.getTestEndpoint(0)); locator = Ice.LocatorPrxHelper.uncheckedCast(obj); obj = obj.ice_locator(locator); obj.ice_ping(); obj = communicator.stringToProxy("background@Test").ice_locator(locator); BackgroundPrx bg = BackgroundPrxHelper.uncheckedCast(obj); backgroundController.pauseCall("findAdapterById"); Ice.AsyncResult r1 = bg.begin_op(); Ice.AsyncResult r2 = bg.begin_op(); test(!r1.IsCompleted); test(!r2.IsCompleted); backgroundController.resumeCall("findAdapterById"); bg.end_op(r1); bg.end_op(r2); test(r1.IsCompleted); test(r2.IsCompleted); } Console.Out.WriteLine("ok"); Console.Write("testing router... "); Console.Out.Flush(); { Ice.RouterPrx router; obj = communicator.stringToProxy("router:" + app.getTestEndpoint(0)).ice_invocationTimeout(250); router = Ice.RouterPrxHelper.uncheckedCast(obj); obj = communicator.stringToProxy("background@Test").ice_router(router).ice_oneway(); backgroundController.pauseCall("getClientProxy"); try { obj.ice_ping(); test(false); } catch (Ice.TimeoutException) { } backgroundController.resumeCall("getClientProxy"); obj = communicator.stringToProxy("router:" + app.getTestEndpoint(0)); router = Ice.RouterPrxHelper.uncheckedCast(obj); obj = communicator.stringToProxy("background@Test").ice_router(router); BackgroundPrx bg = BackgroundPrxHelper.uncheckedCast(obj); test(bg.ice_getRouter() != null); backgroundController.pauseCall("getClientProxy"); Ice.AsyncResult r1 = bg.begin_op(); Ice.AsyncResult r2 = bg.begin_op(); test(!r1.IsCompleted); test(!r2.IsCompleted); backgroundController.resumeCall("getClientProxy"); bg.end_op(r1); bg.end_op(r2); test(r1.IsCompleted); test(r2.IsCompleted); } Console.Out.WriteLine("ok"); bool ws = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("test-ws"); bool wss = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("test-wss"); if (!ws && !wss) { Console.Write("testing buffered transport... "); Console.Out.Flush(); configuration.buffered(true); backgroundController.buffered(true); background.begin_op(); background.ice_getCachedConnection().close(Ice.ConnectionClose.Forcefully); background.begin_op(); OpAMICallback cb = new OpAMICallback(); List <Ice.AsyncResult> results = new List <Ice.AsyncResult>(); for (int i = 0; i < 10000; ++i) { Ice.AsyncResult r = background.begin_op().whenCompleted(cb.responseNoOp, cb.noException); results.Add(r); if (i % 50 == 0) { backgroundController.holdAdapter(); backgroundController.resumeAdapter(); } if (i % 100 == 0) { r.waitForCompleted(); } } foreach (Ice.AsyncResult r in results) { r.waitForCompleted(); } Console.Out.WriteLine("ok"); } return(background); }
allTestsWithDeploy(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter"); test(@base != null); Ice.ObjectPrx @base2 = communicator.stringToProxy("test"); test(@base2 != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); test(obj.Equals(@base)); TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(@base2); test(obj2 != null); test(obj2.Equals(@base2)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.ice_ping(); obj2.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing encoding versioning... "); Console.Out.Flush(); Ice.ObjectPrx base10 = communicator.stringToProxy("test10 @ TestAdapter10"); test(base10 != null); Ice.ObjectPrx base102 = communicator.stringToProxy("test10"); test(base102 != null); try { base10.ice_ping(); test(false); } catch (Ice.NoEndpointException) { } try { base102.ice_ping(); test(false); } catch (Ice.NoEndpointException) { } base10 = base10.ice_encodingVersion(Ice.Util.Encoding_1_0); base102 = base102.ice_encodingVersion(Ice.Util.Encoding_1_0); base10.ice_ping(); base102.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown identity... "); Console.Out.Flush(); try { communicator.stringToProxy("unknown/unknown").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object")); test(ex.id.Equals("unknown/unknown")); } Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown adapter... "); Console.Out.Flush(); try { communicator.stringToProxy("test @ TestAdapterUnknown").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object adapter")); test(ex.id.Equals("TestAdapterUnknown")); } Console.Out.WriteLine("ok"); IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast( communicator.stringToProxy(communicator.getDefaultLocator().ice_getIdentity().category + "/Registry")); test(registry != null); IceGrid.AdminSessionPrx session = null; try { session = registry.createAdminSession("foo", "bar"); } catch (IceGrid.PermissionDeniedException) { test(false); } session.ice_getConnection().setACM(registry.getACMTimeout(), Ice.Util.None, Ice.ACMHeartbeat.HeartbeatAlways); IceGrid.AdminPrx admin = session.getAdmin(); test(admin != null); try { admin.enableServer("server", false); admin.stopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } Console.Out.Write("testing whether server is still reachable... "); Console.Out.Flush(); try { obj = TestIntfPrxHelper.checkedCast(@base); test(false); } catch (Ice.NoEndpointException) { } try { obj2 = TestIntfPrxHelper.checkedCast(@base2); test(false); } catch (Ice.NoEndpointException) { } try { admin.enableServer("server", true); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } try { obj = TestIntfPrxHelper.checkedCast(@base); } catch (Ice.NoEndpointException) { test(false); } try { obj2 = TestIntfPrxHelper.checkedCast(@base2); } catch (Ice.NoEndpointException) { test(false); } Console.Out.WriteLine("ok"); try { admin.stopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } session.destroy(); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); String rf = "test @ TestAdapter"; Ice.ObjectPrx @base = communicator.stringToProxy(rf); test(@base != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing IceGrid.Locator is present... "); IceGrid.LocatorPrx locator = IceGrid.LocatorPrxHelper.uncheckedCast(@base); test(locator != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); test(obj.Equals(@base)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing locator finder... "); Ice.Identity finderId = new Ice.Identity(); finderId.category = "Ice"; finderId.name = "LocatorFinder"; Ice.LocatorFinderPrx finder = Ice.LocatorFinderPrxHelper.checkedCast( communicator.getDefaultLocator().ice_identity(finderId)); test(finder.getLocator() != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing discovery... "); { // Add test well-known object IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast( communicator.stringToProxy(communicator.getDefaultLocator().ice_getIdentity().category + "/Registry")); test(registry != null); try { IceGrid.AdminSessionPrx session = registry.createAdminSession("foo", "bar"); session.getAdmin().addObjectWithType(@base, "::Test"); session.destroy(); } catch (Ice.UserException) { test(false); } // // Ensure the IceGrid discovery locator can discover the // registries and make sure locator requests are forwarded. // Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"); initData.properties.setProperty("IceLocatorDiscovery.Port", app.getTestPort(99).ToString()); initData.properties.setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); initData.properties.setProperty("AdapterForDiscoveryTest.Endpoints", "default"); Ice.Communicator com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); com.stringToProxy("test @ TestAdapter").ice_ping(); com.stringToProxy("test").ice_ping(); test(com.getDefaultLocator().getRegistry() != null); test(IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalRegistry() != null); test(IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalQuery() != null); Ice.ObjectAdapter adapter = com.createObjectAdapter("AdapterForDiscoveryTest"); adapter.activate(); adapter.deactivate(); com.destroy(); // // Now, ensure that the IceGrid discovery locator correctly // handles failure to find a locator. // initData.properties.setProperty("IceLocatorDiscovery.InstanceName", "unknown"); initData.properties.setProperty("IceLocatorDiscovery.RetryCount", "1"); initData.properties.setProperty("IceLocatorDiscovery.Timeout", "100"); com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); try { com.stringToProxy("test @ TestAdapter").ice_ping(); } catch (Ice.NoEndpointException) { } try { com.stringToProxy("test").ice_ping(); } catch (Ice.NoEndpointException) { } test(com.getDefaultLocator().getRegistry() == null); test(IceGrid.LocatorPrxHelper.checkedCast(com.getDefaultLocator()) == null); try { IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalRegistry(); } catch (Ice.OperationNotExistException) { } adapter = com.createObjectAdapter("AdapterForDiscoveryTest"); adapter.activate(); adapter.deactivate(); com.destroy(); } Console.Out.WriteLine("ok"); Console.Out.Write("shutting down server... "); Console.Out.Flush(); obj.shutdown(); Console.Out.WriteLine("ok"); }
public static InitialPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); string ref_Renamed = "initial:" + app.getTestEndpoint(0); Ice.ObjectPrx @base = communicator.stringToProxy(ref_Renamed); test(@base != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); InitialPrx initial = InitialPrxHelper.checkedCast(@base); test(initial != null); test(initial.Equals(@base)); WriteLine("ok"); Write("getting proxies for class hierarchy... "); Flush(); Test.MA.CAPrx ca = initial.caop(); Test.MB.CBPrx cb = initial.cbop(); Test.MA.CCPrx cc = initial.ccop(); Test.MA.CDPrx cd = initial.cdop(); test(ca != cb); test(ca != cc); test(ca != cd); test(cb != cc); test(cb != cd); test(cc != cd); WriteLine("ok"); Write("getting proxies for interface hierarchy... "); Flush(); Test.MA.IAPrx ia = initial.iaop(); Test.MB.IB1Prx ib1 = initial.ib1op(); Test.MB.IB2Prx ib2 = initial.ib2op(); Test.MA.ICPrx ic = initial.icop(); test(ia != ib1); test(ia != ib2); test(ia != ic); test(ib1 != ic); test(ib2 != ic); WriteLine("ok"); Write("invoking proxy operations on class hierarchy... "); Flush(); Test.MA.CAPrx cao; Test.MB.CBPrx cbo; Test.MA.CCPrx cco; cao = ca.caop(ca); test(cao.Equals(ca)); cao = ca.caop(cb); test(cao.Equals(cb)); cao = ca.caop(cc); test(cao.Equals(cc)); cao = cb.caop(ca); test(cao.Equals(ca)); cao = cb.caop(cb); test(cao.Equals(cb)); cao = cb.caop(cc); test(cao.Equals(cc)); cao = cc.caop(ca); test(cao.Equals(ca)); cao = cc.caop(cb); test(cao.Equals(cb)); cao = cc.caop(cc); test(cao.Equals(cc)); cao = cb.cbop(cb); test(cao.Equals(cb)); cbo = cb.cbop(cb); test(cbo.Equals(cb)); cao = cb.cbop(cc); test(cao.Equals(cc)); cbo = cb.cbop(cc); test(cbo.Equals(cc)); cao = cc.cbop(cb); test(cao.Equals(cb)); cbo = cc.cbop(cb); test(cbo.Equals(cb)); cao = cc.cbop(cc); test(cao.Equals(cc)); cbo = cc.cbop(cc); test(cbo.Equals(cc)); cao = cc.ccop(cc); test(cao.Equals(cc)); cbo = cc.ccop(cc); test(cbo.Equals(cc)); cco = cc.ccop(cc); test(cco.Equals(cc)); WriteLine("ok"); Write("ditto, but for interface hierarchy... "); Flush(); Test.MA.IAPrx iao; Test.MB.IB1Prx ib1o; Test.MB.IB2Prx ib2o; Test.MA.ICPrx ico; iao = ia.iaop(ia); test(iao.Equals(ia)); iao = ia.iaop(ib1); test(iao.Equals(ib1)); iao = ia.iaop(ib2); test(iao.Equals(ib2)); iao = ia.iaop(ic); test(iao.Equals(ic)); iao = ib1.iaop(ia); test(iao.Equals(ia)); iao = ib1.iaop(ib1); test(iao.Equals(ib1)); iao = ib1.iaop(ib2); test(iao.Equals(ib2)); iao = ib1.iaop(ic); test(iao.Equals(ic)); iao = ib2.iaop(ia); test(iao.Equals(ia)); iao = ib2.iaop(ib1); test(iao.Equals(ib1)); iao = ib2.iaop(ib2); test(iao.Equals(ib2)); iao = ib2.iaop(ic); test(iao.Equals(ic)); iao = ic.iaop(ia); test(iao.Equals(ia)); iao = ic.iaop(ib1); test(iao.Equals(ib1)); iao = ic.iaop(ib2); test(iao.Equals(ib2)); iao = ic.iaop(ic); test(iao.Equals(ic)); iao = ib1.ib1op(ib1); test(iao.Equals(ib1)); ib1o = ib1.ib1op(ib1); test(ib1o.Equals(ib1)); iao = ib1.ib1op(ic); test(iao.Equals(ic)); ib1o = ib1.ib1op(ic); test(ib1o.Equals(ic)); iao = ic.ib1op(ib1); test(iao.Equals(ib1)); ib1o = ic.ib1op(ib1); test(ib1o.Equals(ib1)); iao = ic.ib1op(ic); test(iao.Equals(ic)); ib1o = ic.ib1op(ic); test(ib1o.Equals(ic)); iao = ib2.ib2op(ib2); test(iao.Equals(ib2)); ib2o = ib2.ib2op(ib2); test(ib2o.Equals(ib2)); iao = ib2.ib2op(ic); test(iao.Equals(ic)); ib2o = ib2.ib2op(ic); test(ib2o.Equals(ic)); iao = ic.ib2op(ib2); test(iao.Equals(ib2)); ib2o = ic.ib2op(ib2); test(ib2o.Equals(ib2)); iao = ic.ib2op(ic); test(iao.Equals(ic)); ib2o = ic.ib2op(ic); test(ib2o.Equals(ic)); iao = ic.icop(ic); test(iao.Equals(ic)); ib1o = ic.icop(ic); test(ib1o.Equals(ic)); ib2o = ic.icop(ic); test(ib2o.Equals(ic)); ico = ic.icop(ic); test(ico.Equals(ic)); WriteLine("ok"); Write("ditto, but for class implementing interfaces... "); Flush(); cao = cd.caop(cd); test(cao.Equals(cd)); cbo = cd.cbop(cd); test(cbo.Equals(cd)); cco = cd.ccop(cd); test(cco.Equals(cd)); iao = cd.iaop(cd); test(iao.Equals(cd)); ib1o = cd.ib1op(cd); test(ib1o.Equals(cd)); ib2o = cd.ib2op(cd); test(ib2o.Equals(cd)); cao = cd.cdop(cd); test(cao.Equals(cd)); cbo = cd.cdop(cd); test(cbo.Equals(cd)); cco = cd.cdop(cd); test(cco.Equals(cd)); iao = cd.cdop(cd); test(iao.Equals(cd)); ib1o = cd.cdop(cd); test(ib1o.Equals(cd)); ib2o = cd.cdop(cd); test(ib2o.Equals(cd)); WriteLine("ok"); return(initial); }
public static TestIntfPrx allTests(TestCommon.Application app, bool collocated) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); String @ref = "Test:" + app.getTestEndpoint(0) + " -t 2000"; Ice.ObjectPrx @base = communicator.stringToProxy(@ref); test(@base != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); TestIntfPrx testPrx = TestIntfPrxHelper.checkedCast(@base); test(testPrx != null); test(testPrx.Equals(@base)); WriteLine("ok"); Write("base... "); Flush(); { try { testPrx.baseAsBase(); test(false); } catch (Base b) { test(b.b.Equals("Base.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("base (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_baseAsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (Base b) { test(b.b.Equals("Base.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.baseAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("Base.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("slicing of unknown derived... "); Flush(); { try { testPrx.unknownDerivedAsBase(); test(false); } catch (Base b) { test(b.b.Equals("UnknownDerived.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("slicing of unknown derived (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_unknownDerivedAsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (Base b) { test(b.b.Equals("UnknownDerived.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.unknownDerivedAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("UnknownDerived.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("non-slicing of known derived as base... "); Flush(); { try { testPrx.knownDerivedAsBase(); test(false); } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().FullName.Equals("Test.KnownDerived")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("non-slicing of known derived as base (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_knownDerivedAsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().Name.Equals("KnownDerived")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.knownDerivedAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().Name.Equals("KnownDerived")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("non-slicing of known derived as derived... "); Flush(); { try { testPrx.knownDerivedAsKnownDerived(); test(false); } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().FullName.Equals("Test.KnownDerived")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("non-slicing of known derived as derived (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_knownDerivedAsKnownDerived().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().Name.Equals("KnownDerived")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.knownDerivedAsKnownDerivedAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownDerived k) { test(k.b.Equals("KnownDerived.b")); test(k.kd.Equals("KnownDerived.kd")); test(k.GetType().Name.Equals("KnownDerived")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("slicing of unknown intermediate as base... "); Flush(); { try { testPrx.unknownIntermediateAsBase(); test(false); } catch (Base b) { test(b.b.Equals("UnknownIntermediate.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("slicing of unknown intermediate as base (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_unknownIntermediateAsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (Base b) { test(b.b.Equals("UnknownIntermediate.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.unknownIntermediateAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("UnknownIntermediate.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("slicing of known intermediate as base... "); Flush(); { try { testPrx.knownIntermediateAsBase(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("slicing of known intermediate as base (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_knownIntermediateAsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.knownIntermediateAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("slicing of known most derived as base... "); Flush(); { try { testPrx.knownMostDerivedAsBase(); test(false); } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().FullName.Equals("Test.KnownMostDerived")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("slicing of known most derived as base (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_knownMostDerivedAsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.knownMostDerivedAsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("non-slicing of known intermediate as intermediate... "); Flush(); { try { testPrx.knownIntermediateAsKnownIntermediate(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("non-slicing of known intermediate as intermediate (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_knownIntermediateAsKnownIntermediate().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.knownIntermediateAsKnownIntermediateAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("KnownIntermediate.b")); test(ki.ki.Equals("KnownIntermediate.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("non-slicing of known most derived as intermediate... "); Flush(); { try { testPrx.knownMostDerivedAsKnownIntermediate(); test(false); } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().FullName.Equals("Test.KnownMostDerived")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("non-slicing of known most derived as intermediate (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_knownMostDerivedAsKnownIntermediate().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.knownMostDerivedAsKnownIntermediateAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("non-slicing of known most derived as most derived... "); Flush(); { try { testPrx.knownMostDerivedAsKnownMostDerived(); test(false); } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().FullName.Equals("Test.KnownMostDerived")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("non-slicing of known most derived as most derived (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_knownMostDerivedAsKnownMostDerived().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.knownMostDerivedAsKnownMostDerivedAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownMostDerived kmd) { test(kmd.b.Equals("KnownMostDerived.b")); test(kmd.ki.Equals("KnownMostDerived.ki")); test(kmd.kmd.Equals("KnownMostDerived.kmd")); test(kmd.GetType().Name.Equals("KnownMostDerived")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("slicing of unknown most derived, known intermediate as base... "); Flush(); { try { testPrx.unknownMostDerived1AsBase(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("slicing of unknown most derived, known intermediate as base (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_unknownMostDerived1AsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.unknownMostDerived1AsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("slicing of unknown most derived, known intermediate as intermediate... "); Flush(); { try { testPrx.unknownMostDerived1AsKnownIntermediate(); test(false); } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().FullName.Equals("Test.KnownIntermediate")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("slicing of unknown most derived, known intermediate as intermediate (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_unknownMostDerived1AsKnownIntermediate().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.unknownMostDerived1AsKnownIntermediateAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (KnownIntermediate ki) { test(ki.b.Equals("UnknownMostDerived1.b")); test(ki.ki.Equals("UnknownMostDerived1.ki")); test(ki.GetType().Name.Equals("KnownIntermediate")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("slicing of unknown most derived, unknown intermediate thrown as base... "); Flush(); { try { testPrx.unknownMostDerived2AsBase(); test(false); } catch (Base b) { test(b.b.Equals("UnknownMostDerived2.b")); test(b.GetType().FullName.Equals("Test.Base")); } catch (Exception) { test(false); } } WriteLine("ok"); Write("slicing of unknown most derived, unknown intermediate thrown as base (AMI)... "); Flush(); { Callback cb = new Callback(); testPrx.begin_unknownMostDerived2AsBase().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { try { throw ex; } catch (Base b) { test(b.b.Equals("UnknownMostDerived2.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } cb.called(); }); cb.check(); try { testPrx.unknownMostDerived2AsBaseAsync().Wait(); test(false); } catch (AggregateException ae) { try { throw ae.InnerException; } catch (Base b) { test(b.b.Equals("UnknownMostDerived2.b")); test(b.GetType().Name.Equals("Base")); } catch (Exception) { test(false); } } } WriteLine("ok"); Write("unknown most derived in compact format... "); Flush(); { try { testPrx.unknownMostDerived2AsBaseCompact(); test(false); } catch (Base) { // // For the 1.0 encoding, the unknown exception is sliced to Base. // test(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0)); } catch (Ice.UnknownUserException) { // // A MarshalException is raised for the compact format because the // most-derived type is unknown and the exception cannot be sliced. // test(!testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0)); } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } } WriteLine("ok"); Write("preserved exceptions... "); Flush(); { try { testPrx.unknownPreservedAsBase(); test(false); } catch (Base ex) { if (testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0)) { test(ex.ice_getSlicedData() == null); } else { Ice.SlicedData slicedData = ex.ice_getSlicedData(); test(slicedData != null); test(slicedData.slices.Length == 2); test(slicedData.slices[1].typeId.Equals("::Test::SPreserved1")); test(slicedData.slices[0].typeId.Equals("::Test::SPreserved2")); } } try { testPrx.unknownPreservedAsKnownPreserved(); test(false); } catch (KnownPreserved ex) { test(ex.kp.Equals("preserved")); if (testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0)) { test(ex.ice_getSlicedData() == null); } else { Ice.SlicedData slicedData = ex.ice_getSlicedData(); test(slicedData != null); test(slicedData.slices.Length == 2); test(slicedData.slices[1].typeId.Equals("::Test::SPreserved1")); test(slicedData.slices[0].typeId.Equals("::Test::SPreserved2")); } } Ice.ObjectAdapter adapter = communicator.createObjectAdapter(""); RelayPrx relay = RelayPrxHelper.uncheckedCast(adapter.addWithUUID(new RelayI())); adapter.activate(); testPrx.ice_getConnection().setAdapter(adapter); try { testPrx.relayKnownPreservedAsBase(relay); test(false); } catch (KnownPreservedDerived ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } try { testPrx.relayKnownPreservedAsKnownPreserved(relay); test(false); } catch (KnownPreservedDerived ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } try { testPrx.relayUnknownPreservedAsBase(relay); test(false); } catch (Preserved2 ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); test(ex.p1.ice_id().Equals(PreservedClass.ice_staticId())); PreservedClass pc = ex.p1 as PreservedClass; test(pc.bc.Equals("bc")); test(pc.pc.Equals("pc")); test(ex.p2 == ex.p1); } catch (KnownPreservedDerived ex) { // // For the 1.0 encoding, the unknown exception is sliced to KnownPreserved. // test(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0)); test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } try { testPrx.relayUnknownPreservedAsKnownPreserved(relay); test(false); } catch (Preserved2 ex) { test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); test(ex.p1.ice_id().Equals(PreservedClass.ice_staticId())); PreservedClass pc = ex.p1 as PreservedClass; test(pc.bc.Equals("bc")); test(pc.pc.Equals("pc")); test(ex.p2 == ex.p1); } catch (KnownPreservedDerived ex) { // // For the 1.0 encoding, the unknown exception is sliced to KnownPreserved. // test(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0)); test(ex.b.Equals("base")); test(ex.kp.Equals("preserved")); test(ex.kpd.Equals("derived")); } catch (Ice.OperationNotExistException) { } catch (Exception) { test(false); } adapter.destroy(); } WriteLine("ok"); return(testPrx); }
allTests(TestCommon.Application app, int num) { Ice.Communicator communicator = app.communicator(); List <ControllerPrx> proxies = new List <ControllerPrx>(); List <ControllerPrx> indirectProxies = new List <ControllerPrx>(); for (int i = 0; i < num; ++i) { string id = "controller" + i; proxies.Add(ControllerPrxHelper.uncheckedCast(communicator.stringToProxy(id))); indirectProxies.Add(ControllerPrxHelper.uncheckedCast(communicator.stringToProxy(id + "@control" + i))); } Write("testing indirect proxies... "); Flush(); { foreach (ControllerPrx prx in indirectProxies) { prx.ice_ping(); } } WriteLine("ok"); Write("testing well-known proxies... "); Flush(); { foreach (ControllerPrx prx in proxies) { prx.ice_ping(); } } WriteLine("ok"); Write("testing object adapter registration... "); Flush(); { try { communicator.stringToProxy("object @ oa1").ice_ping(); test(false); } catch (Ice.NoEndpointException) { } proxies[0].activateObjectAdapter("oa", "oa1", ""); try { communicator.stringToProxy("object @ oa1").ice_ping(); test(false); } catch (Ice.ObjectNotExistException) { } proxies[0].deactivateObjectAdapter("oa"); try { communicator.stringToProxy("object @ oa1").ice_ping(); test(false); } catch (Ice.NoEndpointException) { } } WriteLine("ok"); Write("testing object adapter migration..."); Flush(); { proxies[0].activateObjectAdapter("oa", "oa1", ""); proxies[0].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); proxies[0].removeObject("oa", "object"); proxies[0].deactivateObjectAdapter("oa"); proxies[1].activateObjectAdapter("oa", "oa1", ""); proxies[1].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); proxies[1].removeObject("oa", "object"); proxies[1].deactivateObjectAdapter("oa"); } WriteLine("ok"); Write("testing object migration..."); Flush(); { proxies[0].activateObjectAdapter("oa", "oa1", ""); proxies[1].activateObjectAdapter("oa", "oa2", ""); proxies[0].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); communicator.stringToProxy("object").ice_ping(); proxies[0].removeObject("oa", "object"); proxies[1].addObject("oa", "object"); communicator.stringToProxy("object @ oa2").ice_ping(); communicator.stringToProxy("object").ice_ping(); proxies[1].removeObject("oa", "object"); try { communicator.stringToProxy("object @ oa1").ice_ping(); } catch (Ice.ObjectNotExistException) { } try { communicator.stringToProxy("object @ oa2").ice_ping(); } catch (Ice.ObjectNotExistException) { } proxies[0].deactivateObjectAdapter("oa"); proxies[1].deactivateObjectAdapter("oa"); } WriteLine("ok"); Write("testing replica groups..."); Flush(); { proxies[0].activateObjectAdapter("oa", "oa1", "rg"); proxies[1].activateObjectAdapter("oa", "oa2", "rg"); proxies[2].activateObjectAdapter("oa", "oa3", "rg"); proxies[0].addObject("oa", "object"); proxies[1].addObject("oa", "object"); proxies[2].addObject("oa", "object"); communicator.stringToProxy("object @ oa1").ice_ping(); communicator.stringToProxy("object @ oa2").ice_ping(); communicator.stringToProxy("object @ oa3").ice_ping(); communicator.stringToProxy("object @ rg").ice_ping(); List <string> adapterIds = new List <string>(); adapterIds.Add("oa1"); adapterIds.Add("oa2"); adapterIds.Add("oa3"); TestIntfPrx intf = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("object")); intf = (TestIntfPrx)intf.ice_connectionCached(false).ice_locatorCacheTimeout(0); while (adapterIds.Count > 0) { adapterIds.Remove(intf.getAdapterId()); } while (true) { adapterIds.Add("oa1"); adapterIds.Add("oa2"); adapterIds.Add("oa3"); intf = TestIntfPrxHelper.uncheckedCast( communicator.stringToProxy("object @ rg").ice_connectionCached(false)); int nRetry = 100; while (adapterIds.Count > 0 && --nRetry > 0) { adapterIds.Remove(intf.getAdapterId()); } if (nRetry > 0) { break; } // The previous locator lookup probably didn't return all the replicas... try again. communicator.stringToProxy("object @ rg").ice_locatorCacheTimeout(0).ice_ping(); } proxies[0].deactivateObjectAdapter("oa"); proxies[1].deactivateObjectAdapter("oa"); test(TestIntfPrxHelper.uncheckedCast( communicator.stringToProxy("object @ rg")).getAdapterId().Equals("oa3")); proxies[2].deactivateObjectAdapter("oa"); proxies[0].activateObjectAdapter("oa", "oa1", "rg"); proxies[0].addObject("oa", "object"); test(TestIntfPrxHelper.uncheckedCast( communicator.stringToProxy("object @ rg")).getAdapterId().Equals("oa1")); proxies[0].deactivateObjectAdapter("oa"); } WriteLine("ok"); Write("testing invalid lookup endpoints... "); Flush(); { String multicast; if (communicator.getProperties().getProperty("Ice.IPv6").Equals("1")) { multicast = "\"ff15::1\""; } else { multicast = "239.255.0.1"; } { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("IceDiscovery.Lookup", "udp -h " + multicast + " --interface unknown"); Ice.Communicator comm = Ice.Util.initialize(initData); test(comm.getDefaultLocator() != null); try { comm.stringToProxy("controller0@control0").ice_ping(); test(false); } catch (Ice.LocalException) { } comm.destroy(); } { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); string intf = initData.properties.getProperty("IceDiscovery.Interface"); if (!intf.Equals("")) { intf = " --interface \"" + intf + "\""; } string port = initData.properties.getProperty("IceDiscovery.Port"); initData.properties.setProperty("IceDiscovery.Lookup", "udp -h " + multicast + " --interface unknown:" + "udp -h " + multicast + " -p " + port + intf); Ice.Communicator comm = Ice.Util.initialize(initData); test(comm.getDefaultLocator() != null); comm.stringToProxy("controller0@control0").ice_ping(); comm.destroy(); } } WriteLine("ok"); Write("shutting down... "); Flush(); foreach (ControllerPrx prx in proxies) { prx.shutdown(); } WriteLine("ok"); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); string sref = "test:" + app.getTestEndpoint(0); Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj); sref = "testController:" + app.getTestEndpoint(1); obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj); Write("testing dispatcher... "); Flush(); { p.op(); Callback cb = new Callback(); p.begin_op().whenCompleted(cb.response, cb.exception); cb.check(); TestIntfPrx i = (TestIntfPrx)p.ice_adapterId("dummy"); i.begin_op().whenCompleted(cb.exception); cb.check(); // // Expect InvocationTimeoutException. // { Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250)); to.begin_sleep(500).whenCompleted( () => { test(false); }, (Ice.Exception ex) => { test(ex is Ice.InvocationTimeoutException); test(Dispatcher.isDispatcherThread()); cb.called(); }); cb.check(); } testController.holdAdapter(); Test.Callback_TestIntf_opWithPayload resp = cb.payload; Ice.ExceptionCallback excb = cb.ignoreEx; Ice.SentCallback scb = cb.sent; byte[] seq = new byte[10 * 1024]; (new System.Random()).NextBytes(seq); Ice.AsyncResult r; while ((r = p.begin_opWithPayload(seq).whenCompleted(resp, excb).whenSent(scb)).sentSynchronously()) { ; } testController.resumeAdapter(); r.waitForCompleted(); } WriteLine("ok"); p.shutdown(); }
public static TestIntfPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); string @ref = "test:" + app.getTestEndpoint(0); Ice.ObjectPrx @base = communicator.stringToProxy(@ref); test(@base != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); test(obj.Equals(@base)); WriteLine("ok"); { Write("creating/destroying/recreating object adapter... "); Flush(); Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default"); try { communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default"); test(false); } catch (Ice.AlreadyRegisteredException) { } adapter.destroy(); // // Use a different port than the first adapter to avoid an "address already in use" error. // adapter = communicator.createObjectAdapterWithEndpoints("TransientTestAdapter", "default"); adapter.destroy(); Console.Out.WriteLine("ok"); } Write("creating/activating/deactivating object adapter in one operation... "); Flush(); obj.transient(); obj.end_transient(obj.begin_transient()); WriteLine("ok"); { Write("testing connection closure... "); Flush(); for (int i = 0; i < 10; ++i) { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); Ice.Communicator comm = Ice.Util.initialize(initData); comm.stringToProxy("test:" + app.getTestEndpoint(0)).begin_ice_ping(); comm.destroy(); } WriteLine("ok"); } Write("deactivating object adapter in the server... "); Flush(); obj.deactivate(); WriteLine("ok"); Write("testing whether server is gone... "); Flush(); try { obj.ice_timeout(100).ice_ping(); // Use timeout to speed up testing on Windows test(false); } catch (Ice.LocalException) { WriteLine("ok"); } return(obj); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); communicator.getProperties().setProperty("ReplyAdapter.Endpoints", "udp"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("ReplyAdapter"); PingReplyI replyI = new PingReplyI(); Test.PingReplyPrx reply = (Test.PingReplyPrx)Test.PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram(); adapter.activate(); Console.Out.Write("testing udp... "); Console.Out.Flush(); Ice.ObjectPrx @base = communicator.stringToProxy("test:" + app.getTestEndpoint(0, "udp")).ice_datagram(); Test.TestIntfPrx obj = Test.TestIntfPrxHelper.uncheckedCast(@base); int nRetry = 5; bool ret = false; while (nRetry-- > 0) { replyI.reset(); obj.ping(reply); obj.ping(reply); obj.ping(reply); ret = replyI.waitReply(3, 2000); if (ret) { break; // Success } // If the 3 datagrams were not received within the 2 seconds, we try again to // receive 3 new datagrams using a new object. We give up after 5 retries. replyI = new PingReplyI(); reply = (Test.PingReplyPrx)Test.PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram(); } test(ret == true); if (communicator.getProperties().getPropertyAsInt("Ice.Override.Compress") == 0) { // // Only run this test if compression is disabled, the test expect fixed message size // to be sent over the wire. // byte[] seq = null; try { seq = new byte[1024]; while (true) { seq = new byte[seq.Length * 2 + 10]; replyI.reset(); obj.sendByteSeq(seq, reply); replyI.waitReply(1, 10000); } } catch (Ice.DatagramLimitException) { // // The server's Ice.UDP.RcvSize property is set to 16384, which means that DatagramLimitException // will be throw when try to send a packet bigger than that. // test(seq.Length > 16384); } obj.ice_getConnection().close(false); communicator.getProperties().setProperty("Ice.UDP.SndSize", "64000"); seq = new byte[50000]; try { replyI.reset(); obj.sendByteSeq(seq, reply); bool b = replyI.waitReply(1, 500); // // The server's Ice.UDP.RcvSize property is set to 16384, which means this packet // should not be delivered. // test(!b); } catch (Ice.DatagramLimitException) { } catch (Ice.LocalException ex) { Console.Out.WriteLine(ex); test(false); } } Console.Out.WriteLine("ok"); Console.Out.Write("testing udp multicast... "); Console.Out.Flush(); string endpoint; if (communicator.getProperties().getProperty("Ice.IPv6").Equals("1")) { endpoint = "udp -h \"ff15::1:1\" -p 12020"; } else { endpoint = "udp -h 239.255.1.1 -p 12020"; } @base = communicator.stringToProxy("test -d:" + endpoint); TestIntfPrx objMcast = Test.TestIntfPrxHelper.uncheckedCast(@base); nRetry = 5; while (nRetry-- > 0) { replyI.reset(); objMcast.ping(reply); ret = replyI.waitReply(5, 5000); if (ret) { break; } replyI = new PingReplyI(); reply = (Test.PingReplyPrx)Test.PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram(); } if (!ret) { Console.Out.WriteLine("failed (is a firewall enabled?)"); } else { Console.Out.WriteLine("ok"); } Console.Out.Write("testing udp bi-dir connection... "); Console.Out.Flush(); obj.ice_getConnection().setAdapter(adapter); objMcast.ice_getConnection().setAdapter(adapter); nRetry = 5; while (nRetry-- > 0) { replyI.reset(); obj.pingBiDir(reply.ice_getIdentity()); obj.pingBiDir(reply.ice_getIdentity()); obj.pingBiDir(reply.ice_getIdentity()); ret = replyI.waitReply(3, 2000); if (ret) { break; // Success } replyI = new PingReplyI(); reply = (PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram(); } test(ret); Console.Out.WriteLine("ok"); // // Sending the replies back on the multicast UDP connection doesn't work for most // platform (it works for OS X Leopard but not Snow Leopard, doesn't work on SLES, // Windows...). For Windows, see UdpTransceiver constructor for the details. So // we don't run this test. // // Console.Out.Write("testing udp bi-dir connection... "); // nRetry = 5; // while(nRetry-- > 0) // { // replyI.reset(); // objMcast.pingBiDir(reply.ice_getIdentity()); // ret = replyI.waitReply(5, 2000); // if(ret) // { // break; // Success // } // replyI = new PingReplyI(); // reply = (PingReplyPrx)PingReplyPrxHelper.uncheckedCast(adapter.addWithUUID(replyI)).ice_datagram(); // } // if(!ret) // { // Console.Out.WriteLine("failed (is a firewall enabled?)"); // } // else // { // Console.Out.WriteLine("ok"); // } }
internal static void onewaysAMI(TestCommon.Application app, Test.MyClassPrx proxy) { Ice.Communicator communicator = app.communicator(); Test.MyClassPrx p = Test.MyClassPrxHelper.uncheckedCast(proxy.ice_oneway()); { Callback cb = new Callback(); p.ice_pingAsync(progress: new Progress <bool>( sentSynchronously => { cb.sent(sentSynchronously); })); cb.check(); } { Callback cb = new Callback(); p.begin_ice_ping().whenCompleted(cb.noException).whenSent(cb.sent); cb.check(); } { Callback cb = new Callback(); p.begin_ice_ping().whenCompleted( (Ice.Exception ex) => { cb.noException(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); } { try { p.ice_isAAsync("::Test::MyClass"); test(false); } catch (Ice.TwowayOnlyException) { } } { try { p.begin_ice_isA("::Test::MyClass"); test(false); } catch (Ice.TwowayOnlyException) { } } { try { p.ice_idAsync(); test(false); } catch (Ice.TwowayOnlyException) { } } { try { p.begin_ice_id(); test(false); } catch (Ice.TwowayOnlyException) { } } { try { p.begin_ice_ids(); test(false); } catch (Ice.TwowayOnlyException) { } } { Callback cb = new Callback(); p.opVoidAsync(progress: new Progress <bool>( sentSynchronously => { cb.sent(sentSynchronously); })); cb.check(); } { Callback cb = new Callback(); p.begin_opVoid().whenCompleted(cb.noException).whenSent(cb.sent); cb.check(); } { Callback cb = new Callback(); p.begin_opVoid().whenCompleted( (Ice.Exception ex) => { cb.noException(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); } { Callback cb = new Callback(); p.opIdempotentAsync(progress: new Progress <bool>( sentSynchronously => { cb.sent(sentSynchronously); })); cb.check(); } { Callback cb = new Callback(); p.begin_opIdempotent().whenCompleted(cb.noException).whenSent(cb.sent); cb.check(); } { Callback cb = new Callback(); p.begin_opIdempotent().whenCompleted( (Ice.Exception ex) => { cb.noException(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); } { Callback cb = new Callback(); p.opNonmutatingAsync(progress: new Progress <bool>( sentSynchronously => { cb.sent(sentSynchronously); })); cb.check(); } { Callback cb = new Callback(); p.begin_opNonmutating().whenCompleted(cb.noException).whenSent(cb.sent); cb.check(); } { Callback cb = new Callback(); p.begin_opNonmutating().whenCompleted( (Ice.Exception ex) => { cb.noException(ex); } ).whenSent( (bool sentSynchronously) => { cb.sent(sentSynchronously); }); cb.check(); } { try { p.opByteAsync(0xff, 0x0f); test(false); } catch (Ice.TwowayOnlyException) { } } { try { p.begin_opByte(0xff, 0x0f); test(false); } catch (Ice.TwowayOnlyException) { } } }
public static GPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing Ice.Admin.Facets property... "); test(communicator.getProperties().getPropertyAsList("Ice.Admin.Facets").Length == 0); communicator.getProperties().setProperty("Ice.Admin.Facets", "foobar"); String[] facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); test(facetFilter.Length == 1 && facetFilter[0].Equals("foobar")); communicator.getProperties().setProperty("Ice.Admin.Facets", "foo\\'bar"); facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); test(facetFilter.Length == 1 && facetFilter[0].Equals("foo'bar")); communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' toto 'titi'"); facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); test(facetFilter.Length == 3 && facetFilter[0].Equals("foo bar") && facetFilter[1].Equals("toto") && facetFilter[2].Equals("titi")); communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar\\' toto' 'titi'"); facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); test(facetFilter.Length == 2 && facetFilter[0].Equals("foo bar' toto") && facetFilter[1].Equals("titi")); // communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' 'toto titi"); // facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets"); // test(facetFilter.Length == 0); communicator.getProperties().setProperty("Ice.Admin.Facets", ""); WriteLine("ok"); Write("testing facet registration exceptions... "); communicator.getProperties().setProperty("FacetExceptionTestAdapter.Endpoints", "default"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("FacetExceptionTestAdapter"); Ice.Object obj = new EmptyI(); adapter.add(obj, Ice.Util.stringToIdentity("d")); adapter.addFacet(obj, Ice.Util.stringToIdentity("d"), "facetABCD"); try { adapter.addFacet(obj, Ice.Util.stringToIdentity("d"), "facetABCD"); test(false); } catch (Ice.AlreadyRegisteredException) { } adapter.removeFacet(Ice.Util.stringToIdentity("d"), "facetABCD"); try { adapter.removeFacet(Ice.Util.stringToIdentity("d"), "facetABCD"); test(false); } catch (Ice.NotRegisteredException) { } WriteLine("ok"); Write("testing removeAllFacets... "); Ice.Object obj1 = new EmptyI(); Ice.Object obj2 = new EmptyI(); adapter.addFacet(obj1, Ice.Util.stringToIdentity("id1"), "f1"); adapter.addFacet(obj2, Ice.Util.stringToIdentity("id1"), "f2"); Ice.Object obj3 = new EmptyI(); adapter.addFacet(obj1, Ice.Util.stringToIdentity("id2"), "f1"); adapter.addFacet(obj2, Ice.Util.stringToIdentity("id2"), "f2"); adapter.addFacet(obj3, Ice.Util.stringToIdentity("id2"), ""); Dictionary <string, Ice.Object> fm = adapter.removeAllFacets(Ice.Util.stringToIdentity("id1")); test(fm.Count == 2); test(fm["f1"] == obj1); test(fm["f2"] == obj2); try { adapter.removeAllFacets(Ice.Util.stringToIdentity("id1")); test(false); } catch (Ice.NotRegisteredException) { } fm = adapter.removeAllFacets(Ice.Util.stringToIdentity("id2")); test(fm.Count == 3); test(fm["f1"] == obj1); test(fm["f2"] == obj2); test(fm[""] == obj3); WriteLine("ok"); adapter.deactivate(); Write("testing stringToProxy... "); Flush(); string @ref = "d:" + app.getTestEndpoint(0); Ice.ObjectPrx db = communicator.stringToProxy(@ref); test(db != null); WriteLine("ok"); Write("testing unchecked cast... "); Flush(); Ice.ObjectPrx prx = Ice.ObjectPrxHelper.uncheckedCast(db); test(prx.ice_getFacet().Length == 0); prx = Ice.ObjectPrxHelper.uncheckedCast(db, "facetABCD"); test(prx.ice_getFacet() == "facetABCD"); Ice.ObjectPrx prx2 = Ice.ObjectPrxHelper.uncheckedCast(prx); test(prx2.ice_getFacet() == "facetABCD"); Ice.ObjectPrx prx3 = Ice.ObjectPrxHelper.uncheckedCast(prx, ""); test(prx3.ice_getFacet().Length == 0); DPrx d = Test.DPrxHelper.uncheckedCast(db); test(d.ice_getFacet().Length == 0); DPrx df = Test.DPrxHelper.uncheckedCast(db, "facetABCD"); test(df.ice_getFacet() == "facetABCD"); DPrx df2 = Test.DPrxHelper.uncheckedCast(df); test(df2.ice_getFacet() == "facetABCD"); DPrx df3 = Test.DPrxHelper.uncheckedCast(df, ""); test(df3.ice_getFacet().Length == 0); WriteLine("ok"); Write("testing checked cast... "); Flush(); prx = Ice.ObjectPrxHelper.checkedCast(db); test(prx.ice_getFacet().Length == 0); prx = Ice.ObjectPrxHelper.checkedCast(db, "facetABCD"); test(prx.ice_getFacet() == "facetABCD"); prx2 = Ice.ObjectPrxHelper.checkedCast(prx); test(prx2.ice_getFacet() == "facetABCD"); prx3 = Ice.ObjectPrxHelper.checkedCast(prx, ""); test(prx3.ice_getFacet().Length == 0); d = Test.DPrxHelper.checkedCast(db); test(d.ice_getFacet().Length == 0); df = Test.DPrxHelper.checkedCast(db, "facetABCD"); test(df.ice_getFacet() == "facetABCD"); df2 = Test.DPrxHelper.checkedCast(df); test(df2.ice_getFacet() == "facetABCD"); df3 = Test.DPrxHelper.checkedCast(df, ""); test(df3.ice_getFacet().Length == 0); WriteLine("ok"); Write("testing non-facets A, B, C, and D... "); Flush(); d = DPrxHelper.checkedCast(db); test(d != null); test(d.Equals(db)); test(d.callA().Equals("A")); test(d.callB().Equals("B")); test(d.callC().Equals("C")); test(d.callD().Equals("D")); WriteLine("ok"); Write("testing facets A, B, C, and D... "); Flush(); df = DPrxHelper.checkedCast(d, "facetABCD"); test(df != null); test(df.callA().Equals("A")); test(df.callB().Equals("B")); test(df.callC().Equals("C")); test(df.callD().Equals("D")); WriteLine("ok"); Write("testing facets E and F... "); Flush(); FPrx ff = FPrxHelper.checkedCast(d, "facetEF"); test(ff != null); test(ff.callE().Equals("E")); test(ff.callF().Equals("F")); WriteLine("ok"); Write("testing facet G... "); Flush(); GPrx gf = GPrxHelper.checkedCast(ff, "facetGH"); test(gf != null); test(gf.callG().Equals("G")); WriteLine("ok"); Write("testing whether casting preserves the facet... "); Flush(); HPrx hf = HPrxHelper.checkedCast(gf); test(hf != null); test(hf.callG().Equals("G")); test(hf.callH().Equals("H")); WriteLine("ok"); return(gf); }
allTests(TestCommon.Application app, bool collocated) { Ice.Communicator communicator = app.communicator(); string rf = "test:" + app.getTestEndpoint(0); Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf); test(baseProxy != null); Test.ChecksumPrx checksum = Test.ChecksumPrxHelper.checkedCast(baseProxy); test(checksum != null); // // Verify that no checksums are present for local types. // Console.Out.Write("testing checksums... "); Console.Out.Flush(); foreach (KeyValuePair <string, string> entry in Ice.SliceChecksums.checksums) { string key = entry.Key; int pos = key.IndexOf("Local"); test(pos == -1); } // // Get server's Slice checksums. // Dictionary <string, string> d = checksum.getSliceChecksums(); // // Compare the checksums. For a type FooN whose name ends in an integer N, // we assume that the server's type does not change for N = 1, and does // change for N > 1. // char[] digits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' }; foreach (KeyValuePair <string, string> entry in d) { string key = entry.Key; int start = key.IndexOfAny(digits); if (start != -1) { int end = start; while (end < key.Length && char.IsDigit(key[end])) { end++; } int n = int.Parse(key.Substring(start, end - start)); string value = Ice.SliceChecksums.checksums[key]; test(value != null); if (n <= 1) { test(value.Equals(entry.Value)); } else { test(!value.Equals(entry.Value)); } } } Console.Out.WriteLine("ok"); return(checksum); }
public static Test.MyClassPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); string rf = "test:" + app.getTestEndpoint(0); Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf); test(baseProxy != null); Ice.ObjectPrx b1 = communicator.stringToProxy("test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("test "); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy(" test "); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy(" test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("'test -f facet'"); test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); try { b1 = communicator.stringToProxy("\"test -f facet'"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("\"test -f facet\""); test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("\"test -f facet@test\""); test(b1.ice_getIdentity().name.Equals("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.ice_getIdentity().name.Equals("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 (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test\\040test"); test(b1.ice_getIdentity().name.Equals("test test") && b1.ice_getIdentity().category.Length == 0); try { b1 = communicator.stringToProxy("test\\777"); test(false); } catch (Ice.IdentityParseException) { } b1 = communicator.stringToProxy("test\\40test"); test(b1.ice_getIdentity().name.Equals("test test")); // Test some octal and hex corner cases. b1 = communicator.stringToProxy("test\\4test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\04test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\004test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\1114test"); test(b1.ice_getIdentity().name.Equals("test\u00494test")); b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test"); test(b1.ice_getIdentity().name.Equals("test\b\f\n\r\t\'\"\\test") && b1.ice_getIdentity().category.Length == 0); b1 = communicator.stringToProxy("category/test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy(""); test(b1 == null); b1 = communicator.stringToProxy("\"\""); test(b1 == null); try { b1 = communicator.stringToProxy("\"\" test"); // Invalid trailing characters. test(false); } catch (Ice.ProxyParseException) { } try { b1 = communicator.stringToProxy("test:"); // Missing endpoint. test(false); } catch (Ice.EndpointParseException) { } b1 = communicator.stringToProxy("test@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Equals("adapter")); try { b1 = communicator.stringToProxy("id@adapter test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("category/test@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("category/test@adapter:tcp"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter:tcp")); b1 = communicator.stringToProxy("'category 1/test'@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category 1") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("'category/test 1'@adapter"); test(b1.ice_getIdentity().name.Equals("test 1") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("'category/test'@'adapter 1'"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter 1")); b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\""); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && b1.ice_getAdapterId().Equals("adapter:tcp")); b1 = communicator.stringToProxy("id -f facet"); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet")); b1 = communicator.stringToProxy("id -f 'facet x'"); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet x")); b1 = communicator.stringToProxy("id -f \"facet x\""); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet x")); try { b1 = communicator.stringToProxy("id -f \"facet x"); test(false); } catch (Ice.ProxyParseException) { } try { b1 = communicator.stringToProxy("id -f \'facet x"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test -f facet:tcp"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f \"facet:tcp\""); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet:tcp") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f facet@test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Equals("test")); b1 = communicator.stringToProxy("test -f 'facet@test'"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f 'facet@test'@test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Equals("test")); try { b1 = communicator.stringToProxy("test -f facet@test @test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test"); test(b1.ice_isTwoway()); b1 = communicator.stringToProxy("test -t"); test(b1.ice_isTwoway()); b1 = communicator.stringToProxy("test -o"); test(b1.ice_isOneway()); b1 = communicator.stringToProxy("test -O"); test(b1.ice_isBatchOneway()); b1 = communicator.stringToProxy("test -d"); test(b1.ice_isDatagram()); b1 = communicator.stringToProxy("test -D"); test(b1.ice_isBatchDatagram()); b1 = communicator.stringToProxy("test"); test(!b1.ice_isSecure()); b1 = communicator.stringToProxy("test -s"); test(b1.ice_isSecure()); test(b1.ice_getEncodingVersion().Equals(Ice.Util.currentEncoding)); b1 = communicator.stringToProxy("test -e 1.0"); test(b1.ice_getEncodingVersion().major == 1 && b1.ice_getEncodingVersion().minor == 0); b1 = communicator.stringToProxy("test -e 6.5"); test(b1.ice_getEncodingVersion().major == 6 && b1.ice_getEncodingVersion().minor == 5); b1 = communicator.stringToProxy("test -p 1.0 -e 1.0"); test(b1.ToString().Equals("test -t -e 1.0")); b1 = communicator.stringToProxy("test -p 6.5 -e 1.0"); test(b1.ToString().Equals("test -t -p 6.5 -e 1.0")); try { communicator.stringToProxy("test:tcp@adapterId"); test(false); } catch (Ice.EndpointParseException) { } // This is an unknown endpoint warning, not a parse exception. // //try //{ // b1 = communicator.stringToProxy("test -f the:facet:tcp"); // test(false); //} //catch(Ice.EndpointParseException) //{ //} try { communicator.stringToProxy("test: :tcp"); test(false); } catch (Ice.EndpointParseException) { } // // Test invalid endpoint syntax // try { communicator.createObjectAdapterWithEndpoints("BadAdapter", " : "); test(false); } catch (Ice.EndpointParseException) { } try { communicator.createObjectAdapterWithEndpoints("BadAdapter", "tcp: "); test(false); } catch (Ice.EndpointParseException) { } try { communicator.createObjectAdapterWithEndpoints("BadAdapter", ":tcp"); test(false); } catch (Ice.EndpointParseException) { } // // Test for bug ICE-5543: escaped escapes in stringToIdentity // Ice.Identity id = new Ice.Identity("test", ",X2QNUAzSBcJ_e$AV;E\\"); Ice.Identity id2 = Ice.Util.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); id = new Ice.Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\"); id2 = Ice.Util.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); id = new Ice.Identity("/test", "cat/"); string idStr = communicator.identityToString(id); test(idStr == "cat\\//\\/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); // Input string with various pitfalls id = Ice.Util.stringToIdentity("\\342\\x82\\254\\60\\x9\\60\\"); test(id.name == "€0\t0\\" && id.category == ""); try { // Illegal character < 32 id = Ice.Util.stringToIdentity("xx\01FooBar"); test(false); } catch (Ice.IdentityParseException) { } try { // Illegal surrogate id = Ice.Util.stringToIdentity("xx\\ud911"); test(false); } catch (Ice.IdentityParseException) { } // Testing bytes 127 (\x7F, \177) and € id = new Ice.Identity("test", "\x7f€"); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Unicode); test(idStr == "\\u007f€/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); test(Ice.Util.identityToString(id) == idStr); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.ASCII); test(idStr == "\\u007f\\u20ac/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Compat); test(idStr == "\\177\\342\\202\\254/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); id2 = Ice.Util.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); // More unicode character id = new Ice.Identity("banana \x0E-\ud83c\udf4c\u20ac\u00a2\u0024", "greek \ud800\udd6a"); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Unicode); test(idStr == "greek \ud800\udd6a/banana \\u000e-\ud83c\udf4c\u20ac\u00a2$"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.ASCII); test(idStr == "greek \\U0001016a/banana \\u000e-\\U0001f34c\\u20ac\\u00a2$"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Compat); id2 = Ice.Util.stringToIdentity(idStr); test(idStr == "greek \\360\\220\\205\\252/banana \\016-\\360\\237\\215\\214\\342\\202\\254\\302\\242$"); test(id.Equals(id2)); WriteLine("ok"); Write("testing proxyToString... "); Flush(); b1 = communicator.stringToProxy(rf); Ice.ObjectPrx b2 = communicator.stringToProxy(communicator.proxyToString(b1)); test(b1.Equals(b2)); if (b1.ice_getConnection() != null) // not colloc-optimized target { b2 = b1.ice_getConnection().createProxy(Ice.Util.stringToIdentity("fixed")); String str = communicator.proxyToString(b2); test(b2.ToString() == str); String str2 = b1.ice_identity(b2.ice_getIdentity()).ice_secure(b2.ice_isSecure()).ToString(); // Verify that the stringified fixed proxy is the same as a regular stringified proxy // but without endpoints test(str2.StartsWith(str)); test(str2[str.Length] == ':'); } WriteLine("ok"); Write("testing propertyToProxy... "); Flush(); Ice.Properties prop = communicator.getProperties(); String propertyPrefix = "Foo.Proxy"; prop.setProperty(propertyPrefix, "test:" + app.getTestEndpoint(0)); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); string property; property = propertyPrefix + ".Locator"; test(b1.ice_getLocator() == null); prop.setProperty(property, "locator:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.Equals("locator")); try { prop.setProperty(property, ""); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } property = propertyPrefix + ".LocatorCacheTimeout"; test(b1.ice_getLocatorCacheTimeout() == -1); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(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.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.Equals("locator")); prop.setProperty(property, ""); property = propertyPrefix + ".LocatorCacheTimeout"; test(b1.ice_getLocatorCacheTimeout() == -1); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocatorCacheTimeout() == 1); prop.setProperty(property, ""); // This cannot be tested so easily because the property is cached // on communicator initialization. // //prop.setProperty("Ice.Default.LocatorCacheTimeout", "60"); //b1 = communicator.propertyToProxy(propertyPrefix); //test(b1.ice_getLocatorCacheTimeout() == 60); //prop.setProperty("Ice.Default.LocatorCacheTimeout", ""); prop.setProperty(propertyPrefix, "test:" + app.getTestEndpoint(0)); property = propertyPrefix + ".Router"; test(b1.ice_getRouter() == null); prop.setProperty(property, "router:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getRouter() != null && b1.ice_getRouter().ice_getIdentity().name.Equals("router")); prop.setProperty(property, ""); property = propertyPrefix + ".PreferSecure"; test(!b1.ice_isPreferSecure()); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_isPreferSecure()); prop.setProperty(property, ""); property = propertyPrefix + ".ConnectionCached"; test(b1.ice_isConnectionCached()); prop.setProperty(property, "0"); b1 = communicator.propertyToProxy(propertyPrefix); test(!b1.ice_isConnectionCached()); prop.setProperty(property, ""); property = propertyPrefix + ".InvocationTimeout"; test(b1.ice_getInvocationTimeout() == -1); prop.setProperty(property, "1000"); b1 = communicator.propertyToProxy(propertyPrefix); test(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.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); prop.setProperty(property, "Ordered"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); prop.setProperty(property, ""); property = propertyPrefix + ".CollocationOptimized"; test(b1.ice_isCollocationOptimized()); prop.setProperty(property, "0"); b1 = communicator.propertyToProxy(propertyPrefix); test(!b1.ice_isCollocationOptimized()); prop.setProperty(property, ""); property = propertyPrefix + ".Context.c1"; test(!b1.ice_getContext().ContainsKey("c1")); prop.setProperty(property, "TEST"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getContext()["c1"].Equals("TEST")); property = propertyPrefix + ".Context.c2"; test(!b1.ice_getContext().ContainsKey("c2")); prop.setProperty(property, "TEST"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getContext()["c2"].Equals("TEST")); prop.setProperty(propertyPrefix + ".Context.c1", ""); prop.setProperty(propertyPrefix + ".Context.c2", ""); WriteLine("ok"); Write("testing proxyToProperty... "); Flush(); b1 = communicator.stringToProxy("test"); b1 = b1.ice_collocationOptimized(true); b1 = b1.ice_connectionCached(true); b1 = b1.ice_preferSecure(false); 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)); Ice.ObjectPrx router = communicator.stringToProxy("router"); router = router.ice_collocationOptimized(false); router = router.ice_connectionCached(true); router = router.ice_preferSecure(true); router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random); router = router.ice_locatorCacheTimeout(200); router = router.ice_invocationTimeout(1500); Ice.ObjectPrx locator = communicator.stringToProxy("locator"); locator = locator.ice_collocationOptimized(true); locator = locator.ice_connectionCached(false); locator = locator.ice_preferSecure(true); locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random); locator = locator.ice_locatorCacheTimeout(300); locator = locator.ice_invocationTimeout(1500); locator = locator.ice_router(Ice.RouterPrxHelper.uncheckedCast(router)); b1 = b1.ice_locator(Ice.LocatorPrxHelper.uncheckedCast(locator)); Dictionary <string, string> proxyProps = communicator.proxyToProperty(b1, "Test"); test(proxyProps.Count == 21); test(proxyProps["Test"].Equals("test -t -e 1.0")); test(proxyProps["Test.CollocationOptimized"].Equals("1")); test(proxyProps["Test.ConnectionCached"].Equals("1")); test(proxyProps["Test.PreferSecure"].Equals("0")); test(proxyProps["Test.EndpointSelection"].Equals("Ordered")); test(proxyProps["Test.LocatorCacheTimeout"].Equals("100")); test(proxyProps["Test.InvocationTimeout"].Equals("1234")); test(proxyProps["Test.Locator"].Equals( "locator -t -e " + Ice.Util.encodingVersionToString(Ice.Util.currentEncoding))); // Locator collocation optimization is always disabled. //test(proxyProps["Test.Locator.CollocationOptimized"].Equals("1")); test(proxyProps["Test.Locator.ConnectionCached"].Equals("0")); test(proxyProps["Test.Locator.PreferSecure"].Equals("1")); test(proxyProps["Test.Locator.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.LocatorCacheTimeout"].Equals("300")); test(proxyProps["Test.Locator.InvocationTimeout"].Equals("1500")); test(proxyProps["Test.Locator.Router"].Equals( "router -t -e " + Ice.Util.encodingVersionToString(Ice.Util.currentEncoding))); test(proxyProps["Test.Locator.Router.CollocationOptimized"].Equals("0")); test(proxyProps["Test.Locator.Router.ConnectionCached"].Equals("1")); test(proxyProps["Test.Locator.Router.PreferSecure"].Equals("1")); test(proxyProps["Test.Locator.Router.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"].Equals("200")); test(proxyProps["Test.Locator.Router.InvocationTimeout"].Equals("1500")); WriteLine("ok"); Write("testing ice_getCommunicator... "); Flush(); test(baseProxy.ice_getCommunicator() == communicator); WriteLine("ok"); Write("testing proxy methods... "); // Disable Obsolete warning/error #pragma warning disable 612, 618 test(communicator.identityToString( baseProxy.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()).Equals("other")); #pragma warning restore 612, 618 test(baseProxy.ice_facet("facet").ice_getFacet().Equals("facet")); test(baseProxy.ice_adapterId("id").ice_getAdapterId().Equals("id")); test(baseProxy.ice_twoway().ice_isTwoway()); test(baseProxy.ice_oneway().ice_isOneway()); test(baseProxy.ice_batchOneway().ice_isBatchOneway()); test(baseProxy.ice_datagram().ice_isDatagram()); test(baseProxy.ice_batchDatagram().ice_isBatchDatagram()); test(baseProxy.ice_secure(true).ice_isSecure()); test(!baseProxy.ice_secure(false).ice_isSecure()); test(baseProxy.ice_collocationOptimized(true).ice_isCollocationOptimized()); test(!baseProxy.ice_collocationOptimized(false).ice_isCollocationOptimized()); test(baseProxy.ice_preferSecure(true).ice_isPreferSecure()); test(!baseProxy.ice_preferSecure(false).ice_isPreferSecure()); try { baseProxy.ice_timeout(0); test(false); } catch (ArgumentException) { } try { baseProxy.ice_timeout(-1); } catch (ArgumentException) { test(false); } try { baseProxy.ice_timeout(-2); test(false); } catch (ArgumentException) { } try { baseProxy.ice_invocationTimeout(0); test(false); } catch (ArgumentException) { } try { baseProxy.ice_invocationTimeout(-1); baseProxy.ice_invocationTimeout(-2); } catch (ArgumentException) { test(false); } try { baseProxy.ice_invocationTimeout(-3); test(false); } catch (ArgumentException) { } try { baseProxy.ice_locatorCacheTimeout(0); } catch (ArgumentException) { test(false); } try { baseProxy.ice_locatorCacheTimeout(-1); } catch (ArgumentException) { test(false); } try { baseProxy.ice_locatorCacheTimeout(-2); test(false); } catch (ArgumentException) { } WriteLine("ok"); Write("testing proxy comparison... "); Flush(); test(communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo"))); test(!communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo2"))); Ice.ObjectPrx compObj = communicator.stringToProxy("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_secure(true).Equals(compObj.ice_secure(true))); test(!compObj.ice_secure(false).Equals(compObj.ice_secure(true))); test(compObj.ice_collocationOptimized(true).Equals(compObj.ice_collocationOptimized(true))); test(!compObj.ice_collocationOptimized(false).Equals(compObj.ice_collocationOptimized(true))); 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().Equals("id1")); test(compObj.ice_connectionId("id2").ice_getConnectionId().Equals("id2")); test(compObj.ice_compress(true).Equals(compObj.ice_compress(true))); test(!compObj.ice_compress(false).Equals(compObj.ice_compress(true))); test(compObj.ice_timeout(20).Equals(compObj.ice_timeout(20))); test(!compObj.ice_timeout(10).Equals(compObj.ice_timeout(20))); Ice.LocatorPrx loc1 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000")); Ice.LocatorPrx loc2 = Ice.LocatorPrxHelper.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))); Ice.RouterPrx rtr1 = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("rtr1:default -p 10000")); Ice.RouterPrx rtr2 = Ice.RouterPrxHelper.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))); Dictionary <string, string> ctx1 = new Dictionary <string, string>(); ctx1["ctx1"] = "v1"; Dictionary <string, string> ctx2 = new Dictionary <string, string>(); ctx2["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))); test(compObj.ice_preferSecure(true).Equals(compObj.ice_preferSecure(true))); test(!compObj.ice_preferSecure(true).Equals(compObj.ice_preferSecure(false))); Ice.ObjectPrx compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000"); Ice.ObjectPrx compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001"); test(!compObj1.Equals(compObj2)); compObj1 = communicator.stringToProxy("foo@MyAdapter1"); compObj2 = communicator.stringToProxy("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 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000"); compObj2 = communicator.stringToProxy("foo@MyAdapter1"); test(!compObj1.Equals(compObj2)); Ice.Endpoint[] endpts1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints(); Ice.Endpoint[] endpts2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001").ice_getEndpoints(); test(!endpts1[0].Equals(endpts2[0])); test(endpts1[0].Equals(communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints()[0])); // // TODO: Ideally we should also test comparison of fixed proxies. // WriteLine("ok"); Write("testing checked cast... "); Flush(); Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy); test(cl != null); Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(cl); test(derived != null); test(cl.Equals(baseProxy)); test(derived.Equals(baseProxy)); test(cl.Equals(derived)); WriteLine("ok"); Write("testing checked cast with context... "); Flush(); Dictionary <string, string> c = cl.getContext(); test(c == null || c.Count == 0); c = new Dictionary <string, string>(); c["one"] = "hello"; c["two"] = "world"; cl = Test.MyClassPrxHelper.checkedCast(baseProxy, c); Dictionary <string, string> c2 = cl.getContext(); test(Ice.CollectionComparer.Equals(c, c2)); WriteLine("ok"); Write("testing encoding versioning... "); Flush(); string ref20 = "test -e 2.0:" + app.getTestEndpoint(0); Test.MyClassPrx cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); try { cl20.ice_ping(); test(false); } catch (Ice.UnsupportedEncodingException) { // Server 2.0 endpoint doesn't support 1.1 version. } string ref10 = "test -e 1.0:" + app.getTestEndpoint(0); Test.MyClassPrx cl10 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref10)); cl10.ice_ping(); cl10.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); cl.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the // call will use the 1.1 encoding string ref13 = "test -e 1.3:" + app.getTestEndpoint(0); Test.MyClassPrx cl13 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); cl13.end_ice_ping(cl13.begin_ice_ping()); try { // Send request with bogus 1.2 encoding. Ice.EncodingVersion version = new Ice.EncodingVersion(1, 2); Ice.OutputStream os = new Ice.OutputStream(communicator); os.startEncapsulation(); os.endEncapsulation(); byte[] inEncaps = os.finished(); inEncaps[4] = version.major; inEncaps[5] = version.minor; byte[] outEncaps; cl.ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, out outEncaps); test(false); } catch (Ice.UnknownLocalException ex) { // The server thrown an UnsupportedEncodingException test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); } try { // Send request with bogus 2.0 encoding. Ice.EncodingVersion version = new Ice.EncodingVersion(2, 0); Ice.OutputStream os = new Ice.OutputStream(communicator); os.startEncapsulation(); os.endEncapsulation(); byte[] inEncaps = os.finished(); inEncaps[4] = version.major; inEncaps[5] = version.minor; byte[] outEncaps; cl.ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, out outEncaps); test(false); } catch (Ice.UnknownLocalException ex) { // The server thrown an UnsupportedEncodingException test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); } WriteLine("ok"); Write("testing protocol versioning... "); Flush(); ref20 = "test -p 2.0:" + app.getTestEndpoint(0); cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); try { cl20.ice_ping(); test(false); } catch (Ice.UnsupportedProtocolException) { // Server 2.0 proxy doesn't support 1.0 version. } ref10 = "test -p 1.0:" + app.getTestEndpoint(0); cl10 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref10)); cl10.ice_ping(); // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the // call will use the 1.1 protocol ref13 = "test -p 1.3:" + app.getTestEndpoint(0); cl13 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); cl13.end_ice_ping(cl13.begin_ice_ping()); WriteLine("ok"); Write("testing opaque endpoints... "); Flush(); try { // Invalid -x option communicator.stringToProxy("id:opaque -t 99 -v abcd -x abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -t and -v communicator.stringToProxy("id:opaque"); test(false); } catch (Ice.EndpointParseException) { } try { // Repeated -t communicator.stringToProxy("id:opaque -t 1 -t 1 -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Repeated -v communicator.stringToProxy("id:opaque -t 1 -v abcd -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -t communicator.stringToProxy("id:opaque -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -v communicator.stringToProxy("id:opaque -t 1"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing arg for -t communicator.stringToProxy("id:opaque -t -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing arg for -v communicator.stringToProxy("id:opaque -t 1 -v"); test(false); } catch (Ice.EndpointParseException) { } try { // Not a number for -t communicator.stringToProxy("id:opaque -t x -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // < 0 for -t communicator.stringToProxy("id:opaque -t -1 -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Invalid char for -v communicator.stringToProxy("id:opaque -t 99 -v x?c"); test(false); } catch (Ice.EndpointParseException) { } try { // Invalid lenght for base64 input communicator.stringToProxy("id:opaque -t 99 -v xc"); test(false); } catch (Ice.EndpointParseException) { } // Legal TCP endpoint expressed as opaque endpoint Ice.ObjectPrx p1 = communicator.stringToProxy("test -e 1.1:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); string pstr = communicator.proxyToString(p1); test(pstr.Equals("test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")); // Opaque endpoint encoded with 1.1 encoding. Ice.ObjectPrx p2 = communicator.stringToProxy("test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); test(communicator.proxyToString(p2).Equals("test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")); if (communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0) { // Working? bool ssl = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("ssl"); bool tcp = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("tcp"); // Two legal TCP endpoints expressed as opaque endpoints p1 = communicator.stringToProxy("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.Equals("test -t -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -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 = communicator.stringToProxy("test -e 1.0:opaque -e 1.0 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -e 1.0 -t 99 -v abch"); pstr = communicator.proxyToString(p1); if (ssl) { test(pstr.Equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")); } else if (tcp) { test(pstr.Equals( "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch")); } } WriteLine("ok"); return(cl); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); ServerManagerPrx manager = ServerManagerPrxHelper.checkedCast( communicator.stringToProxy("ServerManager :" + app.getTestEndpoint(0))); test(manager != null); TestLocatorPrx locator = TestLocatorPrxHelper.uncheckedCast(communicator.getDefaultLocator()); test(locator != null); TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry()); test(registry != null); Write("testing stringToProxy... "); Flush(); Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter"); Ice.ObjectPrx base2 = communicator.stringToProxy("test @ TestAdapter"); Ice.ObjectPrx base3 = communicator.stringToProxy("test"); Ice.ObjectPrx base4 = communicator.stringToProxy("ServerManager"); Ice.ObjectPrx base5 = communicator.stringToProxy("test2"); Ice.ObjectPrx base6 = communicator.stringToProxy("test @ ReplicatedAdapter"); WriteLine("ok"); Write("testing ice_locator and ice_getLocator... "); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0); Ice.LocatorPrx anotherLocator = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("anotherLocator")); @base = @base.ice_locator(anotherLocator); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0); communicator.setDefaultLocator(null); @base = communicator.stringToProxy("test @ TestAdapter"); test(@base.ice_getLocator() == null); @base = @base.ice_locator(anotherLocator); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0); communicator.setDefaultLocator(locator); @base = communicator.stringToProxy("test @ TestAdapter"); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0); // // We also test ice_router/ice_getRouter (perhaps we should add a // test/Ice/router test?) // test(@base.ice_getRouter() == null); Ice.RouterPrx anotherRouter = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("anotherRouter")); @base = @base.ice_router(anotherRouter); test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), anotherRouter) == 0); Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("dummyrouter")); communicator.setDefaultRouter(router); @base = communicator.stringToProxy("test @ TestAdapter"); test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), communicator.getDefaultRouter()) == 0); communicator.setDefaultRouter(null); @base = communicator.stringToProxy("test @ TestAdapter"); test(@base.ice_getRouter() == null); WriteLine("ok"); Write("starting server... "); Flush(); manager.startServer(); WriteLine("ok"); Write("testing checked cast... "); Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(base2); test(obj2 != null); TestIntfPrx obj3 = TestIntfPrxHelper.checkedCast(base3); test(obj3 != null); ServerManagerPrx obj4 = ServerManagerPrxHelper.checkedCast(base4); test(obj4 != null); TestIntfPrx obj5 = TestIntfPrxHelper.checkedCast(base5); test(obj5 != null); TestIntfPrx obj6 = TestIntfPrxHelper.checkedCast(base6); test(obj6 != null); WriteLine("ok"); Write("testing id@AdapterId indirect proxy... "); Flush(); obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing id@ReplicaGroupId indirect proxy... "); Flush(); obj.shutdown(); manager.startServer(); try { obj6.ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing identity indirect proxy... "); Flush(); obj.shutdown(); manager.startServer(); try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj5 = TestIntfPrxHelper.checkedCast(base5); obj5.ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing proxy with unknown identity... "); Flush(); try { @base = communicator.stringToProxy("unknown/unknown"); @base.ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object")); test(ex.id.Equals("unknown/unknown")); } WriteLine("ok"); Write("testing proxy with unknown adapter... "); Flush(); try { @base = communicator.stringToProxy("test @ TestAdapterUnknown"); @base.ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object adapter")); test(ex.id.Equals("TestAdapterUnknown")); } WriteLine("ok"); Write("testing locator cache timeout... "); Flush(); int count = locator.getRequestCount(); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. test(++count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. test(++count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1200); // 1200ms communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. test(++count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. count += 2; test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1200); // 1200ms communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout count += 2; test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(-1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(-1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_ping(); test(count == locator.getRequestCount()); test(communicator.stringToProxy("test").ice_locatorCacheTimeout(99).ice_getLocatorCacheTimeout() == 99); WriteLine("ok"); Write("testing proxy from server... "); Flush(); obj = TestIntfPrxHelper.checkedCast(communicator.stringToProxy("test@TestAdapter")); HelloPrx hello = obj.getHello(); test(hello.ice_getAdapterId().Equals("TestAdapter")); hello.sayHello(); hello = obj.getReplicatedHello(); test(hello.ice_getAdapterId().Equals("ReplicatedAdapter")); hello.sayHello(); WriteLine("ok"); Write("testing locator request queuing... "); Flush(); hello = (HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false); count = locator.getRequestCount(); hello.ice_ping(); test(++count == locator.getRequestCount()); List <Ice.AsyncResult <Test.Callback_Hello_sayHello> > results = new List <Ice.AsyncResult <Test.Callback_Hello_sayHello> >(); for (int i = 0; i < 1000; i++) { Ice.AsyncResult <Test.Callback_Hello_sayHello> result = hello.begin_sayHello(). whenCompleted( () => { }, (Ice.Exception ex) => { test(false); }); results.Add(result); } foreach (Ice.AsyncResult <Test.Callback_Hello_sayHello> result in results) { result.waitForCompleted(); } results.Clear(); test(locator.getRequestCount() > count && locator.getRequestCount() < count + 999); if (locator.getRequestCount() > count + 800) { Write("queuing = " + (locator.getRequestCount() - count)); } count = locator.getRequestCount(); hello = (HelloPrx)hello.ice_adapterId("unknown"); for (int i = 0; i < 1000; i++) { Ice.AsyncResult <Test.Callback_Hello_sayHello> result = hello.begin_sayHello(). whenCompleted( () => { test(false); }, (Ice.Exception ex) => { test(ex is Ice.NotRegisteredException); }); results.Add(result); } foreach (Ice.AsyncResult <Test.Callback_Hello_sayHello> result in results) { result.waitForCompleted(); } results.Clear(); // XXX: // Take into account the retries. test(locator.getRequestCount() > count && locator.getRequestCount() < count + 1999); if (locator.getRequestCount() > count + 800) { Write("queuing = " + (locator.getRequestCount() - count)); } WriteLine("ok"); Write("testing adapter locator cache... "); Flush(); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject == "object adapter"); test(ex.id.Equals("TestAdapter3")); } registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp")); communicator.stringToProxy("test@TestAdapter3").ice_ping(); } catch (Ice.LocalException) { test(false); } try { communicator.stringToProxy("test@TestAdapter3").ice_locatorCacheTimeout(0).ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing well-known object locator cache... "); Flush(); registry.addObject(communicator.stringToProxy("test3@TestUnknown")); try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject == "object adapter"); test(ex.id.Equals("TestUnknown")); } registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } try { communicator.stringToProxy("test@TestAdapter4").ice_locatorCacheTimeout(0).ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test@TestAdapter4").ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.addObject(communicator.stringToProxy("test3@TestAdapter")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } registry.addObject(communicator.stringToProxy("test4")); try { communicator.stringToProxy("test4").ice_ping(); test(false); } catch (Ice.NoEndpointException) { } WriteLine("ok"); Write("testing locator cache background updates... "); Flush(); { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1"); Ice.Communicator ic = Ice.Util.initialize(initData); registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter")); registry.addObject(communicator.stringToProxy("test3@TestAdapter")); count = locator.getRequestCount(); ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. count += 3; test(count == locator.getRequestCount()); registry.setAdapterDirectProxy("TestAdapter5", null); registry.addObject(communicator.stringToProxy("test3:tcp")); ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout. ic.stringToProxy("test3").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout. test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1200); // The following request should trigger the background // updates but still use the cached endpoints and // therefore succeed. ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. try { while (true) { ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. System.Threading.Thread.Sleep(10); } } catch (Ice.LocalException) { // Expected to fail once they endpoints have been updated in the background. } try { while (true) { ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. System.Threading.Thread.Sleep(10); } } catch (Ice.LocalException) { // Expected to fail once they endpoints have been updated in the background. } ic.destroy(); } WriteLine("ok"); Write("testing proxy from server after shutdown... "); Flush(); hello = obj.getReplicatedHello(); obj.shutdown(); manager.startServer(); hello.sayHello(); WriteLine("ok"); Write("testing object migration... "); Flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); hello.sayHello(); obj.migrateHello(); hello.sayHello(); obj.migrateHello(); hello.sayHello(); WriteLine("ok"); Write("testing locator encoding resolution... "); Flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); count = locator.getRequestCount(); communicator.stringToProxy("test@TestAdapter").ice_encodingVersion(Ice.Util.Encoding_1_1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter10").ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); test(++count == locator.getRequestCount()); communicator.stringToProxy("test -e 1.0@TestAdapter10-2").ice_ping(); test(++count == locator.getRequestCount()); WriteLine("ok"); Write("shutdown server... "); Flush(); obj.shutdown(); WriteLine("ok"); Write("testing whether server is gone... "); Flush(); try { obj2.ice_ping(); test(false); } catch (Ice.LocalException) { } try { obj3.ice_ping(); test(false); } catch (Ice.LocalException) { } try { obj5.ice_ping(); test(false); } catch (Ice.LocalException) { } WriteLine("ok"); Write("testing indirect proxies to collocated objects... "); Flush(); // // Set up test for calling a collocated object through an // indirect, adapterless reference. // Ice.Properties properties = communicator.getProperties(); properties.setProperty("Ice.PrintAdapterReady", "0"); Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "tcp -h *"); adapter.setLocator(locator); Ice.Identity id = new Ice.Identity(); id.name = Guid.NewGuid().ToString(); registry.addObject(adapter.add(new HelloI(), id)); adapter.activate(); HelloPrx helloPrx = HelloPrxHelper.checkedCast( communicator.stringToProxy("\"" + communicator.identityToString(id) + "\"")); test(helloPrx.ice_getConnection() == null); adapter.deactivate(); WriteLine("ok"); Write("shutdown server manager... "); Flush(); manager.shutdown(); WriteLine("ok"); }
allTests(TestCommon.Application app, Ice.Communicator communicator2, string rf) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); Ice.ObjectPrx base1 = communicator.stringToProxy(rf); test(base1 != null); Ice.ObjectPrx base2 = communicator.stringToProxy(rf); test(base2 != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); Test.RetryPrx retry1 = Test.RetryPrxHelper.checkedCast(base1); test(retry1 != null); test(retry1.Equals(base1)); Test.RetryPrx retry2 = Test.RetryPrxHelper.checkedCast(base2); test(retry2 != null); test(retry2.Equals(base2)); WriteLine("ok"); Write("calling regular operation with first proxy... "); Flush(); retry1.op(false); WriteLine("ok"); Instrumentation.testInvocationCount(3); Write("calling operation to kill connection with second proxy... "); Flush(); try { retry2.op(true); test(false); } catch (Ice.UnknownLocalException) { // Expected with collocation } catch (Ice.ConnectionLostException) { } Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(1); Instrumentation.testRetryCount(0); WriteLine("ok"); Write("calling regular operation with first proxy again... "); Flush(); retry1.op(false); Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(0); Instrumentation.testRetryCount(0); WriteLine("ok"); Callback cb = new Callback(); Write("calling regular AMI operation with first proxy... "); retry1.begin_op(false).whenCompleted( () => { cb.called(); }, (Ice.Exception ex) => { test(false); }); cb.check(); Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(0); Instrumentation.testRetryCount(0); WriteLine("ok"); Write("calling AMI operation to kill connection with second proxy... "); retry2.begin_op(true).whenCompleted( () => { test(false); }, (Ice.Exception ex) => { test(ex is Ice.ConnectionLostException || ex is Ice.UnknownLocalException); cb.called(); }); cb.check(); Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(1); Instrumentation.testRetryCount(0); WriteLine("ok"); Write("calling regular AMI operation with first proxy again... "); retry1.begin_op(false).whenCompleted( () => { cb.called(); }, (Ice.Exception ex) => { test(false); }); cb.check(); Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(0); Instrumentation.testRetryCount(0); WriteLine("ok"); Write("testing idempotent operation... "); test(retry1.opIdempotent(4) == 4); Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(0); Instrumentation.testRetryCount(4); test(retry1.end_opIdempotent(retry1.begin_opIdempotent(4)) == 4); Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(0); Instrumentation.testRetryCount(4); WriteLine("ok"); Write("testing non-idempotent operation... "); try { retry1.opNotIdempotent(); test(false); } catch (Ice.LocalException) { } Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(1); Instrumentation.testRetryCount(0); try { retry1.end_opNotIdempotent(retry1.begin_opNotIdempotent()); test(false); } catch (Ice.LocalException) { } Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(1); Instrumentation.testRetryCount(0); WriteLine("ok"); if (retry1.ice_getConnection() == null) { Instrumentation.testInvocationCount(1); Write("testing system exception... "); try { retry1.opSystemException(); test(false); } catch (SystemFailure) { } Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(1); Instrumentation.testRetryCount(0); try { retry1.end_opSystemException(retry1.begin_opSystemException()); test(false); } catch (SystemFailure) { } Instrumentation.testInvocationCount(1); Instrumentation.testFailureCount(1); Instrumentation.testRetryCount(0); WriteLine("ok"); } Write("testing invocation timeout and retries... "); Flush(); retry2 = Test.RetryPrxHelper.checkedCast(communicator2.stringToProxy(retry1.ToString())); try { // No more than 2 retries before timeout kicks-in ((Test.RetryPrx)retry2.ice_invocationTimeout(500)).opIdempotent(4); test(false); } catch (Ice.InvocationTimeoutException) { Instrumentation.testRetryCount(2); retry2.opIdempotent(-1); // Reset the counter Instrumentation.testRetryCount(-1); } try { // No more than 2 retries before timeout kicks-in Test.RetryPrx prx = (Test.RetryPrx)retry2.ice_invocationTimeout(500); prx.end_opIdempotent(prx.begin_opIdempotent(4)); test(false); } catch (Ice.InvocationTimeoutException) { Instrumentation.testRetryCount(2); retry2.opIdempotent(-1); // Reset the counter Instrumentation.testRetryCount(-1); } WriteLine("ok"); return(retry1); }
public static void allTests(TestCommon.Application app, List <int> ports) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); string refString = "test"; for (int i = 0; i < ports.Count; i++) { refString += ":" + app.getTestEndpoint(ports[i]); } Ice.ObjectPrx basePrx = communicator.stringToProxy(refString); test(basePrx != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(basePrx); test(obj != null); test(obj.Equals(basePrx)); WriteLine("ok"); if (IceInternal.AssemblyUtil.runtime_ == IceInternal.AssemblyUtil.Runtime.Mono) { WriteLine(""); WriteLine("This test aborts a number of server processes."); WriteLine("Test output may be interspersed with \"killed\" message from the shell."); WriteLine("These messages are expected and do NOT indicate a test failure."); WriteLine(""); } int oldPid = 0; bool ami = false; for (int i = 1, j = 0; i <= ports.Count; ++i, ++j) { if (j > 3) { j = 0; ami = !ami; } if (!ami) { Write("testing server #" + i + "... "); Flush(); int pid = obj.pid(); test(pid != oldPid); WriteLine("ok"); oldPid = pid; } else { Write("testing server #" + i + " with AMI... "); Flush(); Callback cb = new Callback(); int pid = -1; obj.begin_pid().whenCompleted( (int p) => { pid = p; cb.called(); }, (Ice.Exception ex) => { WriteLine(ex.ToString()); test(false); }); cb.check(); test(pid != oldPid); WriteLine("ok"); oldPid = pid; } if (j == 0) { if (!ami) { Write("shutting down server #" + i + "... "); Flush(); obj.shutdown(); WriteLine("ok"); } else { Write("shutting down server #" + i + " with AMI... "); Callback cb = new Callback(); obj.begin_shutdown().whenCompleted( () => { cb.called(); }, (Ice.Exception ex) => { WriteLine(ex.ToString()); test(false); }); cb.check(); WriteLine("ok"); } } else if (j == 1 || i + 1 > ports.Count) { if (!ami) { Write("aborting server #" + i + "... "); Flush(); try { obj.abort(); test(false); } catch (Ice.ConnectionLostException) { WriteLine("ok"); } catch (Ice.ConnectFailedException) { WriteLine("ok"); } catch (Ice.SocketException) { WriteLine("ok"); } } else { Write("aborting server #" + i + " with AMI... "); Flush(); Callback cb = new Callback(); obj.begin_abort().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { exceptAbortI(ex); cb.called(); }); cb.check(); WriteLine("ok"); } } else if (j == 2 || j == 3) { if (!ami) { Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent call... "); Flush(); try { obj.idempotentAbort(); test(false); } catch (Ice.ConnectionLostException) { WriteLine("ok"); } catch (Ice.ConnectFailedException) { WriteLine("ok"); } catch (Ice.SocketException) { WriteLine("ok"); } } else { Write("aborting server #" + i + " and #" + (i + 1) + " with idempotent AMI call... "); Flush(); Callback cb = new Callback(); obj.begin_idempotentAbort().whenCompleted( () => { test(false); }, (Ice.Exception ex) => { exceptAbortI(ex); cb.called(); }); cb.check(); WriteLine("ok"); } ++i; } else { Debug.Assert(false); } } Write("testing whether all servers are gone... "); Flush(); try { obj.ice_ping(); test(false); } catch (Ice.LocalException) { WriteLine("ok"); } }
public static Test.TimeoutPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); string sref = "timeout:" + app.getTestEndpoint(0); Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); Test.TimeoutPrx timeout = Test.TimeoutPrxHelper.checkedCast(obj); test(timeout != null); Write("testing connect timeout... "); Flush(); { // // Expect ConnectTimeoutException. // Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(100)); timeout.holdAdapter(500); try { to.op(); test(false); } catch (Ice.ConnectTimeoutException) { // Expected. } } { // // Expect success. // timeout.op(); // Ensure adapter is active. Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(1000)); timeout.holdAdapter(500); try { to.op(); } catch (Ice.ConnectTimeoutException) { test(false); } } WriteLine("ok"); // The sequence needs to be large enough to fill the write/recv buffers byte[] seq = new byte[2000000]; Write("testing connection timeout... "); Flush(); { // // Expect TimeoutException. // Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(100)); timeout.holdAdapter(500); try { to.sendData(seq); test(false); } catch (Ice.TimeoutException) { // Expected. } } { // // Expect success. // timeout.op(); // Ensure adapter is active. Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_timeout(1000)); timeout.holdAdapter(500); try { to.sendData(new byte[1000000]); } catch (Ice.TimeoutException) { test(false); } } WriteLine("ok"); Write("testing invocation timeout... "); Flush(); { Ice.Connection connection = obj.ice_getConnection(); Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(100)); test(connection == to.ice_getConnection()); try { to.sleep(750); test(false); } catch (Ice.InvocationTimeoutException) { } obj.ice_ping(); to = Test.TimeoutPrxHelper.checkedCast(obj.ice_invocationTimeout(500)); test(connection == to.ice_getConnection()); try { to.sleep(250); } catch (Ice.InvocationTimeoutException) { test(false); } test(connection == to.ice_getConnection()); } { // // Expect InvocationTimeoutException. // Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(100)); Callback cb = new Callback(); to.begin_sleep(750).whenCompleted( () => { test(false); }, (Ice.Exception ex) => { test(ex is Ice.InvocationTimeoutException); cb.called(); }); cb.check(); obj.ice_ping(); } { // // Expect success. // Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(500)); Callback cb = new Callback(); to.begin_sleep(250).whenCompleted( () => { cb.called(); }, (Ice.Exception ex) => { test(false); }); cb.check(); } { // // Backward compatible connection timeouts // Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(obj.ice_invocationTimeout(-2).ice_timeout(250)); Ice.Connection con = to.ice_getConnection(); try { to.sleep(750); test(false); } catch (Ice.TimeoutException) { try { con.getInfo(); test(false); } catch (Ice.TimeoutException) { // Connection got closed as well. } } obj.ice_ping(); try { con = to.ice_getConnection(); to.end_sleep(to.begin_sleep(750)); test(false); } catch (Ice.TimeoutException) { try { con.getInfo(); test(false); } catch (Ice.TimeoutException) { // Connection got closed as well. } } obj.ice_ping(); } WriteLine("ok"); Write("testing close timeout... "); Flush(); { Test.TimeoutPrx to = Test.TimeoutPrxHelper.checkedCast(obj.ice_timeout(100)); Ice.Connection connection = to.ice_getConnection(); timeout.holdAdapter(500); connection.close(Ice.ConnectionClose.GracefullyWithWait); try { connection.getInfo(); // getInfo() doesn't throw in the closing state. } catch (Ice.LocalException) { test(false); } Thread.Sleep(500); try { connection.getInfo(); test(false); } catch (Ice.ConnectionManuallyClosedException ex) { // Expected. test(ex.graceful); } timeout.op(); // Ensure adapter is active. } WriteLine("ok"); Write("testing timeout overrides... "); Flush(); { // // Test Ice.Override.Timeout. This property overrides all // endpoint timeouts. // string[] args = new string[0]; Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.Override.Timeout", "250"); Ice.Communicator comm = Ice.Util.initialize(ref args, initData); Test.TimeoutPrx to = Test.TimeoutPrxHelper.checkedCast(comm.stringToProxy(sref)); timeout.holdAdapter(700); try { to.sendData(seq); test(false); } catch (Ice.TimeoutException) { // Expected. } // // Calling ice_timeout() should have no effect. // timeout.op(); // Ensure adapter is active. to = Test.TimeoutPrxHelper.checkedCast(to.ice_timeout(1000)); timeout.holdAdapter(500); try { to.sendData(seq); test(false); } catch (Ice.TimeoutException) { // Expected. } comm.destroy(); } { // // Test Ice.Override.ConnectTimeout. // string[] args = new string[0]; Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.Override.ConnectTimeout", "250"); Ice.Communicator comm = Ice.Util.initialize(ref args, initData); timeout.holdAdapter(750); Test.TimeoutPrx to = Test.TimeoutPrxHelper.uncheckedCast(comm.stringToProxy(sref)); try { to.op(); test(false); } catch (Ice.ConnectTimeoutException) { // Expected. } // // Calling ice_timeout() should have no effect on the connect timeout. // timeout.op(); // Ensure adapter is active. timeout.holdAdapter(750); to = Test.TimeoutPrxHelper.uncheckedCast(to.ice_timeout(1000)); try { to.op(); test(false); } catch (Ice.ConnectTimeoutException) { // Expected. } // // Verify that timeout set via ice_timeout() is still used for requests. // timeout.op(); // Ensure adapter is active. to = Test.TimeoutPrxHelper.uncheckedCast(to.ice_timeout(250)); to.ice_getConnection(); // Establish connection. timeout.holdAdapter(750); try { to.sendData(seq); test(false); } catch (Ice.TimeoutException) { // Expected. } comm.destroy(); } { // // Test Ice.Override.CloseTimeout. // Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.Override.CloseTimeout", "100"); Ice.Communicator comm = Ice.Util.initialize(initData); comm.stringToProxy(sref).ice_getConnection(); timeout.holdAdapter(800); long begin = System.DateTime.Now.Ticks; comm.destroy(); test(((long)new System.TimeSpan(System.DateTime.Now.Ticks - begin).TotalMilliseconds - begin) < 700); } WriteLine("ok"); Write("testing invocation timeouts with collocated calls... "); Flush(); { communicator.getProperties().setProperty("TimeoutCollocated.AdapterId", "timeoutAdapter"); Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TimeoutCollocated"); adapter.activate(); Test.TimeoutPrx proxy = Test.TimeoutPrxHelper.uncheckedCast(adapter.addWithUUID(new TimeoutI())); proxy = (Test.TimeoutPrx)proxy.ice_invocationTimeout(100); try { proxy.sleep(500); test(false); } catch (Ice.InvocationTimeoutException) { } try { proxy.end_sleep(proxy.begin_sleep(500)); test(false); } catch (Ice.InvocationTimeoutException) { } try { ((Test.TimeoutPrx)proxy.ice_invocationTimeout(-2)).ice_ping(); ((Test.TimeoutPrx)proxy.ice_invocationTimeout(-2)).begin_ice_ping().waitForCompleted(); } catch (Ice.Exception) { test(false); } Test.TimeoutPrx batchTimeout = (Test.TimeoutPrx)proxy.ice_batchOneway(); batchTimeout.ice_ping(); batchTimeout.ice_ping(); batchTimeout.ice_ping(); ((Test.TimeoutPrx)proxy.ice_invocationTimeout(-1)).begin_sleep(300); // Keep the server thread pool busy. try { batchTimeout.ice_flushBatchRequests(); test(false); } catch (Ice.InvocationTimeoutException) { } batchTimeout.ice_ping(); batchTimeout.ice_ping(); batchTimeout.ice_ping(); ((Test.TimeoutPrx)proxy.ice_invocationTimeout(-1)).begin_sleep(300); // Keep the server thread pool busy. try { batchTimeout.end_ice_flushBatchRequests(batchTimeout.begin_ice_flushBatchRequests()); test(false); } catch (Ice.InvocationTimeoutException) { } adapter.destroy(); } WriteLine("ok"); return(timeout); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); string sref = "test:" + app.getTestEndpoint(0); Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj); sref = "testController:" + app.getTestEndpoint(1); obj = communicator.stringToProxy(sref); test(obj != null); Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj); Write("testing dispatcher... "); Flush(); { p.op(); Callback cb = new Callback(); p.begin_op().whenCompleted(cb.response, cb.exception); cb.check(); TestIntfPrx i = (TestIntfPrx)p.ice_adapterId("dummy"); i.begin_op().whenCompleted(cb.exception); cb.check(); // // Expect InvocationTimeoutException. // { Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250)); to.begin_sleep(500).whenCompleted( () => { test(false); }, (Ice.Exception ex) => { test(ex is Ice.InvocationTimeoutException); test(Dispatcher.isDispatcherThread()); cb.called(); }); cb.check(); } testController.holdAdapter(); Test.Callback_TestIntf_opWithPayload resp = cb.payload; Ice.ExceptionCallback excb = cb.ignoreEx; Ice.SentCallback scb = cb.sent; byte[] seq = new byte[10 * 1024]; (new System.Random()).NextBytes(seq); Ice.AsyncResult r; while ((r = p.begin_opWithPayload(seq).whenCompleted(resp, excb).whenSent(scb)).sentSynchronously()) { ; } testController.resumeAdapter(); r.waitForCompleted(); } WriteLine("ok"); Write("testing dispatcher with continuations... "); Flush(); { p.op(); Callback cb = new Callback(); System.Action <Task> continuation = (Task previous) => { try { previous.Wait(); cb.response(); } catch (System.AggregateException ex) { cb.exception((Ice.Exception)ex.InnerException); } }; // We use sleepAsync instead of opAsync to ensure the response isn't received before // we setup the continuation var t = p.sleepAsync(100).ContinueWith(continuation, TaskContinuationOptions.ExecuteSynchronously); t.Wait(); cb.check(); TestIntfPrx i = (TestIntfPrx)p.ice_adapterId("dummy"); i.opAsync().ContinueWith(continuation, TaskContinuationOptions.ExecuteSynchronously).Wait(); cb.check(); // // Expect InvocationTimeoutException. // { Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250)); to.sleepAsync(500).ContinueWith( previous => { try { previous.Wait(); test(false); } catch (System.AggregateException ex) { test(ex.InnerException is Ice.InvocationTimeoutException); test(Dispatcher.isDispatcherThread()); } }, TaskContinuationOptions.ExecuteSynchronously).Wait(); } testController.holdAdapter(); System.Action <Task> continuation2 = (Task previous) => { test(Dispatcher.isDispatcherThread()); try { previous.Wait(); } catch (System.AggregateException ex) { test(ex.InnerException is Ice.CommunicatorDestroyedException); } }; byte[] seq = new byte[10 * 1024]; (new System.Random()).NextBytes(seq); Progress sentSynchronously; do { sentSynchronously = new Progress(); t = p.opWithPayloadAsync(seq, progress: sentSynchronously).ContinueWith(continuation2, TaskContinuationOptions.ExecuteSynchronously); }while(sentSynchronously.getResult()); testController.resumeAdapter(); t.Wait(); } WriteLine("ok"); Write("testing dispatcher with async/await... "); Flush(); p.opAsync().ContinueWith(async previous => // Execute the code below from the Ice client thread pool { await p.opAsync(); test(Dispatcher.isDispatcherThread()); try { TestIntfPrx i = (TestIntfPrx)p.ice_adapterId("dummy"); await i.opAsync(); test(false); } catch (Exception) { test(Dispatcher.isDispatcherThread()); } Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(250)); try { await to.sleepAsync(500); test(false); } catch (Ice.InvocationTimeoutException) { test(Dispatcher.isDispatcherThread()); } }, TaskContinuationOptions.ExecuteSynchronously).Wait(); WriteLine("ok"); p.shutdown(); }
public static TestIntfPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); string sref = "test:" + app.getTestEndpoint(0); Ice.ObjectPrx obj = communicator.stringToProxy(sref); test(obj != null); TestIntfPrx proxy = TestIntfPrxHelper.uncheckedCast(obj); test(proxy != null); Console.Out.Write("testing enum values... "); Console.Out.Flush(); test((int)ByteEnum.benum1 == 0); test((int)ByteEnum.benum2 == 1); test((int)ByteEnum.benum3 == ByteConst1.value); test((int)ByteEnum.benum4 == ByteConst1.value + 1); test((int)ByteEnum.benum5 == ShortConst1.value); test((int)ByteEnum.benum6 == ShortConst1.value + 1); test((int)ByteEnum.benum7 == IntConst1.value); test((int)ByteEnum.benum8 == IntConst1.value + 1); test((int)ByteEnum.benum9 == LongConst1.value); test((int)ByteEnum.benum10 == LongConst1.value + 1); test((int)ByteEnum.benum11 == ByteConst2.value); test((int)ShortEnum.senum1 == 3); test((int)ShortEnum.senum2 == 4); test((int)ShortEnum.senum3 == ByteConst1.value); test((int)ShortEnum.senum4 == ByteConst1.value + 1); test((int)ShortEnum.senum5 == ShortConst1.value); test((int)ShortEnum.senum6 == ShortConst1.value + 1); test((int)ShortEnum.senum7 == IntConst1.value); test((int)ShortEnum.senum8 == IntConst1.value + 1); test((int)ShortEnum.senum9 == LongConst1.value); test((int)ShortEnum.senum10 == LongConst1.value + 1); test((int)ShortEnum.senum11 == ShortConst2.value); test((int)IntEnum.ienum1 == 0); test((int)IntEnum.ienum2 == 1); test((int)IntEnum.ienum3 == ByteConst1.value); test((int)IntEnum.ienum4 == ByteConst1.value + 1); test((int)IntEnum.ienum5 == ShortConst1.value); test((int)IntEnum.ienum6 == ShortConst1.value + 1); test((int)IntEnum.ienum7 == IntConst1.value); test((int)IntEnum.ienum8 == IntConst1.value + 1); test((int)IntEnum.ienum9 == LongConst1.value); test((int)IntEnum.ienum10 == LongConst1.value + 1); test((int)IntEnum.ienum11 == IntConst2.value); test((int)IntEnum.ienum12 == LongConst2.value); test((int)SimpleEnum.red == 0); test((int)SimpleEnum.green == 1); test((int)SimpleEnum.blue == 2); Console.Out.WriteLine("ok"); Console.Out.Write("testing enum streaming... "); Console.Out.Flush(); Ice.OutputStream ostr; byte[] bytes; bool encoding_1_0 = communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0"); ostr = new Ice.OutputStream(communicator); ostr.writeEnum((int)ByteEnum.benum11, (int)ByteEnum.benum11); bytes = ostr.finished(); test(bytes.Length == 1); // ByteEnum should require one byte ostr = new Ice.OutputStream(communicator); ostr.writeEnum((int)ShortEnum.senum11, (int)ShortEnum.senum11); bytes = ostr.finished(); test(bytes.Length == (encoding_1_0 ? 2 : 5)); ostr = new Ice.OutputStream(communicator); ostr.writeEnum((int)IntEnum.ienum11, (int)IntEnum.ienum12); bytes = ostr.finished(); test(bytes.Length == (encoding_1_0 ? 4 : 5)); ostr = new Ice.OutputStream(communicator); ostr.writeEnum((int)SimpleEnum.blue, (int)SimpleEnum.blue); bytes = ostr.finished(); test(bytes.Length == 1); // SimpleEnum should require one byte Console.Out.WriteLine("ok"); Console.Out.Write("testing enum operations... "); Console.Out.Flush(); ByteEnum byteEnum; test(proxy.opByte(ByteEnum.benum1, out byteEnum) == ByteEnum.benum1); test(byteEnum == ByteEnum.benum1); test(proxy.opByte(ByteEnum.benum11, out byteEnum) == ByteEnum.benum11); test(byteEnum == ByteEnum.benum11); ShortEnum shortEnum; test(proxy.opShort(ShortEnum.senum1, out shortEnum) == ShortEnum.senum1); test(shortEnum == ShortEnum.senum1); test(proxy.opShort(ShortEnum.senum11, out shortEnum) == ShortEnum.senum11); test(shortEnum == ShortEnum.senum11); IntEnum intEnum; test(proxy.opInt(IntEnum.ienum1, out intEnum) == IntEnum.ienum1); test(intEnum == IntEnum.ienum1); test(proxy.opInt(IntEnum.ienum11, out intEnum) == IntEnum.ienum11); test(intEnum == IntEnum.ienum11); test(proxy.opInt(IntEnum.ienum12, out intEnum) == IntEnum.ienum12); test(intEnum == IntEnum.ienum12); SimpleEnum s; test(proxy.opSimple(SimpleEnum.green, out s) == SimpleEnum.green); test(s == SimpleEnum.green); Console.Out.WriteLine("ok"); Console.Out.Write("testing enum sequences operations... "); Console.Out.Flush(); { ByteEnum[] b1 = new ByteEnum[11] { ByteEnum.benum1, ByteEnum.benum2, ByteEnum.benum3, ByteEnum.benum4, ByteEnum.benum5, ByteEnum.benum6, ByteEnum.benum7, ByteEnum.benum8, ByteEnum.benum9, ByteEnum.benum10, ByteEnum.benum11 }; ByteEnum[] b2; ByteEnum[] b3 = proxy.opByteSeq(b1, out b2); for (int i = 0; i < b1.Length; ++i) { test(b1[i] == b2[i]); test(b1[i] == b3[i]); } } { ShortEnum[] s1 = new ShortEnum[11] { ShortEnum.senum1, ShortEnum.senum2, ShortEnum.senum3, ShortEnum.senum4, ShortEnum.senum5, ShortEnum.senum6, ShortEnum.senum7, ShortEnum.senum8, ShortEnum.senum9, ShortEnum.senum10, ShortEnum.senum11 }; ShortEnum[] s2; ShortEnum[] s3 = proxy.opShortSeq(s1, out s2); for (int i = 0; i < s1.Length; ++i) { test(s1[i] == s2[i]); test(s1[i] == s3[i]); } } { IntEnum[] i1 = new IntEnum[11] { IntEnum.ienum1, IntEnum.ienum2, IntEnum.ienum3, IntEnum.ienum4, IntEnum.ienum5, IntEnum.ienum6, IntEnum.ienum7, IntEnum.ienum8, IntEnum.ienum9, IntEnum.ienum10, IntEnum.ienum11 }; IntEnum[] i2; IntEnum[] i3 = proxy.opIntSeq(i1, out i2); for (int i = 0; i < i1.Length; ++i) { test(i1[i] == i2[i]); test(i1[i] == i3[i]); } } { SimpleEnum[] s1 = new SimpleEnum[3] { SimpleEnum.red, SimpleEnum.green, SimpleEnum.blue }; SimpleEnum[] s2; SimpleEnum[] s3 = proxy.opSimpleSeq(s1, out s2); for (int i = 0; i < s1.Length; ++i) { test(s1[i] == s2[i]); test(s1[i] == s3[i]); } } Console.Out.WriteLine("ok"); return(proxy); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing communicator operations... "); Flush(); { // // Test: Exercise addAdminFacet, findAdminFacet, removeAdminFacet with a typical configuration. // Ice.InitializationData init = new Ice.InitializationData(); init.properties = Ice.Util.createProperties(); init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); init.properties.setProperty("Ice.Admin.InstanceName", "Test"); Ice.Communicator com = Ice.Util.initialize(init); testFacets(com, true); com.destroy(); } { // // Test: Verify that the operations work correctly in the presence of facet filters. // Ice.InitializationData init = new Ice.InitializationData(); init.properties = Ice.Util.createProperties(); init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); init.properties.setProperty("Ice.Admin.InstanceName", "Test"); init.properties.setProperty("Ice.Admin.Facets", "Properties"); Ice.Communicator com = Ice.Util.initialize(init); testFacets(com, false); com.destroy(); } { // // Test: Verify that the operations work correctly with the Admin object disabled. // Ice.Communicator com = Ice.Util.initialize(); testFacets(com, false); com.destroy(); } { // // Test: Verify that the operations work correctly with Ice.Admin.Enabled=1 // Ice.InitializationData init = new Ice.InitializationData(); init.properties = Ice.Util.createProperties(); init.properties.setProperty("Ice.Admin.Enabled", "1"); Ice.Communicator com = Ice.Util.initialize(init); test(com.getAdmin() == null); Ice.Identity id = Ice.Util.stringToIdentity("test-admin"); try { com.createAdmin(null, id); test(false); } catch (Ice.InitializationException) { } Ice.ObjectAdapter adapter = com.createObjectAdapter(""); test(com.createAdmin(adapter, id) != null); test(com.getAdmin() != null); testFacets(com, true); com.destroy(); } { // // Test: Verify that the operations work correctly when creation of the Admin object is delayed. // Ice.InitializationData init = new Ice.InitializationData(); init.properties = Ice.Util.createProperties(); init.properties.setProperty("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); init.properties.setProperty("Ice.Admin.InstanceName", "Test"); init.properties.setProperty("Ice.Admin.DelayCreation", "1"); Ice.Communicator com = Ice.Util.initialize(init); testFacets(com, true); com.getAdmin(); testFacets(com, true); com.destroy(); } WriteLine("ok"); string @ref = "factory:" + app.getTestEndpoint(0) + " -t 10000"; RemoteCommunicatorFactoryPrx factory = RemoteCommunicatorFactoryPrxHelper.uncheckedCast(communicator.stringToProxy(@ref)); Write("testing process facet... "); Flush(); { // // Test: Verify that Process::shutdown() operation shuts down the communicator. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process"); proc.shutdown(); com.waitForShutdown(); com.destroy(); } WriteLine("ok"); Write("testing properties facet... "); Flush(); { Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Prop1", "1"); props.Add("Prop2", "2"); props.Add("Prop3", "3"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties"); // // Test: PropertiesAdmin::getProperty() // test(pa.getProperty("Prop2").Equals("2")); test(pa.getProperty("Bogus").Equals("")); // // Test: PropertiesAdmin::getProperties() // Dictionary <string, string> pd = pa.getPropertiesForPrefix(""); test(pd.Count == 5); test(pd["Ice.Admin.Endpoints"].Equals("tcp -h 127.0.0.1")); test(pd["Ice.Admin.InstanceName"].Equals("Test")); test(pd["Prop1"].Equals("1")); test(pd["Prop2"].Equals("2")); test(pd["Prop3"].Equals("3")); Dictionary <string, string> changes; // // Test: PropertiesAdmin::setProperties() // Dictionary <string, string> setProps = new Dictionary <string, string>(); setProps.Add("Prop1", "10"); // Changed setProps.Add("Prop2", "20"); // Changed setProps.Add("Prop3", ""); // Removed setProps.Add("Prop4", "4"); // Added setProps.Add("Prop5", "5"); // Added pa.setProperties(setProps); test(pa.getProperty("Prop1").Equals("10")); test(pa.getProperty("Prop2").Equals("20")); test(pa.getProperty("Prop3").Equals("")); test(pa.getProperty("Prop4").Equals("4")); test(pa.getProperty("Prop5").Equals("5")); changes = com.getChanges(); test(changes.Count == 5); test(changes["Prop1"].Equals("10")); test(changes["Prop2"].Equals("20")); test(changes["Prop3"].Equals("")); test(changes["Prop4"].Equals("4")); test(changes["Prop5"].Equals("5")); pa.setProperties(setProps); changes = com.getChanges(); test(changes.Count == 0); com.destroy(); } WriteLine("ok"); Write("testing logger facet... "); Flush(); { Dictionary <String, String> props = new Dictionary <String, String>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("NullLogger", "1"); RemoteCommunicatorPrx com = factory.createCommunicator(props); com.trace("testCat", "trace"); com.warning("warning"); com.error("error"); com.print("print"); Ice.ObjectPrx obj = com.getAdmin(); Ice.LoggerAdminPrx logger = Ice.LoggerAdminPrxHelper.checkedCast(obj, "Logger"); test(logger != null); string prefix = null; // // Get all // Ice.LogMessage[] logMessages = logger.getLog(null, null, -1, out prefix); test(logMessages.Length == 4); test(prefix.Equals("NullLogger")); test(logMessages[0].traceCategory.Equals("testCat") && logMessages[0].message.Equals("trace")); test(logMessages[1].message.Equals("warning")); test(logMessages[2].message.Equals("error")); test(logMessages[3].message.Equals("print")); // // Get only errors and warnings // com.error("error2"); com.print("print2"); com.trace("testCat", "trace2"); com.warning("warning2"); Ice.LogMessageType[] messageTypes = { Ice.LogMessageType.ErrorMessage, Ice.LogMessageType.WarningMessage }; logMessages = logger.getLog(messageTypes, null, -1, out prefix); test(logMessages.Length == 4); test(prefix.Equals("NullLogger")); foreach (var msg in logMessages) { test(msg.type == Ice.LogMessageType.ErrorMessage || msg.type == Ice.LogMessageType.WarningMessage); } // // Get only errors and traces with Cat = "testCat" // com.trace("testCat2", "A"); com.trace("testCat", "trace3"); com.trace("testCat2", "B"); messageTypes = new Ice.LogMessageType[] { Ice.LogMessageType.ErrorMessage, Ice.LogMessageType.TraceMessage }; string[] categories = { "testCat" }; logMessages = logger.getLog(messageTypes, categories, -1, out prefix); test(logMessages.Length == 5); test(prefix.Equals("NullLogger")); foreach (var msg in logMessages) { test(msg.type == Ice.LogMessageType.ErrorMessage || (msg.type == Ice.LogMessageType.TraceMessage && msg.traceCategory.Equals("testCat"))); } // // Same, but limited to last 2 messages (trace3 + error3) // com.error("error3"); logMessages = logger.getLog(messageTypes, categories, 2, out prefix); test(logMessages.Length == 2); test(prefix.Equals("NullLogger")); test(logMessages[0].message.Equals("trace3")); test(logMessages[1].message.Equals("error3")); // // Now, test RemoteLogger // Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("RemoteLoggerAdapter", "tcp -h localhost"); RemoteLoggerI remoteLogger = new RemoteLoggerI(); Ice.RemoteLoggerPrx myProxy = Ice.RemoteLoggerPrxHelper.uncheckedCast(adapter.addWithUUID(remoteLogger)); adapter.activate(); // // No filtering // logMessages = logger.getLog(null, null, -1, out prefix); remoteLogger.checkNextInit(prefix, logMessages); logger.attachRemoteLogger(myProxy, null, null, -1); remoteLogger.wait(1); remoteLogger.checkNextLog(Ice.LogMessageType.TraceMessage, "rtrace", "testCat"); remoteLogger.checkNextLog(Ice.LogMessageType.WarningMessage, "rwarning", ""); remoteLogger.checkNextLog(Ice.LogMessageType.ErrorMessage, "rerror", ""); remoteLogger.checkNextLog(Ice.LogMessageType.PrintMessage, "rprint", ""); com.trace("testCat", "rtrace"); com.warning("rwarning"); com.error("rerror"); com.print("rprint"); remoteLogger.wait(4); test(logger.detachRemoteLogger(myProxy)); test(!logger.detachRemoteLogger(myProxy)); // // Use Error + Trace with "traceCat" filter with 4 limit // logMessages = logger.getLog(messageTypes, categories, 4, out prefix); test(logMessages.Length == 4); remoteLogger.checkNextInit(prefix, logMessages); logger.attachRemoteLogger(myProxy, messageTypes, categories, 4); remoteLogger.wait(1); remoteLogger.checkNextLog(Ice.LogMessageType.TraceMessage, "rtrace2", "testCat"); remoteLogger.checkNextLog(Ice.LogMessageType.ErrorMessage, "rerror2", ""); com.warning("rwarning2"); com.trace("testCat", "rtrace2"); com.warning("rwarning3"); com.error("rerror2"); com.print("rprint2"); remoteLogger.wait(2); // // Attempt reconnection with slightly different proxy // try { logger.attachRemoteLogger(Ice.RemoteLoggerPrxHelper.uncheckedCast(myProxy.ice_oneway()), messageTypes, categories, 4); test(false); } catch (Ice.RemoteLoggerAlreadyAttachedException) { // expected } com.destroy(); } WriteLine("ok"); Write("testing custom facet... "); Flush(); { // // Test: Verify that the custom facet is present. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet"); tf.op(); com.destroy(); } WriteLine("ok"); Write("testing facet filtering... "); Flush(); { // // Test: Set Ice.Admin.Facets to expose only the Properties facet, // meaning no other facet is available. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "Properties"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process"); test(proc == null); TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet"); test(tf == null); com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose only the Process facet, // meaning no other facet is available. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "Process"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties"); test(pa == null); TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet"); test(tf == null); com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose only the TestFacet facet, // meaning no other facet is available. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "TestFacet"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties"); test(pa == null); Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process"); test(proc == null); com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose two facets. Use whitespace to separate the // facet names. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "Properties TestFacet"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties"); test(pa.getProperty("Ice.Admin.InstanceName").Equals("Test")); TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet"); tf.op(); Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process"); test(proc == null); com.destroy(); } { // // Test: Set Ice.Admin.Facets to expose two facets. Use a comma to separate the // facet names. // Dictionary <string, string> props = new Dictionary <string, string>(); props.Add("Ice.Admin.Endpoints", "tcp -h 127.0.0.1"); props.Add("Ice.Admin.InstanceName", "Test"); props.Add("Ice.Admin.Facets", "TestFacet, Process"); RemoteCommunicatorPrx com = factory.createCommunicator(props); Ice.ObjectPrx obj = com.getAdmin(); Ice.PropertiesAdminPrx pa = Ice.PropertiesAdminPrxHelper.checkedCast(obj, "Properties"); test(pa == null); TestFacetPrx tf = TestFacetPrxHelper.checkedCast(obj, "TestFacet"); tf.op(); Ice.ProcessPrx proc = Ice.ProcessPrxHelper.checkedCast(obj, "Process"); proc.shutdown(); com.waitForShutdown(); com.destroy(); } WriteLine("ok"); factory.shutdown(); }
static public int run(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing serialization... "); Flush(); MyInterfacePrx proxy = MyInterfacePrxHelper.uncheckedCast(communicator.stringToProxy("test")); MyException ex, ex2; ex = new MyException(); ex.name = ""; ex.vss = new ValStruct[0]; ex.vsl = new List <ValStruct>(); ex.vsll = new LinkedList <ValStruct>(); ex.vssk = new Stack <ValStruct>(); ex.vsq = new Queue <ValStruct>(); ex.isd = new Dictionary <int, string>(); ex.ivd = new Dictionary <int, ValStruct>(); ex.ipd = null; ex.issd = new SortedDictionary <int, string>(); ex.optName = new Ice.Optional <string>(); ex.optInt = new Ice.Optional <int>(); ex.optValStruct = new Ice.Optional <ValStruct>(); ex.optRefStruct = new Ice.Optional <RefStruct>(); ex.optEnum = new Ice.Optional <MyEnum>(); ex.optClass = new Ice.Optional <MyClass>(); ex.optProxy = new Ice.Optional <MyInterfacePrx>(); ex2 = inOut(ex, communicator); test(ex.Equals(ex2)); ex.name = "MyException"; ex.b = 1; ex.s = 2; ex.i = 3; ex.l = 4; ex.vs = new ValStruct(true, 1, 2, 3, 4, MyEnum.enum2); ex.rs = new RefStruct("RefStruct", "prop", null, proxy, new MyInterfacePrx[] { proxy, null, proxy }); ex.vss = new ValStruct[1]; ex.vss[0] = ex.vs; ex.vsl = new List <ValStruct>(); ex.vsl.Add(ex.vs); ex.vsll = new LinkedList <ValStruct>(); ex.vsll.AddLast(ex.vs); ex.vssk = new Stack <ValStruct>(); ex.vssk.Push(ex.vs); ex.vsq = new Queue <ValStruct>(); ex.vsq.Enqueue(ex.vs); ex.isd = new Dictionary <int, string>(); ex.isd[5] = "five"; ex.ivd = new Dictionary <int, ValStruct>(); ex.ivd[1] = ex.vs; ex.ipd = new Dictionary <int, MyInterfacePrx>() { { 1, proxy }, { 2, null }, { 3, proxy } }; ex.issd = new SortedDictionary <int, string>(); ex.issd[3] = "three"; ex.optName = new Ice.Optional <string>("MyException"); ex.optInt = new Ice.Optional <int>(99); ex.optValStruct = new Ice.Optional <ValStruct>(ex.vs); ex.optRefStruct = new Ice.Optional <RefStruct>(ex.rs); ex.optEnum = new Ice.Optional <MyEnum>(MyEnum.enum3); ex.optClass = new Ice.Optional <MyClass>(null); ex.optProxy = new Ice.Optional <MyInterfacePrx>(proxy); ex2 = inOut(ex, communicator); test(ex.Equals(ex2)); RefStruct rs, rs2; rs = new RefStruct(); rs.s = "RefStruct"; rs.sp = "prop"; rs.c = null; rs.p = MyInterfacePrxHelper.uncheckedCast(communicator.stringToProxy("test")); rs.seq = new MyInterfacePrx[] { rs.p }; rs2 = inOut(rs, communicator); test(rs.Equals(rs2)); Base b, b2; b = new Base(true, 1, 2, 3, 4, MyEnum.enum2); b2 = inOut(b, communicator); test(b2.bo == b.bo); test(b2.by == b.by); test(b2.sh == b.sh); test(b2.i == b.i); test(b2.l == b.l); test(b2.e == b.e); MyClass c, c2; c = new MyClass(true, 1, 2, 3, 4, MyEnum.enum1, null, null, new ValStruct(true, 1, 2, 3, 4, MyEnum.enum2)); c.c = c; c.o = c; c2 = inOut(c, communicator); test(c2.bo == c.bo); test(c2.by == c.by); test(c2.sh == c.sh); test(c2.i == c.i); test(c2.l == c.l); test(c2.e == c.e); test(c2.c == c2); test(c2.o == c2); test(c2.s.Equals(c.s)); WriteLine("ok"); return(0); }
public static InitialPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::B"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::C"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::D"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::E"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::F"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::I"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::J"); communicator.getValueFactoryManager().add(MyValueFactory, "::Test::H"); // Disable Obsolete warning/error #pragma warning disable 612, 618 communicator.addObjectFactory(new MyObjectFactory(), "TestOF"); #pragma warning restore 612, 618 Write("testing stringToProxy... "); Flush(); String @ref = "initial:" + app.getTestEndpoint(0); Ice.ObjectPrx @base = communicator.stringToProxy(@ref); test(@base != null); WriteLine("ok"); Write("testing checked cast... "); Flush(); InitialPrx initial = InitialPrxHelper.checkedCast(@base); test(initial != null); test(initial.Equals(@base)); WriteLine("ok"); Write("getting B1... "); Flush(); B b1 = initial.getB1(); test(b1 != null); WriteLine("ok"); Write("getting B2... "); Flush(); B b2 = initial.getB2(); test(b2 != null); WriteLine("ok"); Write("getting C... "); Flush(); C c = initial.getC(); test(c != null); WriteLine("ok"); Write("getting D... "); Flush(); D d = initial.getD(); test(d != null); WriteLine("ok"); Write("checking consistency... "); Flush(); test(b1 != b2); //test(b1 != c); //test(b1 != d); //test(b2 != c); //test(b2 != d); //test(c != d); test(b1.theB == b1); test(b1.theC == null); test(b1.theA is B); test(((B)b1.theA).theA == b1.theA); test(((B)b1.theA).theB == b1); //test(((B)b1.theA).theC is C); // Redundant -- theC is always of type C test(((C)(((B)b1.theA).theC)).theB == b1.theA); test(b1.preMarshalInvoked); test(b1.postUnmarshalInvoked); test(b1.theA.preMarshalInvoked); test(b1.theA.postUnmarshalInvoked); test(((B)b1.theA).theC.preMarshalInvoked); test(((B)b1.theA).theC.postUnmarshalInvoked); // More tests possible for b2 and d, but I think this is already // sufficient. test(b2.theA == b2); test(d.theC == null); WriteLine("ok"); Write("getting B1, B2, C, and D all at once... "); Flush(); B b1out; B b2out; C cout; D dout; initial.getAll(out b1out, out b2out, out cout, out dout); test(b1out != null); test(b2out != null); test(cout != null); test(dout != null); WriteLine("ok"); Write("checking consistency... "); Flush(); test(b1out != b2out); test(b1out.theA == b2out); test(b1out.theB == b1out); test(b1out.theC == null); test(b2out.theA == b2out); test(b2out.theB == b1out); test(b2out.theC == cout); test(cout.theB == b2out); test(dout.theA == b1out); test(dout.theB == b2out); test(dout.theC == null); test(dout.preMarshalInvoked); test(dout.postUnmarshalInvoked); test(dout.theA.preMarshalInvoked); test(dout.theA.postUnmarshalInvoked); test(dout.theB.preMarshalInvoked); test(dout.theB.postUnmarshalInvoked); test(dout.theB.theC.preMarshalInvoked); test(dout.theB.theC.postUnmarshalInvoked); WriteLine("ok"); Write("testing protected members... "); Flush(); EI e = (EI)initial.getE(); test(e != null && e.checkValues()); System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance; test(!typeof(E).GetField("i", flags).IsPublic&& !typeof(E).GetField("i", flags).IsPrivate); test(!typeof(E).GetField("s", flags).IsPublic&& !typeof(E).GetField("s", flags).IsPrivate); FI f = (FI)initial.getF(); test(f.checkValues()); test(((EI)f.e2).checkValues()); test(!typeof(F).GetField("e1", flags).IsPublic&& !typeof(F).GetField("e1", flags).IsPrivate); test(typeof(F).GetField("e2", flags).IsPublic&& !typeof(F).GetField("e2", flags).IsPrivate); WriteLine("ok"); Write("getting I, J and H... "); Flush(); var i = initial.getI(); test(i != null); var j = initial.getJ(); test(j != null); var h = initial.getH(); test(h != null); WriteLine("ok"); Write("getting D1... "); Flush(); D1 d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4")); d1 = initial.getD1(d1); test(d1.a1.name.Equals("a1")); test(d1.a2.name.Equals("a2")); test(d1.a3.name.Equals("a3")); test(d1.a4.name.Equals("a4")); WriteLine("ok"); Write("throw EDerived... "); Flush(); try { initial.throwEDerived(); test(false); } catch (EDerived ederived) { test(ederived.a1.name.Equals("a1")); test(ederived.a2.name.Equals("a2")); test(ederived.a3.name.Equals("a3")); test(ederived.a4.name.Equals("a4")); } WriteLine("ok"); Write("setting G... "); Flush(); try { initial.setG(new G(new S("hello"), "g")); } catch (Ice.OperationNotExistException) { } WriteLine("ok"); Write("setting I... "); Flush(); initial.setI(i); initial.setI(j); initial.setI(h); WriteLine("ok"); Write("testing sequences..."); Flush(); try { Base[] inS = new Base[0]; Base[] outS; Base[] retS; retS = initial.opBaseSeq(inS, out outS); inS = new Base[1]; inS[0] = new Base(new S(), ""); retS = initial.opBaseSeq(inS, out outS); test(retS.Length == 1 && outS.Length == 1); } catch (Ice.OperationNotExistException) { } WriteLine("ok"); Write("testing recursive type... "); Flush(); Recursive top = new Recursive(); Recursive p = top; int depth = 0; try { for (; depth <= 1000; ++depth) { p.v = new Recursive(); p = p.v; if ((depth < 10 && (depth % 10) == 0) || (depth < 1000 && (depth % 100) == 0) || (depth < 10000 && (depth % 1000) == 0) || (depth % 10000) == 0) { initial.setRecursive(top); } } test(!initial.supportsClassGraphDepthMax()); } catch (Ice.UnknownLocalException) { // Expected marshal exception from the server (max class graph depth reached) } catch (Ice.UnknownException) { // Expected stack overflow from the server (Java only) } initial.setRecursive(new Recursive()); WriteLine("ok"); Write("testing compact ID..."); Flush(); try { test(initial.getCompact() != null); } catch (Ice.OperationNotExistException) { } WriteLine("ok"); Write("testing marshaled results..."); Flush(); b1 = initial.getMB(); test(b1 != null && b1.theB == b1); b1 = initial.getAMDMBAsync().Result; test(b1 != null && b1.theB == b1); WriteLine("ok"); Write("testing UnexpectedObjectException..."); Flush(); @ref = "uoet:" + app.getTestEndpoint(0); @base = communicator.stringToProxy(@ref); test(@base != null); UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrxHelper.uncheckedCast(@base); test(uoet != null); try { uoet.op(); test(false); } catch (Ice.UnexpectedObjectException ex) { test(ex.type.Equals("::Test::AlsoEmpty")); test(ex.expectedType.Equals("::Test::Empty")); } catch (System.Exception ex) { WriteLine(ex.ToString()); test(false); } WriteLine("ok"); // Disable Obsolete warning/error #pragma warning disable 612, 618 Write("testing getting ObjectFactory..."); Flush(); test(communicator.findObjectFactory("TestOF") != null); WriteLine("ok"); Write("testing getting ObjectFactory as ValueFactory..."); Flush(); test(communicator.getValueFactoryManager().find("TestOF") != null); WriteLine("ok"); #pragma warning restore 612, 618 Write("testing partial ice_initialize..."); Flush(); var ib1 = new IBase(); test(ib1.id.Equals("My id")); var id1 = new IDerived(); test(id1.id.Equals("My id")); test(id1.name.Equals("My name")); var id2 = new IDerived2(); test(id2.id.Equals("My id")); var i2 = new I2(); test(i2.called); var s1 = new S1(); // The struct default constructor do not call ice_initialize test(s1.id == 0); s1 = new S1(2); // The id should have the value set by ice_initialize and not 2 test(s1.id == 1); var sc1 = new SC1(); test(sc1.id.Equals("My id")); WriteLine("ok"); return(initial); }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); TestIntfPrx service1 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:" + app.getTestEndpoint(0))); TestIntfPrx service2 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:" + app.getTestEndpoint(1))); TestIntfPrx service3 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:" + app.getTestEndpoint(2))); TestIntfPrx service4 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:" + app.getTestEndpoint(3))); if (service1.getProperty("IceBox.InheritProperties").Equals("")) { Console.Out.Write("testing service properties... "); Console.Out.Flush(); test(service1.getProperty("Ice.ProgramName").Equals("IceBox-Service1")); test(service1.getProperty("Service").Equals("1")); test(service1.getProperty("Service1.Ovrd").Equals("2")); test(service1.getProperty("Service1.Unset").Equals("")); test(service1.getProperty("Arg").Equals("1")); string[] args1 = { "-a", "--Arg=2" }; test(IceUtilInternal.Arrays.Equals(service1.getArgs(), args1)); test(service2.getProperty("Ice.ProgramName").Equals("Test")); test(service2.getProperty("Service").Equals("2")); test(service2.getProperty("Service1.ArgProp").Equals("")); test(service2.getProperty("IceBox.InheritProperties").Equals("1")); string[] args2 = { "--Service1.ArgProp=1" }; test(IceUtilInternal.Arrays.Equals(service2.getArgs(), args2)); Console.Out.WriteLine("ok"); Console.Out.Write("testing with shared communicator... "); Console.Out.Flush(); test(service3.getProperty("Ice.ProgramName").Equals("IceBox-SharedCommunicator")); test(service3.getProperty("Service").Equals("4")); test(service3.getProperty("Prop").Equals("")); test(service3.getProperty("Service3.Prop").Equals("1")); test(service3.getProperty("Ice.Trace.Slicing").Equals("3")); test(service4.getProperty("Ice.ProgramName").Equals("IceBox-SharedCommunicator")); test(service4.getProperty("Service").Equals("4")); test(service4.getProperty("Prop").Equals("")); test(service4.getProperty("Service3.Prop").Equals("1")); test(service4.getProperty("Ice.Trace.Slicing").Equals("3")); string[] args4 = { "--Service3.Prop=2" }; test(IceUtilInternal.Arrays.Equals(service4.getArgs(), args4)); Console.Out.WriteLine("ok"); } else { Console.Out.Write("testing property inheritance... "); Console.Out.Flush(); test(service1.getProperty("Ice.ProgramName").Equals("IceBox2-Service1")); test(service1.getProperty("ServerProp").Equals("1")); test(service1.getProperty("OverrideMe").Equals("2")); test(service1.getProperty("UnsetMe").Equals("")); test(service1.getProperty("Service1.Prop").Equals("1")); test(service1.getProperty("Service1.ArgProp").Equals("2")); test(service2.getProperty("Ice.ProgramName").Equals("IceBox2-SharedCommunicator")); test(service2.getProperty("ServerProp").Equals("1")); test(service2.getProperty("OverrideMe").Equals("3")); test(service2.getProperty("UnsetMe").Equals("")); test(service2.getProperty("Service2.Prop").Equals("1")); Console.Out.WriteLine("ok"); } }