aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
authoruser <user@laptop.(none)>2012-10-21 17:44:59 +1300
committeruser <user@laptop.(none)>2012-10-21 17:44:59 +1300
commita3441d3bcd02ec48e408957dfdc61dc6850bc339 (patch)
treeb62cd0cd31b7deb2e6c4360e5a4d2cbcba55acc4 /test/org/traccar
parentf5bb85ff12db673ecc30f5cbaddc3b43a9d3310b (diff)
downloadtrackermap-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.tar.gz
trackermap-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.tar.bz2
trackermap-server-a3441d3bcd02ec48e408957dfdc61dc6850bc339.zip
Add JT600 support (fix #58)
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/helper/ChannelBufferToolsTest.java23
-rw-r--r--test/org/traccar/protocol/Jt600ProtocolDecoderTest1.java32
2 files changed, 55 insertions, 0 deletions
diff --git a/test/org/traccar/helper/ChannelBufferToolsTest.java b/test/org/traccar/helper/ChannelBufferToolsTest.java
new file mode 100644
index 000000000..16ff036b8
--- /dev/null
+++ b/test/org/traccar/helper/ChannelBufferToolsTest.java
@@ -0,0 +1,23 @@
+package org.traccar.helper;
+
+import org.jboss.netty.buffer.ChannelBufferFactory;
+import org.jboss.netty.buffer.HeapChannelBufferFactory;
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class ChannelBufferToolsTest {
+
+ private ChannelBufferFactory factory = new HeapChannelBufferFactory();
+
+ @Test
+ public void testFind() {
+ }
+
+ @Test
+ public void testReadHexInteger() {
+ byte[] buf = {0x01,(byte)0x90,0x34};
+ int result = ChannelBufferTools.readHexInteger(
+ factory.getBuffer(buf, 0, buf.length), 5);
+ assertEquals(1903, result);
+ }
+}
diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest1.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest1.java
new file mode 100644
index 000000000..cdf8f1568
--- /dev/null
+++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest1.java
@@ -0,0 +1,32 @@
+package org.traccar.protocol;
+
+import java.nio.charset.Charset;
+import org.jboss.netty.buffer.ChannelBuffers;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+
+public class Jt600ProtocolDecoderTest1 {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ Jt600ProtocolDecoder decoder = new Jt600ProtocolDecoder(new TestDataManager(), 0);
+
+ byte[] buf1 = {0x24,0x31,0x10,0x21,0x60,0x01,0x11,0x00,0x1B,0x16,0x02,0x11,0x05,0x59,0x10,0x22,0x32,(byte)0x98,0x62,0x11,0x40,0x46,0x22,0x7B,0x05,(byte)0x98,0x09,0x50,(byte)0x80,0x01,0x23,0x27,(byte)0x95,0x14,0x35,0x16,0x1F};
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf1)));
+
+ byte[] buf2 = {0x24,0x31,0x20,(byte)0x82,0x00,0x29,0x11,0x00,0x1B,0x17,0x10,0x12,0x05,0x28,0x31,0x24,0x38,0x10,0x12,0x02,0x55,0x33,0x64,0x25,0x00,0x19,0x07,0x19,0x00,0x03,(byte)0xFD,0x2B,(byte)0x91,0x04,0x4D,0x1F,(byte)0xA0};
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf2)));
+
+ byte[] buf3 = {0x24,0x31,0x20,(byte)0x82,0x00,0x29,0x11,0x00,0x1B,0x17,0x10,0x12,0x05,0x33,0x05,0x24,0x38,0x09,(byte)0x97,0x02,0x55,0x33,0x58,0x45,0x00,0x04,0x06,0x1E,0x00,0x03,(byte)0xEE,0x00,0x00,0x00,0x00,0x0C,0x00};
+ assertNotNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(buf2)));
+
+ assertNotNull(decoder.decode(null, null,
+ ChannelBuffers.copiedBuffer("(3110312099,W01,11404.6204,E,2232.9961,N,A,040511,063736,4,7,100,4,17,1,1,company)", Charset.defaultCharset())));
+
+ assertNotNull(decoder.decode(null, null,
+ ChannelBuffers.copiedBuffer("(3120820029,W01,02553.3555,E,2438.0997,S,A,171012,053339,0,8,20,6,31,5,20,20)", Charset.defaultCharset())));
+
+ }
+
+}