Exemplo n.º 1
0
    public static TestIntfPrx allTests(Ice.Communicator communicator)
#endif
    {
        Write("testing stringToProxy... ");
        Flush();
        string @ref = "asm:default -p 12010";

        Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
        test(@base != null);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base);

        test(obj != null);
        test(obj.Equals(@base));
        WriteLine("ok");

        Write("testing ice_ids... ");
        Flush();
        try
        {
            Ice.ObjectPrx o = communicator.stringToProxy("category/locate:default -p 12010");
            o.ice_ids();
            test(false);
        }
        catch (UnknownUserException ex)
        {
            test(ex.unknown.Equals("::Test::TestIntfUserException"));
        }
        catch (System.Exception)
        {
            test(false);
        }

        try
        {
            Ice.ObjectPrx o = communicator.stringToProxy("category/finished:default -p 12010");
            o.ice_ids();
            test(false);
        }
        catch (UnknownUserException ex)
        {
            test(ex.unknown.Equals("::Test::TestIntfUserException"));
        }
        catch (System.Exception)
        {
            test(false);
        }
        WriteLine("ok");

        Write("testing servant locator...");
        Flush();
        @base = communicator.stringToProxy("category/locate:default -p 12010");
        obj   = TestIntfPrxHelper.checkedCast(@base);
        try
        {
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("category/unknown:default -p 12010"));
        }
        catch (ObjectNotExistException)
        {
        }
        WriteLine("ok");

        Write("testing default servant locator...");
        Flush();
        @base = communicator.stringToProxy("anothercat/locate:default -p 12010");
        obj   = TestIntfPrxHelper.checkedCast(@base);
        @base = communicator.stringToProxy("locate:default -p 12010");
        obj   = TestIntfPrxHelper.checkedCast(@base);
        try
        {
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("anothercat/unknown:default -p 12010"));
        }
        catch (ObjectNotExistException)
        {
        }
        try
        {
            TestIntfPrxHelper.checkedCast(communicator.stringToProxy("unknown:default -p 12010"));
        }
        catch (ObjectNotExistException)
        {
        }
        WriteLine("ok");

        Write("testing locate exceptions... ");
        Flush();
        @base = communicator.stringToProxy("category/locate:default -p 12010");
        obj   = TestIntfPrxHelper.checkedCast(@base);
        testExceptions(obj);
        WriteLine("ok");

        Write("testing finished exceptions... ");
        Flush();
        @base = communicator.stringToProxy("category/finished:default -p 12010");
        obj   = TestIntfPrxHelper.checkedCast(@base);
        testExceptions(obj);

        //
        // Only call these for category/finished.
        //
        try
        {
            obj.asyncResponse();
        }
        catch (TestIntfUserException)
        {
            test(false);
        }
        catch (TestImpossibleException)
        {
            //
            // Called by finished().
            //
        }

        //
        // Only call these for category/finished.
        //
        try
        {
            obj.asyncException();
        }
        catch (TestIntfUserException)
        {
            test(false);
        }
        catch (TestImpossibleException)
        {
            //
            // Called by finished().
            //
        }

        WriteLine("ok");

        Write("testing servant locator removal... ");
        Flush();
        @base = communicator.stringToProxy("test/activation:default -p 12010");
        TestActivationPrx activation = TestActivationPrxHelper.checkedCast(@base);

        activation.activateServantLocator(false);
        try
        {
            obj.ice_ping();
            test(false);
        }
        catch (ObjectNotExistException)
        {
            WriteLine("ok");
        }
        Write("testing servant locator addition... ");
        Flush();
        activation.activateServantLocator(true);
        try
        {
            obj.ice_ping();
            WriteLine("ok");
        }
        catch (System.Exception)
        {
            test(false);
        }
#if SILVERLIGHT
        obj.shutdown();
#else
        return(obj);
#endif
    }