diff options
Diffstat (limited to 'test')
48 files changed, 433 insertions, 109 deletions
diff --git a/test/org/traccar/ProtocolDecoderTest.java b/test/org/traccar/ProtocolDecoderTest.java index e52ea4695..133b0229f 100644 --- a/test/org/traccar/ProtocolDecoderTest.java +++ b/test/org/traccar/ProtocolDecoderTest.java @@ -38,7 +38,7 @@ public class ProtocolDecoderTest { } @Override - public Device getDeviceByUniqueId(String imei) { + public Device getDeviceByUniqueId(String uniqueId) { return createDevice(); } @@ -67,8 +67,8 @@ public class ProtocolDecoderTest { protected void verifyPositions(BaseProtocolDecoder decoder, Object object) throws Exception { Object decodedObject = decoder.decode(null, null, object); - Assert.assertNotNull(decodedObject); - Assert.assertTrue(decodedObject instanceof List); + Assert.assertNotNull("list is null", decodedObject); + Assert.assertTrue("not a list", decodedObject instanceof List); Assert.assertFalse("list if empty", ((List) decodedObject).isEmpty()); for (Object item : (List) decodedObject) { verifyDecodedPosition(item); @@ -77,8 +77,8 @@ public class ProtocolDecoderTest { protected void verifyPositions(BaseProtocolDecoder decoder, Object object, Position position) throws Exception { Object decodedObject = decoder.decode(null, null, object); - Assert.assertNotNull(decodedObject); - Assert.assertTrue(decodedObject instanceof List); + Assert.assertNotNull("list is null", decodedObject); + Assert.assertTrue("not a list", decodedObject instanceof List); Assert.assertFalse("list if empty", ((List) decodedObject).isEmpty()); for (Object item : (List) decodedObject) { verifyDecodedPosition(item, position); @@ -154,6 +154,17 @@ public class ProtocolDecoderTest { Assert.assertEquals("latitude", expected.getLatitude(), position.getLatitude(), 0.00001); Assert.assertEquals("longitude", expected.getLongitude(), position.getLongitude(), 0.00001); + Assert.assertTrue("altitude >= -12262", position.getAltitude() >= -12262); + Assert.assertTrue("altitude <= 18000", position.getAltitude() <= 18000); + + Assert.assertTrue("speed >= 0", position.getSpeed() >= 0); + Assert.assertTrue("speed <= 869", position.getSpeed() <= 869); + + Assert.assertTrue("course >= 0", position.getCourse() >= 0); + Assert.assertTrue("course <= 360", position.getCourse() <= 360); + + Assert.assertNotNull("protocol is null", position.getProtocol()); + } private void verifyDecodedPosition(Object decodedObject) { @@ -183,6 +194,8 @@ public class ProtocolDecoderTest { Assert.assertTrue("course >= 0", position.getCourse() >= 0); Assert.assertTrue("course <= 360", position.getCourse() <= 360); + Assert.assertNotNull("protocol is null", position.getProtocol()); + } } diff --git a/test/org/traccar/helper/ChannelBufferToolsTest.java b/test/org/traccar/helper/ChannelBufferToolsTest.java index 6e2c6310c..6733a8f2a 100644 --- a/test/org/traccar/helper/ChannelBufferToolsTest.java +++ b/test/org/traccar/helper/ChannelBufferToolsTest.java @@ -1,8 +1,7 @@ package org.traccar.helper; import org.jboss.netty.buffer.ChannelBuffers; - -import static org.junit.Assert.*; +import org.junit.Assert; import org.junit.Test; public class ChannelBufferToolsTest { @@ -12,7 +11,15 @@ public class ChannelBufferToolsTest { byte[] buf = {0x01, (byte) 0x90, 0x34}; int result = ChannelBufferTools.readHexInteger( ChannelBuffers.wrappedBuffer(buf), 5); - assertEquals(1903, result); + Assert.assertEquals(1903, result); + } + + @Test + public void testReadCoordinate() { + byte[] buf = {0x03, (byte) 0x85, 0x22, 0x59, 0x34}; + double result = ChannelBufferTools.readCoordinate( + ChannelBuffers.wrappedBuffer(buf)); + Assert.assertEquals(38.870989, result, 0.00001); } } diff --git a/test/org/traccar/helper/ObdDecoderTest.java b/test/org/traccar/helper/ObdDecoderTest.java new file mode 100644 index 000000000..238f3e0a6 --- /dev/null +++ b/test/org/traccar/helper/ObdDecoderTest.java @@ -0,0 +1,19 @@ +package org.traccar.helper; + +import org.junit.Assert; +import org.junit.Test; + +public class ObdDecoderTest { + + @Test + public void testDecode() { + + Assert.assertEquals(83, ObdDecoder.decode(0x01, 0x05, "7b").getValue()); + Assert.assertEquals(1225, ObdDecoder.decode(0x01, 0x0C, "1324").getValue()); + Assert.assertEquals(20, ObdDecoder.decode(0x01, 0x0D, "14").getValue()); + Assert.assertEquals(64050, ObdDecoder.decode(0x01, 0x31, "fa32").getValue()); + Assert.assertEquals(25, ObdDecoder.decode(0x01, 0x2F, "41").getValue()); + + } + +} diff --git a/test/org/traccar/helper/PatternBuilderTest.java b/test/org/traccar/helper/PatternBuilderTest.java index 36054bcea..975cc1621 100644 --- a/test/org/traccar/helper/PatternBuilderTest.java +++ b/test/org/traccar/helper/PatternBuilderTest.java @@ -8,7 +8,7 @@ public class PatternBuilderTest { @Test public void testPatternBuilder() { Assert.assertEquals("\\$GPRMC", new PatternBuilder().text("$GPRMC").toString()); - Assert.assertEquals("(\\d{2}\\.\\p{XDigit}+)", new PatternBuilder().number("(dd.x+)").toString()); + Assert.assertEquals("(\\d{2}\\.[0-9a-fA-F]+)", new PatternBuilder().number("(dd.x+)").toString()); Assert.assertEquals("a(?:bc)?", new PatternBuilder().text("a").text("b").text("c").optional(2).toString()); Assert.assertEquals("a|b", new PatternBuilder().expression("a|b").toString()); Assert.assertEquals("ab\\|", new PatternBuilder().expression("ab|").toString()); diff --git a/test/org/traccar/protocol/Ardi01ProtocolDecoderTest.java b/test/org/traccar/protocol/Ardi01ProtocolDecoderTest.java index be5578683..717dfd958 100644 --- a/test/org/traccar/protocol/Ardi01ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Ardi01ProtocolDecoderTest.java @@ -11,6 +11,10 @@ public class Ardi01ProtocolDecoderTest extends ProtocolDecoderTest { Ardi01ProtocolDecoder decoder = new Ardi01ProtocolDecoder(new Ardi01Protocol()); verifyPosition(decoder, text( + "013227003054776,20141010052719,24.4736042,56.8445807,110,289,40,7,5,78,-1"), + position("2014-10-10 05:27:19.000", true, 56.84458, 24.47360)); + + verifyPosition(decoder, text( "013227003054776,20141010052719,24.4736042,56.8445807,110,289,40,7,5,78,-1")); } diff --git a/test/org/traccar/protocol/AtrackProtocolDecoderTest.java b/test/org/traccar/protocol/AtrackProtocolDecoderTest.java index 882501e9e..72c54f1e6 100644 --- a/test/org/traccar/protocol/AtrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AtrackProtocolDecoderTest.java @@ -1,9 +1,7 @@ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffers; import org.junit.Test; import org.traccar.ProtocolDecoderTest; -import org.traccar.helper.ChannelBufferTools; public class AtrackProtocolDecoderTest extends ProtocolDecoderTest { @@ -12,12 +10,26 @@ public class AtrackProtocolDecoderTest extends ProtocolDecoderTest { AtrackProtocolDecoder decoder = new AtrackProtocolDecoder(new AtrackProtocol()); + decoder.setLongDate(true); + + verifyPositions(decoder, binary( + "0203b494003c00eb00014104d8dd3a3e07de011b0b1f0307de011b0b1f0307de011b0b1f0300307f28030574d30000020000000600160100020000000007d007d000")); + + decoder.setLongDate(false); + + decoder.setCustom(true); + + verifyPositions(decoder, binary( + "405025e30096eb730001452efaf6a7d6562fe4f8562fe4f7562fe52c02a006d902273f810064650000e0f5000a0100000000000007d007d000254349255341254d5625425625475125415400090083002a1a000001a8562fe4f8562fe4f7562fe52c02a006d902273f810064020000e0f5000a0100000000000007d007d000254349255341254d5625425625475125415400090083002a1a000001a8")); + + decoder.setCustom(false); + verifyNothing(decoder, binary( "fe0200014104d8f196820001")); - // invalid GPS data - //verifyPositions(decoder, binary( - // "40503835003300070001441c3d8ed1c400000000000000c9000000c900000000000000000000020000000003de0100000000000007d007d000")); + verifyPositions(decoder, binary( + "40503835003300070001441c3d8ed1c400000000000000c9000000c900000000000000000000020000000003de0100000000000007d007d000"), + position("1970-01-01 00:00:00.000", true, 0.00000, 0.00000)); verifyPositions(decoder, binary( "4050993f005c000200014104d8f19682525666c252568c3c52568c63ffc8338402698885000002000009cf03de0100000000000007d007d000525666c252568c5a52568c63ffc8338402698885000002000009cf03de0100000000000007d007d000")); @@ -28,13 +40,6 @@ public class AtrackProtocolDecoderTest extends ProtocolDecoderTest { verifyPositions(decoder, binary( "40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000000000000000")); - // 7-byte date - //verifyPosition(decoder, binary( - // "0203b494003c00eb00014104d8dd3a3e07de011b0b1f0307de011b0b1f0307de011b0b1f0300307f28030574d30000020000000600160100020000000007d007d000")); - - //verifyPosition(decoder, binary( - // "4050d2c500da055200014104d8f19682530755515307555053075581ffbba66a0231295c001902000000da000a0100830000000007d007d000000000001200080e090085530755605307555f53075582ffbbb04102313b4b001802000000e0000c0100850000000007d007d000000000001200080d0000865307556f5307556e53075582ffbbbbea02314b49002402000000e5000a01007b0000000007d007d000000000001200080d0200855307557e5307557d53075582ffbbc98702315982002502000000ea000901007a0000000007d007d000000000001300180d08007b")); - } } diff --git a/test/org/traccar/protocol/AutoFon45ProtocolDecoderTest.java b/test/org/traccar/protocol/AutoFon45ProtocolDecoderTest.java index 50df04117..f739c6709 100644 --- a/test/org/traccar/protocol/AutoFon45ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/AutoFon45ProtocolDecoderTest.java @@ -12,9 +12,16 @@ public class AutoFon45ProtocolDecoderTest extends ProtocolDecoderTest { AutoFon45ProtocolDecoder decoder = new AutoFon45ProtocolDecoder(new AutoFon45Protocol()); verifyNothing(decoder, binary( + "41035151305289931441139602662095148807")); + + verifyNothing(decoder, binary( "41032125656985547543619173484002123481")); verifyPosition(decoder, binary( + "023E00001E004D411EFA01772F185285009C48041F1E366C2961380F26B10B00911C"), + position("2010-01-27 04:00:08.000", true, 54.73838, 56.10343)); + + verifyPosition(decoder, binary( "023E00001E004D411EFA01772F185285009C48041F1E366C2961380F26B10B00911C")); } } diff --git a/test/org/traccar/protocol/CarTrackProtocolDecoderTest.java b/test/org/traccar/protocol/CarTrackProtocolDecoderTest.java index 6b26607d7..a23dea444 100644 --- a/test/org/traccar/protocol/CarTrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CarTrackProtocolDecoderTest.java @@ -11,6 +11,10 @@ public class CarTrackProtocolDecoderTest extends ProtocolDecoderTest { CarTrackProtocolDecoder decoder = new CarTrackProtocolDecoder(new CarTrackProtocol()); verifyPosition(decoder, text( + "$$2222234???????&A9955&B102904.000,A,2233.0655,N,11404.9440,E,0.00,,030109,,*17|6.3|&C0100000100&D000024?>&E10000000"), + position("2009-01-03 10:29:04.000", true, 22.55109, 114.08240)); + + verifyPosition(decoder, text( "$$2222234???????&A9955&B102904.000,A,2233.0655,N,11404.9440,E,0.00,,030109,,*17|6.3|&C0100000100&D000024?>&E10000000&Y00100020")); verifyPosition(decoder, text( diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java index be4cab227..49fa5b0be 100644 --- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java @@ -13,6 +13,39 @@ public class CastelProtocolDecoderTest extends ProtocolDecoderTest { CastelProtocolDecoder decoder = new CastelProtocolDecoder(new CastelProtocol()); + //verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, + // "4040590004313030303030303030303800000000000000000040010072f53f56c25240560000000078b00900000000009c3100000000030100011900030001090b0f080106c04fe40b4037310c0060e001ff018d01e05e0d0a")); + + verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "404055000431303031313132353239393837000000000000001002C1F0695230086A529C911100000000000F890000A60500000000036301014CFF000001190A0D0539191480D60488C5721800000000BF8A640D0A")); + + verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "40406000043130303131313235323939383700000000000000400705000000C1F0695249F469529C9111000000000069830000D80040000400036401014C04030001190A0D04201E1480D60488C5721800000000AF0101060F000F00EA1E0D0A")); + + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "404057000431303031313132353239393837000000000000004002C1F06952F0F169529C9111000000000069830000470000000400036401014C01030078000505210C210D210F21102101073BE8030064280AEB930D0A")); + + verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "40405900043130303131313235323939383700000000000000400101C1F06952E7F069529C9111000000000069830000070000000400036401014C00030001190A0D0412041480D60488C57218000000009F01E803ED9A0D0A")); + + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "4040B9000431303031313132353239393837000000000000004005C1F069521BF169529C9111000000000069830000130000000400036401014C0003000022032104210521062107210C210D210E210F2110211121132115211C211F21212124212E212F2130213121322133213C214221432144214521472149214A214C214D214E210100643B6232E803003E64280A3C24FE00010E010F00D5805A483C640000000000010000E02E000000066400000500000000A7710D0A")); + + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "404043000431303031313132353239393837000000000000004006C1F0695209F169529C91110000000000698300000D0000000400036401014C00030000009AF40D0A")); + + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "404086000431303031313132353239393837000000000000004004C1F0695200F169529C91110000000000698300000D0000000400036401014C00030022032104210521062107210C210D210E210F2110211121132115211C211F21212124212E212F2130213121322133213C214221432144214521472149214A214C214D214E219AE90D0A")); + + verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "40407F000431303031313132353239393837000000000000001001C1F06952FDF069529C91110000000000698300000C0000000000036401014C00030001190A0D04121A1480D60488C5721800000000AF4944445F3231364730325F532056312E322E31004944445F3231364730325F482056312E322E31000000DF640D0A")); + + verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "404044000c3631313135303030303935360000000000000000420600011e0a0f0b1312864fcd08c07a13030100640acf000004000a000000000000007ba083a66ad80d0a")); + + verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "40405c000c363131313530303030393536000000000000000040011c0a0f0e362dca53cd0860831303000000000300000000ff000000000000007ba083a650542d3639305f56312e312e320050542d3639302056312e32008a020d0a")); + verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, "4040450004323132474c31313433303035303033000000000040082ca89b55a6a99b555c57000000000000c40200000b0000001400036401111f000302f5533bd653f10d0a")); diff --git a/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java b/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java index 33ee51c4f..7f39e5dd6 100644 --- a/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java +++ b/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java @@ -13,6 +13,15 @@ public class CityeasyProtocolDecoderTest extends ProtocolDecoderTest { CityeasyProtocolDecoder decoder = new CityeasyProtocolDecoder(new CityeasyProtocol()); + verifyAttributes(decoder, binary( + "545400853575570249020100033b3430342c34352c31303638312c31313632312c33352c31303638312c31313632322c32332c31303638312c32383938332c32332c31303638312c31313632332c32312c31303638312c32333338312c31372c31303638312c32323538332c31372c31303638312c32363434312c31330000000d352e0d0a")); + + verifyNothing(decoder, binary( + "54540019357557024902010002520704100000000bbe700d0a")); + + verifyNothing(decoder, binary( + "5454001735755702490201434a01000000000c24280d0a")); + verifyNothing(decoder, binary( "545400153520000000000100010000000111000D0A")); @@ -20,7 +29,8 @@ public class CityeasyProtocolDecoderTest extends ProtocolDecoderTest { "54540019357557024902000002520704300000000376390d0a")); verifyPosition(decoder, binary( - "5454006135200000000001000332303134313131303039353430392C412C342C4E2C32322E3533373232382C452C3131342E3032323737342C302E312C312E392C35302E363B3436302C302C31303137332C343635322C34310000000B63130D0A")); + "5454006135200000000001000332303134313131303039353430392C412C342C4E2C32322E3533373232382C452C3131342E3032323737342C302E312C312E392C35302E363B3436302C302C31303137332C343635322C34310000000B63130D0A"), + position("2014-11-10 09:54:09.000", true, 22.53723, 114.02277)); verifyPosition(decoder, binary( "5454006135200000000001000432303134313131303039353330362C412C352C4E2C32322E3533373233352C452C3131342E3032323838312C302E322C312E362C35342E313B3436302C302C31303137332C343635322C343100000045EC620D0A")); diff --git a/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java b/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java index 9e1dfce34..f926bdee3 100644 --- a/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/EasyTrackProtocolDecoderTest.java @@ -14,7 +14,8 @@ public class EasyTrackProtocolDecoderTest extends ProtocolDecoderTest { "*ET,135790246811221,GZ,0001,0005")); verifyPosition(decoder, text( - "*ET,135790246811221,DW,A,0A090D,101C0D,00CF27C6,0413FA4E,0000,0000,00000000,20,4,0000,00F123")); + "*ET,135790246811221,DW,A,0A090D,101C0D,00CF27C6,0413FA4E,0000,0000,00000000,20,4,0000,00F123"), + position("2010-09-13 16:28:13.000", true, 22.62689, 114.03021)); verifyPosition(decoder, text( "*ET,135790246811221,DW,A,050915,0C2A27,00CE5954,04132263,0000,0000,01000000,20,4,0000,001254")); @@ -27,7 +28,7 @@ public class EasyTrackProtocolDecoderTest extends ProtocolDecoderTest { verifyPosition(decoder, text( "*ET,358155100003016,HB,A,0d081e,07381e,8038ee09,03d2e9be,004f,0000,40c00000,0f,100,0000,00037c,29")); - + verifyPosition(decoder, text( "*ET,358155100003016,HB,A,0d081e,073900,8038ee2f,03d2e9fd,0114,0000,40c00000,12,100,0000,00037c,32")); diff --git a/test/org/traccar/protocol/EnforaProtocolDecoderTest.java b/test/org/traccar/protocol/EnforaProtocolDecoderTest.java index da1427611..0333d57e9 100644 --- a/test/org/traccar/protocol/EnforaProtocolDecoderTest.java +++ b/test/org/traccar/protocol/EnforaProtocolDecoderTest.java @@ -17,7 +17,8 @@ public class EnforaProtocolDecoderTest extends ProtocolDecoderTest { "003B000502000000000820202020202030313130373030303035373032363720383A000000000D00508401358E640032B37700000367B00000A804")); verifyPosition(decoder, binary( - "007100040200202020202020202020382020202020202031323334353637383930313233343520313320244750524D432C3232333135322E30302C412C333530392E3836303539342C4E2C30333332322E3734333838372C452C302E302C302E302C3032303631322C2C2C412A35320D0A")); + "007100040200202020202020202020382020202020202031323334353637383930313233343520313320244750524D432C3232333135322E30302C412C333530392E3836303539342C4E2C30333332322E3734333838372C452C302E302C302E302C3032303631322C2C2C412A35320D0A"), + position("2012-06-02 22:31:52.000", true, 35.16434, 33.37906)); verifyPosition(decoder, binary( "007600040200202020202020202020382020202020202030313138393230303036303831383920313320244750524D432C3137313834312E30302C412C333530392E3835323431302C4E2C30333332322E3735393131332C452C302E302C302E302C3137303731322C332E342C572C412A32350D0A00")); diff --git a/test/org/traccar/protocol/Ev603ProtocolDecoderTest.java b/test/org/traccar/protocol/Ev603ProtocolDecoderTest.java deleted file mode 100644 index a843fcf21..000000000 --- a/test/org/traccar/protocol/Ev603ProtocolDecoderTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.traccar.protocol; - -import org.junit.Test; -import org.traccar.ProtocolDecoderTest; - -public class Ev603ProtocolDecoderTest extends ProtocolDecoderTest { - - @Test - public void testDecode() throws Exception { - - Ev603ProtocolDecoder decoder = new Ev603ProtocolDecoder(new Ev603Protocol()); - - verifyNothing(decoder, text( - "!1,123456789012345")); - - verifyNothing(decoder, text( - "!5,17,V")); - - verifyNothing(decoder, text( - "!1,860719027585011")); - - verifyPosition(decoder, text( - "!A,26/10/12,00:28:41,7.770385,-72.215706,0.0,25101,0")); - - verifyPosition(decoder, text( - "!A,01/12/10,13:25:35,22.641724,114.023666,000.1,281.6,0")); - - verifyPosition(decoder, text( - "!D,08/07/15,04:01:32,40.428257,-3.704808,0,0,170001,701.7,22,5,14,0")); - - verifyPosition(decoder, text( - "!D,08/07/15,04:55:13,40.428257,-3.704932,0,0,180001,680.0,8,8,13,0")); - - verifyPosition(decoder, text( - "!D,08/07/15,02:01:32,40.428230,-3.704950,4,170,170001,682.7,43,6,13,0")); - - } - -} diff --git a/test/org/traccar/protocol/FlextrackProtocolDecoderTest.java b/test/org/traccar/protocol/FlextrackProtocolDecoderTest.java index 049b0e95e..d7c773b01 100644 --- a/test/org/traccar/protocol/FlextrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/FlextrackProtocolDecoderTest.java @@ -21,6 +21,10 @@ public class FlextrackProtocolDecoderTest extends ProtocolDecoderTest { "-2,UNITSTAT,20060101,123442,1080424008,N0.00.0000,E0.00.0000,0,0,0,4129,-61,2,23866,0,999,A214,63,2EE2,3471676")); verifyPosition(decoder, text( + "-2,UNITSTAT,20050205,181923,7000004634,N55.46.0812,E009.21.1665,122,198,6,3934,-81,01A8,23802,213,55,37FD,45,0055,12878"), + position("2005-02-05 18:19:23.000", true, 55.76802, 9.35278)); + + verifyPosition(decoder, text( "-2,UNITSTAT,20050205,181923,7000004634,N55.46.0812,E009.21.1665,122,198,6,3934,-81,01A8,23802,213,55,37FD,45,0055,12878")); } diff --git a/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java index 52c331f13..f9fccd187 100644 --- a/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl100ProtocolDecoderTest.java @@ -15,7 +15,8 @@ public class Gl100ProtocolDecoderTest extends ProtocolDecoderTest { "AT+GTHBD=HeartBeat,359231030000010,20090101000000,11F0,0102120204")); verifyPosition(decoder, text( - "+RESP:GTSOS,359231030000010,0,0,0,1,4.3,92,70.0,1,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,11F0,0102120204")); + "+RESP:GTSOS,359231030000010,0,0,0,1,4.3,92,70.0,1,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,11F0,0102120204"), + position("2009-01-01 00:00:00.000", false, 31.22207, 121.35434)); verifyPosition(decoder, text( "+RESP:GTRTL,359231030000010,0,0,0,1,4.3,92,70.0,1,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,11F0,0102120204")); diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java index 4596a5c90..1f5242b9c 100644 --- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java @@ -10,6 +10,9 @@ public class Gl200ProtocolDecoderTest extends ProtocolDecoderTest { Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol()); + verifyPosition(decoder, text( + "+RESP:GTIDA,06020A,862170013895931,,,D2C4FBC5,1,1,1,0.8,0,22.2,117.198630,31.845229,20120802121626,0460,0000,5663,2BB9,00,0.0,,,,,20120802121627,008E$")); + verifyAttributes(decoder, text( "+RESP:GTINF,1F0101,135790246811220,1G1JC5444R7252367,,16,898600810906F8048812,16,0,1,12000,,4.2,0,0,,,20090214013254,,,,,,+0800,0,20090214093254,11F0$")); diff --git a/test/org/traccar/protocol/GotopProtocolDecoderTest.java b/test/org/traccar/protocol/GotopProtocolDecoderTest.java index dcafd5add..abc967076 100644 --- a/test/org/traccar/protocol/GotopProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GotopProtocolDecoderTest.java @@ -10,16 +10,19 @@ public class GotopProtocolDecoderTest extends ProtocolDecoderTest { GotopProtocolDecoder decoder = new GotopProtocolDecoder(new GotopProtocol()); - verifyNothing(decoder, text( "")); + verifyNothing(decoder, text( + "")); - verifyNothing(decoder, text( "353327020412763,CMD-X")); + verifyNothing(decoder, text( + "353327020412763,CMD-X")); verifyPosition(decoder, text( "013226009991924,CMD-T,A,DATE:130802,TIME:153721,LAT:25.9757433S,LOT:028.1087816E,Speed:000.0,X-X-X-X-81-26,000,65501-00A0-4B8E")); verifyPosition(decoder, text( - "353327020115804,CMD-T,A,DATE:090329,TIME:223252,LAT:22.7634066N,LOT:114.3964783E,Speed:000.0,84-20,000")); - + "353327020115804,CMD-T,A,DATE:090329,TIME:223252,LAT:22.7634066N,LOT:114.3964783E,Speed:000.0,84-20,000"), + position("2009-03-29 22:32:52.000", true, 22.76341, 114.39648)); + verifyPosition(decoder, text( "353327020115804,CMD-T,A,DATE:090329,TIME:223252,LAT:22.7634066N,LOT:114.3964783E,Speed:000.0,1-1-0-84-20,000")); diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java index 09452c5e6..80d1424fc 100644 --- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java @@ -11,6 +11,10 @@ public class Gps103ProtocolDecoderTest extends ProtocolDecoderTest { Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(new Gps103Protocol()); verifyPosition(decoder, text( + "imei:359710045559474,tracker,151030080103,,F,000101.000,A,5443.3834,N,02512.9071,E,0.00,0;"), + position("2015-10-30 00:01:01.000", true, 54.72306, 25.21512)); + + verifyPosition(decoder, text( "imei:359710049092324,tracker,151027025958,,F,235957.000,A,2429.5156,N,04424.5828,E,0.01,27.91,,0,0,,,;"), position("2015-10-26 23:59:57.000", true, 24.49193, 44.40971)); diff --git a/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java b/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java index 8652b24a6..2d21f53c9 100644 --- a/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GpsGateProtocolDecoderTest.java @@ -10,20 +10,28 @@ public class GpsGateProtocolDecoderTest extends ProtocolDecoderTest { GpsGateProtocolDecoder decoder = new GpsGateProtocolDecoder(new GpsGateProtocol()); - verifyNothing(decoder, text( "$FRLIN,,user1,8IVHF*7A")); + verifyNothing(decoder, text( + "$FRLIN,,user1,8IVHF*7A")); - verifyNothing(decoder, text( "$FRLIN,,354503026292842,VGZTHKT*0C")); + verifyNothing(decoder, text( + "$FRLIN,,354503026292842,VGZTHKT*0C")); - verifyNothing(decoder, text( "$FRLIN,IMEI,1234123412341234,*7B")); + verifyNothing(decoder, text( + "$FRLIN,IMEI,1234123412341234,*7B")); - verifyNothing(decoder, text( "$FRLIN,,saab93_device,KLRFBGIVDJ*28")); + verifyNothing(decoder, text( + "$FRLIN,,saab93_device,KLRFBGIVDJ*28")); verifyPosition(decoder, text( - "$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A")); - + "$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A"), + position("2007-07-27 15:44:03.000", true, 63.19402, 14.63379)); + verifyPosition(decoder, text( "$GPRMC,074524,A,5553.73701,N,03728.90491,E,10.39,226.5,160614,0.0,E*75")); + verifyPosition(decoder, text( + "$GPRMC,154403.000,A,6311.64120,N,01438.02740,E,0.000,0.0,270707,,*0A")); + } } diff --git a/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java b/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java index 28237b5b2..fc3116577 100644 --- a/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java @@ -16,7 +16,8 @@ public class GpsMarkerProtocolDecoderTest extends ProtocolDecoderTest { "$GM300350123456789012T100511123300G25000001772F185200000000000000005230298#")); verifyPosition(decoder, text( - "$GM200350123456789012T100511123300N55516789E03756123400000035230298#")); + "$GM200350123456789012T100511123300N55516789E03756123400000035230298#"), + position("2011-05-10 12:33:00.000", true, 55.86132, 37.93539)); verifyPosition(decoder, text( "$GM1350123456789012T1005111233N55516789E03756123400000035200298#")); diff --git a/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java b/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java index cd1257de7..8d7b6ab0f 100644 --- a/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GpsmtaProtocolDecoderTest.java @@ -11,6 +11,9 @@ public class GpsmtaProtocolDecoderTest extends ProtocolDecoderTest { GpsmtaProtocolDecoder decoder = new GpsmtaProtocolDecoder(new GpsmtaProtocol()); verifyPosition(decoder, text( + "3085a94ef459 1446536867 49.81621 24.054207 1 0 22 0 10 12 24 0 0")); + + verifyPosition(decoder, text( "864528021249771 1446116686 49.85073 24.004438 0 217 6 338 00 59 27 0 0")); verifyPosition(decoder, text( diff --git a/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java index 76590fe3f..4f086d4f3 100644 --- a/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Gt02ProtocolDecoderTest.java @@ -1,9 +1,7 @@ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffers; import org.junit.Test; import org.traccar.ProtocolDecoderTest; -import org.traccar.helper.ChannelBufferTools; public class Gt02ProtocolDecoderTest extends ProtocolDecoderTest { @@ -13,7 +11,8 @@ public class Gt02ProtocolDecoderTest extends ProtocolDecoderTest { Gt02ProtocolDecoder decoder = new Gt02ProtocolDecoder(new Gt02Protocol()); verifyPosition(decoder, binary( - "68682500000123456789012345000110010101010101026B3F3E026B3F3E000000000000000000010D0A")); + "68682500000123456789012345000110010101010101026B3F3E026B3F3E000000000000000000010D0A"), + position("2001-01-01 01:01:01.000", true, -22.54610, -22.54610)); verifyNothing(decoder, binary( "6868110603035889905101276600001a0402292d0d0a")); diff --git a/test/org/traccar/protocol/HaicomProtocolDecoderTest.java b/test/org/traccar/protocol/HaicomProtocolDecoderTest.java index df1c33a06..f8a35499a 100644 --- a/test/org/traccar/protocol/HaicomProtocolDecoderTest.java +++ b/test/org/traccar/protocol/HaicomProtocolDecoderTest.java @@ -11,7 +11,8 @@ public class HaicomProtocolDecoderTest extends ProtocolDecoderTest { HaicomProtocolDecoder decoder = new HaicomProtocolDecoder(new HaicomProtocol()); verifyPosition(decoder, text( - "$GPRS012497007097169,T100001,150618,230031,5402267400332464,0004,2014,000001,,,1,00#V040*")); + "$GPRS012497007097169,T100001,150618,230031,5402267400332464,0004,2014,000001,,,1,00#V040*"), + position("2015-06-18 23:00:31.000", true, 40.37790, -3.54107)); verifyPosition(decoder, text( "$GPRS123456789012345,602S19A,100915,063515,7240649312041079,0019,3156,111000,10004,0000,11111,00LH#V037")); diff --git a/test/org/traccar/protocol/HuabaoFrameDecoderTest.java b/test/org/traccar/protocol/HuabaoFrameDecoderTest.java new file mode 100644 index 000000000..923096f50 --- /dev/null +++ b/test/org/traccar/protocol/HuabaoFrameDecoderTest.java @@ -0,0 +1,20 @@ +package org.traccar.protocol; + +import org.junit.Assert; +import org.junit.Test; +import org.traccar.ProtocolDecoderTest; + +public class HuabaoFrameDecoderTest extends ProtocolDecoderTest { + + @Test + public void testDecode() throws Exception { + + HuabaoFrameDecoder decoder = new HuabaoFrameDecoder(); + + Assert.assertEquals( + binary("7e307e087d557e"), + decoder.decode(null, null, binary("7e307d02087d01557e"))); + + } + +} diff --git a/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java new file mode 100644 index 000000000..0968d6d9c --- /dev/null +++ b/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java @@ -0,0 +1,18 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolDecoderTest; + +public class HuabaoProtocolDecoderTest extends ProtocolDecoderTest { + + @Test + public void testDecode() throws Exception { + + HuabaoProtocolDecoder decoder = new HuabaoProtocolDecoder(new HuabaoProtocol()); + + verifyNothing(decoder, binary( + "7e0100002d007089994489002800000000000000000048422d523033474244000000000000000000000031393036373531024142433030303030d17e")); + + } + +} diff --git a/test/org/traccar/protocol/IntellitracProtocolDecoderTest.java b/test/org/traccar/protocol/IntellitracProtocolDecoderTest.java index 9cba712bb..23d7fb48a 100644 --- a/test/org/traccar/protocol/IntellitracProtocolDecoderTest.java +++ b/test/org/traccar/protocol/IntellitracProtocolDecoderTest.java @@ -10,10 +10,12 @@ public class IntellitracProtocolDecoderTest extends ProtocolDecoderTest { IntellitracProtocolDecoder decoder = new IntellitracProtocolDecoder(new IntellitracProtocol()); - verifyNothing(decoder, text( "$OK:TRACKING")); + verifyNothing(decoder, text( + "$OK:TRACKING")); verifyPosition(decoder, text( - "101000001,20100304075545,121.64547,25.06200,0,0,61,7,2,1,0,0.046,0.000,20100304075546,0")); + "101000001,20100304075545,121.64547,25.06200,0,0,61,7,2,1,0,0.046,0.000,20100304075546,0"), + position("2010-03-04 07:55:45.000", true, 25.06200, 121.64547)); verifyPosition(decoder, text( "1010000002,20030217132813,121.646060,25.061725,20,157,133,7,0,11,15,0.096,0.000")); diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java index 8acdbe15b..bcd87f9fb 100644 --- a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java @@ -15,7 +15,8 @@ public class Jt600ProtocolDecoderTest extends ProtocolDecoderTest { Jt600ProtocolDecoder decoder = new Jt600ProtocolDecoder(new Jt600Protocol()); verifyPosition(decoder, binary( - "24311021600111001B16021105591022329862114046227B0598095080012327951435161F")); + "24311021600111001B16021105591022329862114046227B0598095080012327951435161F"), + position("2011-02-16 05:59:10.000", true, 22.54977, -114.07705)); verifyPosition(decoder, binary( "24312082002911001B171012052831243810120255336425001907190003FD2B91044D1FA0")); @@ -27,7 +28,8 @@ public class Jt600ProtocolDecoderTest extends ProtocolDecoderTest { "24608111888821001B09060908045322564025113242329F0598000001003F0000002D00AB")); verifyPosition(decoder, buffer( - "(3110312099,W01,11404.6204,E,2232.9961,N,A,040511,063736,4,7,100,4,17,1,1,company)")); + "(3110312099,W01,11404.6204,E,2232.9961,N,A,040511,063736,4,7,100,4,17,1,1,company)"), + position("2011-05-04 06:37:36.000", true, 22.54994, 114.07701)); verifyPosition(decoder, buffer( "(3120820029,W01,02553.3555,E,2438.0997,S,A,171012,053339,0,8,20,6,31,5,20,20)")); diff --git a/test/org/traccar/protocol/MegastekProtocolDecoderTest.java b/test/org/traccar/protocol/MegastekProtocolDecoderTest.java index 4ccf2a7e0..9046b3928 100644 --- a/test/org/traccar/protocol/MegastekProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MegastekProtocolDecoderTest.java @@ -11,7 +11,8 @@ public class MegastekProtocolDecoderTest extends ProtocolDecoderTest { MegastekProtocolDecoder decoder = new MegastekProtocolDecoder(new MegastekProtocol()); verifyPosition(decoder, text( - "$MGV002,860719020193193,DeviceName,R,240214,104742,A,2238.20471,N,11401.97967,E,00,03,00,1.20,0.462,356.23,137.9,1.5,460,07,262C,0F54,25,0000,0000,0,0,0,28.5,28.3,,,100,Timer;!")); + "$MGV002,860719020193193,DeviceName,R,240214,104742,A,2238.20471,N,11401.97967,E,00,03,00,1.20,0.462,356.23,137.9,1.5,460,07,262C,0F54,25,0000,0000,0,0,0,28.5,28.3,,,100,Timer;!"), + position("2014-02-24 10:47:42.000", true, 22.63675, 114.03299)); verifyPosition(decoder, text( "STX2010101801 j$GPRMC,101053.000,A,2232.7607,N,11404.7669,E,0.00,,231110,,,A*7F,460,00,2795,0E6A,14,94,1000,0000,91,Timer;1D")); diff --git a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java index 2c513272c..88d11d551 100644 --- a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java @@ -12,8 +12,9 @@ public class MeitrackProtocolDecoderTest extends ProtocolDecoderTest { MeitrackProtocolDecoder decoder = new MeitrackProtocolDecoder(new MeitrackProtocol()); verifyPosition(decoder, buffer( - "$$A158,79007001520234,AAA,35,40.996370,-8.575065,150730184834,A,8,24,0,1,1.3,173,32573389,31405012,268|3|2BC0|250B,2000,|||0A2D|0000,00000001,,50,,,,,,,,,,,,,*4A")); - + "$$A158,79007001520234,AAA,35,40.996370,-8.575065,150730184834,A,8,24,0,1,1.3,173,32573389,31405012,268|3|2BC0|250B,2000,|||0A2D|0000,00000001,,50,,,,,,,,,,,,,*4A"), + position("2015-07-30 18:48:34.000", true, 40.99637, -8.57507)); + verifyPosition(decoder, buffer( "$$G145,862106024274815,AAA,35,-1.287125,36.906061,150530054639,A,10,13,12,67,0.8,1621,38359791,42330881,639|2|FB2|2F3,0000,3|0|0|A58|432,,,1,0009,*26")); @@ -63,7 +64,8 @@ public class MeitrackProtocolDecoderTest extends ProtocolDecoderTest { "$$J163,123123123123123,AFF,0004,35,58.588926,16.180473,140928192856,A,10,27,0,161,1.2,19,1648894,435695,240|24|88B9|E435,0000,|||0A22|0000,00000001,,50,,,,,,,,,,,,,*70\r\n")); verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, - "24245838362c3336393830303031343039303032312c4343432c020134000100000023381f91ffe354b806c5e3121b0009130000000000000000d33801007cbf0200fe0101000435feeb02000500a3010000000000002a62650d0a")); + "24245838362c3336393830303031343039303032312c4343432c020134000100000023381f91ffe354b806c5e3121b0009130000000000000000d33801007cbf0200fe0101000435feeb02000500a3010000000000002a62650d0a"), + position("2014-05-24 04:59:49.000", false, -7.26650, 112.74365)); verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, "2424473937302c3336393830303031333436303637342c4343432c020134005b000000010ce304035db9e000ec6f591a000013000000000c001801edb70200c96d0100e60001004838576501000300a101c20400000000010ce304035db9e000ee6f591a000013000000000c001801edb70200ca6d0100e60001004838576501000300a101c20400000000010ce304035db9e000ef6f591a000013000000000c001801edb70200cc6d0100e60001004838576501000300a101c20400000000020ce304035db9e000f76f591a000016000000000c001801edb70200d36d0100e60001004838576502000300a101bf04000000000a0ce304035db9e000f76f591a000016000000000c001801edb70200d46d0100e60001004838576500000300a101bf0400000000020ce304035db9e000fb6f591a000016000000000c001801edb70200d86d0100e60001004838576502000300a101760400000000180ce304035db9e000fc6f591a0000120000000000008c00edb70200d96d0100e60001004838576502000300a10176040000000019b1e2040323b9e0000b70591a0105150600bb0012002901edb70200e76d0100e60001004838576502000300a2017005000000002023e304031fb9e0001070591a010615070027010d001601fcb70200ec6d0100e60001004838576502000300a201800500000000201fe3040302b9e0001170591a010615090019010d001501feb70200ed6d0100e60001004838576502000300a2018005000000002018e30403dcb8e0001270591a0106150b0011010d00150100b80200ee6d0100e60001004838576502000300a2018005000000002036e3040345b8e0001570591a0107150b002d010b0013010ab80200f16d0100e60001004838576502000300a2018005000000002053e3040326b8e0001670591a0107150d0041010b0013010eb80200f26d0100e60001004838576502000300a2018005000000002070e3040310b8e0001770591a0107150e004f010b00130111b80200f36d0100e60001004838576502000300a2018005000000002095e3040306b8e0001870591a0107150d005a010b00140115b80200f46d0100e60001004838576502000300a20180050000000020b3e3040305b8e0001970591a0107150b0060010b00140118b80200f56d0100e60001004838576502000300a20183050000000020cfe3040308b8e0001a70591a0107150b0066010b0014011bb80200f66d0100e60001004838576502000300a20183050000000020eee304030cb8e0001b70591a0106170b0004000d0014011eb80200f76d0100e60001004838576502000300a2018305000000002a62350d0a")); diff --git a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java index 5f6add6c5..04e5c1172 100644 --- a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java +++ b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java @@ -10,10 +10,36 @@ public class MiniFinderProtocolDecoderTest extends ProtocolDecoderTest { MiniFinderProtocolDecoder decoder = new MiniFinderProtocolDecoder(new MiniFinderProtocol()); - verifyNothing(decoder, text( "!1,860719020212696")); + verifyNothing(decoder, text( + "!1,123456789012345")); + + verifyNothing(decoder, text( + "!5,17,V")); + + verifyNothing(decoder, text( + "!1,860719027585011")); + + verifyPosition(decoder, text( + "!A,26/10/12,00:28:41,7.770385,-72.215706,0.0,25101,0")); + + verifyPosition(decoder, text( + "!A,01/12/10,13:25:35,22.641724,114.023666,000.1,281.6,0")); + + verifyPosition(decoder, text( + "!D,08/07/15,04:01:32,40.428257,-3.704808,0,0,170001,701.7,22,5,14,0")); + + verifyPosition(decoder, text( + "!D,08/07/15,04:55:13,40.428257,-3.704932,0,0,180001,680.0,8,8,13,0")); + + verifyPosition(decoder, text( + "!D,08/07/15,02:01:32,40.428230,-3.704950,4,170,170001,682.7,43,6,13,0")); + + verifyNothing(decoder, text( + "!1,860719020212696")); verifyPosition(decoder, text( - "!D,22/2/14,13:40:58,56.899601,14.811541,0,0,1,176.0,98,5,16,0")); + "!D,22/2/14,13:40:58,56.899601,14.811541,0,0,1,176.0,98,5,16,0"), + position("2014-02-22 13:40:58.000", true, 56.89960, 14.81154)); verifyPosition(decoder, text( "!D,22/2/14,13:47:51,56.899517,14.811665,0,0,b0001,179.3,97,5,16,0")); diff --git a/test/org/traccar/protocol/NavisProtocolDecoderTest.java b/test/org/traccar/protocol/NavisProtocolDecoderTest.java index c0d0357b0..51e3ec94a 100644 --- a/test/org/traccar/protocol/NavisProtocolDecoderTest.java +++ b/test/org/traccar/protocol/NavisProtocolDecoderTest.java @@ -19,6 +19,9 @@ public class NavisProtocolDecoderTest extends ProtocolDecoderTest { "404E5443010000007B000000130044342A3E533A383631373835303035323035303739")); verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, + "404e544301000000000000005a002e6c2a3e410125d7540100001512233a0b0a0f08026300000a000b000b00020000000000000000000c12233b0b0a0f03fd6d3f0fde603f00000000ba0051e0c845000000000000000000000000000000000000000000000080808080")); + + verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN, "404E5443010000007B0000005A0050692A3E410125DB0E00000015110707110A0C0880630000AA39A2381600020000000000000000000C110708110A0CB389793F1AEF263F00000000120034F516440000000000000000000000FAFF000000FAFF000000FAFF80808080")); verifyNothing(decoder, binary(ByteOrder.LITTLE_ENDIAN, diff --git a/test/org/traccar/protocol/Pt3000ProtocolDecoderTest.java b/test/org/traccar/protocol/Pt3000ProtocolDecoderTest.java index cadc76928..7c01d6022 100644 --- a/test/org/traccar/protocol/Pt3000ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Pt3000ProtocolDecoderTest.java @@ -11,7 +11,8 @@ public class Pt3000ProtocolDecoderTest extends ProtocolDecoderTest { Pt3000ProtocolDecoder decoder = new Pt3000ProtocolDecoder(new Pt3000Protocol()); verifyPosition(decoder, text( - "%356939010012099,$GPRMC,124945.752,A,4436.6245,N,01054.4634,E,0.11,358.52,060408,,,A,+393334347445,N028d")); + "%356939010012099,$GPRMC,124945.752,A,4436.6245,N,01054.4634,E,0.11,358.52,060408,,,A,+393334347445,N028d"), + position("2008-04-06 12:49:45.000", true, 44.61041, 10.90772)); verifyPosition(decoder, text( "%356939010014433,$GPRMC,172821.000,A,4019.5147,N,00919.1160,E,0.00,,010613,,,A,+393998525043,N098d")); diff --git a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java index b09082b2e..a811de3ce 100644 --- a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java @@ -11,7 +11,8 @@ public class Pt502ProtocolDecoderTest extends ProtocolDecoderTest { Pt502ProtocolDecoder decoder = new Pt502ProtocolDecoder(new Pt502Protocol()); verifyPosition(decoder, text( - "$POS,216769295715,163237.000,A,3258.1738,S,02755.4350,E,0.00,215.88,100915,,,A/0000,0//232300//5b3/")); + "$POS,216769295715,163237.000,A,3258.1738,S,02755.4350,E,0.00,215.88,100915,,,A/0000,0//232300//5b3/"), + position("2015-09-10 16:32:37.000", true, -32.96956, 27.92392)); verifyPosition(decoder, text( "$POS,11023456,033731.000,A,0335.2617,N,09841.1587,E,0.00,88.12,210615,,,A/0000,0/1f8/388900//f33//")); diff --git a/test/org/traccar/protocol/Stl060ProtocolDecoderTest.java b/test/org/traccar/protocol/Stl060ProtocolDecoderTest.java index f167f983a..3af99374d 100644 --- a/test/org/traccar/protocol/Stl060ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Stl060ProtocolDecoderTest.java @@ -11,8 +11,9 @@ public class Stl060ProtocolDecoderTest extends ProtocolDecoderTest { Stl060ProtocolDecoder decoder = new Stl060ProtocolDecoder(new Stl060Protocol()); verifyPosition(decoder, text( - "$1,357804048043099,D001,AP29AW0963,23/02/14,14:06:54,17248488N,078342226E,0.08,193.12,1,1,1,1,1,A")); - + "$1,357804048043099,D001,AP29AW0963,23/02/14,14:06:54,17248488N,078342226E,0.08,193.12,1,1,1,1,1,A"), + position("2014-02-23 14:06:54.000", true, 17.41415, 78.57038)); + verifyPosition(decoder, text( "$1,357804048043099,D001,AP29AW0963,12/05/14,07:39:57,1724.8564N,07834.2199E,0.00,302.84,1,1,1,1,1,A")); diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java index 54cc77d6c..d0987f289 100644 --- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java +++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java @@ -10,16 +10,19 @@ public class SuntechProtocolDecoderTest extends ProtocolDecoderTest { SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(new SuntechProtocol()); - verifyNothing(decoder, text( "SA200ALV;317652")); + verifyNothing(decoder, text( + "SA200ALV;317652")); verifyPosition(decoder, text( - "ST910;Alert;123456;410;20141018;18:30:12;+37.478774;+126.889690;000.000;000.00;0;4.0;1;6002")); + "ST910;Alert;123456;410;20141018;18:30:12;+37.478774;+126.889690;000.000;000.00;0;4.0;1;6002"), + position("2014-10-18 18:30:12.000", true, 37.47877, 126.88969)); verifyPosition(decoder, text( "ST910;Alert;123456;410;20141018;18:30:12;+37.478774;+126.889690;000.000;000.00;0;4.0;1;6002;02;0;0310000100;450;01;-282;70;255;3;0")); verifyPosition(decoder, text( - "SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979")); + "SA200STT;317652;042;20120718;15:37:12;16d41;-15.618755;-056.083241;000.024;000.00;8;1;41548;12.17;100000;2;1979"), + position("2012-07-18 15:37:12.000", true, -15.61876, -56.08324)); verifyPosition(decoder, text( "SA200STT;317652;042;20120721;19:04:30;16d41;-15.618743;-056.083221;000.001;000.00;12;1;41557;12.21;000000;1;3125")); diff --git a/test/org/traccar/protocol/T55ProtocolDecoderTest.java b/test/org/traccar/protocol/T55ProtocolDecoderTest.java index ddabc8ee4..b7adee89b 100644 --- a/test/org/traccar/protocol/T55ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/T55ProtocolDecoderTest.java @@ -10,13 +10,17 @@ public class T55ProtocolDecoderTest extends ProtocolDecoderTest { T55ProtocolDecoder decoder = new T55ProtocolDecoder(new T55Protocol()); - verifyNothing(decoder, text( "$GPFID,ID123456ABC")); + verifyNothing(decoder, text( + "$GPFID,ID123456ABC")); - verifyNothing(decoder, text( "$PGID,359853000144328*0F")); + verifyNothing(decoder, text( + "$PGID,359853000144328*0F")); - verifyNothing(decoder, text( "$PCPTI,CradlePoint Test,184453,184453.0,6F*57")); + verifyNothing(decoder, text( + "$PCPTI,CradlePoint Test,184453,184453.0,6F*57")); - verifyNothing(decoder, text( "IMEI 351467108700000")); + verifyNothing(decoder, text( + "IMEI 351467108700000")); verifyPosition(decoder, text( "$GPRMC,012006,A,4828.10,N,1353.52,E,0.00,0.00,180915,020.3,E*42")); @@ -68,4 +72,19 @@ public class T55ProtocolDecoderTest extends ProtocolDecoderTest { } + @Test + public void testMaxonDecode() throws Exception { + + // Maxon devices can send NMEA before identification + + T55ProtocolDecoder decoder = new T55ProtocolDecoder(new T55Protocol()); + + verifyNothing(decoder, text( + "$GPRMC,012006,A,4828.10,N,1353.52,E,0.00,0.00,180915,020.3,E*42")); + + verifyPosition(decoder, text( + "$GPFID,ID123456ABC")); + + } + } diff --git a/test/org/traccar/protocol/T800xProtocolDecoderTest.java b/test/org/traccar/protocol/T800xProtocolDecoderTest.java new file mode 100644 index 000000000..56efa5a92 --- /dev/null +++ b/test/org/traccar/protocol/T800xProtocolDecoderTest.java @@ -0,0 +1,30 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolDecoderTest; + +public class T800xProtocolDecoderTest extends ProtocolDecoderTest { + + @Test + public void testDecode() throws Exception { + + T800xProtocolDecoder decoder = new T800xProtocolDecoder(new T800xProtocol()); + + verifyNothing(decoder, binary( + "232301001500020357367031063979150208625010")); + + verifyNothing(decoder, binary( + "232303000f00000357367031063979")); + + verifyPosition(decoder, binary( + "232304004200030357367031063979003c03842307d00000c80000050100008000008900890100000017b100151022121648b8ef0c4422969342cec5944100000110")); + + verifyPosition(decoder, binary( + "232302004200150357367031063979003c03842307d000004a0000050100004001009500940000000285ab001510281350477f710d4452819342d1ba944101160038")); + + verifyAttributes(decoder, binary( + "232302004200000357367031063979003c03842307d000008000000501000000010094009400000002a0b90015102814590694015a00620cf698620cf49e620cf498")); + + } + +} diff --git a/test/org/traccar/protocol/TaipProtocolDecoderTest.java b/test/org/traccar/protocol/TaipProtocolDecoderTest.java index d9f74f33d..d0e800ec1 100644 --- a/test/org/traccar/protocol/TaipProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TaipProtocolDecoderTest.java @@ -11,7 +11,8 @@ public class TaipProtocolDecoderTest extends ProtocolDecoderTest { TaipProtocolDecoder decoder = new TaipProtocolDecoder(new TaipProtocol(), false); verifyPosition(decoder, text( - ">RGP230615010248-2682523-065236820000003007F4101;ID=0005;#0002;*2A<")); + ">RGP230615010248-2682523-065236820000003007F4101;ID=0005;#0002;*2A<"), + position("2015-06-23 01:02:48.000", true, -26.82523, -65.23682)); verifyPosition(decoder, text( ">RGP190805211932-3457215-058493640000000FFBF0300;ID=8251;#2122;*54<")); @@ -23,7 +24,8 @@ public class TaipProtocolDecoderTest extends ProtocolDecoderTest { "\r\n>REV691615354941+3570173+1397742703203212;ID=Test")); verifyPosition(decoder, text( - ">REV481599462982+2578391-0802945201228512;ID=Test")); + ">REV481599462982+2578391-0802945201228512;ID=Test"), + position("2010-09-02 17:29:42.000", true, 25.78391, -80.29452)); verifyPosition(decoder, text( ">REV131756153215+3359479-0075299001031332;VO=10568798;IO=310;SV=10;BL=4190;CV09=0;AD=0;AL=+47;ID=356612021059680")); diff --git a/test/org/traccar/protocol/TelikProtocolDecoderTest.java b/test/org/traccar/protocol/TelikProtocolDecoderTest.java index 4344fe070..49ea41165 100644 --- a/test/org/traccar/protocol/TelikProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TelikProtocolDecoderTest.java @@ -14,8 +14,12 @@ public class TelikProtocolDecoderTest extends ProtocolDecoderTest { "0026436729|232|01|003002030")); verifyPosition(decoder, text( + "182043672999,010100001301,0,270613041652,166653,475341,3,0,355,6,2,1,231,8112432,23201,01,00,217,0,0,0,0,7"), + position("2013-06-27 04:16:52.000", true, 47.53410, 16.66530)); + + verifyPosition(decoder, text( "182043672999,010100001301,0,270613041652,166653,475341,3,0,355,6,2,1,231,8112432,23201,01,00,217,0,0,0,0,7")); - + } } diff --git a/test/org/traccar/protocol/Tk102ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk102ProtocolDecoderTest.java index fd8033902..7d34d8383 100644 --- a/test/org/traccar/protocol/Tk102ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Tk102ProtocolDecoderTest.java @@ -10,7 +10,8 @@ public class Tk102ProtocolDecoderTest extends ProtocolDecoderTest { Tk102ProtocolDecoder decoder = new Tk102ProtocolDecoder(new Tk102Protocol()); - verifyNothing(decoder, text( "")); + verifyNothing(decoder, text( + "")); verifyNothing(decoder, text( "[!0000000081r(353327023367238,TK102-W998_01_V1.1.001_130219,255,001,255,001,0,100,100,0,internet,0000,0000,0,0,255,0,4,1,11,00)")); diff --git a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java index 8f2cea217..d9152ecf0 100644 --- a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java @@ -10,6 +10,12 @@ public class Tk103ProtocolDecoderTest extends ProtocolDecoderTest { Tk103ProtocolDecoder decoder = new Tk103ProtocolDecoder(new Tk103Protocol()); + verifyAttributes(decoder, text( + "(013632651491,ZC20,040613,040137,6,42,112,0")); + + verifyAttributes(decoder, text( + "(864768010159785,ZC20,291015,030413,3,362,65535,255")); + verifyPosition(decoder, text( "(088047365460BR00151024A2555.3531S02855.3329E004.7055148276.1701000000L00009AA3)"), position("2015-10-24 05:51:48.000", true, -25.92255, 28.92222)); diff --git a/test/org/traccar/protocol/Tr20ProtocolDecoderTest.java b/test/org/traccar/protocol/Tr20ProtocolDecoderTest.java index 2bf504176..11d7847c2 100644 --- a/test/org/traccar/protocol/Tr20ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Tr20ProtocolDecoderTest.java @@ -10,7 +10,12 @@ public class Tr20ProtocolDecoderTest extends ProtocolDecoderTest { Tr20ProtocolDecoder decoder = new Tr20ProtocolDecoder(new Tr20Protocol()); - verifyNothing(decoder, text( "%%TRACKPRO01,1")); + verifyNothing(decoder, text( + "%%TRACKPRO01,1")); + + verifyPosition(decoder, text( + "%%TR-10,A,050916070549,N2240.8887E11359.2994,0,000,NA,D3800000,150,CFG:resend|"), + position("2005-09-16 07:05:49.000", true, 22.68148, 113.98832)); verifyPosition(decoder, text( "%%TR-10,A,050916070549,N2240.8887E11359.2994,0,000,NA,D3800000,150,CFG:resend|")); diff --git a/test/org/traccar/protocol/Tr900ProtocolDecoderTest.java b/test/org/traccar/protocol/Tr900ProtocolDecoderTest.java index 627b2296f..ddcacba1c 100644 --- a/test/org/traccar/protocol/Tr900ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Tr900ProtocolDecoderTest.java @@ -11,7 +11,8 @@ public class Tr900ProtocolDecoderTest extends ProtocolDecoderTest { Tr900ProtocolDecoder decoder = new Tr900ProtocolDecoder(new Tr900Protocol()); verifyPosition(decoder, text( - ">00001001,4,1,150626,131252,W05830.2978,S3137.2783,,00,348,18,00,003-000,0,3,11111011*3b!")); + ">00001001,4,1,150626,131252,W05830.2978,S3137.2783,,00,348,18,00,003-000,0,3,11111011*3b!"), + position("2015-06-26 13:12:52.000", true, -31.62131, -58.50496)); verifyPosition(decoder, text( ">12345678,1,1,070201,144111,W05829.2613,S3435.2313,,00,034,25,00,126-000,0,3,11111111*2d!")); diff --git a/test/org/traccar/protocol/TrackboxProtocolDecoderTest.java b/test/org/traccar/protocol/TrackboxProtocolDecoderTest.java index 08b17a130..697c1ff66 100644 --- a/test/org/traccar/protocol/TrackboxProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TrackboxProtocolDecoderTest.java @@ -10,10 +10,12 @@ public class TrackboxProtocolDecoderTest extends ProtocolDecoderTest { TrackboxProtocolDecoder decoder = new TrackboxProtocolDecoder(new TrackboxProtocol()); - verifyNothing(decoder, text( "a=connect&v=11&i=111111111111111")); + verifyNothing(decoder, text( + "a=connect&v=11&i=111111111111111")); verifyPosition(decoder, text( - "183457.999,5126.0247N,00002.8686E,5.2,70.4,3,57.63,32.11,17.32,150507,05")); + "183457.999,5126.0247N,00002.8686E,5.2,70.4,3,57.63,32.11,17.32,150507,05"), + position("2007-05-15 18:34:57.999", true, 51.43375, 0.04781)); verifyPosition(decoder, text( "183558.999,5126.3979N,00003.0745E,5.2,70.4,3,57.63,32.11,17.32,150507,05")); diff --git a/test/org/traccar/protocol/TrvProtocolDecoderTest.java b/test/org/traccar/protocol/TrvProtocolDecoderTest.java new file mode 100644 index 000000000..a8e9fdb04 --- /dev/null +++ b/test/org/traccar/protocol/TrvProtocolDecoderTest.java @@ -0,0 +1,28 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolDecoderTest; + +public class TrvProtocolDecoderTest extends ProtocolDecoderTest { + + @Test + public void testDecode() throws Exception { + + TrvProtocolDecoder decoder = new TrvProtocolDecoder(new TrvProtocol()); + + verifyNothing(decoder, text( + "TRVAP00353456789012345")); + + verifyPosition(decoder, text( + "TRVAP01080524A2232.9806N11404.9355E000.1061830323.8706000908000102,460,0,9520,3671")); + + verifyPosition(decoder, text( + "TRVAP01080524A2232.9806N11404.9355E000.1061830323.8706000908000102,460,0,9520,3671"), + position("2008-05-24 06:18:30.000", true, 22.54968, 114.08226)); + + verifyPosition(decoder, text( + "TRVAP10080524A2232.9806N11404.9355E000.1061830323.8706000908000502,460,0,9520,3671,00,zh-cn,00")); + + } + +} diff --git a/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java b/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java index 7e321fa8e..30e040e3d 100644 --- a/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java +++ b/test/org/traccar/protocol/UlbotechProtocolDecoderTest.java @@ -13,6 +13,9 @@ public class UlbotechProtocolDecoderTest extends ProtocolDecoderTest { UlbotechProtocolDecoder decoder = new UlbotechProtocolDecoder(new UlbotechProtocol()); verifyPosition(decoder, binary( + "f8010108679650230651689dc8e45b010e01194a26fbd47fa6001f003c0054030402420000040400024d7b0506037c18692212071131057f410c0ee0310d1b312f41413112ef0804000dd59fcc32f8")); + + verifyPosition(decoder, binary( "f8010103596580419465449da89d16010efe5580fe0923d82100140129005903040242000004040001a7f10506037818be220e070e31057b410c1324310d144131fa3208040020b1418297f8")); verifyPosition(decoder, binary( diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java new file mode 100644 index 000000000..41af104dd --- /dev/null +++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java @@ -0,0 +1,37 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolDecoderTest; + +public class WatchProtocolDecoderTest extends ProtocolDecoderTest { + + @Test + public void testDecode() throws Exception { + + WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol()); + + verifyPosition(decoder, text( + "[3G*4700186508*00B1*UD,301015,084840,V,45.853100,N,14.6224899,E,0.00,0.0,0.0,0,84,61,0,11,00000008,7,255,293,70,60,6453,139,60,6432,139,60,6431,132,60,6457,127,60,16353,126,60,6451,121,60,16352,118")); + + verifyNothing(decoder, text( + "[SG*8800000015*0002*LK")); + + verifyAttributes(decoder, text( + "[3G*4700186508*000B*LK,0,10,100")); + + verifyPosition(decoder, text( + "[SG*8800000015*0087*UD,220414,134652,A,22.571707,N,113.8613968,E,0.1,0.0,100,7,60,90,1000,50,0000,4,1,460,0,9360,4082,131,9360,4092,148,9360,4091,143,9360,4153,141"), + position("2014-04-22 13:46:52.000", true, 22.57171, 113.86140)); + + verifyPosition(decoder, text( + "[SG*8800000015*0087*UD,220414,134652,A,22.571707,N,113.8613968,E,0.1,0.0,100,7,60,90,1000,50,0000,4,1,460,0,9360,4082,131,9360,4092,148,9360,4091,143,9360,4153,141")); + + verifyPosition(decoder, text( + "[SG*8800000015*0088*UD2,220414,134652,A,22.571707,N,113.8613968,E,0.1,0.0,100,7,60,90,1000,50,0000,4,1,460,0,9360,4082,131,9360,4092,148,9360,4091,143,9360,4153,141")); + + verifyPosition(decoder, text( + "[SG*8800000015*0087*AL,220414,134652,A,22.571707,N,113.8613968,E,0.1,0.0,100,7,60,90,1000,50,0001,4,1,460,0,9360,4082,131,9360,4092,148,9360,4091,143,9360,4153,141")); + + } + +} diff --git a/test/org/traccar/protocol/WondexProtocolDecoderTest.java b/test/org/traccar/protocol/WondexProtocolDecoderTest.java index 5173734a8..e5685033c 100644 --- a/test/org/traccar/protocol/WondexProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WondexProtocolDecoderTest.java @@ -9,6 +9,20 @@ public class WondexProtocolDecoderTest extends ProtocolDecoderTest { public void testDecode() throws Exception { WondexProtocolDecoder decoder = new WondexProtocolDecoder(new WondexProtocol()); + + verifyPosition(decoder, text( + "2000000108,20151030145404,76.948633,43.354700,0,140,15,100,1,1325,125.4,10.5,0.0"), + position("2015-10-30 14:54:04.000", true, 43.35470, 76.94863)); + + verifyPosition(decoder, text( + "2000000257,20151030145351,69.379976,53.283905,0,0,16,2,0,0,469.1,58.9,0.0"), + position("2015-10-30 14:53:51.000", false, 53.28390, 69.37998)); + + verifyPosition(decoder, text( + "2000000232,20151030145206,51.166900,43.651353,0,132,11,2,0,0,0.0,0.0,0.0")); + + verifyPosition(decoder, text( + "2000000259,20151030145653,69.380826,53.283890,9,10,15,2,1,695,1002.6,108.2,0.0")); verifyPosition(decoder, text( "1044989601,20130323074605,0.000000,90.000000,0,000,0,0,2")); |