diff options
author | Benoit Foucher <benoit@zeroc.com> | 2016-11-25 13:13:22 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2016-11-25 13:13:22 +0100 |
commit | dcdc32af1fced49d80a8ccd93230e15d91ab45d8 (patch) | |
tree | eb69e2555fbd54496fce8a33f4dd610e1473ff51 /csharp/test/Ice/background/Server.cs | |
parent | C# IceSSL/configuration log expired certificate exceptions. (diff) | |
download | ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.bz2 ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.tar.xz ice-dcdc32af1fced49d80a8ccd93230e15d91ab45d8.zip |
Refactored test scripts
Diffstat (limited to 'csharp/test/Ice/background/Server.cs')
-rw-r--r-- | csharp/test/Ice/background/Server.cs | 93 |
1 files changed, 35 insertions, 58 deletions
diff --git a/csharp/test/Ice/background/Server.cs b/csharp/test/Ice/background/Server.cs index 2e1dcb3b7f7..f387b8a8729 100644 --- a/csharp/test/Ice/background/Server.cs +++ b/csharp/test/Ice/background/Server.cs @@ -18,7 +18,7 @@ using System.Threading.Tasks; [assembly: AssemblyDescription("Ice test")] [assembly: AssemblyCompany("ZeroC, Inc.")] -public class Server +public class Server : TestCommon.Application { internal class LocatorI : Ice.LocatorDisp_ { @@ -77,25 +77,29 @@ public class Server private BackgroundControllerI _controller; } - public static int run(string[] args, Ice.Communicator communicator, TextWriter @out) + public override int run(string[] args) { + PluginI plugin = new PluginI(communicator()); + plugin.initialize(); + communicator().getPluginManager().addPlugin("Test", plugin); + // // When running as a MIDlet the properties for the server may be // overridden by configuration. If it isn't then we assume // defaults. // - if(communicator.getProperties().getProperty("TestAdapter.Endpoints").Length == 0) + if(communicator().getProperties().getProperty("TestAdapter.Endpoints").Length == 0) { - communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010"); + communicator().getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(0)); } - if(communicator.getProperties().getProperty("ControllerAdapter.Endpoints").Length == 0) + if(communicator().getProperties().getProperty("ControllerAdapter.Endpoints").Length == 0) { - communicator.getProperties().setProperty("ControllerAdapter.Endpoints", "tcp -p 12011"); - communicator.getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1"); + communicator().getProperties().setProperty("ControllerAdapter.Endpoints", getTestEndpoint(1, "tcp")); + communicator().getProperties().setProperty("ControllerAdapter.ThreadPool.Size", "1"); } - Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter"); - Ice.ObjectAdapter adapter2 = communicator.createObjectAdapter("ControllerAdapter"); + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter"); + Ice.ObjectAdapter adapter2 = communicator().createObjectAdapter("ControllerAdapter"); BackgroundControllerI backgroundController = new BackgroundControllerI(adapter); @@ -107,63 +111,36 @@ public class Server adapter2.add(backgroundController, Ice.Util.stringToIdentity("backgroundController")); adapter2.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); - - // - // This test kills connections, so we don't want warnings. - // - initData.properties.setProperty("Ice.Warn.Connections", "0"); + Ice.InitializationData initData = base.getInitData(ref args); - initData.properties.setProperty("Ice.MessageSizeMax", "50000"); - - // This test relies on filling the TCP send/recv buffer, so - // we rely on a fixed value for these buffers. - initData.properties.setProperty("Ice.TCP.RcvSize", "50000"); + // + // This test kills connections, so we don't want warnings. + // + initData.properties.setProperty("Ice.Warn.Connections", "0"); - // - // Setup the test transport plug-in. - // - string defaultProtocol = initData.properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); - initData.properties.setProperty("Ice.Default.Protocol", "test-" + defaultProtocol); + initData.properties.setProperty("Ice.MessageSizeMax", "50000"); - communicator = Ice.Util.initialize(ref args, initData); - PluginI plugin = new PluginI(communicator); - plugin.initialize(); - communicator.getPluginManager().addPlugin("Test", plugin); + // This test relies on filling the TCP send/recv buffer, so + // we rely on a fixed value for these buffers. + initData.properties.setProperty("Ice.TCP.RcvSize", "50000"); - status = run(args, communicator, Console.Out); - } - catch(System.Exception ex) - { - Console.Error.WriteLine(ex); - status = 1; - } - - if(communicator != null) - { - try - { - communicator.destroy(); - } - catch(Ice.LocalException ex) - { - Console.Error.WriteLine(ex); - status = 1; - } - } + // + // Setup the test transport plug-in. + // + string defaultProtocol = initData.properties.getPropertyWithDefault("Ice.Default.Protocol", "tcp"); + initData.properties.setProperty("Ice.Default.Protocol", "test-" + defaultProtocol); + return initData; + } - return status; + public static int Main(string[] args) + { + Server app = new Server(); + return app.runmain(args); } } |