aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/org/traccar/protocol/Arnavi4FrameDecoderTest.java23
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