Beispiel #1
0
    private static int run(string[] args, Ice.Communicator communicator)
    {
        communicator.addValueFactory(MyValueFactory, "::Test::I");
        communicator.addValueFactory(MyValueFactory, "::Test::J");
        communicator.addValueFactory(MyValueFactory, "::Test::H");

        communicator.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010");
        Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter");
        Ice.Object @object = new InitialI(adapter);
        adapter.add(@object, communicator.stringToIdentity("initial"));
        @object = new UnexpectedObjectExceptionTestI();
        adapter.add(@object, communicator.stringToIdentity("uoet"));
        adapter.activate();
        communicator.waitForShutdown();
        return 0;
    }
Beispiel #2
0
    static public int run(Ice.Communicator communicator)
#endif
    {
        MyClassFactoryWrapper factoryWrapper = new MyClassFactoryWrapper();

        communicator.addValueFactory(factoryWrapper.create, Test.MyClass.ice_staticId());
        communicator.addValueFactory(MyInterfaceFactory, Test.MyInterfaceDisp_.ice_staticId());

        Ice.InputStream @in;
        Ice.OutputStream @out;

        Write("testing primitive types... ");
        Flush();

        {
            byte[] data = new byte[0];
            @in = Ice.Util.createInputStream(communicator, data);
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.startEncapsulation();
            @out.writeBool(true);
            @out.endEncapsulation();
            byte[] data = @out.finished();
            @out.destroy();

            @in = Ice.Util.createInputStream(communicator, data);
            @in.startEncapsulation();
            test(@in.readBool());
            @in.endEncapsulation();
            @in.destroy();

            @in = Ice.Util.wrapInputStream(communicator, data);
            @in.startEncapsulation();
            test(@in.readBool());
            @in.endEncapsulation();
            @in.destroy();
        }

        {
            byte[] data = new byte[0];
            @in = Ice.Util.createInputStream(communicator, data);
            try
            {
                @in.readBool();
                test(false);
            }
            catch (Ice.UnmarshalOutOfBoundsException)
            {
            }
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeBool(true);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readBool());
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeByte((byte)1);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readByte() == (byte)1);
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeShort((short)2);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readShort() == (short)2);
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeInt(3);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readInt() == 3);
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeLong(4);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readLong() == 4);
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeFloat((float)5.0);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readFloat() == (float)5.0);
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeDouble(6.0);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readDouble() == 6.0);
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeString("hello world");
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(@in.readString().Equals("hello world"));
            @out.destroy();
            @in.destroy();
        }

        WriteLine("ok");

        Write("testing constructed types... ");
        Flush();

        {
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyEnumHelper.write(@out, Test.MyEnum.enum3);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            test(Test.MyEnumHelper.read(@in) == Test.MyEnum.enum3);
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Test.SmallStruct s = new Test.SmallStruct();
            s.bo = true;
            s.by = (byte)1;
            s.sh = (short)2;
            s.i = 3;
            s.l = 4;
            s.f = (float)5.0;
            s.d = 6.0;
            s.str = "7";
            s.e = Test.MyEnum.enum2;
            s.p = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
            s.ice_write(@out);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.SmallStruct s2 = new Test.SmallStruct();
            s2.ice_read(@in);
            test(s2.Equals(s));
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            OptionalClass o = new OptionalClass();
            o.bo = true;
            o.by = (byte)5;
            o.sh = 4;
            o.i = 3;
            @out.writeObject(o);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            TestReadObjectCallback cb = new TestReadObjectCallback();
            @in.readObject(cb);
            @in.readPendingObjects();
            OptionalClass o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            if(communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0"))
            {
                test(!o2.sh.HasValue);
                test(!o2.i.HasValue);
            }
            else
            {
                test(o2.sh.Value == o.sh.Value);
                test(o2.i.Value == o.i.Value);
            }
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator, Ice.Util.Encoding_1_0);
            OptionalClass o = new OptionalClass();
            o.bo = true;
            o.by = 5;
            o.sh = 4;
            o.i = 3;
            @out.writeObject(o);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data, Ice.Util.Encoding_1_0);
            TestReadObjectCallback cb = new TestReadObjectCallback();
            @in.readObject(cb);
            @in.readPendingObjects();
            OptionalClass o2 = (OptionalClass)cb.obj;
            test(o2.bo == o.bo);
            test(o2.by == o.by);
            test(!o2.sh.HasValue);
            test(!o2.i.HasValue);
            @out.destroy();
            @in.destroy();
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.BoolSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            bool[] arr2 = Ice.BoolSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            bool[][] arrS =
            {
                arr,
                new bool[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.BoolSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            bool[][] arr2S = Test.BoolSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        {
            byte[] arr =
            {
                (byte)0x01,
                (byte)0x11,
                (byte)0x12,
                (byte)0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.ByteSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            byte[] arr2 = Ice.ByteSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            byte[][] arrS =
            {
                arr,
                new byte[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.ByteSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            byte[][] arr2S = Test.ByteSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

#if !COMPACT && !SILVERLIGHT
        {
            Serialize.Small small = new Serialize.Small();
            small.i = 99;
            @out = Ice.Util.createOutputStream(communicator);
            @out.writeSerializable(small);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Serialize.Small small2 = (Serialize.Small)@in.readSerializable();
            test(small2.i == 99);
            @out.destroy();
            @in.destroy();
        }
#endif

        {
            short[] arr =
            {
                (short)0x01,
                (short)0x11,
                (short)0x12,
                (short)0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.ShortSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            short[] arr2 = Ice.ShortSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            short[][] arrS =
            {
                arr,
                new short[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.ShortSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            short[][] arr2S = Test.ShortSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.IntSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            int[] arr2 = Ice.IntSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            int[][] arrS =
            {
                arr,
                new int[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.IntSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            int[][] arr2S = Test.IntSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        {
            long[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.LongSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            long[] arr2 = Ice.LongSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            long[][] arrS =
            {
                arr,
                new long[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.LongSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            long[][] arr2S = Test.LongSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        {
            float[] arr =
            {
                (float)1,
                (float)2,
                (float)3,
                (float)4
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.FloatSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            float[] arr2 = Ice.FloatSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            float[][] arrS =
            {
                arr,
                new float[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.FloatSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            float[][] arr2S = Test.FloatSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        {
            double[] arr =
            {
                (double)1,
                (double)2,
                (double)3,
                (double)4
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.DoubleSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            double[] arr2 = Ice.DoubleSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            double[][] arrS =
            {
                arr,
                new double[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.DoubleSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            double[][] arr2S = Test.DoubleSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = Ice.Util.createOutputStream(communicator);
            Ice.StringSeqHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            string[] arr2 = Ice.StringSeqHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.StringSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            string[][] arr2S = Test.StringSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyEnumSHelper.write(@out, arr);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.MyEnum[] arr2 = Test.MyEnumSHelper.read(@in);
            test(Compare(arr2, arr));
            @out.destroy();
            @in.destroy();

            Test.MyEnum[][] arrS =
            {
                arr,
                new Test.MyEnum[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyEnumSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.MyEnum[][] arr2S = Test.MyEnumSSHelper.read(@in);
            test(Compare(arr2S, arrS));
            @out.destroy();
            @in.destroy();
        }

        Test.SmallStruct[] smallStructArray = new Test.SmallStruct[3];
        for (int i = 0; i < smallStructArray.Length; ++i)
        {
            smallStructArray[i] = new Test.SmallStruct();
            smallStructArray[i].bo = true;
            smallStructArray[i].by = (byte)1;
            smallStructArray[i].sh = (short)2;
            smallStructArray[i].i = 3;
            smallStructArray[i].l = 4;
            smallStructArray[i].f = (float)5.0;
            smallStructArray[i].d = 6.0;
            smallStructArray[i].str = "7";
            smallStructArray[i].e = Test.MyEnum.enum2;
            smallStructArray[i].p = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("test:default"));
        }

        Test.MyClass[] myClassArray = new Test.MyClass[4];
        for (int i = 0; i < myClassArray.Length; ++i)
        {
            myClassArray[i] = new Test.MyClass();
            myClassArray[i].c = myClassArray[i];
            myClassArray[i].o = myClassArray[i];
            myClassArray[i].s = new Test.SmallStruct();
            myClassArray[i].s.e = Test.MyEnum.enum2;
            myClassArray[i].seq1 = new bool[] { true, false, true, false };
            myClassArray[i].seq2 = new byte[] { (byte)1, (byte)2, (byte)3, (byte)4 };
            myClassArray[i].seq3 = new short[] { (short)1, (short)2, (short)3, (short)4 };
            myClassArray[i].seq4 = new int[] { 1, 2, 3, 4 };
            myClassArray[i].seq5 = new long[] { 1, 2, 3, 4 };
            myClassArray[i].seq6 = new float[] { (float)1, (float)2, (float)3, (float)4 };
            myClassArray[i].seq7 = new double[] { (double)1, (double)2, (double)3, (double)4 };
            myClassArray[i].seq8 = new string[] { "string1", "string2", "string3", "string4" };
            myClassArray[i].seq9 = new Test.MyEnum[] { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1 };
            myClassArray[i].seq10 = new Test.MyClass[4]; // null elements.
            myClassArray[i].d = new System.Collections.Generic.Dictionary<string, Test.MyClass>();
            myClassArray[i].d["hi"] = myClassArray[i];
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyClassSHelper.write(@out, myClassArray);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.MyClass[] arr2 = Test.MyClassSHelper.read(@in);
            @in.readPendingObjects();
            test(arr2.Length == myClassArray.Length);
            for (int i = 0; i < arr2.Length; ++i)
            {
                test(arr2[i] != null);
                test(arr2[i].c == arr2[i]);
                test(arr2[i].o == arr2[i]);
                test(arr2[i].s.e == Test.MyEnum.enum2);
                test(Compare(arr2[i].seq1, myClassArray[i].seq1));
                test(Compare(arr2[i].seq2, myClassArray[i].seq2));
                test(Compare(arr2[i].seq3, myClassArray[i].seq3));
                test(Compare(arr2[i].seq4, myClassArray[i].seq4));
                test(Compare(arr2[i].seq5, myClassArray[i].seq5));
                test(Compare(arr2[i].seq6, myClassArray[i].seq6));
                test(Compare(arr2[i].seq7, myClassArray[i].seq7));
                test(Compare(arr2[i].seq8, myClassArray[i].seq8));
                test(Compare(arr2[i].seq9, myClassArray[i].seq9));
                test(arr2[i].d["hi"].Equals(arr2[i]));
            }
            @out.destroy();
            @in.destroy();

            Test.MyClass[][] arrS =
            {
                myClassArray,
                new Test.MyClass[0],
                myClassArray
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyClassSSHelper.write(@out, arrS);
            data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.MyClass[][] arr2S = Test.MyClassSSHelper.read(@in);
            test(arr2S.Length == arrS.Length);
            test(arr2S[0].Length == arrS[0].Length);
            test(arr2S[1].Length == arrS[1].Length);
            test(arr2S[2].Length == arrS[2].Length);
            @out.destroy();
            @in.destroy();
        }

        {
            Test.MyInterface i = new MyInterfaceI();
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyInterfaceHelper.write(@out, i);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.MyInterfaceHelper helper = new Test.MyInterfaceHelper(@in);
            helper.read();
            @in.readPendingObjects();
            test(helper.value != null);
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyClass obj = new Test.MyClass();
            obj.s = new Test.SmallStruct();
            obj.s.e = Test.MyEnum.enum2;
            TestObjectWriter writer = new TestObjectWriter(obj);
            @out.writeObject(writer);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            test(writer.called);
            factoryWrapper.setFactory(TestObjectFactory);
            @in = Ice.Util.createInputStream(communicator, data);
            TestReadObjectCallback cb = new TestReadObjectCallback();
            @in.readObject(cb);
            @in.readPendingObjects();
            test(cb.obj != null);
            test(cb.obj is TestObjectReader);
            TestObjectReader reader = (TestObjectReader)cb.obj;
            test(reader.called);
            test(reader.obj != null);
            test(reader.obj.s.e == Test.MyEnum.enum2);
            @out.destroy();
            @in.destroy();
            factoryWrapper.setFactory(null);
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyException ex = new Test.MyException();

            Test.MyClass c = new Test.MyClass();
            c.c = c;
            c.o = c;
            c.s = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum2;
            c.seq1 = new bool[] { true, false, true, false };
            c.seq2 = new byte[] { (byte)1, (byte)2, (byte)3, (byte)4 };
            c.seq3 = new short[] { (short)1, (short)2, (short)3, (short)4 };
            c.seq4 = new int[] { 1, 2, 3, 4 };
            c.seq5 = new long[] { 1, 2, 3, 4 };
            c.seq6 = new float[] { (float)1, (float)2, (float)3, (float)4 };
            c.seq7 = new double[] { (double)1, (double)2, (double)3, (double)4 };
            c.seq8 = new string[] { "string1", "string2", "string3", "string4" };
            c.seq9 = new Test.MyEnum[] { Test.MyEnum.enum3, Test.MyEnum.enum2, Test.MyEnum.enum1 };
            c.seq10 = new Test.MyClass[4]; // null elements.
            c.d = new Dictionary<string, Test.MyClass>();
            c.d.Add("hi", c);

            ex.c = c;

            @out.writeException(ex);
            byte[] data = @out.finished();

            @in = Ice.Util.createInputStream(communicator, data);
            try
            {
                @in.throwException();
                test(false);
            }
            catch (Test.MyException ex1)
            {
                test(ex1.c.s.e == c.s.e);
                test(Compare(ex1.c.seq1, c.seq1));
                test(Compare(ex1.c.seq2, c.seq2));
                test(Compare(ex1.c.seq3, c.seq3));
                test(Compare(ex1.c.seq4, c.seq4));
                test(Compare(ex1.c.seq5, c.seq5));
                test(Compare(ex1.c.seq6, c.seq6));
                test(Compare(ex1.c.seq7, c.seq7));
                test(Compare(ex1.c.seq8, c.seq8));
                test(Compare(ex1.c.seq9, c.seq9));
            }
            catch (Ice.UserException)
            {
                test(false);
            }
        }

        {
            Dictionary<byte, bool> dict = new Dictionary<byte, bool>();
            dict.Add((byte)4, true);
            dict.Add((byte)1, false);
            @out = Ice.Util.createOutputStream(communicator);
            Test.ByteBoolDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Dictionary<byte, bool> dict2 = Test.ByteBoolDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<short, int> dict = new Dictionary<short, int>();
            dict.Add((short)1, 9);
            dict.Add((short)4, 8);
            @out = Ice.Util.createOutputStream(communicator);
            Test.ShortIntDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Dictionary<short, int> dict2 = Test.ShortIntDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<long, float> dict = new Dictionary<long, float>();
            dict.Add((long)123809828, (float)0.51f);
            dict.Add((long)123809829, (float)0.56f);
            @out = Ice.Util.createOutputStream(communicator);
            Test.LongFloatDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Dictionary<long, float> dict2 = Test.LongFloatDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<string, string> dict = new Dictionary<string, string>();
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            @out = Ice.Util.createOutputStream(communicator);
            Test.StringStringDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Dictionary<string, string> dict2 = Test.StringStringDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Dictionary<string, Test.MyClass> dict = new Dictionary<string, Test.MyClass>();
            Test.MyClass c;
            c = new Test.MyClass();
            c.s = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum2;
            dict.Add("key1", c);
            c = new Test.MyClass();
            c.s = new Test.SmallStruct();
            c.s.e = Test.MyEnum.enum3;
            dict.Add("key2", c);
            @out = Ice.Util.createOutputStream(communicator);
            Test.StringMyClassDHelper.write(@out, dict);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Dictionary<string, Test.MyClass> dict2 = Test.StringMyClassDHelper.read(@in);
            @in.readPendingObjects();
            test(dict2.Count == dict.Count);
            test(dict2["key1"].s.e == Test.MyEnum.enum2);
            test(dict2["key2"].s.e == Test.MyEnum.enum3);
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = Ice.Util.createOutputStream(communicator);
            List<bool> l = new List<bool>(arr);
            Test.BoolListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            List<bool> l2 = Test.BoolListHelper.read(@in);
            test(Compare(l, l2));
            @out.destroy();
            @in.destroy();
        }

        {
            byte[] arr =
            {
                (byte)0x01,
                (byte)0x11,
                (byte)0x12,
                (byte)0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            List<byte> l = new List<byte>(arr);
            Test.ByteListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            List<byte> l2 = Test.ByteListHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = Ice.Util.createOutputStream(communicator);
            List<Test.MyEnum> l = new List<Test.MyEnum>(arr);
            Test.MyEnumListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            List<Test.MyEnum> l2 = Test.MyEnumListHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            List<Test.SmallStruct> l = new List<Test.SmallStruct>(smallStructArray);
            Test.SmallStructListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            List<Test.SmallStruct> l2 = Test.SmallStructListHelper.read(@in);
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i].Equals(smallStructArray[i]));
            }
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            List<Test.MyClass> l = new List<Test.MyClass>(myClassArray);
            Test.MyClassListHelper.write(@out, l);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            List<Test.MyClass> l2 = Test.MyClassListHelper.read(@in);
            @in.readPendingObjects();
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i] != null);
                test(l2[i].c == l2[i]);
                test(l2[i].o == l2[i]);
                test(l2[i].s.e == Test.MyEnum.enum2);
                test(Compare(l2[i].seq1, l[i].seq1));
                test(Compare(l2[i].seq2, l[i].seq2));
                test(Compare(l2[i].seq3, l[i].seq3));
                test(Compare(l2[i].seq4, l[i].seq4));
                test(Compare(l2[i].seq5, l[i].seq5));
                test(Compare(l2[i].seq6, l[i].seq6));
                test(Compare(l2[i].seq7, l[i].seq7));
                test(Compare(l2[i].seq8, l[i].seq8));
                test(Compare(l2[i].seq9, l[i].seq9));
                test(l2[i].d["hi"].Equals(l2[i]));
            }
            @out.destroy();
            @in.destroy();
        }

        {
            Test.MyClassPrx[] arr = new Test.MyClassPrx[2];
            arr[0] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            @out = Ice.Util.createOutputStream(communicator);
            List<Test.MyClassPrx> l = new List<Test.MyClassPrx>(arr);
            Test.MyClassProxyListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            List<Test.MyClassPrx> l2 = Test.MyClassProxyListHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            short[] arr =
            {
                (short)0x01,
                (short)0x11,
                (short)0x12,
                (short)0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            LinkedList<short> l = new LinkedList<short>(arr);
            Test.ShortLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            LinkedList<short> l2 = Test.ShortLinkedListHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            LinkedList<int> l = new LinkedList<int>(arr);
            Test.IntLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            LinkedList<int> l2 = Test.IntLinkedListHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = Ice.Util.createOutputStream(communicator);
            LinkedList<Test.MyEnum> l = new LinkedList<Test.MyEnum>(arr);
            Test.MyEnumLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            LinkedList<Test.MyEnum> l2 = Test.MyEnumLinkedListHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            LinkedList<Test.SmallStruct> l = new LinkedList<Test.SmallStruct>(smallStructArray);
            Test.SmallStructLinkedListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            LinkedList<Test.SmallStruct> l2 = Test.SmallStructLinkedListHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator<Test.SmallStruct> e = l.GetEnumerator();
            IEnumerator<Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
            @out.destroy();
            @in.destroy();
        }

        {
            long[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            Stack<long> l = new Stack<long>(arr);
            Test.LongStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Stack<long> l2 = Test.LongStackHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            float[] arr =
            {
                (float)1,
                (float)2,
                (float)3,
                (float)4
            };
            @out = Ice.Util.createOutputStream(communicator);
            Stack<float> l = new Stack<float>(arr);
            Test.FloatStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Stack<float> l2 = Test.FloatStackHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Stack<Test.SmallStruct> l = new Stack<Test.SmallStruct>(smallStructArray);
            Test.SmallStructStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Stack<Test.SmallStruct> l2 = Test.SmallStructStackHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator<Test.SmallStruct> e = l.GetEnumerator();
            IEnumerator<Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
            @out.destroy();
            @in.destroy();
        }

        {
            Test.MyClassPrx[] arr = new Test.MyClassPrx[2];
            arr[0] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("zero"));
            arr[1] = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy("one"));
            @out = Ice.Util.createOutputStream(communicator);
            Stack<Test.MyClassPrx> l = new Stack<Test.MyClassPrx>(arr);
            Test.MyClassProxyStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Stack<Test.MyClassPrx> l2 = Test.MyClassProxyStackHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            double[] arr =
            {
                (double)1,
                (double)2,
                (double)3,
                (double)4
            };
            @out = Ice.Util.createOutputStream(communicator);
            Queue<double> l = new Queue<double>(arr);
            Test.DoubleQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Queue<double> l2 = Test.DoubleQueueHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = Ice.Util.createOutputStream(communicator);
            Queue<string> l = new Queue<string>(arr);
            Test.StringQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Queue<string> l2 = Test.StringQueueHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Queue<Test.SmallStruct> l = new Queue<Test.SmallStruct>(smallStructArray);
            Test.SmallStructQueueHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Queue<Test.SmallStruct> l2 = Test.SmallStructQueueHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator<Test.SmallStruct> e = l.GetEnumerator();
            IEnumerator<Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
            @out.destroy();
            @in.destroy();
        }

        {
            bool[] arr =
            {
                true,
                false,
                true,
                false
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.BoolCollection l = new Test.BoolCollection(arr);
            Test.BoolCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.BoolCollection l2 = Test.BoolCollectionHelper.read(@in);
            test(Compare(l, l2));
            @out.destroy();
            @in.destroy();
        }

        {
            int[] arr =
            {
                0x01,
                0x11,
                0x12,
                0x22
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.IntCollection l = new Test.IntCollection(arr);
            Test.IntCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.IntCollection l2 = Test.IntCollectionHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.StringCollection l = new Test.StringCollection(arr);
            Test.StringCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.StringCollection l2 = Test.StringCollectionHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            Test.MyEnum[] arr =
            {
                Test.MyEnum.enum3,
                Test.MyEnum.enum2,
                Test.MyEnum.enum1,
                Test.MyEnum.enum2
            };
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyEnumCollection l = new Test.MyEnumCollection(arr);
            Test.MyEnumCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.MyEnumCollection l2 = Test.MyEnumCollectionHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Test.SmallStructCollection l = new Test.SmallStructCollection(smallStructArray);
            Test.SmallStructCollectionHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.SmallStructCollection l2 = Test.SmallStructCollectionHelper.read(@in);
            test(l2.Count == l.Count);
            IEnumerator<Test.SmallStruct> e = l.GetEnumerator();
            IEnumerator<Test.SmallStruct> e2 = l2.GetEnumerator();
            while (e.MoveNext() && e2.MoveNext())
            {
                test(e.Current.Equals(e2.Current));
            }
            @out.destroy();
            @in.destroy();
        }

        {
            @out = Ice.Util.createOutputStream(communicator);
            Test.MyClassCollection l = new Test.MyClassCollection(myClassArray);
            Test.MyClassCollectionHelper.write(@out, l);
            @out.writePendingObjects();
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.MyClassCollection l2 = Test.MyClassCollectionHelper.read(@in);
            @in.readPendingObjects();
            test(l2.Count == l.Count);
            for (int i = 0; i < l2.Count; ++i)
            {
                test(l2[i] != null);
                test(l2[i].c == l2[i]);
                test(l2[i].o == l2[i]);
                test(l2[i].s.e == Test.MyEnum.enum2);
                test(Compare(l2[i].seq1, l[i].seq1));
                test(Compare(l2[i].seq2, l[i].seq2));
                test(Compare(l2[i].seq3, l[i].seq3));
                test(Compare(l2[i].seq4, l[i].seq4));
                test(Compare(l2[i].seq5, l[i].seq5));
                test(Compare(l2[i].seq6, l[i].seq6));
                test(Compare(l2[i].seq7, l[i].seq7));
                test(Compare(l2[i].seq8, l[i].seq8));
                test(Compare(l2[i].seq9, l[i].seq9));
                test(l2[i].d["hi"].Equals(l2[i]));
            }
            @out.destroy();
            @in.destroy();
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            List<string[]> l = new List<string[]>(arrS);
            Test.StringSListHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            List<string[]> l2 = Test.StringSListHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }

        {
            string[] arr =
            {
                "string1",
                "string2",
                "string3",
                "string4"
            };
            string[][] arrS =
            {
                arr,
                new string[0],
                arr
            };
            @out = Ice.Util.createOutputStream(communicator);
            Stack<string[]> l = new Stack<string[]>(arrS);
            Test.StringSStackHelper.write(@out, l);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Stack<string[]> l2 = Test.StringSStackHelper.read(@in);
            test(Compare(l2, l));
            @out.destroy();
            @in.destroy();
        }
#if !SILVERLIGHT
        {
#if COMPACT
            SortedList<string, string> dict = new SortedList<string, string>();
#else
            SortedDictionary<string, string> dict = new SortedDictionary<string, string>();
#endif
            dict.Add("key1", "value1");
            dict.Add("key2", "value2");
            @out = Ice.Util.createOutputStream(communicator);
            Test.SortedStringStringDHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            IDictionary<string, string> dict2 = Test.SortedStringStringDHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }

        {
            Test.StringIntDCollection dict = new Test.StringIntDCollection();
            dict.Add("key1", 1);
            dict.Add("key2", 2);
            @out = Ice.Util.createOutputStream(communicator);
            Test.StringIntDCollectionHelper.write(@out, dict);
            byte[] data = @out.finished();
            @in = Ice.Util.createInputStream(communicator, data);
            Test.StringIntDCollection dict2 = Test.StringIntDCollectionHelper.read(@in);
            test(Ice.CollectionComparer.Equals(dict2, dict));
        }
#endif
        WriteLine("ok");
#if !SILVERLIGHT
        return 0;
#endif
    }
Beispiel #3
0
    public static TestIntfPrx allTests(Ice.Communicator communicator, bool collocated)
#endif
    {
        Write("testing stringToProxy... ");
        Flush();
        Ice.ObjectPrx basePrx = communicator.stringToProxy("Test:default -p 12010 -t 2000");
        test(basePrx != null);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        TestIntfPrx testPrx = TestIntfPrxHelper.checkedCast(basePrx);
        test(testPrx != null);
        test(testPrx.Equals(basePrx));
        WriteLine("ok");

        Write("base as Object... ");
        Flush();
        {
            Ice.Object o;
            SBase sb = null;
            try
            {
                o = testPrx.SBaseAsObject();
                test(o != null);
                test(o.ice_id().Equals("::Test::SBase"));
                sb = (SBase) o;
            }
            catch(Exception)
            {
                test(false);
            }
            test(sb != null);
            test(sb.sb.Equals("SBase.sb"));
        }
        WriteLine("ok");

        Write("base as Object (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_SBaseAsObject().whenCompleted(
                (Ice.Object o) =>
                {
                    test(o != null);
                    test(o.ice_id().Equals("::Test::SBase"));
                    SBase sb = (SBase) o;
                    test(sb != null);
                    test(sb.sb.Equals("SBase.sb"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("base as base... ");
        Flush();
        {
            SBase sb;
            try
            {
                sb = testPrx.SBaseAsSBase();
                test(sb.sb.Equals("SBase.sb"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("base as base (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_SBaseAsSBase().whenCompleted(
                (SBase sb) =>
                {
                    test(sb.sb.Equals("SBase.sb"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("base with known derived as base... ");
        Flush();
        {
            SBase sb;
            SBSKnownDerived sbskd = null;
            try
            {
                sb = testPrx.SBSKnownDerivedAsSBase();
                test(sb.sb.Equals("SBSKnownDerived.sb"));
                sbskd = (SBSKnownDerived) sb;
            }
            catch(Exception)
            {
                test(false);
            }
            test(sbskd != null);
            test(sbskd.sbskd.Equals("SBSKnownDerived.sbskd"));
        }
        WriteLine("ok");

        Write("base with known derived as base (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_SBSKnownDerivedAsSBase().whenCompleted(
                (SBase sb) =>
                {
                    test(sb.sb.Equals("SBSKnownDerived.sb"));
                    SBSKnownDerived sbskd = (SBSKnownDerived) sb;
                    test(sbskd != null);
                    test(sbskd.sbskd.Equals("SBSKnownDerived.sbskd"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("base with known derived as known derived... ");
        Flush();
        {
            SBSKnownDerived sbskd;
            try
            {
                sbskd = testPrx.SBSKnownDerivedAsSBSKnownDerived();
                test(sbskd.sbskd.Equals("SBSKnownDerived.sbskd"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("base with known derived as known derived (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_SBSKnownDerivedAsSBSKnownDerived().whenCompleted(
                (SBSKnownDerived sbskd) =>
                {
                    test(sbskd.sbskd.Equals("SBSKnownDerived.sbskd"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("base with unknown derived as base... ");
        Flush();
        {
            SBase sb;
            try
            {
                sb = testPrx.SBSUnknownDerivedAsSBase();
                test(sb.sb.Equals("SBSUnknownDerived.sb"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
        {
            try
            {
                SBase sb = testPrx.SBSUnknownDerivedAsSBaseCompact();
                test(sb.sb.Equals("SBSUnknownDerived.sb"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        else
        {
            try
            {
                //
                // This test fails when using the compact format because the instance cannot
                // be sliced to a known type.
                //
                testPrx.SBSUnknownDerivedAsSBaseCompact();
                test(false);
            }
            catch(Ice.NoValueFactoryException)
            {
                // Expected.
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("base with unknown derived as base (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_SBSUnknownDerivedAsSBase().whenCompleted(
                (SBase sb) =>
                {
                    test(sb.sb.Equals("SBSUnknownDerived.sb"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
        {
            //
            // This test succeeds for the 1.0 encoding.
            //
            Callback cb = new Callback();
            testPrx.begin_SBSUnknownDerivedAsSBaseCompact().whenCompleted(
                (SBase sb) =>
                {
                    test(sb.sb.Equals("SBSUnknownDerived.sb"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        else
        {
            //
            // This test fails when using the compact format because the instance cannot
            // be sliced to a known type.
            //
            Callback cb = new Callback();
            testPrx.begin_SBSUnknownDerivedAsSBaseCompact().whenCompleted(
                (SBase sb) =>
                {
                    test(false);
                },
                (Ice.Exception ex) =>
                {
                    test(ex is Ice.NoValueFactoryException);
                    cb.called();
                });
            cb.check();
        }
        WriteLine("ok");

        Write("unknown with Object as Object... ");
        Flush();
        {
            try
            {
                Ice.Object o = testPrx.SUnknownAsObject();
                test(!testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0));
                test(o is Ice.UnknownSlicedObject);
                test((o as Ice.UnknownSlicedObject).getUnknownTypeId().Equals("::Test::SUnknown"));
                testPrx.checkSUnknown(o);
            }
            catch(Ice.NoValueFactoryException)
            {
                test(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("unknown with Object as Object (AMI)... ");
        Flush();
        {
            try
            {
                Callback cb = new Callback();
                if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
                {
                    testPrx.begin_SUnknownAsObject().whenCompleted(
                        (Ice.Object o) =>
                        {
                            test(false);
                        },
                        (Ice.Exception ex) =>
                        {
                            test(ex.GetType().FullName.Equals("Ice.NoValueFactoryException"));
                            cb.called();
                        });
                }
                else
                {
                    testPrx.begin_SUnknownAsObject().whenCompleted(
                        (Ice.Object o) =>
                        {
                            test(o is Ice.UnknownSlicedObject);
                            test((o as Ice.UnknownSlicedObject).getUnknownTypeId().Equals("::Test::SUnknown"));
                            cb.called();
                        },
                        (Ice.Exception ex) =>
                        {
                            test(false);
                        });
                }
                cb.check();
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("one-element cycle... ");
        Flush();
        {
            try
            {
                B b = testPrx.oneElementCycle();
                test(b != null);
                test(b.ice_id().Equals("::Test::B"));
                test(b.sb.Equals("B1.sb"));
                test(b.pb == b);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("one-element cycle (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_oneElementCycle().whenCompleted(
                (B b) =>
                {
                    test(b != null);
                    test(b.ice_id().Equals("::Test::B"));
                    test(b.sb.Equals("B1.sb"));
                    test(b.pb == b);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("two-element cycle... ");
        Flush();
        {
            try
            {
                B b1 = testPrx.twoElementCycle();
                test(b1 != null);
                test(b1.ice_id().Equals("::Test::B"));
                test(b1.sb.Equals("B1.sb"));

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B"));
                test(b2.sb.Equals("B2.sb"));
                test(b2.pb == b1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("two-element cycle (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_twoElementCycle().whenCompleted(
                (B b1) =>
                {
                    test(b1 != null);
                    test(b1.ice_id().Equals("::Test::B"));
                    test(b1.sb.Equals("B1.sb"));

                    B b2 = b1.pb;
                    test(b2 != null);
                    test(b2.ice_id().Equals("::Test::B"));
                    test(b2.sb.Equals("B2.sb"));
                    test(b2.pb == b1);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("known derived pointer slicing as base... ");
        Flush();
        {
            try
            {
                B b1;
                b1 = testPrx.D1AsB();
                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb != null);
                test(b1.pb != b1);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 != null);
                test(d1.pd1 != b1);
                test(b1.pb == d1.pd1);

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.pb == b1);
                test(b2.sb.Equals("D2.sb"));
                test(b2.ice_id().Equals("::Test::B"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("known derived pointer slicing as base (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_D1AsB().whenCompleted(
                (B b1) =>
                {
                    test(b1 != null);
                    test(b1.ice_id().Equals("::Test::D1"));
                    test(b1.sb.Equals("D1.sb"));
                    test(b1.pb != null);
                    test(b1.pb != b1);
                    D1 d1 = (D1) b1;
                    test(d1 != null);
                    test(d1.sd1.Equals("D1.sd1"));
                    test(d1.pd1 != null);
                    test(d1.pd1 != b1);
                    test(b1.pb == d1.pd1);

                    B b2 = b1.pb;
                    test(b2 != null);
                    test(b2.pb == b1);
                    test(b2.sb.Equals("D2.sb"));
                    test(b2.ice_id().Equals("::Test::B"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("known derived pointer slicing as derived... ");
        Flush();
        {
            try
            {
                D1 d1;
                d1 = testPrx.D1AsD1();
                test(d1 != null);
                test(d1.ice_id().Equals("::Test::D1"));
                test(d1.sb.Equals("D1.sb"));
                test(d1.pb != null);
                test(d1.pb != d1);

                B b2 = d1.pb;
                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B"));
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb == d1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("known derived pointer slicing as derived (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_D1AsD1().whenCompleted(
                (D1 d1) =>
                {
                    test(d1 != null);
                    test(d1.ice_id().Equals("::Test::D1"));
                    test(d1.sb.Equals("D1.sb"));
                    test(d1.pb != null);
                    test(d1.pb != d1);

                    B b2 = d1.pb;
                    test(b2 != null);
                    test(b2.ice_id().Equals("::Test::B"));
                    test(b2.sb.Equals("D2.sb"));
                    test(b2.pb == d1);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("unknown derived pointer slicing as base... ");
        Flush();
        {
            try
            {
                B b2;
                b2 = testPrx.D2AsB();
                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B"));
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb != null);
                test(b2.pb != b2);

                B b1 = b2.pb;
                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb == b2);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 == b2);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("unknown derived pointer slicing as base (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_D2AsB().whenCompleted(
                (B b2) =>
                {
                    test(b2 != null);
                    test(b2.ice_id().Equals("::Test::B"));
                    test(b2.sb.Equals("D2.sb"));
                    test(b2.pb != null);
                    test(b2.pb != b2);

                    B b1 = b2.pb;
                    test(b1 != null);
                    test(b1.ice_id().Equals("::Test::D1"));
                    test(b1.sb.Equals("D1.sb"));
                    test(b1.pb == b2);
                    D1 d1 = (D1) b1;
                    test(d1 != null);
                    test(d1.sd1.Equals("D1.sd1"));
                    test(d1.pd1 == b2);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("param ptr slicing with known first... ");
        Flush();
        {
            try
            {
                B b1;
                B b2;
                testPrx.paramTest1(out b1, out b2);

                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb == b2);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 == b2);

                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B")); // No factory, must be sliced
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb == b1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("param ptr slicing with known first (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_paramTest1().whenCompleted(
                (B b1, B b2) =>
                {
                    test(b1 != null);
                    test(b1.ice_id().Equals("::Test::D1"));
                    test(b1.sb.Equals("D1.sb"));
                    test(b1.pb == b2);
                    D1 d1 = (D1) b1;
                    test(d1 != null);
                    test(d1.sd1.Equals("D1.sd1"));
                    test(d1.pd1 == b2);

                    test(b2 != null);
                    test(b2.ice_id().Equals("::Test::B")); // No factory, must be sliced
                    test(b2.sb.Equals("D2.sb"));
                    test(b2.pb == b1);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("param ptr slicing with unknown first... ");
        Flush();
        {
            try
            {
                B b2;
                B b1;
                testPrx.paramTest2(out b2, out b1);

                test(b1 != null);
                test(b1.ice_id().Equals("::Test::D1"));
                test(b1.sb.Equals("D1.sb"));
                test(b1.pb == b2);
                D1 d1 = (D1) b1;
                test(d1 != null);
                test(d1.sd1.Equals("D1.sd1"));
                test(d1.pd1 == b2);

                test(b2 != null);
                test(b2.ice_id().Equals("::Test::B")); // No factory, must be sliced
                test(b2.sb.Equals("D2.sb"));
                test(b2.pb == b1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("param ptr slicing with unknown first (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_paramTest2().whenCompleted(
                (B b2, B b1) =>
                {
                    test(b1 != null);
                    test(b1.ice_id().Equals("::Test::D1"));
                    test(b1.sb.Equals("D1.sb"));
                    test(b1.pb == b2);
                    D1 d1 = (D1) b1;
                    test(d1 != null);
                    test(d1.sd1.Equals("D1.sd1"));
                    test(d1.pd1 == b2);

                    test(b2 != null);
                    test(b2.ice_id().Equals("::Test::B")); // No factory, must be sliced
                    test(b2.sb.Equals("D2.sb"));
                    test(b2.pb == b1);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("return value identity with known first... ");
        Flush();
        {
            try
            {
                B p1;
                B p2;
                B ret = testPrx.returnTest1(out p1, out p2);
                test(ret == p1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("return value identity with known first (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_returnTest1().whenCompleted(
                (B r, B p1, B p2) =>
                {
                    test(r == p1);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("return value identity with unknown first... ");
        Flush();
        {
            try
            {
                B p1;
                B p2;
                B ret = testPrx.returnTest2(out p1, out p2);
                test(ret == p1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("return value identity with unknown first (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_returnTest2().whenCompleted(
                (B r, B p1, B p2) =>
                {
                    test(r == p1);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("return value identity for input params known first... ");
        Flush();
        {
            try
            {
                D1 d1 = new D1();
                d1.sb = "D1.sb";
                d1.sd1 = "D1.sd1";
                D3 d3 = new D3();
                d3.pb = d1;
                d3.sb = "D3.sb";
                d3.sd3 = "D3.sd3";
                d3.pd3 = d1;
                d1.pb = d3;
                d1.pd1 = d3;

                B b1 = testPrx.returnTest3(d1, d3);

                test(b1 != null);
                test(b1.sb.Equals("D1.sb"));
                test(b1.ice_id().Equals("::Test::D1"));
                D1 p1 = (D1) b1;
                test(p1 != null);
                test(p1.sd1.Equals("D1.sd1"));
                test(p1.pd1 == b1.pb);

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.sb.Equals("D3.sb"));
                test(b2.ice_id().Equals("::Test::B")); // Sliced by server
                test(b2.pb == b1);
                try
                {
                    D3 p3 = (D3) b2;
                    test(false);
                    D3 tmp = p3; p3 = tmp; // Stop compiler warning about unused variable.
                }
                catch(InvalidCastException)
                {
                }

                test(b1 != d1);
                test(b1 != d3);
                test(b2 != d1);
                test(b2 != d3);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("return value identity for input params known first (AMI)... ");
        Flush();
        {
            D1 d1 = new D1();
            d1.sb = "D1.sb";
            d1.sd1 = "D1.sd1";
            D3 d3 = new D3();
            d3.pb = d1;
            d3.sb = "D3.sb";
            d3.sd3 = "D3.sd3";
            d3.pd3 = d1;
            d1.pb = d3;
            d1.pd1 = d3;

            B b1 = null;
            Callback cb = new Callback();
            testPrx.begin_returnTest3(d1, d3).whenCompleted(
                (B b) =>
                {
                    b1 = b;
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();

            test(b1 != null);
            test(b1.sb.Equals("D1.sb"));
            test(b1.ice_id().Equals("::Test::D1"));
            D1 p1 = (D1) b1;
            test(p1 != null);
            test(p1.sd1.Equals("D1.sd1"));
            test(p1.pd1 == b1.pb);

            B b2 = b1.pb;
            test(b2 != null);
            test(b2.sb.Equals("D3.sb"));
            test(b2.ice_id().Equals("::Test::B")); // Sliced by server
            test(b2.pb == b1);
            try
            {
                D3 p3 = (D3) b2;
                test(false);
                D3 tmp = p3; p3 = tmp; // Stop compiler warning about unused variable.
            }
            catch(InvalidCastException)
            {
            }

            test(b1 != d1);
            test(b1 != d3);
            test(b2 != d1);
            test(b2 != d3);
        }
        WriteLine("ok");

        Write("return value identity for input params unknown first... ");
        Flush();
        {
            try
            {
                D1 d1 = new D1();
                d1.sb = "D1.sb";
                d1.sd1 = "D1.sd1";
                D3 d3 = new D3();
                d3.pb = d1;
                d3.sb = "D3.sb";
                d3.sd3 = "D3.sd3";
                d3.pd3 = d1;
                d1.pb = d3;
                d1.pd1 = d3;

                B b1 = testPrx.returnTest3(d3, d1);

                test(b1 != null);
                test(b1.sb.Equals("D3.sb"));
                test(b1.ice_id().Equals("::Test::B")); // Sliced by server

                try
                {
                    D3 p1 = (D3) b1;
                    test(false);
                    D3 tmp = p1; p1 = tmp; // Stop compiler warning about unused variable.
                }
                catch(InvalidCastException)
                {
                }

                B b2 = b1.pb;
                test(b2 != null);
                test(b2.sb.Equals("D1.sb"));
                test(b2.ice_id().Equals("::Test::D1"));
                test(b2.pb == b1);
                D1 p3 = (D1) b2;
                test(p3 != null);
                test(p3.sd1.Equals("D1.sd1"));
                test(p3.pd1 == b1);

                test(b1 != d1);
                test(b1 != d3);
                test(b2 != d1);
                test(b2 != d3);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("return value identity for input params unknown first (AMI)... ");
        Flush();
        {
            D1 d1 = new D1();
            d1.sb = "D1.sb";
            d1.sd1 = "D1.sd1";
            D3 d3 = new D3();
            d3.pb = d1;
            d3.sb = "D3.sb";
            d3.sd3 = "D3.sd3";
            d3.pd3 = d1;
            d1.pb = d3;
            d1.pd1 = d3;

            B b1 = null;
            Callback cb = new Callback();
            testPrx.begin_returnTest3(d3, d1).whenCompleted(
                (B b) =>
                {
                    b1 = b;
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();

            test(b1 != null);
            test(b1.sb.Equals("D3.sb"));
            test(b1.ice_id().Equals("::Test::B")); // Sliced by server

            try
            {
                D3 p1 = (D3) b1;
                test(false);
                D3 tmp = p1; p1 = tmp; // Stop compiler warning about unused variable.
            }
            catch(InvalidCastException)
            {
            }

            B b2 = b1.pb;
            test(b2 != null);
            test(b2.sb.Equals("D1.sb"));
            test(b2.ice_id().Equals("::Test::D1"));
            test(b2.pb == b1);
            D1 p3 = (D1) b2;
            test(p3 != null);
            test(p3.sd1.Equals("D1.sd1"));
            test(p3.pd1 == b1);

            test(b1 != d1);
            test(b1 != d3);
            test(b2 != d1);
            test(b2 != d3);
        }
        WriteLine("ok");

        Write("remainder unmarshaling (3 instances)... ");
        Flush();
        {
            try
            {
                B p1;
                B p2;
                B ret = testPrx.paramTest3(out p1, out p2);

                test(p1 != null);
                test(p1.sb.Equals("D2.sb (p1 1)"));
                test(p1.pb == null);
                test(p1.ice_id().Equals("::Test::B"));

                test(p2 != null);
                test(p2.sb.Equals("D2.sb (p2 1)"));
                test(p2.pb == null);
                test(p2.ice_id().Equals("::Test::B"));

                test(ret != null);
                test(ret.sb.Equals("D1.sb (p2 2)"));
                test(ret.pb == null);
                test(ret.ice_id().Equals("::Test::D1"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("remainder unmarshaling (3 instances) (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_paramTest3().whenCompleted(
                (B ret, B p1, B p2) =>
                {
                    test(p1 != null);
                    test(p1.sb.Equals("D2.sb (p1 1)"));
                    test(p1.pb == null);
                    test(p1.ice_id().Equals("::Test::B"));

                    test(p2 != null);
                    test(p2.sb.Equals("D2.sb (p2 1)"));
                    test(p2.pb == null);
                    test(p2.ice_id().Equals("::Test::B"));

                    test(ret != null);
                    test(ret.sb.Equals("D1.sb (p2 2)"));
                    test(ret.pb == null);
                    test(ret.ice_id().Equals("::Test::D1"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("remainder unmarshaling (4 instances)... ");
        Flush();
        {
            try
            {
                B b;
                B ret = testPrx.paramTest4(out b);

                test(b != null);
                test(b.sb.Equals("D4.sb (1)"));
                test(b.pb == null);
                test(b.ice_id().Equals("::Test::B"));

                test(ret != null);
                test(ret.sb.Equals("B.sb (2)"));
                test(ret.pb == null);
                test(ret.ice_id().Equals("::Test::B"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("remainder unmarshaling (4 instances) (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_paramTest4().whenCompleted(
                (B ret, B b) =>
                {
                    test(b != null);
                    test(b.sb.Equals("D4.sb (1)"));
                    test(b.pb == null);
                    test(b.ice_id().Equals("::Test::B"));

                    test(ret != null);
                    test(ret.sb.Equals("B.sb (2)"));
                    test(ret.pb == null);
                    test(ret.ice_id().Equals("::Test::B"));
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("param ptr slicing, instance marshaled in unknown derived as base... ");
        Flush();
        {
            try
            {
                B b1 = new B();
                b1.sb = "B.sb(1)";
                b1.pb = b1;

                D3 d3 = new D3();
                d3.sb = "D3.sb";
                d3.pb = d3;
                d3.sd3 = "D3.sd3";
                d3.pd3 = b1;

                B b2 = new B();
                b2.sb = "B.sb(2)";
                b2.pb = b1;

                B ret = testPrx.returnTest3(d3, b2);

                test(ret != null);
                test(ret.ice_id().Equals("::Test::B"));
                test(ret.sb.Equals("D3.sb"));
                test(ret.pb == ret);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("param ptr slicing, instance marshaled in unknown derived as base (AMI)... ");
        Flush();
        {
            B b1 = new B();
            b1.sb = "B.sb(1)";
            b1.pb = b1;

            D3 d3 = new D3();
            d3.sb = "D3.sb";
            d3.pb = d3;
            d3.sd3 = "D3.sd3";
            d3.pd3 = b1;

            B b2 = new B();
            b2.sb = "B.sb(2)";
            b2.pb = b1;

            B rv = null;
            Callback cb = new Callback();
            testPrx.begin_returnTest3(d3, b2).whenCompleted(
                (B b) =>
                {
                    rv = b;
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();

            test(rv != null);
            test(rv.ice_id().Equals("::Test::B"));
            test(rv.sb.Equals("D3.sb"));
            test(rv.pb == rv);
        }
        WriteLine("ok");

        Write("param ptr slicing, instance marshaled in unknown derived as derived... ");
        Flush();
        {
            try
            {
                D1 d11 = new D1();
                d11.sb = "D1.sb(1)";
                d11.pb = d11;
                d11.sd1 = "D1.sd1(1)";

                D3 d3 = new D3();
                d3.sb = "D3.sb";
                d3.pb = d3;
                d3.sd3 = "D3.sd3";
                d3.pd3 = d11;

                D1 d12 = new D1();
                d12.sb = "D1.sb(2)";
                d12.pb = d12;
                d12.sd1 = "D1.sd1(2)";
                d12.pd1 = d11;

                B ret = testPrx.returnTest3(d3, d12);
                test(ret != null);
                test(ret.ice_id().Equals("::Test::B"));
                test(ret.sb.Equals("D3.sb"));
                test(ret.pb == ret);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("param ptr slicing, instance marshaled in unknown derived as derived (AMI)... ");
        Flush();
        {
            D1 d11 = new D1();
            d11.sb = "D1.sb(1)";
            d11.pb = d11;
            d11.sd1 = "D1.sd1(1)";

            D3 d3 = new D3();
            d3.sb = "D3.sb";
            d3.pb = d3;
            d3.sd3 = "D3.sd3";
            d3.pd3 = d11;

            D1 d12 = new D1();
            d12.sb = "D1.sb(2)";
            d12.pb = d12;
            d12.sd1 = "D1.sd1(2)";
            d12.pd1 = d11;

            B rv = null;
            Callback cb = new Callback();
            testPrx.begin_returnTest3(d3, d12).whenCompleted(
                (B b) =>
                {
                    rv = b;
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();

            test(rv != null);
            test(rv.ice_id().Equals("::Test::B"));
            test(rv.sb.Equals("D3.sb"));
            test(rv.pb == rv);
        }
        WriteLine("ok");

        Write("sequence slicing... ");
        Flush();
        {
            try
            {
                SS3 ss;
                {
                    B ss1b = new B();
                    ss1b.sb = "B.sb";
                    ss1b.pb = ss1b;

                    D1 ss1d1 = new D1();
                    ss1d1.sb = "D1.sb";
                    ss1d1.sd1 = "D1.sd1";
                    ss1d1.pb = ss1b;

                    D3 ss1d3 = new D3();
                    ss1d3.sb = "D3.sb";
                    ss1d3.sd3 = "D3.sd3";
                    ss1d3.pb = ss1b;

                    B ss2b = new B();
                    ss2b.sb = "B.sb";
                    ss2b.pb = ss1b;

                    D1 ss2d1 = new D1();
                    ss2d1.sb = "D1.sb";
                    ss2d1.sd1 = "D1.sd1";
                    ss2d1.pb = ss2b;

                    D3 ss2d3 = new D3();
                    ss2d3.sb = "D3.sb";
                    ss2d3.sd3 = "D3.sd3";
                    ss2d3.pb = ss2b;

                    ss1d1.pd1 = ss2b;
                    ss1d3.pd3 = ss2d1;

                    ss2d1.pd1 = ss1d3;
                    ss2d3.pd3 = ss1d1;

                    SS1 ss1 = new SS1();
                    ss1.s = new BSeq(3);
                    ss1.s.Add(ss1b);
                    ss1.s.Add(ss1d1);
                    ss1.s.Add(ss1d3);

                    SS2 ss2 = new SS2();
                    ss2.s = new BSeq(3);
                    ss2.s.Add(ss2b);
                    ss2.s.Add(ss2d1);
                    ss2.s.Add(ss2d3);

                    ss = testPrx.sequenceTest(ss1, ss2);
                }

                test(ss.c1 != null);
                B ss1b2 = ss.c1.s[0];
                B ss1d2 = ss.c1.s[1];
                test(ss.c2 != null);
                B ss1d4 = ss.c1.s[2];

                test(ss.c2 != null);
                B ss2b2 = ss.c2.s[0];
                B ss2d2 = ss.c2.s[1];
                B ss2d4 = ss.c2.s[2];

                test(ss1b2.pb == ss1b2);
                test(ss1d2.pb == ss1b2);
                test(ss1d4.pb == ss1b2);

                test(ss2b2.pb == ss1b2);
                test(ss2d2.pb == ss2b2);
                test(ss2d4.pb == ss2b2);

                test(ss1b2.ice_id().Equals("::Test::B"));
                test(ss1d2.ice_id().Equals("::Test::D1"));
                test(ss1d4.ice_id().Equals("::Test::B"));

                test(ss2b2.ice_id().Equals("::Test::B"));
                test(ss2d2.ice_id().Equals("::Test::D1"));
                test(ss2d4.ice_id().Equals("::Test::B"));
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("sequence slicing (AMI)... ");
        Flush();
        {
            SS3 ss = null;
            {
                B ss1b = new B();
                ss1b.sb = "B.sb";
                ss1b.pb = ss1b;

                D1 ss1d1 = new D1();
                ss1d1.sb = "D1.sb";
                ss1d1.sd1 = "D1.sd1";
                ss1d1.pb = ss1b;

                D3 ss1d3 = new D3();
                ss1d3.sb = "D3.sb";
                ss1d3.sd3 = "D3.sd3";
                ss1d3.pb = ss1b;

                B ss2b = new B();
                ss2b.sb = "B.sb";
                ss2b.pb = ss1b;

                D1 ss2d1 = new D1();
                ss2d1.sb = "D1.sb";
                ss2d1.sd1 = "D1.sd1";
                ss2d1.pb = ss2b;

                D3 ss2d3 = new D3();
                ss2d3.sb = "D3.sb";
                ss2d3.sd3 = "D3.sd3";
                ss2d3.pb = ss2b;

                ss1d1.pd1 = ss2b;
                ss1d3.pd3 = ss2d1;

                ss2d1.pd1 = ss1d3;
                ss2d3.pd3 = ss1d1;

                SS1 ss1 = new SS1();
                ss1.s = new BSeq();
                ss1.s.Add(ss1b);
                ss1.s.Add(ss1d1);
                ss1.s.Add(ss1d3);

                SS2 ss2 = new SS2();
                ss2.s = new BSeq();
                ss2.s.Add(ss2b);
                ss2.s.Add(ss2d1);
                ss2.s.Add(ss2d3);

                Callback cb = new Callback();
                testPrx.begin_sequenceTest(ss1, ss2).whenCompleted(
                    (SS3 s) =>
                    {
                        ss = s;
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        test(false);
                    });
                cb.check();
            }
            test(ss.c1 != null);
            B ss1b3 = ss.c1.s[0];
            B ss1d5 = ss.c1.s[1];
            test(ss.c2 != null);
            B ss1d6 = ss.c1.s[2];

            test(ss.c2 != null);
            B ss2b3 = ss.c2.s[0];
            B ss2d5 = ss.c2.s[1];
            B ss2d6 = ss.c2.s[2];

            test(ss1b3.pb == ss1b3);
            test(ss1d6.pb == ss1b3);
            test(ss1d6.pb == ss1b3);

            test(ss2b3.pb == ss1b3);
            test(ss2d6.pb == ss2b3);
            test(ss2d6.pb == ss2b3);

            test(ss1b3.ice_id().Equals("::Test::B"));
            test(ss1d5.ice_id().Equals("::Test::D1"));
            test(ss1d6.ice_id().Equals("::Test::B"));

            test(ss2b3.ice_id().Equals("::Test::B"));
            test(ss2d5.ice_id().Equals("::Test::D1"));
            test(ss2d6.ice_id().Equals("::Test::B"));
        }
        WriteLine("ok");

        Write("dictionary slicing... ");
        Flush();
        {
            try
            {
                Dictionary<int, B> bin = new Dictionary<int, B>();
                Dictionary<int, B> bout;
                Dictionary<int, B> ret;
                int i;
                for(i = 0; i < 10; ++i)
                {
                    string s = "D1." + i.ToString();
                    D1 d1 = new D1();
                    d1.sb = s;
                    d1.pb = d1;
                    d1.sd1 = s;
                    bin[i] = d1;
                }

                ret = testPrx.dictionaryTest(bin, out bout);

                test(bout.Count == 10);
                for(i = 0; i < 10; ++i)
                {
                    B b = bout[i * 10];
                    test(b != null);
                    string s = "D1." + i.ToString();
                    test(b.sb.Equals(s));
                    test(b.pb != null);
                    test(b.pb != b);
                    test(b.pb.sb.Equals(s));
                    test(b.pb.pb == b.pb);
                }

                test(ret.Count == 10);
                for(i = 0; i < 10; ++i)
                {
                    B b = ret[i * 20];
                    test(b != null);
                    string s = "D1." + (i * 20).ToString();
                    test(b.sb.Equals(s));
                    test(b.pb == (i == 0 ? (B)null : ret[(i - 1) * 20]));
                    D1 d1 = (D1) b;
                    test(d1 != null);
                    test(d1.sd1.Equals(s));
                    test(d1.pd1 == d1);
                }
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("dictionary slicing (AMI)... ");
        Flush();
        {
            Dictionary<int, B> bin = new Dictionary<int, B>();
            Dictionary<int, B> bout = null;
            Dictionary<int, B> rv = null;
            int i;
            for(i = 0; i < 10; ++i)
            {
                string s = "D1." + i.ToString();
                D1 d1 = new D1();
                d1.sb = s;
                d1.pb = d1;
                d1.sd1 = s;
                bin[i] = d1;
            }

            Callback cb = new Callback();
            testPrx.begin_dictionaryTest(bin).whenCompleted(
                (Dictionary<int, B> r, Dictionary<int, B> b) =>
                {
                    rv = (Dictionary<int, B>)r;
                    bout = (Dictionary<int, B>)b;
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();

            test(bout.Count == 10);
            for(i = 0; i < 10; ++i)
            {
                B b = bout[i * 10];
                test(b != null);
                string s = "D1." + i.ToString();
                test(b.sb.Equals(s));
                test(b.pb != null);
                test(b.pb != b);
                test(b.pb.sb.Equals(s));
                test(b.pb.pb == b.pb);
            }

            test(rv.Count == 10);
            for(i = 0; i < 10; ++i)
            {
                B b = rv[i * 20];
                test(b != null);
                string s = "D1." + (i * 20).ToString();
                test(b.sb.Equals(s));
                test(b.pb == (i == 0 ? (B)null : rv[(i - 1) * 20]));
                D1 d1 = (D1) b;
                test(d1 != null);
                test(d1.sd1.Equals(s));
                test(d1.pd1 == d1);
            }
        }
        WriteLine("ok");

        Write("base exception thrown as base exception... ");
        Flush();
        {
            try
            {
                testPrx.throwBaseAsBase();
                test(false);
            }
            catch(BaseException e)
            {
                test(e.GetType().FullName.Equals("Test.BaseException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb"));
                test(e.pb.pb == e.pb);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("base exception thrown as base exception (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_throwBaseAsBase().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception ex) =>
                {
                     try
                    {
                        BaseException e = (BaseException)ex;
                        test(e.sbe.Equals("sbe"));
                        test(e.pb != null);
                        test(e.pb.sb.Equals("sb"));
                        test(e.pb.pb == e.pb);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }
        WriteLine("ok");

        Write("derived exception thrown as base exception... ");
        Flush();
        {
            try
            {
                testPrx.throwDerivedAsBase();
                test(false);
            }
            catch(DerivedException e)
            {
                test(e.GetType().FullName.Equals("Test.DerivedException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb1"));
                test(e.pb.pb == e.pb);
                test(e.sde.Equals("sde1"));
                test(e.pd1 != null);
                test(e.pd1.sb.Equals("sb2"));
                test(e.pd1.pb == e.pd1);
                test(e.pd1.sd1.Equals("sd2"));
                test(e.pd1.pd1 == e.pd1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("derived exception thrown as base exception (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_throwDerivedAsBase().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception ex) =>
                {
                    try
                    {
                        DerivedException e = (DerivedException)ex;
                        test(e.sbe.Equals("sbe"));
                        test(e.pb != null);
                        test(e.pb.sb.Equals("sb1"));
                        test(e.pb.pb == e.pb);
                        test(e.sde.Equals("sde1"));
                        test(e.pd1 != null);
                        test(e.pd1.sb.Equals("sb2"));
                        test(e.pd1.pb == e.pd1);
                        test(e.pd1.sd1.Equals("sd2"));
                        test(e.pd1.pd1 == e.pd1);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }
        WriteLine("ok");

        Write("derived exception thrown as derived exception... ");
        Flush();
        {
            try
            {
                testPrx.throwDerivedAsDerived();
                test(false);
            }
            catch(DerivedException e)
            {
                test(e.GetType().FullName.Equals("Test.DerivedException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb1"));
                test(e.pb.pb == e.pb);
                test(e.sde.Equals("sde1"));
                test(e.pd1 != null);
                test(e.pd1.sb.Equals("sb2"));
                test(e.pd1.pb == e.pd1);
                test(e.pd1.sd1.Equals("sd2"));
                test(e.pd1.pd1 == e.pd1);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("derived exception thrown as derived exception (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_throwDerivedAsDerived().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception ex) =>
                {
                    try
                    {
                        DerivedException e = (DerivedException)ex;
                        test(e.sbe.Equals("sbe"));
                        test(e.pb != null);
                        test(e.pb.sb.Equals("sb1"));
                        test(e.pb.pb == e.pb);
                        test(e.sde.Equals("sde1"));
                        test(e.pd1 != null);
                        test(e.pd1.sb.Equals("sb2"));
                        test(e.pd1.pb == e.pd1);
                        test(e.pd1.sd1.Equals("sd2"));
                        test(e.pd1.pd1 == e.pd1);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }
        WriteLine("ok");

        Write("unknown derived exception thrown as base exception... ");
        Flush();
        {
            try
            {
                testPrx.throwUnknownDerivedAsBase();
                test(false);
            }
            catch(BaseException e)
            {
                test(e.GetType().FullName.Equals("Test.BaseException"));
                test(e.sbe.Equals("sbe"));
                test(e.pb != null);
                test(e.pb.sb.Equals("sb d2"));
                test(e.pb.pb == e.pb);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("unknown derived exception thrown as base exception (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_throwUnknownDerivedAsBase().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception ex) =>
                {
                    try
                    {
                        BaseException e = (BaseException)ex;
                        test(e.sbe.Equals("sbe"));
                        test(e.pb != null);
                        test(e.pb.sb.Equals("sb d2"));
                        test(e.pb.pb == e.pb);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }
        WriteLine("ok");

        Write("forward-declared class... ");
        Flush();
        {
            try
            {
                Forward f;
                testPrx.useForward(out f);
                test(f != null);
            }
            catch(Exception)
            {
                test(false);
            }
        }
        WriteLine("ok");

        Write("forward-declared class (AMI)... ");
        Flush();
        {
            Callback cb = new Callback();
            testPrx.begin_useForward().whenCompleted(
                (Forward f) =>
                {
                    test(f != null);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }
        WriteLine("ok");

        Write("preserved classes... ");
        Flush();

        //
        // Register a factory in order to substitute our own subclass of Preserved. This provides
        // an easy way to determine how many unmarshaled instances currently exist.
        //
        // TODO: We have to install this now (even though it's not necessary yet), because otherwise
        // the Ice run time will install its own internal factory for Preserved upon receiving the
        // first instance.
        //
        communicator.addValueFactory(PreservedFactoryI, Preserved.ice_staticId());

        try
        {
            //
            // Server knows the most-derived class PDerived.
            //
            PDerived pd = new PDerived();
            pd.pi = 3;
            pd.ps = "preserved";
            pd.pb = pd;

            PBase r = testPrx.exchangePBase(pd);
            PDerived p2 = r as PDerived;
            test(p2.pi == 3);
            test(p2.ps.Equals("preserved"));
            test(p2.pb == p2);
        }
        catch(Ice.OperationNotExistException)
        {
        }

        try
        {
            //
            // Server only knows the base (non-preserved) type, so the object is sliced.
            //
            PCUnknown pu = new PCUnknown();
            pu.pi = 3;
            pu.pu = "preserved";

            PBase r = testPrx.exchangePBase(pu);
            test(!(r is PCUnknown));
            test(r.pi == 3);
        }
        catch(Ice.OperationNotExistException)
        {
        }

        try
        {
            //
            // Server only knows the intermediate type Preserved. The object will be sliced to
            // Preserved for the 1.0 encoding; otherwise it should be returned intact.
            //
            PCDerived pcd = new PCDerived();
            pcd.pi = 3;
            pcd.pbs = new PBase[] { pcd };

            PBase r = testPrx.exchangePBase(pcd);
            if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                test(!(r is PCDerived));
                test(r.pi == 3);
            }
            else
            {
                PCDerived p2 = r as PCDerived;
                test(p2.pi == 3);
                test(p2.pbs[0] == p2);
            }
        }
        catch(Ice.OperationNotExistException)
        {
        }

        try
        {
            //
            // Server only knows the intermediate type Preserved. The object will be sliced to
            // Preserved for the 1.0 encoding; otherwise it should be returned intact.
            //
            CompactPCDerived pcd = new CompactPCDerived();
            pcd.pi = 3;
            pcd.pbs = new PBase[] { pcd };

            PBase r = testPrx.exchangePBase(pcd);
            if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                test(!(r is CompactPCDerived));
                test(r.pi == 3);
            }
            else
            {
                CompactPCDerived p2 = r as CompactPCDerived;
                test(p2.pi == 3);
                test(p2.pbs[0] == p2);
            }
        }
        catch(Ice.OperationNotExistException)
        {
        }

        try
        {
            //
            // Send an object that will have multiple preserved slices in the server.
            // The object will be sliced to Preserved for the 1.0 encoding.
            //
            PCDerived3 pcd = new PCDerived3();
            pcd.pi = 3;
            //
            // Sending more than 254 objects exercises the encoding for object ids.
            //
            pcd.pbs = new PBase[300];
            int i;
            for(i = 0; i < 300; ++i)
            {
                PCDerived2 p2 = new PCDerived2();
                p2.pi = i;
                p2.pbs = new PBase[] { null }; // Nil reference. This slice should not have an indirection table.
                p2.pcd2 = i;
                pcd.pbs[i] = p2;
            }
            pcd.pcd2 = pcd.pi;
            pcd.pcd3 = pcd.pbs[10];

            PBase r = testPrx.exchangePBase(pcd);
            if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                test(!(r is PCDerived3));
                test(r is Preserved);
                test(r.pi == 3);
            }
            else
            {
                PCDerived3 p3 = r as PCDerived3;
                test(p3.pi == 3);
                for(i = 0; i < 300; ++i)
                {
                    PCDerived2 p2 = p3.pbs[i] as PCDerived2;
                    test(p2.pi == i);
                    test(p2.pbs.Length == 1);
                    test(p2.pbs[0] == null);
                    test(p2.pcd2 == i);
                }
                test(p3.pcd2 == p3.pi);
                test(p3.pcd3 == p3.pbs[10]);
            }
        }
        catch(Ice.OperationNotExistException)
        {
        }

        try
        {
            //
            // Obtain an object with preserved slices and send it back to the server.
            // The preserved slices should be excluded for the 1.0 encoding, otherwise
            // they should be included.
            //
            Preserved p = testPrx.PBSUnknownAsPreserved();
            testPrx.checkPBSUnknown(p);
            if(!testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                (testPrx.ice_encodingVersion(Ice.Util.Encoding_1_0) as TestIntfPrx).checkPBSUnknown(p);
            }
        }
        catch(Ice.OperationNotExistException)
        {
        }

        WriteLine("ok");

        Write("preserved classes (AMI)... ");
        Flush();
        {
            //
            // Server knows the most-derived class PDerived.
            //
            PDerived pd = new PDerived();
            pd.pi = 3;
            pd.ps = "preserved";
            pd.pb = pd;

            Callback cb = new Callback();
            testPrx.begin_exchangePBase(pd).whenCompleted(
                (PBase r) =>
                {
                    PDerived p2 = (PDerived)r;
                    test(p2.pi == 3);
                    test(p2.ps.Equals("preserved"));
                    test(p2.pb == p2);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }

        {
            //
            // Server only knows the base (non-preserved) type, so the object is sliced.
            //
            PCUnknown pu = new PCUnknown();
            pu.pi = 3;
            pu.pu = "preserved";

            Callback cb = new Callback();
            testPrx.begin_exchangePBase(pu).whenCompleted(
                (PBase r) =>
                {
                    test(!(r is PCUnknown));
                    test(r.pi == 3);
                    cb.called();
                },
                (Ice.Exception ex) =>
                {
                    test(false);
                });
            cb.check();
        }

        {
            //
            // Server only knows the intermediate type Preserved. The object will be sliced to
            // Preserved for the 1.0 encoding; otherwise it should be returned intact.
            //
            PCDerived pcd = new PCDerived();
            pcd.pi = 3;
            pcd.pbs = new PBase[] { pcd };

            Callback cb = new Callback();
            if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                testPrx.begin_exchangePBase(pcd).whenCompleted(
                    (PBase r) =>
                    {
                        test(!(r is PCDerived));
                        test(r.pi == 3);
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        test(false);
                    });
            }
            else
            {
                testPrx.begin_exchangePBase(pcd).whenCompleted(
                    (PBase r) =>
                    {
                        PCDerived p2 = r as PCDerived;
                        test(p2.pi == 3);
                        test(p2.pbs[0] == p2);
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        test(false);
                    });
            }
            cb.check();
        }

        {
            //
            // Server only knows the intermediate type Preserved. The object will be sliced to
            // Preserved for the 1.0 encoding; otherwise it should be returned intact.
            //
            CompactPCDerived pcd = new CompactPCDerived();
            pcd.pi = 3;
            pcd.pbs = new PBase[] { pcd };

            Callback cb = new Callback();
            if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                testPrx.begin_exchangePBase(pcd).whenCompleted(
                    (PBase r) =>
                    {
                        test(!(r is CompactPCDerived));
                        test(r.pi == 3);
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        test(false);
                    });
            }
            else
            {
                testPrx.begin_exchangePBase(pcd).whenCompleted(
                    (PBase r) =>
                    {
                        CompactPCDerived p2 = r as CompactPCDerived;
                        test(p2.pi == 3);
                        test(p2.pbs[0] == p2);
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        test(false);
                    });
            }
            cb.check();
        }

        {
            //
            // Send an object that will have multiple preserved slices in the server.
            // The object will be sliced to Preserved for the 1.0 encoding.
            //
            PCDerived3 pcd = new PCDerived3();
            pcd.pi = 3;
            //
            // Sending more than 254 objects exercises the encoding for object ids.
            //
            pcd.pbs = new PBase[300];
            for(int i = 0; i < 300; ++i)
            {
                PCDerived2 p2 = new PCDerived2();
                p2.pi = i;
                p2.pbs = new PBase[] { null }; // Nil reference. This slice should not have an indirection table.
                p2.pcd2 = i;
                pcd.pbs[i] = p2;
            }
            pcd.pcd2 = pcd.pi;
            pcd.pcd3 = pcd.pbs[10];

            Callback cb = new Callback();
            if(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                testPrx.begin_exchangePBase(pcd).whenCompleted(
                    (PBase r) =>
                    {
                        test(!(r is PCDerived3));
                        test(r is Preserved);
                        test(r.pi == 3);
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        test(false);
                    });
            }
            else
            {
                testPrx.begin_exchangePBase(pcd).whenCompleted(
                    (PBase r) =>
                    {
                        PCDerived3 p3 = r as PCDerived3;
                        test(p3.pi == 3);
                        for(int i = 0; i < 300; ++i)
                        {
                            PCDerived2 p2 = p3.pbs[i] as PCDerived2;
                            test(p2.pi == i);
                            test(p2.pbs.Length == 1);
                            test(p2.pbs[0] == null);
                            test(p2.pcd2 == i);
                        }
                        test(p3.pcd2 == p3.pi);
                        test(p3.pcd3 == p3.pbs[10]);
                        cb.called();
                    },
                    (Ice.Exception ex) =>
                    {
                        test(false);
                    });
            }
            cb.check();
        }

        try
        {
            //
            // Obtain an object with preserved slices and send it back to the server.
            // The preserved slices should be excluded for the 1.0 encoding, otherwise
            // they should be included.
            //
            Preserved p = testPrx.PBSUnknownAsPreserved();
            testPrx.checkPBSUnknown(p);
            if(!testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0))
            {
                (testPrx.ice_encodingVersion(Ice.Util.Encoding_1_0) as TestIntfPrx).checkPBSUnknown(p);
            }
        }
        catch(Ice.OperationNotExistException)
        {
        }

        WriteLine("ok");

        Write("garbage collection for preserved classes... ");
        Flush();
        try
        {
            //
            // Register a factory in order to substitute our own subclass of PNode. This provides
            // an easy way to determine how many unmarshaled instances currently exist.
            //
            communicator.addValueFactory((string id) =>
            {
                if(id.Equals(PNode.ice_staticId()))
                {
                    return new PNodeI();
                }
                return null;
            }, PNode.ice_staticId());

            //
            // Relay a graph through the server.
            //
            {
                PNode c = new PNode();
                c.next = new PNode();
                c.next.next = new PNode();
                c.next.next.next = c;

                test(PNodeI.counter == 0);
                PNode n = testPrx.exchangePNode(c);

                test(PNodeI.counter == 3);
                PNodeI.counter = 0;
                n.next = null;
            }

            //
            // Obtain a preserved object from the server where the most-derived
            // type is unknown. The preserved slice refers to a graph of PNode
            // objects.
            //
            {
                test(PNodeI.counter == 0);
                Preserved p = testPrx.PBSUnknownAsPreservedWithGraph();
                testPrx.checkPBSUnknownWithGraph(p);
                test(PNodeI.counter == 3);
                PNodeI.counter = 0;
            }

            //
            // Obtain a preserved object from the server where the most-derived
            // type is unknown. A data member in the preserved slice refers to the
            // outer object, so the chain of references looks like this:
            //
            // outer.slicedData.outer
            //
            {
                PreservedI.counter = 0;
                Preserved p = testPrx.PBSUnknown2AsPreservedWithGraph();
                testPrx.checkPBSUnknown2WithGraph(p);
                test(PreservedI.counter == 1);
                PreservedI.counter = 0;
            }

            //
            // Throw a preserved exception where the most-derived type is unknown.
            // The preserved exception slice contains a class data member. This
            // object is also preserved, and its most-derived type is also unknown.
            // The preserved slice of the object contains a class data member that
            // refers to itself.
            //
            // The chain of references looks like this:
            //
            // ex.slicedData.obj.slicedData.obj
            //
            try
            {
                test(PreservedI.counter == 0);

                try
                {
                    testPrx.throwPreservedException();
                }
                catch(PreservedException)
                {
                    test(PreservedI.counter == 1);
                }

                PreservedI.counter = 0;
            }
            catch(Exception)
            {
                test(false);
            }
        }
        catch(Ice.OperationNotExistException)
        {
        }

        WriteLine("ok");

#if SILVERLIGHT
        testPrx.shutdown();
#else
        return testPrx;
#endif
    }
Beispiel #4
0
    public static InitialPrx allTests(Ice.Communicator communicator)
#endif
    {
        communicator.addValueFactory(MyValueFactory, "::Test::B");
        communicator.addValueFactory(MyValueFactory, "::Test::C");
        communicator.addValueFactory(MyValueFactory, "::Test::D");
        communicator.addValueFactory(MyValueFactory, "::Test::E");
        communicator.addValueFactory(MyValueFactory, "::Test::F");
        communicator.addValueFactory(MyValueFactory, "::Test::I");
        communicator.addValueFactory(MyValueFactory, "::Test::J");
        communicator.addValueFactory(MyValueFactory, "::Test::H");

// Disable Obsolete warning/error
#pragma warning disable 612, 618
        communicator.addObjectFactory(new MyObjectFactory(), "TestOF");
#pragma warning restore 612, 618


        Write("testing stringToProxy... ");
        Flush();
        String @ref = "initial:default -p 12010";
        Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
        test(@base != null);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        InitialPrx initial = InitialPrxHelper.checkedCast(@base);
        test(initial != null);
        test(initial.Equals(@base));
        WriteLine("ok");

        Write("getting B1... ");
        Flush();
        B b1 = initial.getB1();
        test(b1 != null);
        WriteLine("ok");

        Write("getting B2... ");
        Flush();
        B b2 = initial.getB2();
        test(b2 != null);
        WriteLine("ok");

        Write("getting C... ");
        Flush();
        C c = initial.getC();
        test(c != null);
        WriteLine("ok");

        Write("getting D... ");
        Flush();
        D d = initial.getD();
        test(d != null);
        WriteLine("ok");

        Write("checking consistency... ");
        Flush();
        test(b1 != b2);
        //test(b1 != c);
        //test(b1 != d);
        //test(b2 != c);
        //test(b2 != d);
        //test(c != d);
        test(b1.theB == b1);
        test(b1.theC == null);
        test(b1.theA is B);
        test(((B) b1.theA).theA == b1.theA);
        test(((B) b1.theA).theB == b1);
        //test(((B)b1.theA).theC is C); // Redundant -- theC is always of type C
        test(((C) (((B) b1.theA).theC)).theB == b1.theA);
        test(b1.preMarshalInvoked);
        test(b1.postUnmarshalInvoked());
        test(b1.theA.preMarshalInvoked);
        test(b1.theA.postUnmarshalInvoked());
        test(((B)b1.theA).theC.preMarshalInvoked);
        test(((B)b1.theA).theC.postUnmarshalInvoked());

        // More tests possible for b2 and d, but I think this is already
        // sufficient.
        test(b2.theA == b2);
        test(d.theC == null);
        WriteLine("ok");

        Write("getting B1, B2, C, and D all at once... ");
        Flush();
        B b1out;
        B b2out;
        C cout;
        D dout;
        initial.getAll(out b1out, out b2out, out cout, out dout);
        test(b1out != null);
        test(b2out != null);
        test(cout != null);
        test(dout != null);
        WriteLine("ok");

        Write("checking consistency... ");
        Flush();
        test(b1out != b2out);
        test(b1out.theA == b2out);
        test(b1out.theB == b1out);
        test(b1out.theC == null);
        test(b2out.theA == b2out);
        test(b2out.theB == b1out);
        test(b2out.theC == cout);
        test(cout.theB == b2out);
        test(dout.theA == b1out);
        test(dout.theB == b2out);
        test(dout.theC == null);
        test(dout.preMarshalInvoked);
        test(dout.postUnmarshalInvoked());
        test(dout.theA.preMarshalInvoked);
        test(dout.theA.postUnmarshalInvoked());
        test(dout.theB.preMarshalInvoked);
        test(dout.theB.postUnmarshalInvoked());
        test(dout.theB.theC.preMarshalInvoked);
        test(dout.theB.theC.postUnmarshalInvoked());

        WriteLine("ok");

        Write("testing protected members... ");
        Flush();
        E e = initial.getE();
        test(e.checkValues());
        System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic |
                                               System.Reflection.BindingFlags.Public |
                                               System.Reflection.BindingFlags.Instance;
        test(!typeof(E).GetField("i", flags).IsPublic && !typeof(E).GetField("i", flags).IsPrivate);
        test(!typeof(E).GetField("s", flags).IsPublic && !typeof(E).GetField("s", flags).IsPrivate);
        F f = initial.getF();
        test(f.checkValues());
        test(f.e2.checkValues());
        test(!typeof(F).GetField("e1", flags).IsPublic && !typeof(F).GetField("e1", flags).IsPrivate);
        test(typeof(F).GetField("e2", flags).IsPublic && !typeof(F).GetField("e2", flags).IsPrivate);
        WriteLine("ok");

        Write("getting I, J and H... ");
        Flush();
        I i = initial.getI();
        test(i != null);
        I j = initial.getJ();
        test(j != null && ((J)j) != null);
        I h = initial.getH();
        test(h != null && ((H)h) != null);
        WriteLine("ok");

        Write("getting D1... ");
        Flush();
        D1 d1 = new D1(new A1("a1"), new A1("a2"), new A1("a3"), new A1("a4"));
        d1 = initial.getD1(d1);
        test(d1.a1.name.Equals("a1"));
        test(d1.a2.name.Equals("a2"));
        test(d1.a3.name.Equals("a3"));
        test(d1.a4.name.Equals("a4"));
        WriteLine("ok");

        Write("throw EDerived... ");
        Flush();
        try
        {
            initial.throwEDerived();
            test(false);
        }
        catch(EDerived ederived)
        {
            test(ederived.a1.name.Equals("a1"));
            test(ederived.a2.name.Equals("a2"));
            test(ederived.a3.name.Equals("a3"));
            test(ederived.a4.name.Equals("a4"));
        }
        WriteLine("ok");

        Write("setting I... ");
        Flush();
        initial.setI(i);
        initial.setI(j);
        initial.setI(h);
        WriteLine("ok");

        Write("testing sequences...");
        Flush();
        try
        {
            Base[] inS = new Base[0];
            Base[] outS;
            Base[] retS;
            retS = initial.opBaseSeq(inS, out outS);

            inS = new Base[1];
            inS[0] = new Base(new S(), "");
            retS = initial.opBaseSeq(inS, out outS);
            test(retS.Length == 1 && outS.Length == 1);
        }
        catch(Ice.OperationNotExistException)
        {
        }
        WriteLine("ok");

        Write("testing compact ID...");
        Flush();
        try
        {
            test(initial.getCompact() != null);
        }
        catch(Ice.OperationNotExistException)
        {
        }
        WriteLine("ok");

        Write("testing UnexpectedObjectException...");
        Flush();
        @ref = "uoet:default -p 12010";
        @base = communicator.stringToProxy(@ref);
        test(@base != null);
        UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrxHelper.uncheckedCast(@base);
        test(uoet != null);
        try
        {
            uoet.op();
            test(false);
        }
        catch(Ice.UnexpectedObjectException ex)
        {
            test(ex.type.Equals("::Test::AlsoEmpty"));
            test(ex.expectedType.Equals("::Test::Empty"));
        }
        catch(System.Exception ex)
        {
            WriteLine(ex.ToString());
            test(false);
        }
        WriteLine("ok");

// Disable Obsolete warning/error
#pragma warning disable 612, 618
        Write("testing getting ObjectFactory...");
        Flush();
        test(communicator.findObjectFactory("TestOF") != null);
        WriteLine("ok");
        Write("testing getting ObjectFactory as ValueFactory...");
        Flush();
        test(communicator.findValueFactory("TestOF") != null);
        WriteLine("ok");
#pragma warning restore 612, 618

#if SILVERLIGHT
        initial.shutdown();
#else
        return initial;
#endif
    }
Beispiel #5
0
    public static ThrowerPrx allTests(Ice.Communicator communicator)
#endif
    {
#if SILVERLIGHT
        WriteLine("Ice.FactoryAssemblies: " + communicator.getProperties().getProperty("Ice.FactoryAssemblies"));
#endif

#if !SILVERLIGHT
        {
            Write("testing object adapter registration exceptions... ");
            Ice.ObjectAdapter first;
            try
            {
                first = communicator.createObjectAdapter("TestAdapter0");
            }
            catch(Ice.InitializationException)
            {
                // Expected
            }

            communicator.getProperties().setProperty("TestAdapter0.Endpoints", "default");
            first = communicator.createObjectAdapter("TestAdapter0");
            try
            {
                communicator.createObjectAdapter("TestAdapter0");
                test(false);
            }
            catch(Ice.AlreadyRegisteredException)
            {
                // Expected.
            }

            try
            {
                Ice.ObjectAdapter second =
                    communicator.createObjectAdapterWithEndpoints("TestAdapter0", "ssl -h foo -p 12011");
                test(false);

                //
                // Quell mono error that variable second isn't used.
                //
                second.deactivate();
            }
            catch(Ice.AlreadyRegisteredException)
            {
                // Expected
            }
            first.deactivate();
            WriteLine("ok");
        }

        {
            Write("testing servant registration exceptions... ");
            communicator.getProperties().setProperty("TestAdapter1.Endpoints", "default");
            Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter1");
            Ice.Object obj = new EmptyI();
            adapter.add(obj, communicator.stringToIdentity("x"));
            try
            {
                adapter.add(obj, communicator.stringToIdentity("x"));
                test(false);
            }
            catch(Ice.AlreadyRegisteredException)
            {
            }

            try
            {
                adapter.add(obj, communicator.stringToIdentity(""));
                test(false);
            }
            catch(Ice.IllegalIdentityException e)
            {
                test(e.id.name.Equals(""));
            }

            try
            {
                adapter.add(null, communicator.stringToIdentity("x"));
                test(false);
            }
            catch(Ice.IllegalServantException)
            {
            }

            adapter.remove(communicator.stringToIdentity("x"));
            try
            {
                adapter.remove(communicator.stringToIdentity("x"));
                test(false);
            }
            catch(Ice.NotRegisteredException)
            {
            }
            adapter.deactivate();
            WriteLine("ok");
        }

        {
            Write("testing servant locator registration exceptions... ");
            communicator.getProperties().setProperty("TestAdapter2.Endpoints", "default");
            Ice.ObjectAdapter adapter = communicator.createObjectAdapter("TestAdapter2");
            Ice.ServantLocator loc = new ServantLocatorI();
            adapter.addServantLocator(loc, "x");
            try
            {
                adapter.addServantLocator(loc, "x");
                test(false);
            }
            catch(Ice.AlreadyRegisteredException)
            {
            }

            adapter.deactivate();
            WriteLine("ok");
        }
#endif
        {
            Write("testing object factory registration exception... ");
            communicator.addValueFactory( _ => { return null; }, "::x");
            try
            {
                communicator.addValueFactory( _ => { return null; }, "::x");
                test(false);
            }
            catch(Ice.AlreadyRegisteredException)
            {
            }
            WriteLine("ok");
        }

        Write("testing stringToProxy... ");
        Flush();
        String @ref = "thrower:default -p 12010";
        Ice.ObjectPrx @base = communicator.stringToProxy(@ref);
        test(@base != null);
        WriteLine("ok");

        Write("testing checked cast... ");
        Flush();
        ThrowerPrx thrower = ThrowerPrxHelper.checkedCast(@base);

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

        Write("catching exact types... ");
        Flush();

        try
        {
            thrower.throwAasA(1);
            test(false);
        }
        catch(A ex)
        {
            test(ex.aMem == 1);
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwAorDasAorD(1);
            test(false);
        }
        catch(A ex)
        {
            test(ex.aMem == 1);
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwAorDasAorD(- 1);
            test(false);
        }
        catch(D ex)
        {
            test(ex.dMem == - 1);
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwBasB(1, 2);
            test(false);
        }
        catch(B ex)
        {
            test(ex.aMem == 1);
            test(ex.bMem == 2);
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwCasC(1, 2, 3);
            test(false);
        }
        catch(C ex)
        {
            test(ex.aMem == 1);
            test(ex.bMem == 2);
            test(ex.cMem == 3);
        }
        catch(Exception)
        {
            test(false);
        }

        WriteLine("ok");

        Write("catching base types... ");
        Flush();

        try
        {
            thrower.throwBasB(1, 2);
            test(false);
        }
        catch(A ex)
        {
            test(ex.aMem == 1);
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwCasC(1, 2, 3);
            test(false);
        }
        catch(B ex)
        {
            test(ex.aMem == 1);
            test(ex.bMem == 2);
        }
        catch(Exception)
        {
            test(false);
        }

        WriteLine("ok");

        Write("catching derived types... ");
        Flush();

        try
        {
            thrower.throwBasA(1, 2);
            test(false);
        }
        catch(B ex)
        {
            test(ex.aMem == 1);
            test(ex.bMem == 2);
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwCasA(1, 2, 3);
            test(false);
        }
        catch(C ex)
        {
            test(ex.aMem == 1);
            test(ex.bMem == 2);
            test(ex.cMem == 3);
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwCasB(1, 2, 3);
            test(false);
        }
        catch(C ex)
        {
            test(ex.aMem == 1);
            test(ex.bMem == 2);
            test(ex.cMem == 3);
        }
        catch(Exception)
        {
            test(false);
        }

        WriteLine("ok");

        if(thrower.supportsUndeclaredExceptions())
        {
            Write("catching unknown user exception... ");
            Flush();

            try
            {
                thrower.throwUndeclaredA(1);
                test(false);
            }
            catch(Ice.UnknownUserException)
            {
            }
            catch(Exception)
            {
                test(false);
            }

            try
            {
                thrower.throwUndeclaredB(1, 2);
                test(false);
            }
            catch(Ice.UnknownUserException)
            {
            }
            catch(Exception)
            {
                test(false);
            }

            try
            {
                thrower.throwUndeclaredC(1, 2, 3);
                test(false);
            }
            catch(Ice.UnknownUserException)
            {
            }
            catch(Exception)
            {
                test(false);
            }

            WriteLine("ok");
        }

        if(thrower.ice_getConnection() != null)
        {
            Write("testing memory limit marshal exception...");
            Flush();
            try
            {
                thrower.throwMemoryLimitException(null);
                test(false);
            }
            catch(Ice.MemoryLimitException)
            {
            }
            catch(Exception)
            {
                test(false);
            }

            try
            {
                thrower.throwMemoryLimitException(new byte[20 * 1024]); // 20KB
                test(false);
            }
            catch(Ice.ConnectionLostException)
            {
            }
            catch(Exception)
            {
                test(false);
            }

            ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(
                communicator.stringToProxy("thrower:default -p 12011"));
            try
            {
                thrower2.throwMemoryLimitException(new byte[2 * 1024 * 1024]); // 2MB (no limits)
            }
            catch(Ice.MemoryLimitException)
            {
            }
            ThrowerPrx thrower3 = ThrowerPrxHelper.uncheckedCast(
                communicator.stringToProxy("thrower:default -p 12012"));
            try
            {
                thrower3.throwMemoryLimitException(new byte[1024]); // 1KB limit
                test(false);
            }
            catch(Ice.ConnectionLostException)
            {
            }

            WriteLine("ok");
        }

        Write("catching object not exist exception... ");
        Flush();

        {
            Ice.Identity id = communicator.stringToIdentity("does not exist");
            try
            {
                ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id));
                thrower2.ice_ping();
                test(false);
            }
            catch(Ice.ObjectNotExistException ex)
            {
                test(ex.id.Equals(id));
            }
            catch(Exception)
            {
                test(false);
            }
        }

        WriteLine("ok");

        Write("catching facet not exist exception... ");
        Flush();

        try
        {
            ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet");
            try
            {
                thrower2.ice_ping();
                test(false);
            }
            catch(Ice.FacetNotExistException ex)
            {
                test(ex.facet.Equals("no such facet"));
            }
        }
        catch(Exception)
        {
            test(false);
        }

        WriteLine("ok");

        Write("catching operation not exist exception... ");
        Flush();

        try
        {
            WrongOperationPrx thrower2 = WrongOperationPrxHelper.uncheckedCast(thrower);
            thrower2.noSuchOperation();
            test(false);
        }
        catch(Ice.OperationNotExistException ex)
        {
            test(ex.operation.Equals("noSuchOperation"));
        }
        catch(Exception)
        {
            test(false);
        }

        WriteLine("ok");

        Write("catching unknown local exception... ");
        Flush();

        try
        {
            thrower.throwLocalException();
            test(false);
        }
        catch(Ice.UnknownLocalException)
        {
        }
        catch(Exception)
        {
            test(false);
        }
        try
        {
            thrower.throwLocalExceptionIdempotent();
            test(false);
        }
        catch(Ice.UnknownLocalException)
        {
        }
        catch(Ice.OperationNotExistException)
        {
        }
        catch(Exception)
        {
            test(false);
        }

        WriteLine("ok");

        Write("catching unknown non-Ice exception... ");
        Flush();

        try
        {
            thrower.throwNonIceException();
            test(false);
        }
        catch(Ice.UnknownException)
        {
        }
        catch(System.Exception)
        {
            test(false);
        }

        WriteLine("ok");

        Write("testing asynchronous exceptions... ");
        Flush();

        try
        {
            thrower.throwAfterResponse();
        }
        catch(Exception)
        {
            test(false);
        }

        try
        {
            thrower.throwAfterException();
            test(false);
        }
        catch(A)
        {
        }
        catch(Exception)
        {
            test(false);
        }

        WriteLine("ok");

        Write("catching exact types with AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            thrower.begin_throwAasA(1).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    test(exc is A);
                    A ex = exc as A;
                    test(ex.aMem == 1);
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwAorDasAorD(1).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(A ex)
                    {
                        test(ex.aMem == 1);
                    }
                    catch(D ex)
                    {
                        test(ex.dMem == -1);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwAorDasAorD(-1).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                     try
                    {
                        throw exc;
                    }
                    catch(A ex)
                    {
                        test(ex.aMem == 1);
                    }
                    catch(D ex)
                    {
                        test(ex.dMem == -1);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwBasB(1, 2).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(B ex)
                    {
                        test(ex.aMem == 1);
                        test(ex.bMem == 2);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwCasC(1, 2, 3).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(C ex)
                    {
                        test(ex.aMem == 1);
                        test(ex.bMem == 2);
                        test(ex.cMem == 3);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching derived types with new AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            thrower.begin_throwBasA(1, 2).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(B ex)
                    {
                        test(ex.aMem == 1);
                        test(ex.bMem == 2);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwCasA(1, 2, 3).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                     try
                    {
                        throw exc;
                    }
                    catch(C ex)
                    {
                        test(ex.aMem == 1);
                        test(ex.bMem == 2);
                        test(ex.cMem == 3);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwCasB(1, 2, 3).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                     try
                    {
                        throw exc;
                    }
                    catch(C ex)
                    {
                        test(ex.aMem == 1);
                        test(ex.bMem == 2);
                        test(ex.cMem == 3);
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        if(thrower.supportsUndeclaredExceptions())
        {
            Write("catching unknown user exception with new AMI mapping... ");
            Flush();

            {
                Callback cb = new Callback();
                thrower.begin_throwUndeclaredA(1).whenCompleted(
                    () =>
                    {
                        test(false);
                    },
                    (Ice.Exception exc) =>
                    {
                        try
                        {
                            throw exc;
                        }
                        catch(Ice.UnknownUserException)
                        {
                        }
                        catch(Exception)
                        {
                            test(false);
                        }
                        cb.called();
                    });
                cb.check();
            }

            {
                Callback cb = new Callback();
                thrower.begin_throwUndeclaredB(1, 2).whenCompleted(
                    () =>
                    {
                        test(false);
                    },
                    (Ice.Exception exc) =>
                    {
                        try
                        {
                            throw exc;
                        }
                        catch(Ice.UnknownUserException)
                        {
                        }
                        catch(Exception)
                        {
                            test(false);
                        }
                        cb.called();
                    });
                cb.check();
            }

            {
                Callback cb = new Callback();
                thrower.begin_throwUndeclaredC(1, 2, 3).whenCompleted(
                    () =>
                    {
                        test(false);
                    },
                    (Ice.Exception exc) =>
                    {
                        try
                        {
                            throw exc;
                        }
                        catch(Ice.UnknownUserException)
                        {
                        }
                        catch(Exception)
                        {
                            test(false);
                        }
                        cb.called();
                    });
                cb.check();
            }

            WriteLine("ok");
        }

        Write("catching object not exist exception with new AMI mapping... ");
        Flush();

        {
            Ice.Identity id = communicator.stringToIdentity("does not exist");
            ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id));
            Callback cb = new Callback();
            thrower2.begin_throwAasA(1).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.ObjectNotExistException ex)
                    {
                        test(ex.id.Equals(id));
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching facet not exist exception with new AMI mapping... ");
        Flush();

        {
            ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet");
            Callback cb = new Callback();
            thrower2.begin_throwAasA(1).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.FacetNotExistException ex)
                    {
                        test(ex.facet.Equals("no such facet"));
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching operation not exist exception with new AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            WrongOperationPrx thrower4 = WrongOperationPrxHelper.uncheckedCast(thrower);
            thrower4.begin_noSuchOperation().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.OperationNotExistException ex)
                    {
                        test(ex.operation.Equals("noSuchOperation"));
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching unknown local exception with new AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            thrower.begin_throwLocalException().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.UnknownLocalException)
                    {
                    }
                    catch(Ice.OperationNotExistException)
                    {
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwLocalExceptionIdempotent().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.UnknownLocalException)
                    {
                    }
                    catch(Ice.OperationNotExistException)
                    {
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching unknown non-Ice exception with new AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            thrower.begin_throwNonIceException().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.UnknownException)
                    {
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        // ----------------------------------------
        if(thrower.supportsUndeclaredExceptions())
        {
            Write("catching unknown user exception with new AMI mapping... ");
            Flush();

            {
                Callback cb = new Callback();
                thrower.begin_throwUndeclaredA(1).whenCompleted(
                    () =>
                    {
                        test(false);
                    },
                    (Ice.Exception exc) =>
                    {
                        try
                        {
                            throw exc;
                        }
                        catch(Ice.UnknownUserException)
                        {
                        }
                        catch(Exception)
                        {
                            test(false);
                        }
                        cb.called();
                    });
                cb.check();
            }

            {
                Callback cb = new Callback();
                thrower.begin_throwUndeclaredB(1, 2).whenCompleted(
                    () =>
                    {
                        test(false);
                    },
                    (Ice.Exception exc) =>
                    {
                        try
                        {
                            throw exc;
                        }
                        catch(Ice.UnknownUserException)
                        {
                        }
                        catch(Exception)
                        {
                            test(false);
                        }
                        cb.called();
                    });
                cb.check();
            }

            {
                Callback cb = new Callback();
                thrower.begin_throwUndeclaredC(1, 2, 3).whenCompleted(
                    () =>
                    {
                        test(false);
                    },
                    (Ice.Exception exc) =>
                    {
                        try
                        {
                            throw exc;
                        }
                        catch(Ice.UnknownUserException)
                        {
                        }
                        catch(Exception)
                        {
                            test(false);
                        }
                        cb.called();
                    });
                cb.check();
            }

            WriteLine("ok");
        }

        Write("catching object not exist exception with new AMI mapping... ");
        Flush();

        {
            Ice.Identity id = communicator.stringToIdentity("does not exist");
            ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower.ice_identity(id));
            Callback cb = new Callback();
            thrower2.begin_throwAasA(1).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.ObjectNotExistException ex)
                    {
                        test(ex.id.Equals(id));
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching facet not exist exception with new AMI mapping... ");
        Flush();

        {
            ThrowerPrx thrower2 = ThrowerPrxHelper.uncheckedCast(thrower, "no such facet");
            Callback cb = new Callback();
            thrower2.begin_throwAasA(1).whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.FacetNotExistException ex)
                    {
                        test(ex.facet.Equals("no such facet"));
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching operation not exist exception with new AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            WrongOperationPrx thrower4 = WrongOperationPrxHelper.uncheckedCast(thrower);
            thrower4.begin_noSuchOperation().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.OperationNotExistException ex)
                    {
                        test(ex.operation.Equals("noSuchOperation"));
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching unknown local exception with new AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            thrower.begin_throwLocalException().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.UnknownLocalException)
                    {
                    }
                    catch(Ice.OperationNotExistException)
                    {
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        {
            Callback cb = new Callback();
            thrower.begin_throwLocalExceptionIdempotent().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.UnknownLocalException)
                    {
                    }
                    catch(Ice.OperationNotExistException)
                    {
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");

        Write("catching unknown non-Ice exception with new AMI mapping... ");
        Flush();

        {
            Callback cb = new Callback();
            thrower.begin_throwNonIceException().whenCompleted(
                () =>
                {
                    test(false);
                },
                (Ice.Exception exc) =>
                {
                    try
                    {
                        throw exc;
                    }
                    catch(Ice.UnknownException)
                    {
                    }
                    catch(Exception)
                    {
                        test(false);
                    }
                    cb.called();
                });
            cb.check();
        }

        WriteLine("ok");
#if SILVERLIGHT
        thrower.shutdown();
#else
        return thrower;
#endif
    }