aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2013-08-31 18:48:30 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2013-08-31 18:48:30 +1200
commit4b5b368a7bff1d4126458b8032ec313ec28dd911 (patch)
tree5d48ca5f5888995ad92e8f01eb1dbcc301639903
parent743ed6cd39d661aba7d9b6671feda5c08949be6f (diff)
downloadtraccar-server-4b5b368a7bff1d4126458b8032ec313ec28dd911.tar.gz
traccar-server-4b5b368a7bff1d4126458b8032ec313ec28dd911.tar.bz2
traccar-server-4b5b368a7bff1d4126458b8032ec313ec28dd911.zip
Add Cellocator unit test
-rw-r--r--test/org/traccar/protocol/CellocatorProtocolDecoderTest.java12
-rwxr-xr-xtools/hex.sh2
2 files changed, 9 insertions, 5 deletions
diff --git a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
index 1384b29bb..5d5594fcb 100644
--- a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
@@ -4,6 +4,7 @@ import java.nio.ByteOrder;
import org.jboss.netty.buffer.ChannelBuffers;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
+import org.traccar.helper.ChannelBufferTools;
public class CellocatorProtocolDecoderTest {
@@ -13,11 +14,14 @@ public class CellocatorProtocolDecoderTest {
CellocatorProtocolDecoder decoder = new CellocatorProtocolDecoder(null);
decoder.setDataManager(new TestDataManager());
- byte[] buf1 = {0x4D,0x43,0x47,0x50,0x00,0x06,0x00,0x00,0x00,0x08,0x1A,0x02,0x02,0x12,0x04,0x00,0x00,0x00,0x21,0x00,0x62,0x30,0x00,0x00,0x00,0x6B,0x00,(byte)0xE1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,(byte)0xE5,(byte)0xA1,0x00,0x04,0x02,0x06,0x61,0x4E,(byte)0xA3,0x03,0x18,0x1A,0x57,0x03,0x4E,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x25,0x07,0x14,0x03,(byte)0xD6,0x07,0x49};
- assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf1)));
+ int[] buf1 = {0x4D,0x43,0x47,0x50,0x00,0x06,0x00,0x00,0x00,0x08,0x1A,0x02,0x02,0x12,0x04,0x00,0x00,0x00,0x21,0x00,0x62,0x30,0x00,0x00,0x00,0x6B,0x00,0xE1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE5,0xA1,0x00,0x04,0x02,0x06,0x61,0x4E,0xA3,0x03,0x18,0x1A,0x57,0x03,0x4E,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x15,0x25,0x07,0x14,0x03,0xD6,0x07,0x49};
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(buf1))));
- byte[] buf2 = {0x4d,0x43,0x47,0x50,0x00,0x01,0x01,0x00,0x00,0x08,0x01,0x1f,0x04,0x18,0x04,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x00,0x00,0x00,0x5e,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,(byte)0x85,0x00,0x04,0x02,0x04,(byte)0xda,0x4d,(byte)0xa3,0x03,0x67,0x19,0x57,0x03,(byte)0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x14,0x15,0x10,0x07,(byte)0xdd,0x07,(byte)0xf7};
- assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf2)));
+ int[] buf2 = {0x4d,0x43,0x47,0x50,0x00,0x01,0x01,0x00,0x00,0x08,0x01,0x1f,0x04,0x18,0x04,0x00,0x00,0x00,0x20,0x01,0x00,0x00,0x00,0x00,0x00,0x5e,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x85,0x00,0x04,0x02,0x04,0xda,0x4d,0xa3,0x03,0x67,0x19,0x57,0x03,0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x14,0x15,0x10,0x07,0xdd,0x07,0xf7};
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(buf2))));
+
+ int[] buf3 = {0x4d,0x43,0x47,0x50,0x00,0x5e,0x93,0x01,0x00,0x08,0x01,0x02,0x04,0x18,0x04,0x00,0x00,0x00,0x20,0x0f,0x20,0x00,0x00,0x00,0x00,0x5e,0x75,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x5a,0xf4,0x00,0x04,0x02,0x04,0xda,0x4d,0xa3,0x03,0x67,0x19,0x57,0x03,0xe8,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x1a,0x11,0x1e,0x08,0xdd,0x07,0x60};
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, ChannelBufferTools.convertArray(buf3))));
}
diff --git a/tools/hex.sh b/tools/hex.sh
index 3727b7c3a..9e5dd025d 100755
--- a/tools/hex.sh
+++ b/tools/hex.sh
@@ -1 +1 @@
-echo 504f5354206d6f6e2f677072732e646c6c3f6461746120485454502f312e310d0a486f73743a2034312e3232362e32372e3231310d0a436f6e74656e742d547970653a206170706c69636174696f6e2f62696e6172790d0a436f6e74656e742d4c656e6774683a203136390d0a0d0a69643d38393730313031303035343831313534393030372662696e3d3105010080ff400fde0a0a0fc9edc712399c3006bd0300be00000031e300022c80000000000cc5000000000000000000007f4fffffffa474ff3aff134346f949b04300ae00000031e300022c80000000000cc5000000000000000000007f4fffffffa474fe3aff0c4346f872104300ae00000031e300022c80000000000cc5000000000000000000007f4fff00504f5354206d6f6e2f677072732e646c6c3f6461746120485454502f312e310d0a486f73743a2034312e3232362e32372e3231310d0a436f6e74656e742d547970653a206170706c69636174696f6e2f62696e6172790d0a436f6e74656e742d4c656e6774683a203136390d0a0d0a69643d38393730313031303035343831313534393030372662696e3d3105010080ff400fde0a0a0fc9edc712399c3006bd0300be00000031e300022c80000000000cc5000000000000000000007f4fffffffa474ff3aff134346f949b04300ae00000031e300022c80000000000cc5000000000000000000007f4fffffffa474fe3aff0c4346f872104300ae00000031e300022c80000000000cc5000000000000000000007f4fff00 | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' | nc -v -w 10 localhost 5026
+echo 4d434750005e930100080102041804000000200f20000000005e7500000000000000000000005af400040204da4da30367195703e8030000000000000000021a111e08dd0760 | perl -ne 's/([0-9a-f]{2})/print chr hex $1/gie' | nc -v -w 10 localhost 5033