aboutsummaryrefslogtreecommitdiff
path: root/test/org
diff options
context:
space:
mode:
Diffstat (limited to 'test/org')
-rw-r--r--test/org/traccar/FilterHandlerTest.java2
-rw-r--r--test/org/traccar/ProtocolTest.java18
-rw-r--r--test/org/traccar/location/CellInfoTest.java36
-rw-r--r--test/org/traccar/location/LocationProviderTest.java29
-rw-r--r--test/org/traccar/protocol/CityeasyProtocolDecoderTest.java2
-rw-r--r--test/org/traccar/protocol/Gl200ProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolDecoderTest.java2
9 files changed, 33 insertions, 68 deletions
diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java
index ea06a490d..11b4163a1 100644
--- a/test/org/traccar/FilterHandlerTest.java
+++ b/test/org/traccar/FilterHandlerTest.java
@@ -22,11 +22,11 @@ public class FilterHandlerTest extends BaseTest {
filtingHandler.setFilterInvalid(true);
filtingHandler.setFilterZero(true);
filtingHandler.setFilterDuplicate(true);
- filtingHandler.setFilterFuture(true);
filtingHandler.setFilterApproximate(true);
filtingHandler.setFilterStatic(true);
filtingHandler.setFilterDistance(10);
filtingHandler.setFilterLimit(10);
+ filtingHandler.setFilterFuture(5 * 60);
}
@After
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index 93f3150c7..43be1a59e 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -7,6 +7,7 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.junit.Assert;
import org.traccar.database.IdentityManager;
+import org.traccar.model.CellTower;
import org.traccar.model.Command;
import org.traccar.model.Device;
import org.traccar.model.Position;
@@ -174,16 +175,13 @@ public class ProtocolTest extends BaseTest {
Assert.assertFalse("no attributes", attributes.isEmpty());
}
- if (attributes.containsKey(Position.KEY_LAC) || attributes.containsKey(Position.KEY_CID)) {
- checkInteger(attributes.get(Position.KEY_LAC), 1, 65535);
- checkInteger(attributes.get(Position.KEY_CID), 0, 268435455);
- }
-
- if (attributes.containsKey(Position.KEY_MCC) || attributes.containsKey(Position.KEY_MNC)) {
- checkInteger(attributes.get(Position.KEY_MCC), 100, 999);
- checkInteger(attributes.get(Position.KEY_MNC), 0, 999);
- Assert.assertTrue("value missing", attributes.containsKey(Position.KEY_LAC));
- Assert.assertTrue("value missing", attributes.containsKey(Position.KEY_CID));
+ if (position.getNetwork() != null) {
+ for (CellTower cellTower : position.getNetwork().getCellTowers()) {
+ checkInteger(cellTower.getMobileCountryCode(), 0, 999);
+ checkInteger(cellTower.getMobileNetworkCode(), 0, 999);
+ checkInteger(cellTower.getLocationAreaCode(), 1, 65535);
+ checkInteger(cellTower.getCellId(), 0, 268435455);
+ }
}
}
diff --git a/test/org/traccar/location/CellInfoTest.java b/test/org/traccar/location/CellInfoTest.java
deleted file mode 100644
index e78ce51fb..000000000
--- a/test/org/traccar/location/CellInfoTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.traccar.location;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CellInfoTest {
-
- @Test
- public void testToString() {
-
- CellInfo info = new CellInfo();
- info.addCell(0, 0, 1000, 2000);
- info.addCell(400, 1, 3000, 4000);
-
- Assert.assertEquals("[{\"lac\":1000,\"cid\":2000},{\"mcc\":400,\"mnc\":1,\"lac\":3000,\"cid\":4000}]", info.toString());
-
- }
-
- @Test
- public void testFromString() {
-
- CellInfo info = CellInfo.fromString("[{\"lac\":1000,\"cid\":2000}]");
-
- Assert.assertEquals(1, info.getCells().size());
-
- CellInfo.Cell cell = info.getCells().get(0);
-
- Assert.assertEquals(0, cell.getMcc());
- Assert.assertEquals(0, cell.getMnc());
- Assert.assertEquals(1000, cell.getLac());
- Assert.assertEquals(2000, cell.getCid());
- Assert.assertEquals(0, cell.getSignal());
-
- }
-
-}
diff --git a/test/org/traccar/location/LocationProviderTest.java b/test/org/traccar/location/LocationProviderTest.java
index 910f9e9ea..aec210c84 100644
--- a/test/org/traccar/location/LocationProviderTest.java
+++ b/test/org/traccar/location/LocationProviderTest.java
@@ -2,34 +2,29 @@ package org.traccar.location;
import org.junit.Assert;
import org.junit.Test;
-import org.traccar.model.Position;
+import org.traccar.BaseTest;
+import org.traccar.model.CellTower;
+import org.traccar.model.Network;
-import java.util.HashMap;
-import java.util.Map;
-
-public class LocationProviderTest {
+public class LocationProviderTest extends BaseTest {
private boolean enable = false;
@Test
- public void test() {
+ public void test() throws Exception {
if (enable) {
- testOpenCellId();
+ testGoogleLocationProvider();
}
}
- public void testOpenCellId() {
- OpenCellIdLocationProvider locationProvider = new OpenCellIdLocationProvider("fake");
+ public void testGoogleLocationProvider() throws Exception {
+ GoogleLocationProvider locationProvider = new GoogleLocationProvider("KEY");
- Map<String, Object> attributes = new HashMap<>();
- attributes.put(Position.KEY_MCC, 260);
- attributes.put(Position.KEY_MNC, 2);
- attributes.put(Position.KEY_LAC, 10250);
- attributes.put(Position.KEY_CID, 26511);
+ Network network = new Network(CellTower.from(260, 2, 10250, 26511));
- locationProvider.getLocation(attributes, new LocationProvider.LocationProviderCallback() {
+ locationProvider.getLocation(network, new LocationProvider.LocationProviderCallback() {
@Override
- public void onSuccess(double latitude, double longitude) {
+ public void onSuccess(double latitude, double longitude, double accuracy) {
Assert.assertEquals(60.07254, latitude, 0.00001);
Assert.assertEquals(30.30996, longitude, 0.00001);
}
@@ -39,6 +34,8 @@ public class LocationProviderTest {
Assert.fail();
}
});
+
+ Thread.sleep(Long.MAX_VALUE);
}
}
diff --git a/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java b/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java
index 719703914..e5a571386 100644
--- a/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CityeasyProtocolDecoderTest.java
@@ -11,7 +11,7 @@ public class CityeasyProtocolDecoderTest extends ProtocolTest {
CityeasyProtocolDecoder decoder = new CityeasyProtocolDecoder(new CityeasyProtocol());
- verifyAttributes(decoder, binary(
+ verifyNotNull(decoder, binary(
"545400853575570249020100033b3430342c34352c31303638312c31313632312c33352c31303638312c31313632322c32332c31303638312c32383938332c32332c31303638312c31313632332c32312c31303638312c32333338312c31372c31303638312c32323538332c31372c31303638312c32363434312c31330000000d352e0d0a"));
verifyNothing(decoder, binary(
diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
index c493d5172..7e6287514 100644
--- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class Gl200ProtocolDecoderTest extends ProtocolTest {
Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol());
verifyAttributes(decoder, text(
+ "+RESP:GTINF,210102,A100004D9EF2AE,,41,,8,99,0,17.7,21,3.58,0,1,1,0,0,20161216135038,4,,,,,20161216135038,00AB$"));
+
+ verifyAttributes(decoder, text(
"+RESP:GTSTR,400201,862365030034957,GL500,0,0,2,23.1,5,2,0.2,0,36.0,0.623089,51.582744,20161129174625,0234,0015,03C3,3550,,,,20161129174625,0026$"));
verifyNothing(decoder, text(
diff --git a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
index 93817b575..e110de24b 100644
--- a/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gps103ProtocolDecoderTest.java
@@ -43,13 +43,13 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, text(
"imei:868683020235846,rfid,160202091347,49121185,F,011344.000,A,0447.7273,N,07538.9934,W,0.00,0,,0,0,0.00%,,"));
- verifyAttributes(decoder, text(
+ verifyNotNull(decoder, text(
"imei:359710049075097,help me,,,L,,,113b,,558f,,,,,0,0,,,"));
- verifyAttributes(decoder, text(
+ verifyNotNull(decoder, text(
"imei:359710041100000,tracker,000000000,,L,,,fa8,,c9af,,,,,0,0,0.00%,,"));
- verifyAttributes(decoder, text(
+ verifyNotNull(decoder, text(
"imei:863070016871385,tracker,0000000119,,L,,,0FB6,,CB5D,,,"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 8b6b65b8c..ea9fee0b5 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -22,6 +22,9 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, binary(
"7979000794050000c9b63e0d0a"));
+ verifyNotNull(decoder, binary(
+ "78783b18100c0f1201010195271784005ab63617840002fa47178400ff8f4817840019f3491784005ab54b178400ff8e4c17840019f24cff0002012287c80d0a"));
+
verifyPosition(decoder, binary(
"7878251610051b0f1c34c5022515d504b5dcd20738080902d4022bdf009cba5006640201006759680d0a"));
diff --git a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
index 1875e4ac5..cce2e4c1d 100644
--- a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
@@ -37,7 +37,7 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, text(
"(013612345678BO012061830A2934.0133N10627.2544E040.0080331309.6200000000L000770AD"));
- verifyAttributes(decoder, text(
+ verifyNotNull(decoder, text(
"(088047194605BZ00,510,010,36e6,932c,43,36e6,766b,36,36e6,7668,32"));
verifyAttributes(decoder, text(