aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-09-05 22:28:14 +0400
committerAnton Tananaev <anton.tananaev@gmail.com>2012-09-05 22:28:14 +0400
commit54927aef2dec0bb540699f9c1cfc5e2554f0abf1 (patch)
tree7e0aa317aa05f79c1c448ac7f083ad7fa775c7d9
parent6060bff2be43a704926f4673acc71eb507518193 (diff)
downloadtraccar-server-54927aef2dec0bb540699f9c1cfc5e2554f0abf1.tar.gz
traccar-server-54927aef2dec0bb540699f9c1cfc5e2554f0abf1.tar.bz2
traccar-server-54927aef2dec0bb540699f9c1cfc5e2554f0abf1.zip
Added additional tests
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java2
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java32
2 files changed, 32 insertions, 2 deletions
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 88a83ef80..2578065c1 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -68,11 +68,13 @@ public class Gps103ProtocolDecoder extends GenericProtocolDecoder {
// Send response #1
if (sentence.contains("##")) {
channel.write("LOAD");
+ return null;
}
// Send response #2
if (sentence.length() == 15 && Character.isDigit(sentence.charAt(0))) {
channel.write("ON");
+ return null;
}
// Parse message
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index 7a90e4fbd..8cd25514f 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -1,6 +1,7 @@
package org.traccar.protocol;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import org.junit.Test;
public class Gps103ProtocolDecoderTest {
@@ -9,11 +10,18 @@ public class Gps103ProtocolDecoderTest {
public void testDecode() throws Exception {
Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(new TestDataManager(), 0);
+
+ // Log on request
+ //assertNull(decoder.decode(null, null, "##,imei:359586015829802,A"));
- // assertNull(decoder.decode(null, null, "##,imei:10000000000000,A"));
+ // Heartbeat package
+ //assertNull(decoder.decode(null, null, "359586015829802"));
+
+ // No GPS signal
+ //assertNull(decoder.decode(null, null, "imei:359586015829802,tracker,000000000,13554900601,L,;"));
assertNotNull(decoder.decode(null, null,
- "imei:10000000000000,help me,1004171910,,F,010203.000,A,0102.0003,N,00102.0003,E,1.02,"));
+ "imei:100000000000000,help me,1004171910,,F,010203.000,A,0102.0003,N,00102.0003,E,1.02,"));
assertNotNull(decoder.decode(null, null,
"imei:353451040164707,tracker,1105182344,+36304665439,F,214418.000,A,4804.2222,N,01916.7593,E,0.37,"));
@@ -27,6 +35,26 @@ public class Gps103ProtocolDecoderTest {
assertNotNull(decoder.decode(null, null,
"imei:353451049926460,tracker,1208042043,123456 99008026,F,124336.000,A,3509.8668,N,03322.7636,E,0.00,,"));
+ // SOS alarm
+ assertNotNull(decoder.decode(null, null,
+ "imei:359586015829802,help me,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
+
+ // Low battery alarm
+ assertNotNull(decoder.decode(null, null,
+ "imei:359586015829802,low battery,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
+
+ // Geo-fence alarm
+ assertNotNull(decoder.decode(null, null,
+ "imei:359586015829802,stockade,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
+
+ // Move alarm
+ assertNotNull(decoder.decode(null, null,
+ "imei:359586015829802,move,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
+
+ // Over speed alarm
+ assertNotNull(decoder.decode(null, null,
+ "imei:359586015829802,speed,0809231429,13554900601,F,062947.294,A,2234.4026,N,11354.3277,E,0.00,"));
+
}
}