aboutsummaryrefslogtreecommitdiff
path: root/test/org
diff options
context:
space:
mode:
authorHans van den Elsen <hans.elsen@esds.nl>2016-03-14 20:49:04 +0100
committerHans van den Elsen <hans.elsen@esds.nl>2016-03-14 20:49:04 +0100
commit7fd1c08dd2f789ddd37ff075a6ebda1645947616 (patch)
tree75b715e6dd70f6be3357e1710c4db6f1f6a1e29e /test/org
parent4606737cc07b736f9c8f98ae680b928c94c082c8 (diff)
parent0a1019b59481b6bf8ee8989feb23cef084b6caf5 (diff)
downloadtrackermap-server-7fd1c08dd2f789ddd37ff075a6ebda1645947616.tar.gz
trackermap-server-7fd1c08dd2f789ddd37ff075a6ebda1645947616.tar.bz2
trackermap-server-7fd1c08dd2f789ddd37ff075a6ebda1645947616.zip
Merge remote-tracking branch 'refs/remotes/tananaev/master'
Diffstat (limited to 'test/org')
-rw-r--r--test/org/traccar/geocode/ReverseGeocoderTest.java48
-rw-r--r--test/org/traccar/protocol/FoxProtocolDecoderTest.java27
-rw-r--r--test/org/traccar/protocol/TramigoProtocolDecoderTest.java23
-rw-r--r--test/org/traccar/protocol/WatchProtocolDecoderTest.java6
4 files changed, 94 insertions, 10 deletions
diff --git a/test/org/traccar/geocode/ReverseGeocoderTest.java b/test/org/traccar/geocode/ReverseGeocoderTest.java
index a572b0456..ada0afbbe 100644
--- a/test/org/traccar/geocode/ReverseGeocoderTest.java
+++ b/test/org/traccar/geocode/ReverseGeocoderTest.java
@@ -8,45 +8,75 @@ public class ReverseGeocoderTest {
private boolean enable = false;
@Test
- public void test() {
+ public void test() throws InterruptedException {
if (enable) {
testGoogle();
- testNominatim();
- testGisgraphy();
}
}
- public void testGoogle() {
+ private String address;
+
+ private synchronized String waitAddress() {
+ try {
+ wait(5000);
+ return address;
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private synchronized void setAddress(String address) {
+ this.address = address;
+ notifyAll();
+ }
+
+ public void testGoogle() throws InterruptedException {
ReverseGeocoder reverseGeocoder = new GoogleReverseGeocoder();
reverseGeocoder.getAddress(new AddressFormat(), 37.4217550, -122.0846330, new ReverseGeocoder.ReverseGeocoderCallback() {
@Override
public void onResult(String address) {
- Assert.assertEquals("1600 Amphitheatre Pkwy, Mountain View, CA, US", address);
+ setAddress(address);
}
});
+ Assert.assertEquals("1600 Amphitheatre Pkwy, Mountain View, CA, US", waitAddress());
}
- public void testNominatim() {
+ public void testNominatim() throws InterruptedException {
ReverseGeocoder reverseGeocoder = new NominatimReverseGeocoder();
reverseGeocoder.getAddress(new AddressFormat(), 40.7337807, -73.9974401, new ReverseGeocoder.ReverseGeocoderCallback() {
@Override
public void onResult(String address) {
- Assert.assertEquals("35 West 9th Street, NYC, New York, US", address);
+ setAddress(address);
}
});
+ Assert.assertEquals("35 West 9th Street, NYC, New York, US", waitAddress());
}
- public void testGisgraphy() {
+ public void testGisgraphy() throws InterruptedException {
ReverseGeocoder reverseGeocoder = new GisgraphyReverseGeocoder();
reverseGeocoder.getAddress(new AddressFormat(), 48.8530000, 2.3400000, new ReverseGeocoder.ReverseGeocoderCallback() {
@Override
public void onResult(String address) {
- Assert.assertEquals("Rue du Jardinet, Paris, FR", address);
+ setAddress(address);
+ }
+ });
+ Assert.assertEquals("Rue du Jardinet, Paris, FR", waitAddress());
+ }
+
+ public void testOpenCage() throws InterruptedException {
+ ReverseGeocoder reverseGeocoder = new OpenCageReverseGeocoder(
+ "http://api.opencagedata.com/geocode/v1", "SECRET", 0);
+
+ reverseGeocoder.getAddress(new AddressFormat(), 34.116302, -118.051519, new ReverseGeocoder.ReverseGeocoderCallback() {
+ @Override
+ public void onResult(String address) {
+ setAddress(address);
}
});
+ Assert.assertEquals("Charleston Road, California, US", waitAddress());
}
}
diff --git a/test/org/traccar/protocol/FoxProtocolDecoderTest.java b/test/org/traccar/protocol/FoxProtocolDecoderTest.java
new file mode 100644
index 000000000..304db1891
--- /dev/null
+++ b/test/org/traccar/protocol/FoxProtocolDecoderTest.java
@@ -0,0 +1,27 @@
+package org.traccar.protocol;
+
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class FoxProtocolDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ FoxProtocolDecoder decoder = new FoxProtocolDecoder(new FoxProtocol());
+
+ verifyPosition(decoder, text(
+ "<fox><gps id=\"90\" data=\"1092,V,010101,000004,0000.0000,N,00000.0000,E,0,0,,1111111111111111 123 0 0 0 0 0 00000000 47664,47664\"/></fox>"));
+
+ verifyPosition(decoder, text(
+ "<fox><gps id=\"90\" data=\"31,V,110316,125952,0000.0000,N,00000.0000,E,0,0,,1111111111111111 123 0 0 0 0 0 00000000 47664,65 60 60 60 60 60 60 60 65 65 55 55 60 60 60 60 60 60 60 60 55 55 60 55 65 60 60 60 60 60 60 55\"/></fox>"));
+
+ verifyPosition(decoder, text(
+ "<fox><gps id=\"90\" data=\"0,V,110316,130154,0000.0000,N,00000.0000,E,0,0,,1111111111111111 123 0 0 0 0 0 00000000 47664,47664 0\"/></fox>"));
+
+ verifyPosition(decoder, text(
+ "<fox><gps id=\"90\" data=\"0,A,110316,131834,4448.8355,N,02028.2021,E,0,217,,1111111111111111 123 0 0 0 0 0 00000000 50020,50020 0\"/></fox>"));
+
+ }
+
+}
diff --git a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
index 9ac02a7ad..a11e69a6a 100644
--- a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
@@ -11,7 +11,28 @@ public class TramigoProtocolDecoderTest extends ProtocolTest {
public void testDecode() throws Exception {
TramigoProtocolDecoder decoder = new TramigoProtocolDecoder(new TramigoProtocol());
-
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000853eb000b8000101fcff032f14665a89e2564176656e7369732053797353657276653a2049676e6974696f6e206f6e2064657465637465642c206d6f76696e672c20302e3135206b6d205357206f66204261626120416e696d61736861756e205374726565742d426f64652054686f6d61732053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383736352c20332e33343735352c2031303a3031204d6172203131202020454f46"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000973eb000b90001012128032f14667794e2564176656e7369732053797353657276653a2049676e6974696f6e206f6e2064657465637465642c2073746f707065642c20302e3134206b6d205357206f66204261626120416e696d61736861756e205374726565742d426f64652054686f6d61732053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383736372c20332e33343737332c2031303a3438204d6172203131202020454f46"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000b73eb000ad000101fdd2032f1466c9cbe2564176656e7369732053797353657276653a2049676e6974696f6e206f6e2064657465637465642c206d6f76696e672c20302e3131206b6d2045206f6620416c68616a69204d6173686120526f616420466f6f746272696467652c20537572756c6572652c204c61676f7320436974792c204e472c20362e35303031342c20332e33353434332c2031343a3434204d6172203131202020454f46"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000883eb000d3000101b223032f1466fc89e2564176656e7369732053797353657276653a2049676e6974696f6e206f66662064657465637465642c2049676e4f6e506572696f643a2030303a30323a34312c2073746f707065642c20302e3039206b6d205345206f66204a696e616475205072696d617279205363686f6f6c20416465204f6e6974696d6572696e2053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383639332c20332e33343636302c2031303a3033204d6172203131202020454f46"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "80009a3eb000d300010109ff032f1466b195e2564176656e7369732053797353657276653a2049676e6974696f6e206f66662064657465637465642c2049676e4f6e506572696f643a2030303a30353a31342c2073746f707065642c20302e3039206b6d205345206f66204a696e616475205072696d617279205363686f6f6c20416465204f6e6974696d6572696e2053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383639312c20332e33343636322c2031303a3533204d6172203131202020454f46"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000bc3eb000ba000101622c032f1466bacce2564176656e7369732053797353657276653a2049676e6974696f6e206f66662064657465637465642c2049676e4f6e506572696f643a2030303a30343a30302c206d6f76696e672c20617420416b6572656c6520526f61642d4f67756e6c616e612044726976652c20537572756c6572652c204c61676f7320436974792c204e472c20362e35303630332c20332e33353232382c2031343a3438204d6172203131202020454f46"));
+
+ verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "80001d3cb000b3000101160f032f1466b475e0564176656e7369732053797353657276653a205374617475732c204750533a203931252c2047534d3a203737252c20475052533a20436f6e6e65637465642c20626174746572793a20313030252c207265706f7274733a2049676e6974696f6e20286f6666292c205374617475732028352c322e302c3732302c3330292c20362e34393239382c20332e33343836352c2031393a3038204d6172203920454f46"));
+
verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"80005408b000af000101b23903677f00c8436d3842616c697365204f6e653a20416c6c756d616765206d61726368652064e974656374e92c20676172e92c20302e3735206b6d20452064652045636f6c65204175746f726f757465206465204b696e73686173612c2056696c6c65206465204b696e73686173612c204b696e73686173612c2043442c202d342e33343130362c2031352e33343931352c2030313a3030204a616e2031202020454f46"));
diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
index b7320098f..89e9a7e77 100644
--- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -10,6 +10,12 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol());
+ verifyPosition(decoder, text(
+ "[3G*4700222306*0077*UD,120316,140610,V,48.779045,N, 9.1574736,E,0.00,0.0,0.0,0,25,83,0,0,00000000,2,255,262,1,21041,9067,121,21041,5981,116"));
+
+ verifyPosition(decoder, text(
+ "[3G*4700222306*011F*UD2,120316,140444,A,48.779045,N, 9.1574736,E,0.57,12.8,0.0,7,28,77,0,0,00000000,2,2,262,1,21041,9067,121,21041,5981,116,5,WG-Superlativ,34:31:c4:c8:a9:22,-67,EasyBox-28E858,18:83:bf:28:e8:f4,-70,MoMaXXg,be:05:43:b7:19:15,-72,MoMaXX2,bc:05:43:b7:19:15,-72,Gastzugang,18:83:bf:28:e8:f5,-72"));
+
verifyNothing(decoder, text(
"[SG*9081000548*0009*LK,0,100"));