Пример #1
0
        public void except_Excp1()
        {
            Excp1 e = new Excp1("foo", 23);

            Assert.AreEqual("foo", e.msg);
            Assert.AreEqual(23, e.code);

            e = new Excp1(null, null);
            Assert.IsNull(e.msg);
            Assert.IsNull(e.code);

            e = new Excp1();
            Assert.IsNull(e.msg);
            Assert.IsNull(e.code);

            e.msg  = "bar";
            e.code = 24;

            Assert.AreEqual("bar", e.msg);
            Assert.AreEqual(24, e.code);

            e.msg  = null;
            e.code = null;

            Assert.IsNull(e.msg);
            Assert.IsNull(e.code);

            //Throwable t = e;
            //Assert.IsTrue( t is Exception );
            //Assert.IsFalse( t is RuntimeException );
        }
Пример #2
0
        public void method_blow()
        {
            Message msg = new Message(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_blow, vf);

            msg.Add(ValueFactoryTest1._mf_msg, "foo");
            msg.Add(ValueFactoryTest1._mf_code, 23);
            stub.SessionMessage(null, msg);
            // check the result.
            src.xreply.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1__result_blow);
            Assert.AreEqual(1, src.xreply.Count);
            Excp1 e = (Excp1)src.xreply.Get(ValueFactoryTest1._mf_result);

            Assert.IsNotNull(e);
            Assert.AreEqual("foo", e.msg);
            Assert.AreEqual(23, e.code);
        }
Пример #3
0
        public void test_excps_import()
        {
            Object[] boolObject   = new Object[] { ConstsTest1.BOOL1, ConstsTest1.BOOL2 };
            Object[] byteObject   = new Object[] { ConstsTest1.BYTE1, ConstsTest1.BYTE2, ConstsTest1.BYTE3, ConstsTest1.BYTE4, ConstsTest1.BYTE5 };
            Object[] shortObject  = new Object[] { ConstsTest1.SHORT1, ConstsTest1.SHORT2, ConstsTest1.SHORT3, ConstsTest1.SHORT4, ConstsTest1.SHORT5 };
            Object[] intObject    = new Object[] { ConstsTest1.INT1, ConstsTest1.INT2, ConstsTest1.INT3, ConstsTest1.INT4, ConstsTest1.INT5 };
            Object[] longObject   = new Object[] { ConstsTest1.LONG1, ConstsTest1.LONG2, ConstsTest1.LONG3, ConstsTest1.LONG4, ConstsTest1.LONG5 };
            Object[] floatObject  = new Object[] { ConstsTest1.FLOAT1, ConstsTest1.FLOAT2, ConstsTest1.FLOAT3, ConstsTest1.FLOAT4, ConstsTest1.FLOAT5 };
            Object[] doubleObject = new Object[] { ConstsTest1.DOUBLE1, ConstsTest1.DOUBLE2, ConstsTest1.DOUBLE3, ConstsTest1.DOUBLE4, ConstsTest1.DOUBLE5 };
            Object[] stringObject = new Object[] { ConstsTest1.STRING1, ConstsTest1.STRING2, ConstsTest1.STRING3, ConstsTest1.STRING4, ConstsTest1.STRING5 };

            String msg  = "Exception";
            int    code = 500;

            StructValue sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp1, vf);

            sv.Add(ValueFactoryTest1._mf_msg, "def");
            sv.Add(ValueFactoryTest1._mf_code, 29);
            Excp1 e1 = ( Excp1 )vf.ImportCustomValue(sv);

            Assert.AreEqual("def", e1.msg);
            Assert.AreEqual(29, e1.code);
            e1 = null;

            sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp2, vf);
            Excp2 e2 = ( Excp2 )vf.ImportCustomValue(sv);

            Assert.IsNotNull(e2);
            e2 = null;

            sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp3, vf);
            Excp3 e3 = ( Excp3 )vf.ImportCustomValue(sv);

            Assert.IsNotNull(e3);
            e3 = null;

            sv = new StructValue(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp4, vf);
            Excp4 e4 = ( Excp4 )vf.ImportCustomValue(sv);

            Assert.IsNotNull(e4);
            e4 = null;

            // Import exception with object as param
            testExcp5Import(msg, code, ConstsTest1.BOOL2);
            testExcp5Import(msg, code, ConstsTest1.BYTE5);
            testExcp5Import(msg, code, ConstsTest1.SHORT5);
            testExcp5Import(msg, code, ConstsTest1.INT5);
            testExcp5Import(msg, code, ConstsTest1.LONG5);
            testExcp5Import(msg, code, ConstsTest1.FLOAT5);
            testExcp5Import(msg, code, ConstsTest1.DOUBLE5);
            testExcp5Import(msg, code, ConstsTest1.STRING3);

            // Import exception with array of object as param
            testExcp6Import(msg, code, boolObject);
            testExcp6Import(msg, code, byteObject);
            testExcp6Import(msg, code, shortObject);
            testExcp6Import(msg, code, intObject);
            testExcp6Import(msg, code, longObject);
            testExcp6Import(msg, code, floatObject);
            testExcp6Import(msg, code, doubleObject);
            testExcp6Import(msg, code, stringObject);
        }