Example #1
0
    public static void allTests(Ice.Communicator communicator)
#endif
    {
        string sref = "test:default -p 12010";

        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj);

        sref = "testController:tcp -p 12011";
        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();

            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();
    }
Example #2
0
 public Ice.AsyncResult whenCompleted(Ice.ExceptionCallback cb)
 {
     if (cb == null)
     {
         throw new System.ArgumentException("callback is null");
     }
     lock (this)
     {
         if (exceptionCallback_ != null)
         {
             throw new System.ArgumentException("callback already set");
         }
         exceptionCallback_ = cb;
     }
     setCompletedCallback(getCompletedCallback());
     return(this);
 }
Example #3
0
 whenCompleted(Ice.Callback_Object_ice_getConnection cb, Ice.ExceptionCallback excb)
 {
     if (cb == null && excb == null)
     {
         throw new System.ArgumentException("callback is null");
     }
     lock (this)
     {
         if (_responseCallback != null || exceptionCallback_ != null)
         {
             throw new System.ArgumentException("callback already set");
         }
         _responseCallback  = cb;
         exceptionCallback_ = excb;
     }
     setCompletedCallback(getCompletedCallback());
     return(this);
 }
Example #4
0
        private void PlaceFoup_completed__(Ice.AsyncResult r__, MCS.Callback_MESLink_PlaceFoup cb__, Ice.ExceptionCallback excb__)
        {
            int ret__;

            try
            {
                ret__ = end_PlaceFoup(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }
Example #5
0
 private void getBitmap_completed__(Ice.AsyncResult r__, Streamer.Callback_BitmapProvider_getBitmap cb__, Ice.ExceptionCallback excb__)
 {
     byte[] ret__;
     try
     {
         ret__ = end_getBitmap(r__);
     }
     catch (Ice.Exception ex__)
     {
         if (excb__ != null)
         {
             excb__(ex__);
         }
         return;
     }
     if (cb__ != null)
     {
         cb__(ret__);
     }
 }
Example #6
0
    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();
    }
 private void Send_completed__(Ice.AsyncResult r__, NProgDistributed.TheIce.Callback_IMessageService_Send cb__, Ice.ExceptionCallback excb__)
 {
     NProgDistributed.TheIce.MessageDto ret__;
     try
     {
         ret__ = end_Send(r__);
     }
     catch (Ice.Exception ex__)
     {
         if (excb__ != null)
         {
             excb__(ex__);
         }
         return;
     }
     if (cb__ != null)
     {
         cb__(ret__);
     }
 }
Example #8
0
        private void toUpper_completed__(Ice.AsyncResult r__, Example.Callback_Converter_toUpper cb__, Ice.ExceptionCallback excb__)
        {
            string ret__;

            try
            {
                ret__ = end_toUpper(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }
Example #9
0
    public static void allTests(Test.TestHelper helper)
    {
        var output = helper.getWriter();

        Ice.Communicator communicator = helper.communicator();
        string           sref         = "test:" + helper.getTestEndpoint(0);

        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfPrx p = Test.TestIntfPrxHelper.uncheckedCast(obj);

        sref = "testController:" + helper.getTestEndpoint(1);
        obj  = communicator.stringToProxy(sref);
        test(obj != null);

        Test.TestIntfControllerPrx testController = Test.TestIntfControllerPrxHelper.uncheckedCast(obj);

        output.Write("testing dispatcher... ");
        output.Flush();
        {
            p.op();

            Callback cb = new Callback(output);
            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(10));
                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();
        }
        output.WriteLine("ok");

        output.Write("testing dispatcher with continuations... ");
        output.Flush();
        {
            p.op();

            Callback             cb           = new Callback(output);
            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(500).ContinueWith(continuation, TaskContinuationOptions.ExecuteSynchronously);
            t.Wait();
            cb.check();

            var i = (TestIntfPrx)p.ice_adapterId("dummy");

            //
            // sleepAsync doesn't help here as the test will fail with Ice.NoEndpointException and sleepAsync
            // will not be called.
            //
            //i.sleepAsync(500).ContinueWith(continuation, TaskContinuationOptions.ExecuteSynchronously).Wait();
            //cb.check();

            //
            // Expect InvocationTimeoutException.
            //
            {
                Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(20));
                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();
            }

            //
            // Repeat using the proxy scheduler in this case we don't need to call sleepAsync, continuations
            // are waranted to run with the dispatcher even if not executed synchronously.
            //

            t = p.opAsync().ContinueWith(continuation, p.ice_scheduler());
            t.Wait();
            cb.check();

            i.opAsync().ContinueWith(continuation, i.ice_scheduler()).Wait();
            cb.check();

            //
            // Expect InvocationTimeoutException.
            //
            {
                Test.TestIntfPrx to = Test.TestIntfPrxHelper.uncheckedCast(p.ice_invocationTimeout(10));
                to.sleepAsync(500).ContinueWith(
                    previous =>
                {
                    try
                    {
                        previous.Wait();
                        test(false);
                    }
                    catch (System.AggregateException ex)
                    {
                        test(ex.InnerException is Ice.InvocationTimeoutException);
                        test(Dispatcher.isDispatcherThread());
                    }
                }, p.ice_scheduler()).Wait();
            }

            //
            // Hold adapter to ensure the invocations don't complete synchronously
            // Also disable collocation optimization on p
            //
            testController.holdAdapter();
            var p2 = Test.TestIntfPrxHelper.uncheckedCast(p.ice_collocationOptimized(false));
            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 = p2.opWithPayloadAsync(seq, progress: sentSynchronously).ContinueWith(
                    continuation2,
                    TaskContinuationOptions.ExecuteSynchronously);
            }while(sentSynchronously.getResult());
            testController.resumeAdapter();
            t.Wait();
        }
        output.WriteLine("ok");

        output.Write("testing dispatcher with async/await... ");
        output.Flush();
        {
            TaskCompletionSource <object> t = new TaskCompletionSource <object>();
            p.opAsync().ContinueWith(async previous => // Execute the code below from the Ice client thread pool
            {
                try
                {
                    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(10));
                    try
                    {
                        await to.sleepAsync(500);
                        test(false);
                    }
                    catch (Ice.InvocationTimeoutException)
                    {
                        test(Dispatcher.isDispatcherThread());
                    }
                    t.SetResult(null);
                }
                catch (Exception ex)
                {
                    t.SetException(ex);
                }
            }, p.ice_scheduler());

            t.Task.Wait();
        }
        output.WriteLine("ok");

        p.shutdown();
    }
Example #10
0
        private void SendData_completed__(Ice.AsyncResult r__, IRPC.Callback_NMServer_SendData cb__, Ice.ExceptionCallback excb__)
        {
            int ret__;

            try
            {
                ret__ = end_SendData(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }
Example #11
0
    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();
    }
Example #12
0
 new public Ice.AsyncResult <Ice.Callback_Object_ice_getConnection> whenCompleted(Ice.ExceptionCallback excb)
 {
     base.whenCompleted(excb);
     return(this);
 }
Example #13
0
        private void helloWorld_completed__(Ice.AsyncResult r__, Streamer.Callback_BitmapProvider_helloWorld cb__, Ice.ExceptionCallback excb__)
        {
            string ret__;

            try
            {
                ret__ = end_helloWorld(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }
Example #14
0
        private void WriteLogInit_completed__(Ice.AsyncResult r__, IRPC.Callback_LogServer_RPC_WriteLogInit cb__, Ice.ExceptionCallback excb__)
        {
            bool ret__;

            try
            {
                ret__ = end_WriteLogInit(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }
Example #15
0
        private void Move_completed__(Ice.AsyncResult r__, MCS.Callback_FoupMove_Move cb__, Ice.ExceptionCallback excb__)
        {
            int ret__;

            try
            {
                ret__ = end_Move(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }
Example #16
0
 public Ice.AsyncResult whenCompleted(Ice.ExceptionCallback cb)
 {
     if(cb == null)
     {
         throw new System.ArgumentException("callback is null");
     }
     lock(this)
     {
         if(exceptionCallback_ != null)
         {
             throw new System.ArgumentException("callback already set");
         }
         exceptionCallback_ = cb;
     }
     setCompletedCallback(getCompletedCallback());
     return this;
 }
Example #17
0
        private void TransDataFromClient_completed__(Ice.AsyncResult r__, IRPC.Callback_CSTransDataFromClient_TransDataFromClient cb__, Ice.ExceptionCallback excb__)
        {
            int ret__;

            try
            {
                ret__ = end_TransDataFromClient(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }
Example #18
0
        private void send_completed__(Ice.AsyncResult r__, FaceRecognitionModule.Callback_FaceRecognition_send cb__, Ice.ExceptionCallback excb__)
        {
            string ret__;

            try
            {
                ret__ = end_send(r__);
            }
            catch (Ice.Exception ex__)
            {
                if (excb__ != null)
                {
                    excb__(ex__);
                }
                return;
            }
            if (cb__ != null)
            {
                cb__(ret__);
            }
        }