diff options
author | Ivan Muratov <binakot@gmail.com> | 2017-07-17 14:02:13 +0300 |
---|---|---|
committer | Ivan Muratov <binakot@gmail.com> | 2017-07-17 14:02:13 +0300 |
commit | 7d8bcf871e3ef74d49122ec1e304c4cae5b0a9b6 (patch) | |
tree | 45361febcec29fe6c08a4c3907b35f705cad26d6 /test/org/traccar/protocol/Arnavi4FrameDecoderTest.java | |
parent | 76bd19e5da79ea4b4ec28fd91308c682d5d660f8 (diff) | |
parent | 31e972e169acf4a517ff10f8a64f0e0cf0b8df0e (diff) | |
download | trackermap-server-7d8bcf871e3ef74d49122ec1e304c4cae5b0a9b6.tar.gz trackermap-server-7d8bcf871e3ef74d49122ec1e304c4cae5b0a9b6.tar.bz2 trackermap-server-7d8bcf871e3ef74d49122ec1e304c4cae5b0a9b6.zip |
Merge branch 'arnavi4_remarks'
Diffstat (limited to 'test/org/traccar/protocol/Arnavi4FrameDecoderTest.java')
-rw-r--r-- | test/org/traccar/protocol/Arnavi4FrameDecoderTest.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/test/org/traccar/protocol/Arnavi4FrameDecoderTest.java b/test/org/traccar/protocol/Arnavi4FrameDecoderTest.java index 93d818f56..2203cdafc 100644 --- a/test/org/traccar/protocol/Arnavi4FrameDecoderTest.java +++ b/test/org/traccar/protocol/Arnavi4FrameDecoderTest.java @@ -9,7 +9,7 @@ import java.nio.ByteOrder; public class Arnavi4FrameDecoderTest extends ProtocolTest { @Test - public void testDecode() throws Exception { + public void testDecodeValidPackets() throws Exception { Arnavi4FrameDecoder decoder = new Arnavi4FrameDecoder(); @@ -21,7 +21,7 @@ public class Arnavi4FrameDecoderTest extends ProtocolTest { binary(ByteOrder.LITTLE_ENDIAN, "ff23f30c45f5c90f0300"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "ff23f30c45f5c90f0300"))); - Assert.assertEquals( // Valid PACKAGE with answer to server on file transfer. + Assert.assertEquals( // Valid PACKAGE with answer to server on file transfer null, decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "5bfd005d"))); @@ -43,4 +43,23 @@ public class Arnavi4FrameDecoderTest extends ProtocolTest { } + @Test + public void testDecodeInvalidPackets() throws Exception { + + Arnavi4FrameDecoder decoder = new Arnavi4FrameDecoder(); + + Assert.assertEquals( // Invalid PACKAGE with one DATA packet (missing last byte with end sign) + null, + decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "5b01012800a3175f5903513934420447221c42055402781E0900f0c5215b4e0084005c00007c005d0000a300fa3701000029"))); + + Assert.assertEquals( // Invalid PACKAGE with two DATA packet (missing last 10 bytes) + null, + decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "5b01012800a3175f5903513934420447221c42055402781E0900f0c5215b4e0084005c00007c005d0000a300fa3701000029012800a3175f5903513934420447221c42055402781E0900f0c5215b4e0084005c00007c005d00"))); + + Assert.assertEquals( // Valid PACKAGE with useless extra bytes at the end + binary(ByteOrder.LITTLE_ENDIAN, "5b01012800a3175f5903513934420447221c42055402781E0900f0c5215b4e0084005c00007c005d0000a300fa37010000295d"), + decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "5b01012800a3175f5903513934420447221c42055402781E0900f0c5215b4e0084005c00007c005d0000a300fa37010000295d010203040506070809"))); + + } + }
\ No newline at end of file |