diff options
Diffstat (limited to 'csharp/test/Ice/binding')
-rw-r--r-- | csharp/test/Ice/binding/AllTests.cs | 21 | ||||
-rw-r--r-- | csharp/test/Ice/binding/Client.cs | 36 | ||||
-rw-r--r-- | csharp/test/Ice/binding/RemoteCommunicatorI.cs | 15 | ||||
-rw-r--r-- | csharp/test/Ice/binding/Server.cs | 52 | ||||
-rw-r--r-- | csharp/test/Ice/binding/msbuild/server/server.csproj | 3 | ||||
-rwxr-xr-x | csharp/test/Ice/binding/run.py | 24 |
6 files changed, 44 insertions, 107 deletions
diff --git a/csharp/test/Ice/binding/AllTests.cs b/csharp/test/Ice/binding/AllTests.cs index de76daa74f8..edd2e316928 100644 --- a/csharp/test/Ice/binding/AllTests.cs +++ b/csharp/test/Ice/binding/AllTests.cs @@ -12,7 +12,7 @@ using System.Collections.Generic; using System.Diagnostics; using Test; -public class AllTests : TestCommon.TestApp +public class AllTests : TestCommon.AllTests { private static string getAdapterNameWithAMI(TestIntfPrx testIntf) { @@ -89,9 +89,10 @@ public class AllTests : TestCommon.TestApp } }; - public static void allTests(Ice.Communicator communicator) + public static void allTests(TestCommon.Application app) { - string @ref = "communicator:default -p 12010"; + 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)); @@ -840,19 +841,21 @@ public class AllTests : TestCommon.TestApp clientProps.Add(bothPreferIPv4); clientProps.Add(bothPreferIPv6); + string endpoint = "tcp -p " + app.getTestPort(2).ToString(); + Ice.Properties anyipv4 = ipv4.ice_clone_(); - anyipv4.setProperty("Adapter.Endpoints", "tcp -p 12012"); - anyipv4.setProperty("Adapter.PublishedEndpoints", "tcp -h 127.0.0.1 -p 12012"); + 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", "tcp -p 12012"); - anyipv6.setProperty("Adapter.PublishedEndpoints", "tcp -h \".1\" -p 12012"); + 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", "tcp -p 12012"); - anyboth.setProperty("Adapter.PublishedEndpoints", "tcp -h \"::1\" -p 12012:tcp -h 127.0.0.1 -p 12012"); + 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"); diff --git a/csharp/test/Ice/binding/Client.cs b/csharp/test/Ice/binding/Client.cs index 7c7b51e3b37..fcc80eedcff 100644 --- a/csharp/test/Ice/binding/Client.cs +++ b/csharp/test/Ice/binding/Client.cs @@ -16,43 +16,17 @@ using System.Reflection; [assembly: AssemblyDescription("Ice test")] [assembly: AssemblyCompany("ZeroC, Inc.")] -public class Client +public class Client : TestCommon.Application { - private static int run(string[] args, Ice.Communicator communicator) + public override int run(string[] args) { - AllTests.allTests(communicator); + AllTests.allTests(this); return 0; } public static int Main(string[] args) { - int status = 0; - Ice.Communicator communicator = null; - - try - { - communicator = Ice.Util.initialize(ref args); - status = run(args, communicator); - } - catch(System.Exception ex) - { - System.Console.Error.WriteLine(ex.ToString()); - status = 1; - } - - if(communicator != null) - { - try - { - communicator.destroy(); - } - catch(Ice.LocalException ex) - { - System.Console.Error.WriteLine(ex); - status = 1; - } - } - - return status; + Client app = new Client(); + return app.runmain(args); } } diff --git a/csharp/test/Ice/binding/RemoteCommunicatorI.cs b/csharp/test/Ice/binding/RemoteCommunicatorI.cs index 7c9ffc15479..ed33ad23ce6 100644 --- a/csharp/test/Ice/binding/RemoteCommunicatorI.cs +++ b/csharp/test/Ice/binding/RemoteCommunicatorI.cs @@ -11,17 +11,19 @@ using Test; public class RemoteCommunicatorI : RemoteCommunicatorDisp_ { + + public RemoteCommunicatorI(TestCommon.Application app) + { + _app = app; + } + public override RemoteObjectAdapterPrx createObjectAdapter(string name, string endpts, Ice.Current current) { string endpoints = endpts; if(endpoints.IndexOf("-p") < 0) { - // Use a fixed port if none is specified (bug 2896) - endpoints += " -h \"" + - (current.adapter.getCommunicator().getProperties().getPropertyWithDefault( - "Ice.Default.Host", "127.0.0.1")) + - "\" -p " + _nextPort++; + endpoints = _app.getTestEndpoint(_nextPort++, endpoints); } Ice.Communicator com = current.adapter.getCommunicator(); @@ -43,5 +45,6 @@ public class RemoteCommunicatorI : RemoteCommunicatorDisp_ current.adapter.getCommunicator().shutdown(); } - private int _nextPort = 10001; + private TestCommon.Application _app; + private int _nextPort = 10; }; diff --git a/csharp/test/Ice/binding/Server.cs b/csharp/test/Ice/binding/Server.cs index f427698fbd3..04fea198ac2 100644 --- a/csharp/test/Ice/binding/Server.cs +++ b/csharp/test/Ice/binding/Server.cs @@ -16,52 +16,30 @@ using System.Reflection; [assembly: AssemblyDescription("Ice test")] [assembly: AssemblyCompany("ZeroC, Inc.")] -public class Server +public class Server : TestCommon.Application { - private static int run(string[] args, Ice.Communicator communicator) + public override int run(string[] args) { - communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010:udp"); - Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); + communicator().getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0) + ":udp"); + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); Ice.Identity id = Ice.Util.stringToIdentity("communicator"); - adapter.add(new RemoteCommunicatorI(), id); + adapter.add(new RemoteCommunicatorI(this), id); adapter.activate(); - communicator.waitForShutdown(); + communicator().waitForShutdown(); return 0; } - public static int Main(string[] args) + protected override Ice.InitializationData getInitData(ref string[] args) { - int status = 0; - Ice.Communicator communicator = null; - - try - { - Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = Ice.Util.createProperties(ref args); - initData.properties.setProperty("Ice.ServerIdleTime", "30"); - communicator = Ice.Util.initialize(ref args, initData); - status = run(args, communicator); - } - catch(Exception ex) - { - System.Console.Error.WriteLine(ex); - status = 1; - } - - if(communicator != null) - { - try - { - communicator.destroy(); - } - catch(Ice.LocalException ex) - { - Console.Error.WriteLine(ex); - status = 1; - } - } + Ice.InitializationData initData = base.getInitData(ref args); + initData.properties.setProperty("Ice.ServerIdleTime", "30"); + return initData; + } - return status; + public static int Main(string[] args) + { + Server app = new Server(); + return app.runmain(args); } } diff --git a/csharp/test/Ice/binding/msbuild/server/server.csproj b/csharp/test/Ice/binding/msbuild/server/server.csproj index 6b8d8e6a658..c0ff88ad39b 100644 --- a/csharp/test/Ice/binding/msbuild/server/server.csproj +++ b/csharp/test/Ice/binding/msbuild/server/server.csproj @@ -34,6 +34,9 @@ <Folder Include="Properties\" /> </ItemGroup> <ItemGroup> + <Compile Include="..\..\..\..\TestCommon\TestApp.cs"> + <Link>TestApp.cs</Link> + </Compile> <Compile Include="..\..\RemoteCommunicatorI.cs"> <Link>RemoteCommunicatorI.cs</Link> </Compile> diff --git a/csharp/test/Ice/binding/run.py b/csharp/test/Ice/binding/run.py deleted file mode 100755 index bfec815018d..00000000000 --- a/csharp/test/Ice/binding/run.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -# ********************************************************************** -# -# Copyright (c) 2003-2016 ZeroC, Inc. All rights reserved. -# -# This copy of Ice is licensed to you under the terms described in the -# ICE_LICENSE file included in this distribution. -# -# ********************************************************************** - -import os, sys, getopt - -path = [ ".", "..", "../..", "../../..", "../../../.." ] -head = os.path.dirname(sys.argv[0]) -if len(head) > 0: - path = [os.path.join(head, p) for p in path] -path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] -if len(path) == 0: - raise RuntimeError("can't find toplevel directory!") -sys.path.append(os.path.join(path[0], "scripts")) -import TestUtil - -TestUtil.queueClientServerTest() -TestUtil.runQueuedTests() |