diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-16 14:53:05 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-04-16 14:53:05 +1200 |
commit | 1498b5c5a00c575ba67dce2dcfac0d77a8b4964a (patch) | |
tree | 5a3746b585e524b1f2a306b1009b30988fe314ea /test/org | |
parent | 5c127eee77815eabc5c99ee45b2767a0e61553a9 (diff) | |
download | traccar-server-1498b5c5a00c575ba67dce2dcfac0d77a8b4964a.tar.gz traccar-server-1498b5c5a00c575ba67dce2dcfac0d77a8b4964a.tar.bz2 traccar-server-1498b5c5a00c575ba67dce2dcfac0d77a8b4964a.zip |
Fix H02 status code decoding
Diffstat (limited to 'test/org')
-rw-r--r-- | test/org/traccar/ProtocolTest.java | 4 | ||||
-rw-r--r-- | test/org/traccar/protocol/H02ProtocolDecoderTest.java | 27 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index faf27071d..502fa6284 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -86,6 +86,10 @@ public class ProtocolTest extends BaseTest { Assert.assertNull(decoder.decode(null, null, object)); } + protected void verifyAttribute(BaseProtocolDecoder decoder, Object object, String key, Object expected) throws Exception { + Assert.assertEquals(expected, ((Position) decoder.decode(null, null, object)).getAttributes().get(key)); + } + protected void verifyAttributes(BaseProtocolDecoder decoder, Object object) throws Exception { verifyDecodedPosition(decoder.decode(null, null, object), false, true, null); } diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java index 7498bbcd7..f39c3a689 100644 --- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java +++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java @@ -2,6 +2,7 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class H02ProtocolDecoderTest extends ProtocolTest { @@ -11,6 +12,9 @@ public class H02ProtocolDecoderTest extends ProtocolTest { H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol()); verifyPosition(decoder, buffer( + "*HQ,4109179024,V19,181519,V,3853.2587,S,06205.9175,W,000.00,000,090217,,5492932630888,8954315265044716555?,FFFFFBFF#")); + + verifyPosition(decoder, buffer( "*HQ,8161289587,V1,181933,A,5444.3994,N,02516.3844,E,000.05,000,090317,FFFFBBFF,246,03,00002,41565#")); verifyPosition(decoder, binary( @@ -184,4 +188,27 @@ public class H02ProtocolDecoderTest extends ProtocolTest { } + @Test + public void testDecodeStatus() throws Exception { + + H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol()); + + verifyAttribute(decoder, buffer( + "*HQ,2705171109,V1,213324,A,5002.5849,N,01433.7822,E,0.00,000,140613,FFFFFFFF#"), + Position.KEY_STATUS, 0xFFFFFFFFL); + + verifyAttribute(decoder, buffer( + "*HQ,4109179024,V19,181519,V,3853.2587,S,06205.9175,W,000.00,000,090217,,5492932630888,8954315265044716555?,FFFFFBFF#"), + Position.KEY_STATUS, 0xFFFFFBFFL); + + verifyAttribute(decoder, binary( + "2441091144271222470112142233983006114026520E000000FFFFFBFFFF0014060000000001CC00262B0F170A"), + Position.KEY_STATUS, 0xFFFFFBFFL); + + verifyAttribute(decoder, buffer( + "*HQ,4210051415,V1,164549,A,0956.3869,N,08406.7068,W,000.00,000,221215,FFFFFBFF,712,01,0,0,6#"), + Position.KEY_STATUS, 0xFFFFFBFFL); + + } + } |