public void test_S1_export()
        {
            StructValue sv = vf.ExportCustomValue(new S1(19, 23, 29));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S1);
            Assert.AreEqual(3, sv.Count);
            Assert.AreEqual(19, sv.Get(ValueFactoryTest1._mf_x));
            Assert.AreEqual(23, sv.Get(ValueFactoryTest1._mf_y));
            Assert.AreEqual(29, sv.Get(ValueFactoryTest1._mf_z));
        }
        public void test_excps_export()
        {
            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 = vf.ExportCustomValue(new Excp1("abc", 23));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp1);
            Assert.AreEqual(2, sv.Count);
            Assert.AreEqual("abc", sv.Get(ValueFactoryTest1._mf_msg));
            Assert.AreEqual(23, sv.Get(ValueFactoryTest1._mf_code));

            sv = vf.ExportCustomValue(new Excp2());
            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp2);
            Assert.AreEqual(0, sv.Count);

            sv = vf.ExportCustomValue(new Excp3());
            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp3);
            Assert.AreEqual(0, sv.Count);

            sv = vf.ExportCustomValue(new Excp4());
            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_Excp4);
            Assert.AreEqual(0, sv.Count);

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

            // Import exception with array of object as param
            testExcp6Export(msg, code, boolObject);
            testExcp6Export(msg, code, byteObject);
            testExcp6Export(msg, code, shortObject);
            testExcp6Export(msg, code, intObject);
            testExcp6Export(msg, code, longObject);
            testExcp6Export(msg, code, floatObject);
            testExcp6Export(msg, code, doubleObject);
            testExcp6Export(msg, code, stringObject);
        }
        public void test_S2_export()
        {
            S1 a = new S1(21, 22, 23);
            S1 b = new S1(31, 32, 33);
            E1 c = E1.A;

            StructValue sv = vf.ExportCustomValue(new S2(a, b, c));

            sv.CheckType(ValueFactoryTest1._mt_org_apache_etch_tests_Test1_S2);
            Assert.AreEqual(3, sv.Count);

            Assert.AreEqual(a, sv.Get(ValueFactoryTest1._mf_a));
            Assert.AreEqual(b, sv.Get(ValueFactoryTest1._mf_b));
            Assert.AreEqual(c, sv.Get(ValueFactoryTest1._mf_c));
        }
        private void testEnumExport(E1 e, XType t, Field f)
        {
            StructValue sv = vf.ExportCustomValue(e);

            sv.CheckType(t);
            Assert.AreEqual(1, sv.Count);
            Assert.IsTrue((Boolean)sv.Get(f));
        }
Example #5
0
        public void ExportCustomValue_RuntimeException_msg()
        {
            Exception   value = new NullReferenceException("foo != null");
            StructValue sv    = vf.ExportCustomValue(value);

            sv.CheckType(vf.GetType("_Etch_RuntimeException"));
            Assert.AreEqual(1, sv.Count);
            Assert.AreEqual("System.NullReferenceException: foo != null",
                            sv.Get(DefaultValueFactory._mf_msg));
        }
Example #6
0
        public void ExportCustomValue_RuntimeException()
        {
            Exception   value = new NullReferenceException();
            StructValue sv    = vf.ExportCustomValue(value);

            sv.CheckType(vf.GetType("_Etch_RuntimeException"));
            Assert.AreEqual(1, sv.Count);
            Assert.AreEqual("System.NullReferenceException: Object reference not set to an instance of an object.",
                            sv.Get(DefaultValueFactory._mf_msg));
        }
Example #7
0
        public override Object ImportValue(StructValue sv)
        {
            StrStrHashMap map = new StrStrHashMap();

            Object[] keysAndValues = ( Object[] )sv.Get(field);
            int      n             = keysAndValues.Length;
            int      index         = 0;

            while (index < n)
            {
                String key   = ( String )keysAndValues[index++];
                String value = ( String )keysAndValues[index++];
                map.Add(key, value);
            }

            return(map);
        }
Example #8
0
        public override Object ImportValue(StructValue sv)
        {
            //    List<object> list = new List<object>();
            ArrayList list = new ArrayList();

            Object[] values = ( Object[] )sv.Get(field);
            int      n      = values.Length;
            int      index  = 0;

            while (index < n)
            {
                object value = ( object )values[index++];
                list.Add(value);
            }

            return(list);
        }
Example #9
0
        public override Object ImportValue(StructValue sv)
        {
            //      Dictionary<object,object> map = new Dictionary<object,object>();
            Hashtable map = new Hashtable();

            Object[] keysAndValues = ( Object[] )sv.Get(field);
            int      n             = keysAndValues.Length;
            int      index         = 0;

            while (index < n)
            {
                object key   = ( object )keysAndValues[index++];
                object value = ( object )keysAndValues[index++];
                map.Add(key, value);
            }

            return(map);
        }
Example #10
0
            /**
             * Handle messages from peer.
             * @param sender
             * @param msg
             * @throws Exception
             */
            public void dispatch(Who sender, Message msg)
            {
                Console.WriteLine("msg = " + msg);
                if (msg.IsType(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeServer_doit))
                {
                    StructValue req = (StructValue)msg.Get(MyValueFactoryCuae._mf_req);
                    MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Request.CheckIsAssignableFrom(req.GetXType);
                    int?code = (int?)req.Get(MyValueFactoryCuae._mf_code);

                    // String m;
                    StructValue resp;
                    switch (code.GetValueOrDefault())
                    {
                    case 23:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "foo");
                        delayDoit2a(7);
                        break;

                    case 19:
                        resp =
                            new StructValue(
                                MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "bar");
                        resp.Add(MyValueFactoryCuae._mf_code, 54);
                        delayDoit2b(11, "heaven");
                        break;

                    case 13:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "baz");
                        delayDoit2a(99);
                        break;

                    default:
                        resp =
                            new StructValue(
                                MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, " unknown code " + code);
                        resp.Add(MyValueFactoryCuae._mf_code, 63);
                        delayDoit2b(23, "killer bee");
                        break;
                    }



                    Message rmsg = msg.Reply();
                    Console.WriteLine("rmsg = " + rmsg);
                    Console.WriteLine("resp = " + resp);
                    rmsg.Add(MyValueFactoryCuae._mf_result, resp);
                    svc.TransportMessage(sender, rmsg);
                    return;
                }

                if (msg.IsType(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_CuaeServer_doit3))
                {
                    StructValue[] reqs = (StructValue[])msg.Get(MyValueFactoryCuae._mf_req);
                    StructValue   req  = reqs[0];
                    MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Request.CheckIsAssignableFrom(
                        req.GetXType);
                    int?code = (int?)req.Get(MyValueFactoryCuae._mf_code);

                    StructValue resp;
                    switch (code.GetValueOrDefault())
                    {
                    case 23:
                        resp =
                            new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "foo");
                        delayDoit2a(7);
                        break;

                    case 19:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "bar");
                        resp.Add(MyValueFactoryCuae._mf_code, 54);
                        delayDoit2b(11, "heaven");
                        break;

                    case 13:
                        resp =
                            new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_Response, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "baz");
                        delayDoit2a(99);
                        break;

                    default:
                        resp = new StructValue(MyValueFactoryCuae._mt_etch_bindings_csharp_examples_cuae_Cuae_RespWithCode, vf);
                        resp.Add(MyValueFactoryCuae._mf_msg, "unknown code " + code);
                        resp.Add(MyValueFactoryCuae._mf_code, 63);
                        delayDoit2b(23, "killer bee");
                        break;
                    }

                    Message rmsg = msg.Reply();
                    Console.WriteLine("rmsg = " + rmsg);
                    Console.WriteLine("resp = " + resp);
                    rmsg.Add(MyValueFactoryCuae._mf_result, new StructValue[] { resp });
                    svc.TransportMessage(sender, rmsg);
                    return;
                }


                throw new Exception("unknown msg type " + msg);
            }
Example #11
0
        public override Object ImportValue(StructValue sv)
        {
            long ms = (long)sv.Get(field);

            return(new DateTime(epoch + ms * TICKS_PER_MS, DateTimeKind.Utc).ToLocalTime());
        }
Example #12
0
 public override Object ImportValue(StructValue sv)
 {
     return(new URL((String)sv.Get(field)));
 }
Example #13
0
 public override Object ImportValue(StructValue sv)
 {
     sv.CheckType(type);
     return(new _Etch_RuntimeException((String)sv.Get(field)));
 }