aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java b/test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java
new file mode 100644
index 000000000..078a1b577
--- /dev/null
+++ b/test/org/traccar/protocol/avl08/Avl08ProtocolDecoderTest.java
@@ -0,0 +1,55 @@
+package org.traccar.protocol.avl08;
+
+import java.util.List;
+import org.junit.Test;
+import org.traccar.Device;
+import org.traccar.Position;
+import org.traccar.DataManager;
+import static org.junit.Assert.*;
+
+public class Avl08ProtocolDecoderTest {
+
+ private class TestDataManager implements DataManager {
+ public List getDevices() {
+ return null;
+ }
+
+ public Device getDeviceByImei(String imei) {
+ Device device = new Device();
+ device.setId(new Long(1));
+ device.setImei("10000000000000");
+ return device;
+ }
+
+ public void setPosition(Position position) {
+ }
+ }
+
+ @Test
+ public void testDecode() throws Exception {
+
+ Avl08ProtocolDecoder decoder = new Avl08ProtocolDecoder(new Avl08ProtocolDecoderTest.TestDataManager(), 0);
+
+ //$$(2 Bytes) + Len(2 Bytes) + IMEI(15 Bytes) + | + AlarmType(2 Bytes) + GPRMC + | +
+ //PDOP + | + HDOP + | + VDOP + | + Status(12 Bytes) + | + RTC(14 Bytes) + | + Voltage(8 Bytes)
+ //+ | + ADC(8 Bytes) + | + LACCI(8 Bytes) + | + Temperature(4 Bytes) | +Mile-meter+| +Serial(4
+ //Bytes) + | +RFID(10Bytes)+|+ Checksum (4 Byte) + \r\n(2 Bytes)
+
+ assertNull(decoder.decode(null, null,
+ "AE359772033395899|AA000000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|000000000000|20090215000153|13601435|00000000|00000000|0000|0.0000|0007|2DAA"));
+
+ assertNull(decoder.decode(null, null,
+ "AE359772033395899|AA000000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|00000000|20090215001204|14182037|00000000|0012D888|0000|0.0000|0016|5B51"));
+
+ assertNull(decoder.decode(null, null,
+ "AE359772033395899|AA00000000000000000000000000000000000000000000000000000000000|00.0|00.0|00.0|00000000000|20090215001337|14182013|00000000|0012D888|0000|0.0000|0017|346E"));
+
+ assertNotNull(decoder.decode(null, null,
+ "B3359772032399074|60$GPRMC,094859.000,A,3648.2229,N,01008.0976,E,0.00,,221211,,,A*79|02.3|01.3|02.0|000000000000|20111222094858|13360808|00000000|00000000|0000|0.0000|0001||A977"));
+
+ assertNotNull(decoder.decode(null, null,
+ "B3359772032399074|09$GPRMC,094905.000,A,3648.2229,N,01008.0976,E,0.00,,221211,,,A*71|02.1|01.3|01.7|000000000000|20111222094905|03210533|00000000|00000000|0000|0.0000|0002||FA58"));
+
+ }
+
+}