Пример #1
0
        public virtual TestI createUnboundedTestInteger()
        {
            TestI value_Renamed = new TestI();

            value_Renamed.Value = 0xFAFBFC;
            return(value_Renamed);
        }
Пример #2
0
 public override int run(string[] args)
 {
     Ice.Properties properties = communicator().getProperties();
     properties.setProperty("Ice.Warn.Dispatch", "0");
     properties.setProperty("TestAdapter.Endpoints", getTestEndpoint(0) + " -t 2000");
     Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter");
     Ice.Object        @object = new TestI();
     adapter.add(@object, Ice.Util.stringToIdentity("Test"));
     adapter.activate();
     communicator().waitForShutdown();
     return(0);
 }
Пример #3
0
 private static int run(string[] args, Ice.Communicator communicator)
 {
     Ice.Properties properties = communicator.getProperties();
     properties.setProperty("Ice.Warn.Dispatch", "0");
     properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 2000");
     Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
     Ice.Object obj = new TestI();
     adapter.add(obj, communicator.stringToIdentity("Test"));
     adapter.activate();
     communicator.waitForShutdown();
     return 0;
 }
Пример #4
0
 private static int run(string[] args, Ice.Communicator communicator)
 {
     Ice.Properties properties = communicator.getProperties();
     properties.setProperty("Ice.Warn.Dispatch", "0");
     properties.setProperty("TestAdapter.Endpoints", "default -p 12010 -t 2000");
     Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
     Ice.Object        @object = new TestI();
     adapter.add(@object, communicator.stringToIdentity("Test"));
     adapter.activate();
     communicator.waitForShutdown();
     return(0);
 }
Пример #5
0
    private static int run(string[] args, Ice.Communicator communicator)
    {
        int port = 0;

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i][0] == '-')
            {
                System.Console.Error.WriteLine("Server: unknown option `" + args[i] + "'");
                usage();
                return(1);
            }

            if (port != 0)
            {
                System.Console.Error.WriteLine("Server: only one port can be specified");
                usage();
                return(1);
            }

            try
            {
                port = System.Int32.Parse(args[i]);
            }
            catch (System.FormatException)
            {
                System.Console.Error.WriteLine("Server: invalid port");
                usage();
                return(1);
            }
        }

        if (port <= 0)
        {
            System.Console.Error.WriteLine("Server: no port specified");
            usage();
            return(1);
        }

        communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p " + port + ":udp");
        Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
        Ice.Object        obj     = new TestI();
        adapter.add(obj, communicator.stringToIdentity("test"));
        adapter.activate();
        communicator.waitForShutdown();
        return(0);
    }
Пример #6
0
    public override int run(string[] args)
    {
        int port = 0;

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i][0] == '-')
            {
                Console.Error.WriteLine("Server: unknown option `" + args[i] + "'");
                usage();
                return(1);
            }

            if (port != 0)
            {
                Console.Error.WriteLine("Server: only one port can be specified");
                usage();
                return(1);
            }

            try
            {
                port = int.Parse(args[i]);
            }
            catch (FormatException)
            {
                Console.Error.WriteLine("Server: invalid port");
                usage();
                return(1);
            }
        }

        if (port <= 0)
        {
            Console.Error.WriteLine("Server: no port specified");
            usage();
            return(1);
        }

        communicator().getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(port));
        Ice.ObjectAdapter adapter = communicator().createObjectAdapter("TestAdapter");
        Ice.Object        obj     = new TestI();
        adapter.add(obj, Ice.Util.stringToIdentity("test"));
        adapter.activate();
        communicator().waitForShutdown();
        return(0);
    }
Пример #7
0
    private static int run(string[] args, Ice.Communicator communicator)
    {
        int port = 0;
        for(int i = 0; i < args.Length; i++)
        {
            if(args[i][0] == '-')
            {
                System.Console.Error.WriteLine("Server: unknown option `" + args[i] + "'");
                usage();
                return 1;
            }

            if(port != 0)
            {
                System.Console.Error.WriteLine("Server: only one port can be specified");
                usage();
                return 1;
            }

            try
            {
                port = System.Int32.Parse(args[i]);
            }
            catch(System.FormatException)
            {
                System.Console.Error.WriteLine("Server: invalid port");
                usage();
                return 1;
            }
        }

        if(port <= 0)
        {
            System.Console.Error.WriteLine("Server: no port specified");
            usage();
            return 1;
        }

        communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p " + port + ":udp");
        Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
        Ice.Object obj = new TestI();
        adapter.add(obj, communicator.stringToIdentity("test"));
        adapter.activate();
        communicator.waitForShutdown();
        return 0;
    }
Пример #8
0
    public override void run(string[] args)
    {
        Ice.Properties properties = createTestProperties(ref args);
        properties.setProperty("Ice.ServerIdleTime", "120");
        int port = 0;

        for (int i = 0; i < args.Length; i++)
        {
            if (args[i][0] == '-')
            {
                throw new ArgumentException("Server: unknown option `" + args[i] + "'");
            }

            if (port != 0)
            {
                throw new ArgumentException("Server: only one port can be specified");
            }

            try
            {
                port = int.Parse(args[i]);
            }
            catch (FormatException)
            {
                throw new ArgumentException("Server: invalid port");
            }
        }

        if (port <= 0)
        {
            throw new ArgumentException("Server: no port specified");
        }

        using (var communicator = initialize(properties))
        {
            communicator.getProperties().setProperty("TestAdapter.Endpoints", getTestEndpoint(port));
            Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
            Ice.Object        obj     = new TestI();
            adapter.add(obj, Ice.Util.stringToIdentity("test"));
            adapter.activate();
            communicator.waitForShutdown();
        }
    }
Пример #9
0
    public override void startServer(Ice.Current current)
    {
        foreach (Ice.Communicator c in _communicators)
        {
            c.waitForShutdown();
            c.destroy();
        }
        _communicators.Clear();

        //
        // Simulate a server: create a new communicator and object
        // adapter. The object adapter is started on a system allocated
        // port. The configuration used here contains the Ice.Locator
        // configuration variable. The new object adapter will register
        // its endpoints with the locator and create references containing
        // the adapter id instead of the endpoints.
        //
        Ice.Communicator serverCommunicator = Ice.Util.initialize(_initData);
        _communicators.Add(serverCommunicator);

        //
        // Use fixed port to ensure that OA re-activation doesn't re-use previous port from
        // another OA (e.g.: TestAdapter2 is re-activated using port of TestAdapter).
        //
        serverCommunicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p " + _nextPort++);
        serverCommunicator.getProperties().setProperty("TestAdapter2.Endpoints", "default -p " + _nextPort++);

        Ice.ObjectAdapter adapter  = serverCommunicator.createObjectAdapter("TestAdapter");
        Ice.ObjectAdapter adapter2 = serverCommunicator.createObjectAdapter("TestAdapter2");

        Ice.ObjectPrx locator = serverCommunicator.stringToProxy("locator:default -p 12010");
        adapter.setLocator(Ice.LocatorPrxHelper.uncheckedCast(locator));
        adapter2.setLocator(Ice.LocatorPrxHelper.uncheckedCast(locator));

        Ice.Object @object = new TestI(adapter, adapter2, _registry);
        _registry.addObject(adapter.add(@object, Ice.Util.stringToIdentity("test")));
        _registry.addObject(adapter.add(@object, Ice.Util.stringToIdentity("test2")));
        adapter.add(@object, Ice.Util.stringToIdentity("test3"));

        adapter.activate();
        adapter2.activate();
    }
Пример #10
0
    public override void startServer(Ice.Current current)
    {
        foreach(Ice.Communicator c in _communicators)
        {
            c.waitForShutdown();
            c.destroy();
        }
        _communicators.Clear();

        //
        // Simulate a server: create a new communicator and object
        // adapter. The object adapter is started on a system allocated
        // port. The configuration used here contains the Ice.Locator
        // configuration variable. The new object adapter will register
        // its endpoints with the locator and create references containing
        // the adapter id instead of the endpoints.
        //
        Ice.Communicator serverCommunicator = Ice.Util.initialize(_initData);
        _communicators.Add(serverCommunicator);

        //
        // Use fixed port to ensure that OA re-activation doesn't re-use previous port from
        // another OA (e.g.: TestAdapter2 is re-activated using port of TestAdapter).
        //
        serverCommunicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p " + _nextPort++);
        serverCommunicator.getProperties().setProperty("TestAdapter2.Endpoints", "default -p " + _nextPort++);

        Ice.ObjectAdapter adapter = serverCommunicator.createObjectAdapter("TestAdapter");
        Ice.ObjectAdapter adapter2 = serverCommunicator.createObjectAdapter("TestAdapter2");
        
        Ice.ObjectPrx locator = serverCommunicator.stringToProxy("locator:default -p 12010");
        adapter.setLocator(Ice.LocatorPrxHelper.uncheckedCast(locator));
        adapter2.setLocator(Ice.LocatorPrxHelper.uncheckedCast(locator));
        
        Ice.Object @object = new TestI(adapter, adapter2, _registry);
        _registry.addObject(adapter.add(@object, serverCommunicator.stringToIdentity("test")));
        _registry.addObject(adapter.add(@object, serverCommunicator.stringToIdentity("test2")));
        adapter.add(@object, serverCommunicator.stringToIdentity("test3"));

        adapter.activate();
        adapter2.activate();
    }
Пример #11
0
            public Disp locate(Current current, out object cookie)
            {
                lock (this)
                {
                    test(!_deactivated);
                }

                test(current.Id.category.Equals(_category) || _category.Length == 0);

                if (current.Id.name.Equals("unknown"))
                {
                    cookie = null;
                    return(null);
                }

                if (current.Id.name.Equals("invalidReturnValue") || current.Id.name.Equals("invalidReturnType"))
                {
                    cookie = null;
                    return(null);
                }

                test(current.Id.name.Equals("locate") || current.Id.name.Equals("finished"));
                if (current.Id.name.Equals("locate"))
                {
                    exception(current);
                }

                //
                // Ensure locate() is only called once per request.
                //
                test(_requestId == -1);
                _requestId = current.RequestId;

                cookie = new Cookie();

                TestI          testI = new TestI();
                TestIntfTraits testT = default;

                return((current, incoming) => testT.Dispatch(testI, current, incoming));
            }
Пример #12
0
            public Ice.Disp locate(Current current, out object cookie)
            {
                lock (this)
                {
                    test(!_deactivated);
                }

                if (current.id.name.Equals("router"))
                {
                    cookie = null;
                    RouterTraits routerT = default;
                    return((incoming, current) => routerT.Dispatch(_router, incoming, current));
                }

                test(current.id.category.Length == 0);
                test(current.id.name.Equals("test"));

                cookie = new Cookie();

                var testT = default(Test.TestIntfTraits);
                var testI = new TestI();

                return((incoming, current) => testT.Dispatch(testI, incoming, current));
            }
Пример #13
0
    public override void startServer(Ice.Current current)
    {
        foreach (Ice.Communicator c in _communicators)
        {
            c.waitForShutdown();
            c.destroy();
        }
        _communicators.Clear();

        //
        // Simulate a server: create a new communicator and object
        // adapter. The object adapter is started on a system allocated
        // port. The configuration used here contains the Ice.Locator
        // configuration variable. The new object adapter will register
        // its endpoints with the locator and create references containing
        // the adapter id instead of the endpoints.
        //
        Ice.Communicator serverCommunicator = Ice.Util.initialize(_initData);
        _communicators.Add(serverCommunicator);

        //
        // Use fixed port to ensure that OA re-activation doesn't re-use previous port from
        // another OA (e.g.: TestAdapter2 is re-activated using port of TestAdapter).
        //
        int nRetry = 10;

        while (--nRetry > 0)
        {
            Ice.ObjectAdapter adapter  = null;
            Ice.ObjectAdapter adapter2 = null;
            try
            {
                serverCommunicator.getProperties().setProperty("TestAdapter.Endpoints",
                                                               _app.getTestEndpoint(_nextPort++));
                serverCommunicator.getProperties().setProperty("TestAdapter2.Endpoints",
                                                               _app.getTestEndpoint(_nextPort++));

                adapter  = serverCommunicator.createObjectAdapter("TestAdapter");
                adapter2 = serverCommunicator.createObjectAdapter("TestAdapter2");

                Ice.ObjectPrx locator = serverCommunicator.stringToProxy("locator:" + _app.getTestEndpoint(0));
                adapter.setLocator(Ice.LocatorPrxHelper.uncheckedCast(locator));
                adapter2.setLocator(Ice.LocatorPrxHelper.uncheckedCast(locator));

                Ice.Object @object = new TestI(adapter, adapter2, _registry);
                _registry.addObject(adapter.add(@object, Ice.Util.stringToIdentity("test")));
                _registry.addObject(adapter.add(@object, Ice.Util.stringToIdentity("test2")));
                adapter.add(@object, Ice.Util.stringToIdentity("test3"));

                adapter.activate();
                adapter2.activate();
                break;
            }
            catch (Ice.SocketException ex)
            {
                if (nRetry == 0)
                {
                    throw ex;
                }

                // Retry, if OA creation fails with EADDRINUSE (this can occur when running with JS web
                // browser clients if the driver uses ports in the same range as this test, ICE-8148)
                if (adapter != null)
                {
                    adapter.destroy();
                }
                if (adapter2 != null)
                {
                    adapter2.destroy();
                }
            }
        }
    }
Пример #14
0
            public void startServer(Ice.Current current)
            {
                foreach (Ice.Communicator c in _communicators)
                {
                    c.waitForShutdown();
                    c.destroy();
                }
                _communicators.Clear();

                //
                // Simulate a server: create a new communicator and object
                // adapter. The object adapter is started on a system allocated
                // port. The configuration used here contains the Ice.Locator
                // configuration variable. The new object adapter will register
                // its endpoints with the locator and create references containing
                // the adapter id instead of the endpoints.
                //
                Ice.InitializationData initData = new Ice.InitializationData();
                initData.properties = _helper.communicator().Properties.Clone();
                initData.properties.setProperty("TestAdapter.AdapterId", "TestAdapter");
                initData.properties.setProperty("TestAdapter.ReplicaGroupId", "ReplicatedAdapter");
                initData.properties.setProperty("TestAdapter2.AdapterId", "TestAdapter2");

                Ice.Communicator serverCommunicator = _helper.initialize(initData);
                _communicators.Add(serverCommunicator);

                //
                // Use fixed port to ensure that OA re-activation doesn't re-use previous port from
                // another OA(e.g.: TestAdapter2 is re-activated using port of TestAdapter).
                //
                int nRetry = 10;

                while (--nRetry > 0)
                {
                    ObjectAdapter?adapter  = null;
                    ObjectAdapter?adapter2 = null;
                    try
                    {
                        serverCommunicator.Properties.setProperty("TestAdapter.Endpoints",
                                                                  _helper.getTestEndpoint(_nextPort++));
                        serverCommunicator.Properties.setProperty("TestAdapter2.Endpoints",
                                                                  _helper.getTestEndpoint(_nextPort++));

                        adapter  = serverCommunicator.createObjectAdapter("TestAdapter");
                        adapter2 = serverCommunicator.createObjectAdapter("TestAdapter2");

                        var locator = LocatorPrx.Parse($"locator:{_helper.getTestEndpoint(0)}", serverCommunicator);
                        adapter.SetLocator(locator);
                        adapter2.SetLocator(locator);

                        var testI = new TestI(adapter, adapter2, _registry);
                        _registry.addObject(adapter.Add(testI, "test"));
                        _registry.addObject(adapter.Add(testI, "test2"));
                        adapter.Add(testI, "test3");

                        adapter.Activate();
                        adapter2.Activate();
                        break;
                    }
                    catch (Ice.SocketException ex)
                    {
                        if (nRetry == 0)
                        {
                            throw ex;
                        }

                        // Retry, if OA creation fails with EADDRINUSE(this can occur when running with JS web
                        // browser clients if the driver uses ports in the same range as this test, ICE-8148)
                        if (adapter != null)
                        {
                            adapter.Destroy();
                        }
                        if (adapter2 != null)
                        {
                            adapter2.Destroy();
                        }
                    }
                }
            }