aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/FilterHandlerTest.java4
-rw-r--r--test/org/traccar/ProtocolDecoderTest.java13
-rw-r--r--test/org/traccar/geocode/ReverseGeocoderTest.java4
-rw-r--r--test/org/traccar/location/LocationProviderTest.java49
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/HuabaoProtocolDecoderTest.java21
-rw-r--r--test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java5
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/WatchProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/web/AsyncServletTest.java13
10 files changed, 110 insertions, 11 deletions
diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java
index f860c489f..b1e4fcb16 100644
--- a/test/org/traccar/FilterHandlerTest.java
+++ b/test/org/traccar/FilterHandlerTest.java
@@ -15,8 +15,8 @@ public class FilterHandlerTest {
@Before
public void setUp() {
- filtingHandler = new FilterHandler(true, true, true, true, 10, 10);
- passingHandler = new FilterHandler(false, false, false, false, 0, 0);
+ filtingHandler = new FilterHandler(true, true, true, true, true, 10, 10);
+ passingHandler = new FilterHandler(false, false, false, false, false, 0, 0);
}
@After
diff --git a/test/org/traccar/ProtocolDecoderTest.java b/test/org/traccar/ProtocolDecoderTest.java
index 2906f2002..8f7ed628b 100644
--- a/test/org/traccar/ProtocolDecoderTest.java
+++ b/test/org/traccar/ProtocolDecoderTest.java
@@ -187,12 +187,17 @@ public class ProtocolDecoderTest {
Assert.assertFalse("no attributes", attributes.isEmpty());
}
- /*if (attributes.containsKey(Event.KEY_LAC) || attributes.containsKey(Event.KEY_CID)) {
+ if (attributes.containsKey(Event.KEY_LAC) || attributes.containsKey(Event.KEY_CID)) {
+ checkInteger(attributes.get(Event.KEY_LAC), 1, 65535);
+ checkInteger(attributes.get(Event.KEY_CID), 1, 268435455);
+ }
+
+ if (attributes.containsKey(Event.KEY_MCC) || attributes.containsKey(Event.KEY_MNC)) {
checkInteger(attributes.get(Event.KEY_MCC), 100, 999);
checkInteger(attributes.get(Event.KEY_MNC), 0, 999);
- checkInteger(attributes.get(Event.KEY_LAC), 1, 65535);
- checkInteger(attributes.get(Event.KEY_CID), 1, 65535);
- }*/
+ Assert.assertTrue("value missing", attributes.containsKey(Event.KEY_LAC));
+ Assert.assertTrue("value missing", attributes.containsKey(Event.KEY_CID));
+ }
}
diff --git a/test/org/traccar/geocode/ReverseGeocoderTest.java b/test/org/traccar/geocode/ReverseGeocoderTest.java
index 2336418d8..a572b0456 100644
--- a/test/org/traccar/geocode/ReverseGeocoderTest.java
+++ b/test/org/traccar/geocode/ReverseGeocoderTest.java
@@ -14,11 +14,9 @@ public class ReverseGeocoderTest {
testNominatim();
testGisgraphy();
}
-
}
public void testGoogle() {
-
ReverseGeocoder reverseGeocoder = new GoogleReverseGeocoder();
reverseGeocoder.getAddress(new AddressFormat(), 37.4217550, -122.0846330, new ReverseGeocoder.ReverseGeocoderCallback() {
@@ -30,7 +28,6 @@ public class ReverseGeocoderTest {
}
public void testNominatim() {
-
ReverseGeocoder reverseGeocoder = new NominatimReverseGeocoder();
reverseGeocoder.getAddress(new AddressFormat(), 40.7337807, -73.9974401, new ReverseGeocoder.ReverseGeocoderCallback() {
@@ -42,7 +39,6 @@ public class ReverseGeocoderTest {
}
public void testGisgraphy() {
-
ReverseGeocoder reverseGeocoder = new GisgraphyReverseGeocoder();
reverseGeocoder.getAddress(new AddressFormat(), 48.8530000, 2.3400000, new ReverseGeocoder.ReverseGeocoderCallback() {
diff --git a/test/org/traccar/location/LocationProviderTest.java b/test/org/traccar/location/LocationProviderTest.java
new file mode 100644
index 000000000..b7280cfea
--- /dev/null
+++ b/test/org/traccar/location/LocationProviderTest.java
@@ -0,0 +1,49 @@
+package org.traccar.location;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.traccar.geocode.AddressFormat;
+import org.traccar.geocode.GisgraphyReverseGeocoder;
+import org.traccar.geocode.GoogleReverseGeocoder;
+import org.traccar.geocode.NominatimReverseGeocoder;
+import org.traccar.geocode.ReverseGeocoder;
+import org.traccar.model.Event;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class LocationProviderTest {
+
+ private boolean enable = false;
+
+ @Test
+ public void test() {
+ if (enable) {
+ testOpenCellId();
+ }
+ }
+
+ public void testOpenCellId() {
+ OpenCellIdLocationProvider locationProvider = new OpenCellIdLocationProvider("fake");
+
+ Map<String, Object> attributes = new HashMap<>();
+ attributes.put(Event.KEY_MCC, 260);
+ attributes.put(Event.KEY_MNC, 2);
+ attributes.put(Event.KEY_LAC, 10250);
+ attributes.put(Event.KEY_CID, 26511);
+
+ locationProvider.getLocation(attributes, new LocationProvider.LocationProviderCallback() {
+ @Override
+ public void onSuccess(double latitude, double longitude) {
+ Assert.assertEquals(60.07254, latitude, 0.00001);
+ Assert.assertEquals(30.30996, longitude, 0.00001);
+ }
+
+ @Override
+ public void onFailure() {
+ Assert.fail();
+ }
+ });
+ }
+
+}
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index 80d1424fc..371b137fd 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -10,6 +10,12 @@ public class Gps103ProtocolDecoderTest extends ProtocolDecoderTest {
Gps103ProtocolDecoder decoder = new Gps103ProtocolDecoder(new Gps103Protocol());
+ verifyAttributes(decoder, text(
+ "imei:359710041100000,tracker,000000000,,L,,,fa8,,c9af,,,,,0,0,0.00%,,"));
+
+ verifyAttributes(decoder, text(
+ "imei:863070016871385,tracker,0000000119,,L,,,0FB6,,CB5D,,,"));
+
verifyPosition(decoder, text(
"imei:359710045559474,tracker,151030080103,,F,000101.000,A,5443.3834,N,02512.9071,E,0.00,0;"),
position("2015-10-30 00:01:01.000", true, 54.72306, 25.21512));
diff --git a/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java
index 0968d6d9c..b24b844d9 100644
--- a/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/HuabaoProtocolDecoderTest.java
@@ -11,8 +11,29 @@ public class HuabaoProtocolDecoderTest extends ProtocolDecoderTest {
HuabaoProtocolDecoder decoder = new HuabaoProtocolDecoder(new HuabaoProtocol());
verifyNothing(decoder, binary(
+ "7E0100002D013511221122000500000000373031303748422D52303347424400000000000000000000003233363631303402CBD5424136383630387E"));
+
+ verifyNothing(decoder, binary(
"7e0100002d007089994489002800000000000000000048422d523033474244000000000000000000000031393036373531024142433030303030d17e"));
+ verifyNothing(decoder, binary(
+ "7E0102000E013511221122000661757468656E7469636174696F6E3F7E"));
+
+ verifyPosition(decoder, binary(
+ "7E02000032013511221122000700000000000C000301578CC006CA3A5C00470000000014072317201501040000000030011631010BD07E"));
+
+ verifyNothing(decoder, binary(
+ "7E010200100940278494700084323031313131303831313333323139369F7E"));
+
+ verifyNothing(decoder, binary(
+ "7e010000190940278494700012000000000000000000000000000000000000094027849470000a7e"));
+
+ verifyPosition(decoder, binary(
+ "7e0200002e094027587492000a000000010000000a03083db7001329f3000000140000130412164952010400000012360a0002341502cb0c20085c107e"));
+
+ verifyPosition(decoder, binary(
+ "7e020000220014012499170007000000000000400e012af16f02cbd2ba000000000000150101194257010400000077a97e"));
+
}
}
diff --git a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
index 6d0ba50d5..0c3c570f5 100644
--- a/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MeiligaoProtocolDecoderTest.java
@@ -12,8 +12,11 @@ public class MeiligaoProtocolDecoderTest extends ProtocolDecoderTest {
MeiligaoProtocolDecoder decoder = new MeiligaoProtocolDecoder(new MeiligaoProtocol());
+ verifyNothing(decoder, binary(
+ "24240011671440258855405000b24d0d0a"));
+
verifyPosition(decoder, binary(
- "242400706796502079108999553131333131382e3030302c412c313033372e393637382c4e2c30363132312e353637392c572c302e35342c322e34322c3330303931352c2c2c412a37307c302e37377c392e397c303030307c303030302c303161327c3030313138373132374cae0d0a"),
+ "242400706796502079108999553131333131382e3030302c412c313033372e393637382c4e2c30363132312e353637392c572c302e35342c322e34322c3330303931352c2c2c412a37307c302e37377c392e397c303030307c303030302c303161327c3030313138373132374cae0d0a"),
position("2015-09-30 11:31:18.000", true, 10.63280, -61.35947));
verifyPosition(decoder, binary(
diff --git a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
index d9152ecf0..2bffbcd9a 100644
--- a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class Tk103ProtocolDecoderTest extends ProtocolDecoderTest {
Tk103ProtocolDecoder decoder = new Tk103ProtocolDecoder(new Tk103Protocol());
verifyAttributes(decoder, text(
+ "(088047194605BZ00,510,010,36e6,932c,43,36e6,766b,36,36e6,7668,32"));
+
+ verifyAttributes(decoder, text(
"(013632651491,ZC20,040613,040137,6,42,112,0"));
verifyAttributes(decoder, text(
diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
index 41af104dd..16074d36f 100644
--- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class WatchProtocolDecoderTest extends ProtocolDecoderTest {
WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol());
+ verifyNothing(decoder, text(
+ "[3G*8800000015*0003*TKQ"));
+
verifyPosition(decoder, text(
"[3G*4700186508*00B1*UD,301015,084840,V,45.853100,N,14.6224899,E,0.00,0.0,0.0,0,84,61,0,11,00000008,7,255,293,70,60,6453,139,60,6432,139,60,6431,132,60,6457,127,60,16353,126,60,6451,121,60,16352,118"));
diff --git a/test/org/traccar/web/AsyncServletTest.java b/test/org/traccar/web/AsyncServletTest.java
new file mode 100644
index 000000000..e2f7b2f21
--- /dev/null
+++ b/test/org/traccar/web/AsyncServletTest.java
@@ -0,0 +1,13 @@
+package org.traccar.web;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class AsyncServletTest {
+
+ @Test
+ public void testDebugDisabled() {
+ Assert.assertFalse("debugging enabled", AsyncServlet.AsyncSession.DEBUG_ASYNC);
+ }
+
+}