Beispiel #1
0
            public static void testExceptions(Test.TestIntfPrx obj)
            {
                try
                {
                    obj.requestFailedException();
                    test(false);
                }
                catch (Ice.ObjectNotExistException ex)
                {
                    test(ex.id.Equals(obj.ice_getIdentity()));
                    test(ex.facet.Equals(obj.ice_getFacet()));
                    test(ex.operation.Equals("requestFailedException"));
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.unknownUserException();
                    test(false);
                }
                catch (Ice.UnknownUserException ex)
                {
                    test(ex.unknown.Equals("reason"));
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.unknownLocalException();
                    test(false);
                }
                catch (Ice.UnknownLocalException ex)
                {
                    test(ex.unknown.Equals("reason"));
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.unknownException();
                    test(false);
                }
                catch (Ice.UnknownException ex)
                {
                    test(ex.unknown.Equals("reason"));
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.userException();
                    test(false);
                }
                catch (Ice.UnknownUserException ex)
                {
                    //Console.Error.WriteLine(ex.unknown);
                    test(ex.unknown.IndexOf("Test::TestIntfUserException") >= 0);
                }
                catch (Ice.OperationNotExistException)
                {
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.localException();
                    test(false);
                }
                catch (Ice.UnknownLocalException ex)
                {
                    test(ex.unknown.IndexOf("Ice::SocketException") >= 0 ||
                         ex.unknown.IndexOf("Ice.SocketException") >= 0);
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.csException();
                    test(false);
                }
                catch (Ice.UnknownException ex)
                {
                    test(ex.unknown.IndexOf("System.Exception") >= 0);
                }
                catch (Ice.OperationNotExistException)
                {
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.unknownExceptionWithServantException();
                    test(false);
                }
                catch (Ice.UnknownException ex)
                {
                    test(ex.unknown.Equals("reason"));
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.impossibleException(false);
                    test(false);
                }
                catch (Ice.UnknownUserException)
                {
                    // Operation doesn't throw, but locate() and finished() throw TestIntfUserException.
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.impossibleException(true);
                    test(false);
                }
                catch (Ice.UnknownUserException)
                {
                    // Operation throws TestImpossibleException, but locate() and finished() throw TestIntfUserException.
                }
                catch (Exception)
                {
                    test(false);
                }

                try
                {
                    obj.intfUserException(false);
                    test(false);
                }
                catch (Test.TestImpossibleException)
                {
                    // Operation doesn't throw, but locate() and finished() throw TestImpossibleException.
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    test(false);
                }

                try
                {
                    obj.intfUserException(true);
                    test(false);
                }
                catch (Test.TestImpossibleException)
                {
                    // Operation throws TestIntfUserException, but locate() and finished() throw TestImpossibleException.
                }
                catch (Exception)
                {
                    test(false);
                }
            }