Пример #1
0
        public void ReadXxlJob()
        {
            XxlJob job = new XxlJob();

            job.requestParameterTypes    = new Class[2];
            job.requestParameterTypes[0] = Class.OfName("int");
            job.requestParameterTypes[1] = Class.OfType <Car>();
            job.requestParameters        = new object[2];
            job.requestParameters[0]     = 1;
            job.requestParameters[1]     = new Car("red", "corvette");
            job.responseMessage          = "ok";
            job.responseResult           = new GenericType(200, "hello");
            Serializer.Serialize(Stream, job);

            Stream.Seek(0, SeekOrigin.Begin);
            Serializer.Reset();
            var result = (XxlJob)Serializer.DeSerialize(Stream);

            Assert.Equal(job.requestParameterTypes[0].name, result.requestParameterTypes[0].name);
            Assert.Equal(job.requestParameterTypes[1].name, result.requestParameterTypes[1].name);
            Assert.Equal(job.requestParameters[0], result.requestParameters[0]);
            Assert.Equal(job.requestParameters[1], result.requestParameters[1]);
            Assert.Equal(job.responseMessage, result.responseMessage);
            Assert.Equal(job.responseResult, result.responseResult);
        }
Пример #2
0
        public void WriteXxlJob()
        {
            XxlJob job = new XxlJob();

            job.requestParameterTypes    = new Class[2];
            job.requestParameterTypes[0] = Class.OfName("int");
            job.requestParameterTypes[1] = Class.OfType <Car>();
            job.requestParameters        = new object[2];
            job.requestParameters[0]     = 1;
            job.requestParameters[1]     = new Car("red", "corvette");
            job.responseMessage          = "ok";
            job.responseResult           = new GenericType(200, "hello");
            Serializer.Serialize(Stream, job);
            GetAndReset();
        }
Пример #3
0
        public void ReadXxlJobFromJava()
        {
            XxlJob job = new XxlJob();

            job.requestParameterTypes    = new Class[2];
            job.requestParameterTypes[0] = Class.OfName("int");
            job.requestParameterTypes[1] = Class.OfType <Car>();
            job.requestParameters        = new object[2];
            job.requestParameters[0]     = 1;
            job.requestParameters[1]     = new Car("red", "corvette");
            job.responseMessage          = "ok";
            job.responseResult           = new GenericType(200, "hello");

            var hexString = "x43x17x63x6fx6dx2ex63x61x75x63x68x6fx2ex6dx6fx64x65x6cx2ex58x78x6cx4ax6fx62x94x0fx72x65x73x70x6fx6ex73x65x4dx65x73x73x61x67x65x15x72x65x71x75x65x73x74x50x61x72x61x6dx65x74x65x72x54x79x70x65x73x11x72x65x71x75x65x73x74x50x61x72x61x6dx65x74x65x72x73x0ex72x65x73x70x6fx6ex73x65x52x65x73x75x6cx74x60x02x6fx6bx72x10x5bx6ax61x76x61x2ex6cx61x6ex67x2ex43x6cx61x73x73x43x0fx6ax61x76x61x2ex6cx61x6ex67x2ex43x6cx61x73x73x91x04x6ex61x6dx65x61x03x69x6ex74x61x14x63x6fx6dx2ex63x61x75x63x68x6fx2ex6dx6fx64x65x6cx2ex43x61x72x72x07x5bx6fx62x6ax65x63x74x91x43x14x63x6fx6dx2ex63x61x75x63x68x6fx2ex6dx6fx64x65x6cx2ex43x61x72x92x05x63x6fx6cx6fx72x05x6dx6fx64x65x6cx62x03x72x65x64x08x63x6fx72x76x65x74x74x65x43x1cx63x6fx6dx2ex63x61x75x63x68x6fx2ex6dx6fx64x65x6cx2ex47x65x6ex65x72x69x63x54x79x70x65x92x04x63x6fx64x65x04x64x61x74x61x63xc8xc8x05x68x65x6cx6cx6f";
            var result    = (XxlJob)Serializer.DeSerialize(hexString.ToStream());

            Assert.Equal(job.requestParameterTypes[0].name, result.requestParameterTypes[0].name);
            Assert.Equal(job.requestParameterTypes[1].name, result.requestParameterTypes[1].name);
            Assert.Equal(job.requestParameters[0], result.requestParameters[0]);
            Assert.Equal(job.requestParameters[1], result.requestParameters[1]);
            Assert.Equal(job.responseMessage, result.responseMessage);
            Assert.Equal(job.responseResult, result.responseResult);
        }