diff options
Diffstat (limited to 'test/org')
4 files changed, 31 insertions, 7 deletions
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 8a1602de7..daa495a17 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -270,14 +270,14 @@ public class ProtocolTest extends BaseTest { protected void verifyCommand( BaseProtocolEncoder encoder, Command command, ChannelBuffer expected) throws Exception { - verifyDecodedCommand(encoder.encodeCommand(command), expected); + verifyFrame(expected, encoder.encodeCommand(command)); } - private void verifyDecodedCommand(Object decodedObject, ChannelBuffer expected) { + protected void verifyFrame(ChannelBuffer expected, Object object) { - Assert.assertNotNull("command is null", decodedObject); - Assert.assertTrue("not a buffer", decodedObject instanceof ChannelBuffer); - Assert.assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) decodedObject)); + Assert.assertNotNull("buffer is null", object); + Assert.assertTrue("not a buffer", object instanceof ChannelBuffer); + Assert.assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) object)); } diff --git a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index e694022f2..9e2571916 100644 --- a/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -10,6 +10,12 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(new Gl200Protocol()); + verifyNull(decoder, buffer( + "+RESP:GTINF,280500,A1000043D20139,GL300VC,41,,31,0,0,,,3.87,0,1,1,,,20170802150751,70,,48.0,,,20170802112145,03AC$")); + + verifyAttributes(decoder, buffer( + "+RESP:GTINF,2D0300,A1000043D20139,1G1JC5444R7252367,,11,,31,0,1,12986,,4.16,0,2,,,20170802145640,,,,,,+0000,0,20170802145643,CD5A$")); + verifyPosition(decoder, buffer( "+RESP:GTMPN,450102,865084030001323,gb100,0,1.6,0,-93.1,121.393023,31.164105,20170619103113,0460,0000,1806,2142,00,20170619103143,0512$")); diff --git a/test/org/traccar/protocol/Vt200FrameDecoderTest.java b/test/org/traccar/protocol/Vt200FrameDecoderTest.java index b31e14b7d..a9fff6c33 100644 --- a/test/org/traccar/protocol/Vt200FrameDecoderTest.java +++ b/test/org/traccar/protocol/Vt200FrameDecoderTest.java @@ -11,11 +11,11 @@ public class Vt200FrameDecoderTest extends ProtocolTest { Vt200FrameDecoder decoder = new Vt200FrameDecoder(); - Assert.assertEquals( + verifyFrame( binary("28631037309456208400340102dc0906171616454415760201144494473f920a0c0000030500200100417c1f383a9d1090510000006a00007000000e00180ee129"), decoder.decode(null, null, binary("28631037309456208400340102dc0906171616454415760201144494473f920a0c0000030500200100417c1f383a9d1090510000006a00007000000e00180ee129"))); - Assert.assertEquals( + verifyFrame( binary("28631037309456208400340102f51306171327294418267501208948170231071f0000044300200100005f02180000667500000000000000000000080000624629"), decoder.decode(null, null, binary("28631037309456208400340102f513061713273d144418267501208948170231071f0000044300200100005f02180000667500000000000000000000080000624629"))); diff --git a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java index d63bf0062..37d9c46d9 100644 --- a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java @@ -11,6 +11,24 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { Vt200ProtocolDecoder decoder = new Vt200ProtocolDecoder(new Vt200Protocol()); verifyNull(decoder, binary( + "286310373094563082002701033d010817143327c68a14841e00c27f550e9a000000000c000000084700200120007d01af260b29")); + + verifyPosition(decoder, binary( + "286310373094562086002101033d010817143328441790420114817637207d090a00000847002001207f00d6f229")); + + verifyPosition(decoder, binary( + "286310373094562086002101033d0108171433354417932101148139772c9d080a00000847002001207f00dc6729")); + + verifyNull(decoder, binary( + "2863103730945600880012180108171433004418103801148375470000dd29")); + + verifyNull(decoder, binary( + "28631037309456108800002e29")); + + verifyNull(decoder, binary( + "2863103730945630880062033c862631037309456f222014604362936f01081713365601081713571904c800001b2c000034f66827f0840000000000000000000000000047000006e7000001b9022a000023ff000007f2018a00000a10000003f300cd00000d8d0300000302002729")); + + verifyNull(decoder, binary( "28631037309456008e000801042307171804584229")); verifyNull(decoder, binary( |