aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/BaseTest.java12
-rw-r--r--test/org/traccar/FilterHandlerTest.java68
-rw-r--r--test/org/traccar/ProtocolTest.java32
-rw-r--r--test/org/traccar/database/DataManagerTest.java78
-rw-r--r--test/org/traccar/events/AlertEventHandlerTest.java6
-rw-r--r--test/org/traccar/events/CommandResultEventHandlerTest.java6
-rw-r--r--test/org/traccar/events/IgnitionEventHandlerTest.java4
-rw-r--r--test/org/traccar/events/MotionEventHandlerTest.java108
-rw-r--r--test/org/traccar/events/OverspeedEventHandlerTest.java109
-rw-r--r--test/org/traccar/helper/PatternUtilTest.java4
-rw-r--r--test/org/traccar/protocol/AdmProtocolDecoderTest.java2
-rw-r--r--test/org/traccar/protocol/AdmProtocolEncoderTest.java43
-rw-r--r--test/org/traccar/protocol/AplicomProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/CalAmpProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/CarscopProtocolDecoderTest.java9
-rw-r--r--test/org/traccar/protocol/CastelProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/CityeasyProtocolEncoderTest.java4
-rw-r--r--test/org/traccar/protocol/CradlepointProtocolDecoderTest.java18
-rw-r--r--test/org/traccar/protocol/EelinkProtocolDecoderTest.java26
-rw-r--r--test/org/traccar/protocol/EskyFrameDecoderTest.java28
-rw-r--r--test/org/traccar/protocol/EskyProtocolDecoderTest.java24
-rw-r--r--test/org/traccar/protocol/GenxProtocolDecoderTest.java26
-rw-r--r--test/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java36
-rw-r--r--test/org/traccar/protocol/Gl200FrameDecoderTest.java28
-rw-r--r--test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java (renamed from test/org/traccar/protocol/Gl200ProtocolDecoderTest.java)206
-rw-r--r--test/org/traccar/protocol/Gt06FrameDecoderTest.java16
-rw-r--r--test/org/traccar/protocol/Gt06ProtocolDecoderTest.java39
-rw-r--r--test/org/traccar/protocol/H02ProtocolDecoderTest.java39
-rw-r--r--test/org/traccar/protocol/Jt600ProtocolDecoderTest.java20
-rw-r--r--test/org/traccar/protocol/Jt600ProtocolEncoderTest.java2
-rw-r--r--test/org/traccar/protocol/MegastekFrameDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/MegastekProtocolDecoderTest.java9
-rw-r--r--test/org/traccar/protocol/MeiligaoProtocolEncoderTest.java4
-rw-r--r--test/org/traccar/protocol/MeitrackProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java6
-rw-r--r--test/org/traccar/protocol/OsmAndProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/Pt502ProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/Pt502ProtocolEncoderTest.java2
-rw-r--r--test/org/traccar/protocol/SuntechProtocolDecoderTest.java32
-rw-r--r--test/org/traccar/protocol/TaipProtocolDecoderTest.java12
-rw-r--r--test/org/traccar/protocol/TelicFrameDecoderTest.java14
-rw-r--r--test/org/traccar/protocol/TelicProtocolDecoderTest.java12
-rw-r--r--test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java30
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/TlvProtocolDecoderTest.java24
-rw-r--r--test/org/traccar/protocol/TramigoProtocolDecoderTest.java12
-rw-r--r--test/org/traccar/protocol/TrvProtocolDecoderTest.java9
-rw-r--r--test/org/traccar/protocol/TzoneProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/Vt200FrameDecoderTest.java4
-rw-r--r--test/org/traccar/protocol/Vt200ProtocolDecoderTest.java36
-rw-r--r--test/org/traccar/protocol/WatchProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/WatchProtocolEncoderTest.java15
-rw-r--r--test/org/traccar/protocol/XexunProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java5
-rw-r--r--test/org/traccar/reports/ReportUtilsTest.java214
56 files changed, 1270 insertions, 220 deletions
diff --git a/test/org/traccar/BaseTest.java b/test/org/traccar/BaseTest.java
index 6af8610cd..4b9ee5451 100644
--- a/test/org/traccar/BaseTest.java
+++ b/test/org/traccar/BaseTest.java
@@ -18,12 +18,12 @@ public class BaseTest {
}
@Override
- public Device getDeviceById(long id) {
+ public Device getById(long id) {
return createDevice();
}
@Override
- public Device getDeviceByUniqueId(String uniqueId) {
+ public Device getByUniqueId(String uniqueId) {
return createDevice();
}
@@ -40,25 +40,25 @@ public class BaseTest {
@Override
public boolean lookupAttributeBoolean(
long deviceId, String attributeName, boolean defaultValue, boolean lookupConfig) {
- return false;
+ return defaultValue;
}
@Override
public String lookupAttributeString(
long deviceId, String attributeName, String defaultValue, boolean lookupConfig) {
- return null;
+ return defaultValue;
}
@Override
public int lookupAttributeInteger(
long deviceId, String attributeName, int defaultValue, boolean lookupConfig) {
- return 0;
+ return defaultValue;
}
@Override
public long lookupAttributeLong(
long deviceId, String attributeName, long defaultValue, boolean lookupConfig) {
- return 0;
+ return defaultValue;
}
});
diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java
index 02023096e..7ebab3af5 100644
--- a/test/org/traccar/FilterHandlerTest.java
+++ b/test/org/traccar/FilterHandlerTest.java
@@ -3,6 +3,8 @@ package org.traccar;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.traccar.database.IdentityManager;
+import org.traccar.model.Device;
import org.traccar.model.Position;
import java.util.Date;
@@ -10,7 +12,65 @@ import java.util.Date;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-public class FilterHandlerTest extends BaseTest {
+public class FilterHandlerTest {
+
+ static {
+ Context.init(new IdentityManager() {
+
+ private Device createDevice() {
+ Device device = new Device();
+ device.setId(1);
+ device.setName("test");
+ device.setUniqueId("123456789012345");
+ return device;
+ }
+
+ @Override
+ public Device getById(long id) {
+ return createDevice();
+ }
+
+ @Override
+ public Device getByUniqueId(String uniqueId) {
+ return createDevice();
+ }
+
+ @Override
+ public Position getLastPosition(long deviceId) {
+ return null;
+ }
+
+ @Override
+ public boolean isLatestPosition(Position position) {
+ return true;
+ }
+
+ @Override
+ public boolean lookupAttributeBoolean(
+ long deviceId, String attributeName, boolean defaultValue, boolean lookupConfig) {
+ return defaultValue;
+ }
+
+ @Override
+ public String lookupAttributeString(
+ long deviceId, String attributeName, String defaultValue, boolean lookupConfig) {
+ return "alarm,result";
+ }
+
+ @Override
+ public int lookupAttributeInteger(
+ long deviceId, String attributeName, int defaultValue, boolean lookupConfig) {
+ return defaultValue;
+ }
+
+ @Override
+ public long lookupAttributeLong(
+ long deviceId, String attributeName, long defaultValue, boolean lookupConfig) {
+ return defaultValue;
+ }
+
+ });
+ }
private FilterHandler filtingHandler;
private FilterHandler passingHandler;
@@ -27,7 +87,7 @@ public class FilterHandlerTest extends BaseTest {
filtingHandler.setFilterStatic(true);
filtingHandler.setFilterDistance(10);
filtingHandler.setFilterMaxSpeed(500);
- filtingHandler.setFilterLimit(10);
+ filtingHandler.setSkipLimit(10);
}
@After
@@ -75,6 +135,10 @@ public class FilterHandlerTest extends BaseTest {
assertNull(filtingHandler.decode(null, null, position));
assertNotNull(passingHandler.decode(null, null, position));
+
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
+ filtingHandler.setSkipAttributes(true);
+ assertNotNull(filtingHandler.decode(null, null, position));
}
}
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index 3b801c6eb..1daefabd6 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -82,6 +82,10 @@ public class ProtocolTest extends BaseTest {
Assert.assertNotNull(decoder.decode(null, null, object));
}
+ protected void verifyNull(Object object) throws Exception {
+ Assert.assertNull(object);
+ }
+
protected void verifyNull(BaseProtocolDecoder decoder, Object object) throws Exception {
Assert.assertNull(decoder.decode(null, null, object));
}
@@ -118,7 +122,7 @@ public class ProtocolTest extends BaseTest {
Assert.assertNotNull("list is null", decodedObject);
Assert.assertTrue("not a list", decodedObject instanceof List);
- Assert.assertFalse("list if empty", ((List) decodedObject).isEmpty());
+ Assert.assertFalse("list is empty", ((List) decodedObject).isEmpty());
for (Object item : (List) decodedObject) {
verifyDecodedPosition(item, checkLocation, false, expected);
@@ -237,6 +241,10 @@ public class ProtocolTest extends BaseTest {
Assert.assertTrue(attributes.get(Position.KEY_CHARGE) instanceof Boolean);
}
+ if (attributes.containsKey(Position.KEY_IGNITION)) {
+ Assert.assertTrue(attributes.get(Position.KEY_IGNITION) instanceof Boolean);
+ }
+
if (attributes.containsKey(Position.KEY_MOTION)) {
Assert.assertTrue(attributes.get(Position.KEY_MOTION) instanceof Boolean);
}
@@ -245,6 +253,18 @@ public class ProtocolTest extends BaseTest {
Assert.assertTrue(attributes.get(Position.KEY_ARCHIVE) instanceof Boolean);
}
+ if (attributes.containsKey(Position.KEY_DRIVER_UNIQUE_ID)) {
+ Assert.assertTrue(attributes.get(Position.KEY_DRIVER_UNIQUE_ID) instanceof String);
+ }
+
+ if (attributes.containsKey(Position.KEY_STEPS)) {
+ Assert.assertTrue(attributes.get(Position.KEY_STEPS) instanceof Number);
+ }
+
+ if (attributes.containsKey(Position.KEY_ROAMING)) {
+ Assert.assertTrue(attributes.get(Position.KEY_ROAMING) instanceof Boolean);
+ }
+
if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) {
for (CellTower cellTower : position.getNetwork().getCellTowers()) {
checkInteger(cellTower.getMobileCountryCode(), 0, 999);
@@ -266,14 +286,14 @@ public class ProtocolTest extends BaseTest {
protected void verifyCommand(
BaseProtocolEncoder encoder, Command command, ChannelBuffer expected) throws Exception {
- verifyDecodedCommand(encoder.encodeCommand(command), expected);
+ verifyFrame(expected, encoder.encodeCommand(command));
}
- private void verifyDecodedCommand(Object decodedObject, ChannelBuffer expected) {
+ protected void verifyFrame(ChannelBuffer expected, Object object) {
- Assert.assertNotNull("command is null", decodedObject);
- Assert.assertTrue("not a buffer", decodedObject instanceof ChannelBuffer);
- Assert.assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) decodedObject));
+ Assert.assertNotNull("buffer is null", object);
+ Assert.assertTrue("not a buffer", object instanceof ChannelBuffer);
+ Assert.assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) object));
}
diff --git a/test/org/traccar/database/DataManagerTest.java b/test/org/traccar/database/DataManagerTest.java
new file mode 100644
index 000000000..3d6f5201e
--- /dev/null
+++ b/test/org/traccar/database/DataManagerTest.java
@@ -0,0 +1,78 @@
+package org.traccar.database;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.traccar.model.Attribute;
+import org.traccar.model.Device;
+import org.traccar.model.Driver;
+import org.traccar.model.Geofence;
+import org.traccar.model.Group;
+import org.traccar.model.ManagedUser;
+import org.traccar.model.Position;
+import org.traccar.model.User;
+
+public class DataManagerTest {
+
+ @Test
+ public void constructObjectQuery() {
+ Assert.assertEquals("SELECT * FROM users",
+ DataManager.constructObjectQuery(DataManager.ACTION_SELECT_ALL, User.class, false));
+ Assert.assertEquals("DELETE FROM groups WHERE id = :id",
+ DataManager.constructObjectQuery(DataManager.ACTION_DELETE, Group.class, false));
+ Assert.assertEquals("SELECT * FROM positions WHERE id = :id",
+ DataManager.constructObjectQuery(DataManager.ACTION_SELECT, Position.class, false));
+
+ String insertDevice = DataManager.constructObjectQuery(DataManager.ACTION_INSERT, Device.class, false);
+ Assert.assertFalse(insertDevice.contains("class"));
+ Assert.assertFalse(insertDevice.contains("id"));
+ Assert.assertFalse(insertDevice.contains("status"));
+ Assert.assertFalse(insertDevice.contains("geofenceIds"));
+
+ String updateDeviceStatus = DataManager.constructObjectQuery("update", Device.class, true);
+ Assert.assertTrue(updateDeviceStatus.contains("lastUpdate"));
+
+ String updateUser = DataManager.constructObjectQuery(DataManager.ACTION_UPDATE, User.class, false);
+ Assert.assertFalse(updateUser.contains("class"));
+ Assert.assertFalse(updateUser.contains("password"));
+ Assert.assertFalse(updateUser.contains("salt"));
+
+ String updateUserPassword = DataManager.constructObjectQuery(DataManager.ACTION_UPDATE, User.class, true);
+ Assert.assertFalse(updateUserPassword.contains("name"));
+ Assert.assertTrue(updateUserPassword.contains("hashedPassword"));
+ Assert.assertTrue(updateUserPassword.contains("salt"));
+
+ String insertPosition = DataManager.constructObjectQuery(DataManager.ACTION_INSERT, Position.class, false);
+ Assert.assertFalse(insertPosition.contains("type"));
+ Assert.assertFalse(insertPosition.contains("outdated"));
+
+ }
+
+ @Test
+ public void constructPermissionsQuery() {
+ Assert.assertEquals("SELECT userId, deviceId FROM user_device",
+ DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, User.class, Device.class));
+
+ Assert.assertEquals("SELECT userId, managedUserId FROM user_user",
+ DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, User.class, ManagedUser.class));
+
+ Assert.assertEquals("SELECT deviceId, driverId FROM device_driver",
+ DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, Device.class, Driver.class));
+
+ Assert.assertEquals("SELECT groupId, geofenceId FROM group_geofence",
+ DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, Group.class, Geofence.class));
+
+ Assert.assertEquals("INSERT INTO user_device (userId, deviceId) VALUES (:userId, :deviceId)",
+ DataManager.constructPermissionQuery(DataManager.ACTION_INSERT, User.class, Device.class));
+
+ Assert.assertEquals("DELETE FROM user_user WHERE userId = :userId AND managedUserId = :managedUserId",
+ DataManager.constructPermissionQuery(DataManager.ACTION_DELETE, User.class, ManagedUser.class));
+
+ Assert.assertEquals("INSERT INTO device_geofence (deviceId, geofenceId) VALUES (:deviceId, :geofenceId)",
+ DataManager.constructPermissionQuery(DataManager.ACTION_INSERT, Device.class, Geofence.class));
+
+ Assert.assertEquals("DELETE FROM group_attribute WHERE groupId = :groupId AND attributeId = :attributeId",
+ DataManager.constructPermissionQuery(DataManager.ACTION_DELETE, Group.class, Attribute.class));
+
+ }
+
+}
diff --git a/test/org/traccar/events/AlertEventHandlerTest.java b/test/org/traccar/events/AlertEventHandlerTest.java
index 77128f066..4e11398e1 100644
--- a/test/org/traccar/events/AlertEventHandlerTest.java
+++ b/test/org/traccar/events/AlertEventHandlerTest.java
@@ -3,7 +3,7 @@ package org.traccar.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.util.Collection;
+import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
@@ -19,9 +19,9 @@ public class AlertEventHandlerTest extends BaseTest {
Position position = new Position();
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
- Collection<Event> events = alertEventHandler.analyzePosition(position);
+ Map<Event, Position> events = alertEventHandler.analyzePosition(position);
assertNotNull(events);
- Event event = (Event) events.toArray()[0];
+ Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_ALARM, event.getType());
}
diff --git a/test/org/traccar/events/CommandResultEventHandlerTest.java b/test/org/traccar/events/CommandResultEventHandlerTest.java
index f028e86ee..602108d1a 100644
--- a/test/org/traccar/events/CommandResultEventHandlerTest.java
+++ b/test/org/traccar/events/CommandResultEventHandlerTest.java
@@ -3,7 +3,7 @@ package org.traccar.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.util.Collection;
+import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
@@ -19,9 +19,9 @@ public class CommandResultEventHandlerTest extends BaseTest {
Position position = new Position();
position.set(Position.KEY_RESULT, "Test Result");
- Collection<Event> events = commandResultEventHandler.analyzePosition(position);
+ Map<Event, Position> events = commandResultEventHandler.analyzePosition(position);
assertNotNull(events);
- Event event = (Event) events.toArray()[0];
+ Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_COMMAND_RESULT, event.getType());
}
diff --git a/test/org/traccar/events/IgnitionEventHandlerTest.java b/test/org/traccar/events/IgnitionEventHandlerTest.java
index d6c348c77..7c4ac21b9 100644
--- a/test/org/traccar/events/IgnitionEventHandlerTest.java
+++ b/test/org/traccar/events/IgnitionEventHandlerTest.java
@@ -2,7 +2,7 @@ package org.traccar.events;
import static org.junit.Assert.assertEquals;
-import java.util.Collection;
+import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
@@ -19,7 +19,7 @@ public class IgnitionEventHandlerTest extends BaseTest {
Position position = new Position();
position.set(Position.KEY_IGNITION, true);
position.setValid(true);
- Collection<Event> events = ignitionEventHandler.analyzePosition(position);
+ Map<Event, Position> events = ignitionEventHandler.analyzePosition(position);
assertEquals(events, null);
}
diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java
index f05ef54d5..3fc63adf0 100644
--- a/test/org/traccar/events/MotionEventHandlerTest.java
+++ b/test/org/traccar/events/MotionEventHandlerTest.java
@@ -1,29 +1,119 @@
package org.traccar.events;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import java.util.Collection;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.TimeZone;
import org.junit.Test;
import org.traccar.BaseTest;
+import org.traccar.model.DeviceState;
import org.traccar.model.Event;
import org.traccar.model.Position;
+import org.traccar.reports.model.TripsConfig;
public class MotionEventHandlerTest extends BaseTest {
-
+
+ private Date date(String time) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return dateFormat.parse(time);
+ }
+
@Test
- public void testMotionEventHandler() throws Exception {
-
- MotionEventHandler motionEventHandler = new MotionEventHandler();
-
+ public void testMotionWithPosition() throws Exception {
+ MotionEventHandler motionEventHandler = new MotionEventHandler(
+ new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01));
+
Position position = new Position();
+ position.setTime(date("2017-01-01 00:00:00"));
position.set(Position.KEY_MOTION, true);
- position.setValid(true);
- Collection<Event> events = motionEventHandler.analyzePosition(position);
+ position.set(Position.KEY_TOTAL_DISTANCE, 0);
+ DeviceState deviceState = new DeviceState();
+ deviceState.setMotionState(false);
+ deviceState.setMotionPosition(position);
+ Position nextPosition = new Position();
+
+ nextPosition.setTime(date("2017-01-01 00:02:00"));
+ nextPosition.set(Position.KEY_MOTION, true);
+ nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200);
+
+ Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState, nextPosition);
+ assertNull(events);
+
+ nextPosition.set(Position.KEY_TOTAL_DISTANCE, 600);
+ events = motionEventHandler.updateMotionState(deviceState, nextPosition);
assertNotNull(events);
- Event event = (Event) events.toArray()[0];
+ Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_DEVICE_MOVING, event.getType());
+ assertTrue(deviceState.getMotionState());
+ assertNull(deviceState.getMotionPosition());
+
+ deviceState.setMotionState(false);
+ deviceState.setMotionPosition(position);
+ nextPosition.setTime(date("2017-01-01 00:06:00"));
+ nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200);
+ events = motionEventHandler.updateMotionState(deviceState, nextPosition);
+ assertNotNull(event);
+ event = events.keySet().iterator().next();
+ assertEquals(Event.TYPE_DEVICE_MOVING, event.getType());
+ assertTrue(deviceState.getMotionState());
+ assertNull(deviceState.getMotionPosition());
+ }
+
+ @Test
+ public void testMotionWithStatus() throws Exception {
+ MotionEventHandler motionEventHandler = new MotionEventHandler(
+ new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01));
+
+ Position position = new Position();
+ position.setTime(new Date(System.currentTimeMillis() - 360000));
+ position.set(Position.KEY_MOTION, true);
+ DeviceState deviceState = new DeviceState();
+ deviceState.setMotionState(false);
+ deviceState.setMotionPosition(position);
+
+ Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState);
+
+ assertNotNull(events);
+ Event event = events.keySet().iterator().next();
+ assertEquals(Event.TYPE_DEVICE_MOVING, event.getType());
+ assertTrue(deviceState.getMotionState());
+ assertNull(deviceState.getMotionPosition());
+ }
+
+ @Test
+ public void testStopWithPositionIgnition() throws Exception {
+ MotionEventHandler motionEventHandler = new MotionEventHandler(
+ new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true, false, 0.01));
+
+ Position position = new Position();
+ position.setTime(date("2017-01-01 00:00:00"));
+ position.set(Position.KEY_MOTION, false);
+ position.set(Position.KEY_IGNITION, true);
+ DeviceState deviceState = new DeviceState();
+ deviceState.setMotionState(true);
+ deviceState.setMotionPosition(position);
+
+ Position nextPosition = new Position();
+ nextPosition.setTime(date("2017-01-01 00:02:00"));
+ nextPosition.set(Position.KEY_MOTION, false);
+ nextPosition.set(Position.KEY_IGNITION, false);
+
+ Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState, nextPosition);
+ assertNotNull(events);
+ Event event = events.keySet().iterator().next();
+ assertEquals(Event.TYPE_DEVICE_STOPPED, event.getType());
+ assertFalse(deviceState.getMotionState());
+ assertNull(deviceState.getMotionPosition());
}
}
diff --git a/test/org/traccar/events/OverspeedEventHandlerTest.java b/test/org/traccar/events/OverspeedEventHandlerTest.java
new file mode 100644
index 000000000..d38367cd9
--- /dev/null
+++ b/test/org/traccar/events/OverspeedEventHandlerTest.java
@@ -0,0 +1,109 @@
+package org.traccar.events;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.junit.Test;
+import org.traccar.BaseTest;
+import org.traccar.model.DeviceState;
+import org.traccar.model.Event;
+import org.traccar.model.Position;
+
+public class OverspeedEventHandlerTest extends BaseTest {
+
+ private Date date(String time) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return dateFormat.parse(time);
+ }
+
+ private void testOverspeedWithPosition(boolean notRepeat) throws Exception {
+ OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat);
+
+ Position position = new Position();
+ position.setTime(date("2017-01-01 00:00:00"));
+ position.setSpeed(50);
+ DeviceState deviceState = new DeviceState();
+ deviceState.setOverspeedState(false);
+
+ Map<Event, Position> events = overspeedEventHandler.updateOverspeedState(deviceState, position, 40);
+ assertNull(events);
+ assertFalse(deviceState.getOverspeedState());
+ assertEquals(position, deviceState.getOverspeedPosition());
+
+ Position nextPosition = new Position();
+ nextPosition.setTime(date("2017-01-01 00:00:10"));
+ nextPosition.setSpeed(55);
+
+ events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40);
+ assertNull(events);
+
+ nextPosition.setTime(date("2017-01-01 00:00:20"));
+
+ events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40);
+ assertNotNull(events);
+ Event event = events.keySet().iterator().next();
+ assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType());
+ assertEquals(50, event.getDouble("speed"), 0.1);
+ assertEquals(40, event.getDouble(OverspeedEventHandler.ATTRIBUTE_SPEED_LIMIT), 0.1);
+
+ assertEquals(notRepeat, deviceState.getOverspeedState());
+ assertNull(deviceState.getOverspeedPosition());
+
+ nextPosition.setTime(date("2017-01-01 00:00:30"));
+ events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40);
+ assertNull(events);
+ assertEquals(notRepeat, deviceState.getOverspeedState());
+
+ if (notRepeat) {
+ assertNull(deviceState.getOverspeedPosition());
+ } else {
+ assertNotNull(deviceState.getOverspeedPosition());
+ }
+
+ nextPosition.setTime(date("2017-01-01 00:00:40"));
+ nextPosition.setSpeed(30);
+
+ events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40);
+ assertNull(events);
+ assertFalse(deviceState.getOverspeedState());
+ assertNull(deviceState.getOverspeedPosition());
+ }
+
+ private void testOverspeedWithStatus(boolean notRepeat) throws Exception {
+ OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat);
+
+ Position position = new Position();
+ position.setTime(new Date(System.currentTimeMillis() - 30000));
+ position.setSpeed(50);
+ DeviceState deviceState = new DeviceState();
+ deviceState.setOverspeedState(false);
+ deviceState.setOverspeedPosition(position);
+
+ Map<Event, Position> events = overspeedEventHandler.updateOverspeedState(deviceState, 40);
+
+ assertNotNull(events);
+ Event event = events.keySet().iterator().next();
+ assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType());
+ assertEquals(notRepeat, deviceState.getOverspeedState());
+ }
+
+ @Test
+ public void testOverspeedEventHandler() throws Exception {
+ testOverspeedWithPosition(false);
+ testOverspeedWithPosition(true);
+
+ testOverspeedWithStatus(false);
+ testOverspeedWithStatus(true);
+ }
+
+}
diff --git a/test/org/traccar/helper/PatternUtilTest.java b/test/org/traccar/helper/PatternUtilTest.java
index b6b05e88c..77660078a 100644
--- a/test/org/traccar/helper/PatternUtilTest.java
+++ b/test/org/traccar/helper/PatternUtilTest.java
@@ -1,11 +1,13 @@
package org.traccar.helper;
+import org.junit.Ignore;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class PatternUtilTest {
-
+
+ @Ignore
@Test
public void testCheckPattern() {
diff --git a/test/org/traccar/protocol/AdmProtocolDecoderTest.java b/test/org/traccar/protocol/AdmProtocolDecoderTest.java
index 4299001c3..9a7f91d26 100644
--- a/test/org/traccar/protocol/AdmProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/AdmProtocolDecoderTest.java
@@ -30,6 +30,8 @@ public class AdmProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"01002200333508202000000000000000007F0D9F030000000000E39A1056E24A8210"));
+ verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "01008449443d3120536f66743d30783531204750533d313036382054696d653d30383a35393a32302031302e30392e31372056616c3d30204c61743d36312e36373738204c6f6e3d35302e3832343520563d3020536174436e743d342b3720537461743d30783030313020496e5f616c61726d3d30783030000000000000000000000000"));
}
}
diff --git a/test/org/traccar/protocol/AdmProtocolEncoderTest.java b/test/org/traccar/protocol/AdmProtocolEncoderTest.java
new file mode 100644
index 000000000..6d2452e26
--- /dev/null
+++ b/test/org/traccar/protocol/AdmProtocolEncoderTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 Anatoliy Golubev (darth.naihil@gmail.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar.protocol;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+import org.traccar.model.Command;
+
+public class AdmProtocolEncoderTest extends ProtocolTest {
+
+ @Test
+ public void testEncode() throws Exception {
+
+ AdmProtocolEncoder encoder = new AdmProtocolEncoder();
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_GET_DEVICE_STATUS);
+ Assert.assertEquals("STATUS\r\n", encoder.encodeCommand(command));
+
+ command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_CUSTOM);
+ command.set(Command.KEY_DATA, "INPUT 0");
+ Assert.assertEquals("INPUT 0\r\n", encoder.encodeCommand(command));
+ }
+
+}
diff --git a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java
index 3c71e86b3..862cff055 100644
--- a/test/org/traccar/protocol/AplicomProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/AplicomProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class AplicomProtocolDecoderTest extends ProtocolTest {
AplicomProtocolDecoder decoder = new AplicomProtocolDecoder(new AplicomProtocol());
verifyAttributes(decoder, binary(
+ "44c30144f667c4316500e903ffdfbc00f059aebeb659aebeb302e3f5860065fe32120000ae0000000e47000000000000000000000000000127cd0000014c00000000000000ff010a002900000000000000014542016d0001010090070e140144f667c4316559ae620402e3f7f300660714c0010d15ff0f3332373937313100000000000000000000002a01010737341d331fffcf0103020b8601060c0001a5860001a58600000000010b1001ca01ca7d007d007c7cffffffffffff010a240000ffff0000000100010001ffff0000ffffffffffffffffffffffffffff00000002ffff010c06fec6febffeec"));
+
+ verifyAttributes(decoder, binary(
+ "45c20144f667c06ff9005d0161ef17000104596da2dc4b10c0c01d99020d6c04004cba7a010d44463030303235333731363238303030000000000000000000000000000000000000000000000000000001010d44463030303235333731363238303030000000000000031c"));
+
+ verifyAttributes(decoder, binary(
"45c20144f667c07287008c01ffff6d01000059368963d0340a0616207d7f4b10c0c019e6000039d7000039d71f40ffff5001574442393036363035533132333435363700014142432d33343520202020202000011231303331373139343039303030303031000000000000000000000000000000000000000000000000000001011231303331373139343039303030303031000000000000005a"));
verifyAttributes(decoder, binary(
diff --git a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
index bf0fcf41c..ecbef341d 100644
--- a/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CalAmpProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class CalAmpProtocolDecoderTest extends ProtocolTest {
CalAmpProtocolDecoder decoder = new CalAmpProtocolDecoder(new CalAmpProtocol());
verifyPosition(decoder, binary(
+ "83051633033459010101028afd59ae7c1459ae7c140b06bbce2c01520e0000d916000001b900450900005affa50f091f00260d040000000f24000001b90000000000003714"));
+
+ verifyPosition(decoder, binary(
"83092701131797081078220107010200dc583d4d3f583d4d3f19c70502cd1d512d00005f180000008500ec0800101eff980f090100313102000000000000000000"));
verifyPosition(decoder, binary(
diff --git a/test/org/traccar/protocol/CarscopProtocolDecoderTest.java b/test/org/traccar/protocol/CarscopProtocolDecoderTest.java
index da3ac510f..7b6f2f28d 100644
--- a/test/org/traccar/protocol/CarscopProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CarscopProtocolDecoderTest.java
@@ -11,6 +11,15 @@ public class CarscopProtocolDecoderTest extends ProtocolTest {
CarscopProtocolDecoder decoder = new CarscopProtocolDecoder(new CarscopProtocol());
verifyNull(decoder, text(
+ "*170821223045UB00HSO"));
+
+ verifyPosition(decoder, text(
+ "*170821223121UB05ORANGE000731512061825V0000.0000N00000.0000E000.0040331309.62"));
+
+ verifyPosition(decoder, text(
+ "*170724163029UB05ORANGE000000010061825V0000.0000N00000.0000E000.0040331309.62"));
+
+ verifyNull(decoder, text(
"*160618233129UB00HSO"));
verifyNull(decoder, text(
diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java
index bbc5f1f37..bdf69e1af 100644
--- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java
@@ -12,6 +12,12 @@ public class CastelProtocolDecoderTest extends ProtocolTest {
CastelProtocolDecoder decoder = new CastelProtocolDecoder(new CastelProtocol());
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "40408200033231334c32303137303031313039000000000000100136477b5964477b590400000000000000dc410f000000000204000709207910008304011c07110e110dd41a160714a95a0f00001e058c4944442d3231334c2056312e312e3120323031372d30352d3038004944442d3231334c2056312e312e300000006da10d0a"));
+
+ verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "40408200033231334c323031373030303131370000000000001001000c6759a10d67590a9e1200000000000e3e0000000000020000000e4e791c000004010d0711060515083017086cd1181f000040067d4944442d3231334c2056312e312e3120323031372d30352d3038004944442d3231334c2056312e312e3000000066e30d0a"));
+
verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"404043000432313345503230313630303035383500000000004006a2021d5810031d58ae940400da050000f6040000070000000400076401680000000001001bd20d0a"));
diff --git a/test/org/traccar/protocol/CityeasyProtocolEncoderTest.java b/test/org/traccar/protocol/CityeasyProtocolEncoderTest.java
index 96b3c2b74..7c03b7d5b 100644
--- a/test/org/traccar/protocol/CityeasyProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/CityeasyProtocolEncoderTest.java
@@ -10,11 +10,11 @@ public class CityeasyProtocolEncoderTest extends ProtocolTest {
public void testEncode() throws Exception {
CityeasyProtocolEncoder encoder = new CityeasyProtocolEncoder();
-
+
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_SET_TIMEZONE);
- command.set(Command.KEY_TIMEZONE, 6 * 3600);
+ command.set(Command.KEY_TIMEZONE, "GMT+6");
verifyCommand(encoder, command, binary("5353001100080001680000000B60820D0A"));
diff --git a/test/org/traccar/protocol/CradlepointProtocolDecoderTest.java b/test/org/traccar/protocol/CradlepointProtocolDecoderTest.java
index 4f37d3e1e..757298682 100644
--- a/test/org/traccar/protocol/CradlepointProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CradlepointProtocolDecoderTest.java
@@ -11,6 +11,24 @@ public class CradlepointProtocolDecoderTest extends ProtocolTest {
CradlepointProtocolDecoder decoder = new CradlepointProtocolDecoder(new CradlepointProtocol());
verifyPosition(decoder, text(
+ "356526070063940,0,4337.19009,N,11612.34705,W,0.0,277.2,AT&T,,,-79,,-14.0,"));
+
+ verifyPosition(decoder, text(
+ "356526070063940,1,4337.19008,N,11612.34705,W,0.0,277.2,AT&T,,,-79,,-14.0,"));
+
+ verifyPosition(decoder, text(
+ "+14063964266,162658,4333.62404,N,11636.23469,W,0.0,,Verizon Wireless,LTE,-107,-74,-16,,100.68.169.178"));
+
+ verifyPosition(decoder, text(
+ "+12084014675,162658,4337.174385,N,11612.338373,W,0.0,,Verizon,,-71,-44,-11,,"));
+
+ verifyPosition(decoder, text(
+ "353547063544681,170515,3613.25,N,11559.14,W,0.0,,,,,,,,"));
+
+ verifyPosition(decoder, text(
+ "353547060558130,170519,4337.17,N,11612.34,W,0.0,294.7,,,,,,,"));
+
+ verifyPosition(decoder, text(
"+12084014675,162658,4337.174385,N,11612.338373,W,0.0,,Verizon,,-71,-44,-11,,"));
}
diff --git a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
index 8aabf8375..115eef1a3 100644
--- a/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/EelinkProtocolDecoderTest.java
@@ -14,6 +14,30 @@ public class EelinkProtocolDecoderTest extends ProtocolTest {
"676701000c007b03525440717505180104"));
verifyPosition(decoder, binary(
+ "6767120048000559c1829213059a7400008e277d000c000000000800cc00080d2a000034df3cf0b429dd82cad3048910320000000000007b7320d005ba0000000019a000000000000000000000"));
+
+ verifyPosition(decoder, binary(
+ "6767050020213b59c6aecdff41dce70b8b977d00000001fe000a36e30078fe010159c6aecd"));
+
+ verifyPosition(decoder, binary(
+ "676705002102b459ae7388fcd360d7034332b1000000028f000a4f64002eb101010159ae7388"));
+
+ verifyPosition(decoder, binary(
+ "676702001c02b259ae7387fcd360d6034332b2000000028f000a4f64002eb10101"));
+
+ verifyPosition(decoder, binary(
+ "6767050022001F59643640000000000000000000000001CC0000249500142000015964A6C0006E"));
+
+ verifyAttributes(decoder, binary(
+ "67670300040021006E"));
+
+ verifyPosition(decoder, binary(
+ "676705002200255964369D000000000000000000000001CC0000249500142000025964A71D006A"));
+
+ verifyAttributes(decoder, binary(
+ "67670300040028006A"));
+
+ verifyPosition(decoder, binary(
"676712002d066c592cca6803002631a60b22127700240046005c08020d000301af000da0fd12007f11ce05820000001899c0"));
verifyPosition(decoder, binary(
@@ -46,7 +70,7 @@ public class EelinkProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"676701000b001b035418804661834901"));
- verifyNull(decoder, binary(
+ verifyAttributes(decoder, binary(
"6767030004001A0001"));
verifyNull(decoder, binary(
diff --git a/test/org/traccar/protocol/EskyFrameDecoderTest.java b/test/org/traccar/protocol/EskyFrameDecoderTest.java
new file mode 100644
index 000000000..e8902e8be
--- /dev/null
+++ b/test/org/traccar/protocol/EskyFrameDecoderTest.java
@@ -0,0 +1,28 @@
+package org.traccar.protocol;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class EskyFrameDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ EskyFrameDecoder decoder = new EskyFrameDecoder();
+
+ verifyFrame(
+ binary("454c3b313b3836343930363032393139363632363b3137303832323134333432363b"),
+ decoder.decode(null, null, binary("454c3b313b3836343930363032393139363632363b3137303832323134333432363b")));
+
+ verifyFrame(
+ binary("454f3b303b3836343930363032393139363632363b523b302b3137303830383135353335322b302e30303030302b302e30303030302b302e30302b302b3078312b302b302b302b31323333"),
+ decoder.decode(null, null, binary("454f3b303b3836343930363032393139363632363b523b302b3137303830383135353335322b302e30303030302b302e30303030302b302e30302b302b3078312b302b302b302b31323333")));
+
+ verifyFrame(
+ binary("454f3b303b3836343930363032393139363632363b523b302b3137303830383135353335322b302e30303030302b302e30303030302b302e30302b302b3078312b302b302b302b31323333"),
+ decoder.decode(null, null, binary("454f3b303b3836343930363032393139363632363b523b302b3137303830383135353335322b302e30303030302b302e30303030302b302e30302b302b3078312b302b302b302b31323333454f3b303b3836343930363032393139363632363b523b302b3137303830383135353335322b302e30303030302b302e30303030302b302e30302b302b3078312b302b302b302b31323333")));
+
+ }
+
+}
diff --git a/test/org/traccar/protocol/EskyProtocolDecoderTest.java b/test/org/traccar/protocol/EskyProtocolDecoderTest.java
new file mode 100644
index 000000000..0617ba8a9
--- /dev/null
+++ b/test/org/traccar/protocol/EskyProtocolDecoderTest.java
@@ -0,0 +1,24 @@
+package org.traccar.protocol;
+
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class EskyProtocolDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ EskyProtocolDecoder decoder = new EskyProtocolDecoder(new EskyProtocol());
+
+ verifyNull(decoder, text(
+ "EL;1;864906029196626;170822143426;"));
+
+ verifyPosition(decoder, text(
+ "EO;0;864906029196626;R;7+170822143646+-26.10806+27.94600+0.40+0+0x1+0+102540+0+1242"));
+
+ verifyPosition(decoder, text(
+ "EO;0;864906029196626;R;0+170808155352+0.00000+0.00000+0.00+0+0x1+0+0+0+1233"));
+
+ }
+
+}
diff --git a/test/org/traccar/protocol/GenxProtocolDecoderTest.java b/test/org/traccar/protocol/GenxProtocolDecoderTest.java
new file mode 100644
index 000000000..43d9e7d6e
--- /dev/null
+++ b/test/org/traccar/protocol/GenxProtocolDecoderTest.java
@@ -0,0 +1,26 @@
+package org.traccar.protocol;
+
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class GenxProtocolDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ GenxProtocolDecoder decoder = new GenxProtocolDecoder(new GenxProtocol());
+
+ verifyPosition(decoder, text(
+ "000036004130,08/31/2017 17:24:13,45.47275,-73.65491,5,19,117,1.14,147,ON,1462,0,6,N,0,0.000,-95.0,-1.0,0,0.0000,0.0000,0.000,0,0.00,0.00,0.00,NA,U,UUU,0,-95.0,U"));
+
+ verifyPosition(decoder, text(
+ "000036004130,08/31/2017 17:24:37,45.47257,-73.65506,3,0,117,1.14,124,ON,1489,0,5,N,0,0.000,-95.0,-1.0,0,0.0000,0.0000,0.000,0,0.00,0.00,0.00,NA,U,UUU,0,-95.0,U"));
+
+ decoder.setReportColumns("1,2,3,4");
+
+ verifyPosition(decoder, text(
+ "000036035855,04/16/2017 21:19:07,45.46485,-73.65424,24,32,61:213,342.51,157,ON,20984,0,12,O,18,0.000,95.0,24.0,1990,64.0894,0.0219,316.009,71,0.00,16.78,5.10,NA,U,UUU,0,-95.0,U"));
+
+ }
+
+}
diff --git a/test/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java
new file mode 100644
index 000000000..ebcd4139b
--- /dev/null
+++ b/test/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java
@@ -0,0 +1,36 @@
+package org.traccar.protocol;
+
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class Gl200BinaryProtocolDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ Gl200BinaryProtocolDecoder decoder = new Gl200BinaryProtocolDecoder(new Gl200Protocol());
+
+ verifyPosition(decoder, binary(
+ "2b4556542d00fc1fbf0063450102020956325403000343056437f8220700000200000000010000160100f2007eff75a1f0025c6b1a07e1080108241a02680003189c1ac500000000000002100800000000000000000007e1080108241a19e24e4e0d0a"));
+
+ verifyPositions(decoder, binary(
+ "2b5253506400fc1fbf058e450102020956325403000343056438ed2205010e61c6f0ff75a1b4025c6af959803d8ba07ffe17dea03f7e1fdda0007df7dfa03e7e3fd0a0befdf7cea001fddfd8a000fdefdca042fd9fe1a0427d6fe9a0017db7dca0407d47e7a0027d67e5bfc0fd77eca03ffd8fe4bfff7dcfddbffd7dbfdebffdfddfe2bfbe7e0fe1bf7f7e67e2bf7bfed7e2bf7c7f5fe2bffbffc7e3a12880a7daa0b9013fe3a0f801b7dfa0bd81efe1a03f8207e0a03e8217e4a07e023fe9a0bd824feca03a02affda07b02d004a07f02e007a00002d808a041830001a003834fefa00402b7eebf8382a7ebbfc28267e9bf81821fe3bf0181d7e3bf01016fe9bf010117edbf4080c7f6bf7f8087fabfbf805ff9a0fa8097fca23401300aa0b4016019a13a817026a13b81883ea0be81a83fa0bd81b03ba00101d83abfc0039874bfc081b835bfbf819834bfc081982fa01004702ea00502500da002827802bfc0825fffbf41821fffbf4081d801bf3f816802bec180fffebec20077fdbf80002801bfc0000800a000000800e0e0a202804ffba14a8127eea0460107e4a0cc809fd9a0c4004fcda0c2004fcaa080007fbfa0410067bebfc100c7b6a03f8037c1bfbf004fc6a03f0057c6a0410027c5a081001fbaa0418017baa001001fb8a0007fe7bca000ffdfb7a0817fc7b7a040ffbfb3a0407fb7b4a0407fb7b1bf807fbfb3a0007fb7b5a0007fb7b1a0007fb7b2a0007fbfb3a0407fafaba000ffb7ada0017f97aba040ff7faca001ff77b6bf3fff67b3bf007f87bea082ff47b4bfc27f17c1bfffff3fc2bebdff9fcabe3effbfe0bf3cff47e9a03c002ff0a1740097e9a1f8813fe1a12f01f7fca0fa028ff8a07f02a7fea041829007a00302bff8bf810287f2a0080257e1a0050207dbbfc481cfd3a044819fcda043015fc3a043810fc2a0c680a7b2a0448027b0a0857fa7aea0c37f67a2a0017ee7a7a0407f0f9fa000ff079fa03ffeffa1a03ffeffa2a07fff17a0a03fff1fa0a03fff2fa2a03fff3fa0a07fff47a2a0007f579fa03fff4f9da03fff679ca0007f679ea000ff4f9ca07fff5f9ca0007f579cbfc07f5f9fbf407f6fa6bf807f6fabbfc07f7fadbf807f87b2a0407f87b0a0407f77aba000ff77afbfc07f77aea03fff7fada07fff7faca000ff7fada0007f77abbfc0ff77b0a000ff7faea042ff2faba0037ee7ada0437e57a1a0037e27abbfc1fdf7bcbf827defc5bf01fe0fcebf017e3fd5bfc17e2fdca0ff7e27d7a13cfe27cba0bd7e0fa7a07d7e6fb9a07d7eb7b3a07efedfaea03ffef7afa0c07eefa7a07f7f07a3a03fff0fa3a03f7f27a2a03f7f37a4bfff7f6fa3bfff7f5fa3a07eff979fa03f7fbfa2a03f7fdfa1bfbf8017a5bfbf0037adbeff004fb8bfbf004fc1beff804fcbbf7f8047d5bf408027debf408007e8a03e804fdebf7e8027f2bf00ffefffa0400017efa0418017f1a041002feca0410017edbf007fbffea0007fdff6a1018027e4bf81ffc7f6a1008017dca0c10087bea0018097baa083ffc7cda0837fafc7a102ff0fc8a0c27effb9a0c2fe87c1a143fbf78ea07f7dcfc0a0bd7dffb3a03d7e47b1a03ffe77afa07ffe77ada0007e77aebfc07e77afbfc07e8faea03ffea7afbfbf7ecfb4bfbcfeffbbbf7bff8fb8bf7d0027bebffb809fc7bffa00ffc9bf78813fd9a03d8197e1a03b81d7e6a07e01efdda00081bfdda00101bfdba03f81a7dfbfc001afdbbfbd81a7f1bfbe0187eebf80814feea0028127e7a081813fe2a0010147e6a03e8147f4a0408167eca040817fe7a0018157e4bfc8011fdaa08b002fd1a009ffa7d5a009fe57f6a04b7df7f4a0097e07eca0027df7edbf807e2feca000fe3feca07ffe37f0a0407e0ff7a040fde7f0a0007de7eea000fdcff4a001fddffaa000fdcff8a0027dcffda07f7dbff3a03f7dc7f402680003189c355300000109000002120700000000000000000007e1080108290019e63b5c0d0a"));
+
+ verifyNotNull(decoder, binary(
+ "2B5253500300FC1FFF0064450102020867623130302D446F642F442105007018217345005F010100000001100045073C4D4101DB86BD07E106130B2B0F0460000018770013000000030000000106020F2300002714301107E106130B2B1003424EFB0D0A"));
+
+ verifyPositions(decoder, binary(
+ "2b5253500700fc1fbf005d4501020209563254030003430564377e42071001000000000000007eff75a151025c6a8107e10801081a2a02680003189c1ac500000000000002100700000000000000000007e1080108241019e17ebe0d0a"));
+
+ verifyAttributes(decoder, binary(
+ "2b494e4601fd7f0076676231303000000045010202090104020500004100054007e107150b061d0000003f010e02580000000000d0312a1013648935103226313921591f1200000000000302680003189c1ac3001b02680003189c1ac4000d02680003189c1ac5001207e107150b0d3704f658060d0a"));
+
+ verifyPosition(decoder, binary(
+ "2b4556540c00fc1fbf005c4501010108563254030003430564312a41090100000000003f007dff75a11a025c6a7807e1070a14041202680003189c1ac500000000000000000000000000000000000007e1070b041134054e5c6e0d0a"));
+
+ verifyNull(decoder, binary(
+ "2b41434b017f244501010108676231303000000000ffff07e1070b03112d054dfe030d0a"));
+
+ }
+
+}
diff --git a/test/org/traccar/protocol/Gl200FrameDecoderTest.java b/test/org/traccar/protocol/Gl200FrameDecoderTest.java
new file mode 100644
index 000000000..54c35f084
--- /dev/null
+++ b/test/org/traccar/protocol/Gl200FrameDecoderTest.java
@@ -0,0 +1,28 @@
+package org.traccar.protocol;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class Gl200FrameDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ Gl200FrameDecoder decoder = new Gl200FrameDecoder();
+
+ Assert.assertEquals(
+ binary("2b41434b017f244501010108676231303000000000ffff07e1070b03112d054dfe030d0a"),
+ decoder.decode(null, null, binary("2b41434b017f244501010108676231303000000000ffff07e1070b03112d054dfe030d0a")));
+
+ Assert.assertEquals(
+ binary("2b4556540c00fc1fbf005c4501010108563254030003430564312a41090100000000003f007dff75a11a025c6a7807e1070a14041202680003189c1ac500000000000000000000000000000000000007e1070b041134054e5c6e0d0a"),
+ decoder.decode(null, null, binary("2b4556540c00fc1fbf005c4501010108563254030003430564312a41090100000000003f007dff75a11a025c6a7807e1070a14041202680003189c1ac500000000000000000000000000000000000007e1070b041134054e5c6e0d0a")));
+
+ Assert.assertEquals(
+ binary("2b524553503a47545354522c3430303330302c3836323336353033303134323238392c474c3530302c302c302c302c33392e342c39332c312c302e332c31372c3130352e382c32352e3934343234302c34342e3430333733362c32303137303532393134303533302c303232362c303030312c353643322c373038342c2c2c2c32303137303532393136303533302c30324441"),
+ decoder.decode(null, null, binary("2b524553503a47545354522c3430303330302c3836323336353033303134323238392c474c3530302c302c302c302c33392e342c39332c312c302e332c31372c3130352e382c32352e3934343234302c34342e3430333733362c32303137303532393134303533302c303232362c303030312c353643322c373038342c2c2c2c32303137303532393136303533302c3032444124")));
+
+ }
+
+}
diff --git a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
index 2fd15a5f6..2b0395e48 100644
--- a/test/org/traccar/protocol/Gl200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gl200TextProtocolDecoderTest.java
@@ -3,287 +3,305 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-public class Gl200ProtocolDecoderTest extends ProtocolTest {
+public class Gl200TextProtocolDecoderTest extends ProtocolTest {
@Test
public void testDecode() throws Exception {
- Gl200ProtocolDecoder decoder = new Gl200ProtocolDecoder(new Gl200Protocol());
+ Gl200TextProtocolDecoder decoder = new Gl200TextProtocolDecoder(new Gl200Protocol());
- verifyPosition(decoder, text(
+ verifyAttributes(decoder, buffer(
+ "+RESP:GTINF,04040E,861074023747143,gv200,41,8959301000648637556f,24,0,1,0,1,4.4,0,1,0,0,20170912221854,0,00,01,-0500,1,20170912193448,1D5B$"));
+
+ verifyAttributes(decoder, buffer(
+ "+RESP:GTINF,210102,354524044950583,,42,89011702272048900184,11,99,0,,,4.08,0,1,1,0,0,20170831170831,87,0.00,,,,20170831171010,0064$"));
+
+ verifyPosition(decoder, buffer(
+ "+RESP:GTOBD,360701,864251020253807,LSGTC58UX7Y067312,GV500,0,70FFFF,LSGTC58UX7Y067312,1,12309,983A8140,0,0,33,nan,,0,0,0,,10,0,,0,4.4,0,83.7,36.235142,49.967324,20170829112348,0255,0001,2760,9017,00,690.1,20170829112400,3456$"));
+
+ verifyPositions(decoder, buffer(
+ "+RESP:GTERI,060502,861074023620928,,00000002,27822,10,1,1,0.0,84,2870.9,-78.531796,-0.277329,20170825045344,,,,,,0.0,01138:30:24,,,83,220104,2,1,28FF2776A2150308,1,FFAD,0,20170825045348,A88C$"));
+
+ verifyAttributes(decoder, buffer(
+ "+RESP:GTINF,280500,A1000043D20139,GL300VC,41,,31,0,0,,,3.87,0,1,1,,,20170802150751,70,,48.0,,,20170802112145,03AC$"));
+
+ verifyAttributes(decoder, buffer(
+ "+RESP:GTINF,2D0300,A1000043D20139,1G1JC5444R7252367,,11,,31,0,1,12986,,4.16,0,2,,,20170802145640,,,,,,+0000,0,20170802145643,CD5A$"));
+
+ verifyPosition(decoder, buffer(
"+RESP:GTMPN,450102,865084030001323,gb100,0,1.6,0,-93.1,121.393023,31.164105,20170619103113,0460,0000,1806,2142,00,20170619103143,0512$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTTRI,862370030005908,1,0,99,1,0.0,354,18.5,18.821100,-34.084002,20170607152024,0655,0001,00DD,1CAE,00,0103010100,20170607172115,3E7D$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTERI,060800,861074023677175,,00000002,12351,10,1,1,0.0,0,2862.4,-78.467273,-0.164998,20170529181717,,,,,,0.0,00259:11:50,,,0,210104,2,1,28E17436060000E2,1,015F,0,20170529181723,2824$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTSWG,110100,358688000000158,,1,0,2.1,0,27.1,121.390717,31.164424,20110901073917,0460,0000,1878,0873,,20110901154653,0015$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTTMP,110100,358688000000158,,2,60,1,1,4.3,92,70.0,121.354335,31.222073,20110214013254,0460,0000,18d8,6141,00,80,20110214093254,000F$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTSTT,110100,358688000000158,,41,0,4.3,92,70.0,121.354335,31.222073,20110214013254,0460,0000,18d8,6141,,20110214093254,0022$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTBPL,110100,358688000000158,,3.53,0,4.3,92,70.0,121.354335,31.222073,20110214013254,0460,0000,18d8,6141,,20110214093254,001F$"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+BUFF:GTIGL,060228,862894020180553,,,00,1,1,3.4,199,409.6,-63.174466,-17.739317,20170407121823,0000,0000,0000,0000,00,15989.5,20170407081824,9606$"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+RESP:GTFRI,060228,862894020180553,,14827,10,1,1,3.4,199,409.6,-63.174466,-17.739317,20170407121823,0000,0000,0000,0000,00,15989.5,01070:43:13,13,180,0,220101,,,,20170407081824,9607$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTERI,060502,861074023376992,,00000002,27239,10,1,1,0.2,312,183.3,-79.320820,-2.499110,20170401212005,0740,0000,EE4E,C98F,00,0.0,02114:36:35,,,90,220504,2,0,0,20170401212007,9E3D$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,060502,861074023689626,,25202,10,1,1,0.0,0,2744.1,-78.261047,0.023452,20170401211940,,,,,,0.0,00079:19:15,,,51,110000,,,,20170401212003,4DA7$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,060100,135790246811220,,,00,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,12345:12:34,,,80,210100,,,,20090214093254,11F0$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTERI,06020B,862170010196747,,00000000,,10,1,2,1.8,0,-2.5,117.198440,31.845219,20120802061037,0460,0000,5663,0358,00,0.0,,,,0,410000,20120802061040,0012$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTERI,060502,861074023692562,,00000002,14197,10,1,1,0.2,220,491.8,-79.064212,-2.159754,20170401212007,0740,0000,EE49,CE25,00,0.0,01509:10:58,,,87,220104,2,0,0,20170401212010,D14D$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,210102,354524044925825,,1,1,1,29,2.8,0,133.7,-90.203063,32.265473,20170318005208,,,,,10800,4,20170318005208,0002$"));
- verifyPositions(decoder, false, text(
+ verifyPositions(decoder, false, buffer(
"+RESP:GTFRI,210102,354524044925825,,1,1,1,,,,,,,,310,410,51bc,ca1dae6,10800,1,20170318214333,0002$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTGSM,400201,862365030025161,STR,0234,0015,003a,62a2,16,,0234,0015,003a,56a2,14,,0234,0015,003a,062a,13,,0234,0015,003a,32d9,11,,0234,0015,003a,56a0,11,,,,,,,,0234,0015,003a,7489,17,,20170219200048,0033$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTGSM,400201,862365030025161,STR,0234,0015,003a,56a2,18,,0234,0015,003a,77bc,14,,0234,0015,003a,32d9,12,,0234,0015,003a,062a,12,,0234,0015,003a,62a2,11,,0234,0015,003a,56a0,10,,0234,0015,003a,7489,15,,20170219080049,0030$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTGSM,400201,862365030034940,STR,0234,0030,0870,2469,19,,0234,0030,0870,35ee,18,,0234,0030,0870,16ac,12,,0234,0030,0870,16b2,11,,0234,0030,0870,360f,6,,0234,0030,0870,165d,6,,0234,0030,0870,35ef,17,,20170215220049,008D$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTSTR,400201,862365030034940,GL500,0,0,2,21.1,86,0,1.6,0,5.8,0.622831,51.582688,20170215090422,0234,0030,0870,35EF,,,,20170215220049,008C$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,2C0402,867162020000816,,0,0,1,2,0.3,337,245.7,-82.373387,34.634011,20170215003054,,,,,,63,20170215003241,3EAB$"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+RESP:GTWIF,210102,354524044608058,,4,c413e200ff14,-39,,,,c413e2010e55,-39,,,,c8d3ff04a837,-43,,,,42490f997c6d,-57,,,,,,,,100,20170201020055,0001$"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+RESP:GTWIF,210102,354524044484948,,1,08626693fb98,-36,,,,,,,,97,20170119071300,05E3$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+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(
+ verifyAttributes(decoder, buffer(
"+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$"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+RESP:GTSTR,400201,862365030034957,GL500,0,1,2,21.8,100,0,,,,,,,0234,0015,03C3,3550,,,,20161129174009,0023$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTINF,210102,A10000499AEF9B,,41,,0,0,0,15.0,9,3.87,0,1,1,0,0,20161101140211,72,,,,,20161101140211,00A3$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTNMR,210102,A10000499AEF9B,,0,0,1,9,0.0,0,288.0,-76.902364,39.578828,20161101134145,,,,,00,73,20161101134145,009F$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,210102,A10000499AEF9B,,0,1,1,9,0.5,0,288.0,-76.902364,39.578828,20161101134124,,,,,00,73,20161101134123,009D$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTRTL,210102,A10000499AEF9B,,0,0,1,10,0.2,0,305.4,-76.902274,39.578517,20161101155001,,,,,00,73,20161101155001,00A6$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTINF,110100,358688000000158,,41,898600810906F8048812,18,99,0,33.23,1,4.19,1,1,1,0,0,20110714104934,100,,,,,20110714104934,0014$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTINF,080100,135790246811220,,16,898600810906F8048812,16,0,1,11870,,4.1,0,0,0,,20090214013254,,12340,,00,00,+0800,0,20090214093254,11F0$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTINF,040100,135790246811220,,16,898600810906F8048812,16,0,1,,0,4.4,0,0,0,0,20090214013254,13000,00,00,+0800,0,20090214093254,11F0$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTINF,060100,135790246811220,,16,898600810906F8048812,16,0,1,12000,,4.4,0,0,0,0,20090214013254,0,1300,2000,00,00,+0800,0,20090214093254,11F0$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTINF,1A0800,860599000773978,GL300,41,89701016426133851978,17,0,1,26.6,,3.90,1,1,0,0,0,20161003184043,69,1,44,,,20161004040811,022C$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+BUFF:GTINF,1A0800,860599000773978,GL300,41,89701016426133851978,23,0,1,204.7,,3.84,1,1,0,0,0,20161006072548,62,1,38,,,20161006082343,0C98$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTFRI,360100,864251020141408,3VWGW6AJ0FM237324,gv500,,10,1,1,0.0,0,2258.4,-99.256948,19.555800,20160929214743,0334,0020,0084,65AC,00,0.0,,,,100,410000,0,nan,,20160929214743,13BA$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTOBD,360201,864251020186064,4T1BE46KX7U018210,,0,19FFFF,4T1BE46KX7U018210,1,14283,983901C0,799,36,18,,33792,0,0,0,,,38,,6,53557,0,0.0,0,219.5,-76.661456,39.832588,20160507132153,20160507132154,0230$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,360201,864251020186064,1G1JC5444R7252367,,12802,10,1,0,0.0,0,219.5,-76.661456,39.832588,20160507132235,,,,,,20460.9,00080:03:37,,,100,210000,791,,56,20160507132239,0233$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,1F0101,135790246811220,1G1JC5444R7252367,,,00,2,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,0,4.3,92,70.0,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,2000.0,12345:12:34,,,80,210100,,,50,20090214093254,11F0$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,1F0101,135790246811220,1G1JC5444R7252367,,,00,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,12345:12:34,,92,80,210100,,,50,20090214093254,11F0$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTSTT,060228,862894020178276,,21,0,0.0,0,411.3,-63.169745,-17.776330,20160319132220,0736,0003,6AD4,5BAA,00,20160319092223,1FBD$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTNMR,210102,A10000458356CE,,0,1,1,9,0.0,8,190.7,-85.765865,42.894837,20160316123202,,,,,60,30,20160316123202,0137$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTIDA,060228,862894020178276,,,01C68011010000C7,1,1,0,0.0,0,413.0,-63.169675,-17.776349,20160317222129,0736,0003,6AD4,32CF,00,34.9,,,,,20160317182130,1626$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTIGN,060228,862894020180553,,9860,0,0.2,189,420.0,-63.158195,-17.800608,20160309022951,0736,0003,6AD4,3471,00,,881.2,20160308222956,129A$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+BUFF:GTIGF,060228,862894020180553,,1958,0,0.0,240,390.3,-63.089213,-17.764712,20160309122854,0736,0003,6AB8,5A23,00,,936.8,20160309082858,1368$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,060228,862894020180553,,,10,1,1,20.0,147,329.7,-62.899703,-17.720434,20160309113548,0736,0003,6AAE,3381,00,913.3,,,,0,220101,,,,20160309073554,132B$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+BUFF:GTFRI,060402,862894021808798,,,10,1,1,0.0,349,394.3,-63.287717,-17.662410,20160116234031,0736,0003,6ABA,8305,00,3326.8,,,,94,220100,,,,20160116194035,4D83"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,2C0204,867162020003125,GL300W,0,0,2,1,1.7,205,2867.0,-78.481127,-0.206828,20160215210433,0740,0000,7596,5891C,0.0,1,1.7,205,2867.0,-78.481127,-0.206828,20160215210503,0740,0000,7596,5891C,0.0,88,20160215210506,1E78$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,060228,862894020178276,,15153,10,1,1,0.0,0,431.7,-63.169571,-17.776235,20160210153458,0736,0003,6AD4,80EF,00,34.9,00117:31:26,13442,15163,0,210101,,,,20160210113503,38EE$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,110100,A5868800000015,,0,0,1,1,4.3,92,70.0,121.354335,31.222073,20110214013254,0460,0000,18d8,6141,00,80,20110214013254,000C"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+RESP:GTFRI,210102,A10000458356CE,,0,1,1,15,1.4,0,190.6,-85.765763,42.894896,20160208164505,4126,210,0,18673,00,92,20160208164507,00A6"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+BUFF:GTFRI,060402,862894021808798,,,10,1,1,0.0,349,394.3,-63.287717,-17.662410,20160116234031,0736,0003,6ABA,8305,00,3326.8,,,,94,220100,,,,20160116194035,4D83"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTIDA,06020A,862170013895931,,,D2C4FBC5,1,1,1,0.8,0,22.2,117.198630,31.845229,20120802121626,0460,0000,5663,2BB9,00,0.0,,,,,20120802121627,008E$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTINF,1F0101,135790246811220,1G1JC5444R7252367,,16,898600810906F8048812,16,0,1,12000,,4.2,0,0,,,20090214013254,,,,,,+0800,0,20090214093254,11F0$"));
- verifyPositions(decoder, false, text(
+ verifyPositions(decoder, false, buffer(
"+RESP:GTFRI,120113,555564055560555,,1,1,1,,,,,,,,0282,0380,f080,cabf,6900,79,20140824165629,0001$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,0F0106,862193020451183,,,10,1,1,0.0,163,,-57.513617,-25.368191,20150918182145,,,,,,21235.0,,,,0,210100,,,,20150918182149,00B8$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTOBD,1F0109,864251020135483,,gv500,0,78FFFF,,1,12613,,,,,,,,,,,,,,1286,0,0.0,0,17.1,3.379630,6.529701,20150813074639,0621,0030,51C0,A2B3,00,0.0,20150813074641,A7E6$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTOBD,1F0109,864251020135483,4T1BE46KX7U018210,gv500,0,78FFFF,4T1BE46KX7U018210,1,13411,981B81C0,787,3,43,,921,463,1,10,0300030103030304001200310351035203530354,20,55,,1286,0,6.5,74,21.6,3.379710,6.529714,20150813074824,0621,0030,51C0,A2B3,00,0.0,20150813074828,A7E9$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTSTT,1A0401,860599000508846,,41,0,0.0,84,107.5,-76.657998,39.497203,20150623160622,0310,0260,B435,3B81,,20150623160622,0F54$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,1A0401,860599000508846,,0,0,1,1,134.8,154,278.7,-76.671089,39.778885,20150623154301,0310,0260,043F,7761,,99,20150623154314,0F24$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,1A0200,860599000165464,CRI001,0,0,1,2,,41,,-71.153137,42.301634,20150328020301,,,,,280.3,55,20150327220351,320C"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,02010D,867844001675407,,0,0,1,2,0.0,0,28.9,8.591011,56.476397,20140915213209,0238,0001,03CB,2871,,97,20140915213459,009A"));
- verifyNull(decoder, text(
+ verifyNull(decoder, buffer(
"+RESP:GTINF,359464030073766,8938003990320469804f,18,99,100,1,0,+2.00,0,20131018084015,00EE,0103090402"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,04040C,359231038939904,,,10,1,2,0.0,117,346.0,8.924243,50.798077,20130618122040,0262,0002,0299,109C,00,0.0,,,,,,,,,20130618122045,00F6"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTSTT,04040C,359231038939904,,42,0,0.0,117,346.0,8.924243,50.798077,20130618125152,0262,0002,0299,109C,00,20130618125154,017A"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,020102,000035988863964,,0,0,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,,20090214093254,11F0"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,020102,135790246811220,,0,0,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,,20090214093254,11F0"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,020102,135790246811220,,0,0,2,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,0,4.3,92,70.0,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,,20090214093254,11F0"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTDOG,020102,135790246811220,,0,0,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,20090214093254,11F0"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTLBC,020102,135790246811220,,+8613800000000,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,,20090214093254,11F0"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTGCR,020102,135790246811220,,3,50,180,2,0.4,296,-5.4,121.391055,31.164473,20100714104934,0460,0000,1878,0873,00,,20100714104934,000C"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTFRI,07000D,868487001005941,,0,0,1,1,0.0,0,46.3,-77.039627,38.907573,20120731175232,0310,0260,B44B,EBC9,0015e96913a7,-58,,100,20120731175244,0114"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTHBM,0F0100,135790246811220,,,10,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,20090214093254,11F0$"));
- verifyPosition(decoder, text(
+ verifyPosition(decoder, buffer(
"+RESP:GTHBM,0F0100,135790246811220,,,11,1,1,24.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,20090214093254,11F0$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,02010C,867844001274144,,0,0,1,1,18.0,233,118.1,7.615551,51.515600,20140106130516,0262,0007,79E6,B956,,72,20140106140524,09CE$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,02010C,867844001274649,,0,0,1,1,0.0,0,122.5,7.684216,51.524512,20140106233722,0262,0007,79EE,1D22,,93,20140107003805,03C4$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+BUFF:GTFRI,210101,863286020016706,,,10,1,1,,,,49.903915,40.391669,20140818105815,,,,,,,,,,,210100,,,,,000C$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,240100,135790246811220,,,10,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,2000.0,12345:12:34,,80,,,,,,20090214093254,11F0$"));
- verifyPositions(decoder, text(
+ verifyPositions(decoder, buffer(
"+RESP:GTFRI,240100,135790246811220,,,10,2,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,0,4.3,92,70.0,121.354335,31.222073,20090101000000,0460,0000,18d8,6141,00,2000.0,12345:12:34,,,80,,,,,20090214093254,11F0$"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+RESP:GTSTT,280100,A1000043D20139,,42,0,0.1,321,228.6,-76.660884,39.832552,20150615120628,0310,0484,00600019,0A52,,20150615085741,0320$"));
- verifyNotNull(decoder, text(
+ verifyNotNull(decoder, buffer(
"+RESP:GTRTL,280100,A1000043D20139,,0,0,1,1,0.1,321,239.1,-76.661047,39.832501,20150615114455,0310,0484,00600019,0A52,,87,20150615074456,031E$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+BUFF:GTBPL,1A0800,860599000773978,GL300,3.55,0,0.0,0,257.1,60.565437,56.818277,20161006070553,,,,,204.7,20161006071028,0C75$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTTEM,1A0102,860599000000448,,3,33,0,5.8,0,33.4,117.201191,31.832502,20130109061410,0460,0000,5678,2079,,20130109061517,0091$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTJDR,0A0102,135790246811220,,0,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,20090214093254,11F0$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTJDS,0A0102,135790246811220,,2,0,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,20090214093254,11F0$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTSOS,020102,135790246811220,,0,0,1,1,4.3,92,70.0,121.354335,31.222073,20090214013254,0460,0000,18d8,6141,00,,20090214093254,11F0$"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+RESP:GTVER,1A0800,860599000773978,GL300,GL300,0A03,0103,20161007041531,10F8$"));
- verifyNull(decoder, text(
+ verifyNull(decoder, buffer(
"+ACK:GTHBD,1A0401,135790246811220,,20100214093254,11F0"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+ACK:GTRTO,1A0800,860599000773978,GL300,VER,FFFF,20161006053520,0C19"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+ACK:GTJDC,0A0102,135790246811220,,0016,20090214093254,11F0"));
- verifyAttributes(decoder, text(
+ verifyAttributes(decoder, buffer(
"+ACK:GTGEO,1A0102,135790246811220,,0,0008,20100310172830,11F0"));
}
diff --git a/test/org/traccar/protocol/Gt06FrameDecoderTest.java b/test/org/traccar/protocol/Gt06FrameDecoderTest.java
index 12ee6bb60..ff9d4f51d 100644
--- a/test/org/traccar/protocol/Gt06FrameDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06FrameDecoderTest.java
@@ -12,8 +12,20 @@ public class Gt06FrameDecoderTest extends ProtocolTest {
Gt06FrameDecoder decoder = new Gt06FrameDecoder();
Assert.assertEquals(
- binary("78781f1210020e140613cc04770690003e3f2e3414b20000000000000000044c446a0d0a"),
- decoder.decode(null, null, binary("78781f1210020e140613cc04770690003e3f2e3414b20000000000000000044c446a0d0a")));
+ binary("78780d0103563140414198583c0d0a"),
+ decoder.decode(null, null, binary("78780d0103563140414198583c0d0a")));
+
+ Assert.assertEquals(
+ binary("787800691709261259400700cc0400d376714600d37a3d5000d37a3c5000d393505a00d3765d5a00d376735a00d32e6b640d0a"),
+ decoder.decode(null, null, binary("787800691709261259400700cc0400d376714600d37a3d5000d37a3c5000d393505a00d3765d5a00d376735a00d32e6b640d0a")));
+
+ Assert.assertEquals(
+ binary("7878121011091c0b1e2e98058507f80097a6ac03344a0d0a"),
+ decoder.decode(null, null, binary("7878121011091c0b1e2e98058507f80097a6ac03344a0d0a")));
+
+ Assert.assertEquals(
+ binary("787808171709281135331491827b75594dc8d719a9708452cad719a9708550cad719a97086521491827b75574cac9e17b308085dc8d71939633947cad71939633a480700cc0400d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a0d0a"),
+ decoder.decode(null, null, binary("787808171709281135331491827b75594dc8d719a9708452cad719a9708550cad719a97086521491827b75574cac9e17b308085dc8d71939633947cad71939633a480700cc0400d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a0d0a")));
Assert.assertEquals(
binary("787808134606020002044dc5050d0a"),
diff --git a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
index 0ac51f4b2..05acd314e 100644
--- a/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Gt06ProtocolDecoderTest.java
@@ -16,6 +16,27 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"78780D01086471700328358100093F040D0A"));
+ verifyPosition(decoder, binary(
+ "7878121011091c0b1b2999058508040097a89e0034520d0a"));
+
+ verifyNull(decoder, binary(
+ "78780869170928113413ac9e17b30808514494fcf6e148596cb0ce2c67bd4a6eb0ce2c67bd4b0018e7d4333e55ec086be7f2df5fe48d8c94fc6657e48d8cb8f378510600cc0400d37a3d4600d37a3c5000d37a3b6400d376716400d305ac6400d393506e0d0a"));
+
+ verifyNull(decoder, binary(
+ "787808171709281135331491827b75594dc8d719a9708452cad719a9708550cad719a97086521491827b75574cac9e17b308085dc8d71939633947cad71939633a480700cc0400d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a00d37a3d5a0d0a"));
+
+ verifyNotNull(decoder, binary(
+ "78783b281108111002050136041bcf0000bf09000000000000000000000000000000000000000000000000000000000000000000000000ff00020007d3280d0a"));
+
+ verifyNotNull(decoder, binary(
+ "7878412c11030b011c1f013604cb8a00b17754cb8a00bef357cb8a00b73f5fcb8900b0e25fcb8900b6655fcb8a00b74960cb8a00b178620701001801eb40393800bbbde10d0a"));
+
+ verifyNotNull(decoder, binary(
+ "7878412c11030b012629013604cb8a00b17757cb8a00b73f5bcb8a00b7495ecb8900b0e25fcb8a00b1b9620000000000ff0000000000ffff01001801eb40393e00c0e6340d0a"));
+
+ verifyPosition(decoder, binary(
+ "787822221106160a1016c60278019407c7783800040001940504700046fc01030100065f570d0a"));
+
verifyAttributes(decoder, binary(
"797900143311070609020b00000000a0030046000109e4610d0a"));
@@ -146,6 +167,24 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"787811010123456789012345100B3201000171930D0A"));
+ verifyNull(decoder, binary(
+ "78780d1f000000000000000200b196a20d0a"));
+
+ verifyPosition(decoder, binary(
+ "78781f12110819110216d402f250340828924055d4c801944600d300c09501429c830d0a"));
+
+ verifyPosition(decoder, binary(
+ "78782516110819110208d402f264dc08289a4058d4c70901944600d300c0954606040600014057e90d0a"));
+
+ verifyNull(decoder, binary(
+ "78780d010359339075005244340d0a"));
+
+ verifyNull(decoder, binary(
+ "787800691709261259400700cc0400d376714600d37a3d5000d37a3c5000d393505a00d3765d5a00d376735a00d32e6b640d0a"));
+
+ verifyNull(decoder, binary(
+ "787801080d0a"));
+
}
}
diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
index bd4de3363..b5dcd9ffe 100644
--- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
@@ -11,16 +11,43 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol());
+ verifyPosition(decoder, buffer(
+ "*HQ,353505221264507,V2,100220,0,5238.26259,N,00507.33983,E,0.25,0,280917,FFFFFFFF,cc,28, db,d75b#"));
+
+ verifyPosition(decoder, buffer(
+ "*HQ,353505221264507,VI1,075146,0,5238.25900,N,00507.33429,E,0.54,0,250917,FFFFFFFF,cc,28, db,d75b#"));
+
+ verifyNull(decoder, buffer(
+ "*HQ,353505510948929,V1,,V,,N,,E,0.00,0,,FFFFF7FF,f0,a,11a0,c0c6#"));
+
+ verifyPosition(decoder, buffer(
+ "*hq,356327080425330,VP1,A,2702.7245,S,15251.9311,E,0.48,0.0000,080917#"));
+
+ verifyPosition(decoder, buffer(
+ "*HQ,4209951296,V19,214452,A,5201.0178,N,01830.5029,E,000.00,000,200417,,195.63.13.195,89480610500392633029,BFFFFBFF#"));
+
+ verifyPosition(decoder, buffer(
+ "*hq,356327080425330,VP1,A,2702.7215,S,15251.9309,E,0.62,0.0000,050917#"));
+
+ verifyNull(decoder, buffer(
+ "*HQ,356327080425330,XT,1,100#"));
+
+ verifyAttributes(decoder, buffer(
+ "*HQ,353111080001055,V3,044855,28403,01,001450,011473,158,-62,0292,0,X,030817,FFFFFBFF#"));
+
+ verifyPosition(decoder, binary(
+ "2442091341332059572807175137358006000183640e000000fffffbfdff001f080000000000ea1e0000000021"));
+
verifyNull(decoder, buffer(
"*HQ,4109198974,#"));
verifyAttributes(decoder, buffer(
"*HQ,1700086468,LINK,180902,15,0,84,0,0,240517,FFFFFBFF#"));
- verifyNull(decoder, buffer(
+ verifyAttributes(decoder, buffer(
"*HQ,355488020882405,V3,095426,74001,01,010278,045142,128,-92,02DE,0,X,090517,FFFFFBFF#"));
- verifyNull(decoder, buffer(
+ verifyAttributes(decoder, buffer(
"*HQ,355488020882405,V3,095426,74001,04,010278,045142,128,-92,010278,026311,125,,010278,026582,125,,010278,028322,119,,02DD,0,X,090517,FFFFFBFF#"));
verifyPosition(decoder, buffer(
@@ -47,7 +74,7 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, buffer(
"*HQ,4109179024,NBR,103732,722,310,0,6,8106,32010,23,8101,22007,25,8106,12010,23,8106,22105,22,8101,22012,16,8106,42010,5,100217,FFFFFBFF,5#"));
- verifyNull(decoder, buffer(
+ verifyAttributes(decoder, buffer(
"*HQ,355488020930796,V3,002339,62160,06,024852,035421,148,0,024852,035425,143,,022251,036482,137,,024852,000335,133,,024852,031751,133,,024852,035423,133,,02A1,0,X,010104,EFE7FBFF#"));
verifyPosition(decoder, buffer(
@@ -77,7 +104,7 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
verifyAttributes(decoder, buffer(
"*HQ,1600068860,LINK,112137,20,8,67,0,0,081116,FFFFFBFF#"));
- verifyNull(decoder, buffer(
+ verifyAttributes(decoder, buffer(
"*HQ,355488020533263,V3,121536,65501,04,000152,014001,156,-64,000161,010642,138,,000152,014003,129,,000152,013973,126,,02E4,0,X,071116,FFFFFBFF#"));
verifyPosition(decoder, buffer(
@@ -209,10 +236,6 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
"*HQ,2705171109,V1,213324,A,5002.5849,N,01433.7822,E,0.00,000,140613,FFFFFFFF#"),
Position.KEY_STATUS, 0xFFFFFFFFL);
- verifyAttribute(decoder, buffer(
- "*HQ,4109179024,V19,181519,V,3853.2587,S,06205.9175,W,000.00,000,090217,,5492932630888,8954315265044716555?,FFFFFBFF#"),
- Position.KEY_STATUS, 0xFFFFFBFFL);
-
verifyAttribute(decoder, binary(
"2441091144271222470112142233983006114026520E000000FFFFFBFFFF0014060000000001CC00262B0F170A"),
Position.KEY_STATUS, 0xFFFFFBFFL);
diff --git a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
index 3b040297d..eb82d8c23 100644
--- a/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Jt600ProtocolDecoderTest.java
@@ -11,13 +11,19 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest {
Jt600ProtocolDecoder decoder = new Jt600ProtocolDecoder(new Jt600Protocol());
- verifyPosition(decoder, binary(
+ verifyPositions(decoder, binary(
+ "24624090196121001b19071703493631277203074235752f295800005308010000768b0822"));
+
+ verifyPositions(decoder, binary(
+ "24624090196123019519071703412131285623074214252f10560000130801000076850819071703420631282832074215165f172c0000030801000076850919071703422131282792074216635f222e0000130801000076850919071703423631282808074218261f212a0000130801000076860819071703435131283678074222928f08350000930801000076860919071703440631283003074223174f19500000930801000076870819071703445131279872074224584f07380000930801000076870819071703453631280643074227091f1b220000530801000076880919071703455131281043074228216f0a260000530801000076880819071703460631281229074228988f0c260000530801000076880819071703462131281551074229954f1f220000530801000076880919071703463631281289074230503f114e0000530801000076880819071703465131281186074230884f094f0000530801000076880819071703470631280308074231240f17500000530801000076880619071703472131280358074231636f0b1d0000530801000076890821"));
+
+ verifyPositions(decoder, binary(
"2475604055531611002311111600311326144436028210791d016c0000001f070000000020c03c4f6d07d80ccf"));
- verifyPosition(decoder, binary(
+ verifyPositions(decoder, binary(
"2475201509260111002313101503464722331560113555309F00000000002D0500CB206800F064109326381A03"));
- verifyPosition(decoder, binary(
+ verifyPositions(decoder, binary(
"2475605035891613002328091601152806086750106533350c00000000000a000000000000e1ff4f97007f1607"));
verifyPosition(decoder, buffer(
@@ -50,17 +56,17 @@ public class Jt600ProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, buffer(
"(3460311327,U06,10,220916,140619,T,9.552495,N,13.658227,W,0.43,0,7,0%,00101001000000,11012,10,0,0,0,126,0,30)"));
- verifyPosition(decoder, binary(
+ verifyPositions(decoder, binary(
"24311021600111001B16021105591022329862114046227B0598095080012327951435161F"),
position("2011-02-16 05:59:10.000", true, 22.54977, -114.07705));
- verifyPosition(decoder, binary(
+ verifyPositions(decoder, binary(
"24312082002911001B171012052831243810120255336425001907190003FD2B91044D1FA0"));
- verifyPosition(decoder, binary(
+ verifyPositions(decoder, binary(
"24312082002911001B1710120533052438099702553358450004061E0003EE000000000C00"));
- verifyPosition(decoder, binary(
+ verifyPositions(decoder, binary(
"24608111888821001B09060908045322564025113242329F0598000001003F0000002D00AB"));
verifyPosition(decoder, buffer(
diff --git a/test/org/traccar/protocol/Jt600ProtocolEncoderTest.java b/test/org/traccar/protocol/Jt600ProtocolEncoderTest.java
index 80802dc35..100d7492a 100644
--- a/test/org/traccar/protocol/Jt600ProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/Jt600ProtocolEncoderTest.java
@@ -25,7 +25,7 @@ public class Jt600ProtocolEncoderTest extends ProtocolTest {
@Test
public void testSetTimezone() throws Exception {
command.setType(Command.TYPE_SET_TIMEZONE);
- command.set(Command.KEY_TIMEZONE, 240 * 60);
+ command.set(Command.KEY_TIMEZONE, "GMT+4");
assertEquals("(S09,1,240)", encoder.encodeCommand(command));
}
diff --git a/test/org/traccar/protocol/MegastekFrameDecoderTest.java b/test/org/traccar/protocol/MegastekFrameDecoderTest.java
index c2a8f4ecd..9a327bb1f 100644
--- a/test/org/traccar/protocol/MegastekFrameDecoderTest.java
+++ b/test/org/traccar/protocol/MegastekFrameDecoderTest.java
@@ -11,15 +11,15 @@ public class MegastekFrameDecoderTest extends ProtocolTest {
MegastekFrameDecoder decoder = new MegastekFrameDecoder();
- Assert.assertEquals(
+ verifyFrame(
binary("30313337244d47563030322c3335343535303035303239323636392c4756543930302c522c3134313231352c3033313830342c412c2c532c2c452c30302c30332c30302c332e36372c302e3030302c302e30302c3131372e312c302e302c3531302c31302c2c2c2c303030302c303030302c32322c31322c302c202c202c2c312d312c39382c5057204f4e3b21"),
decoder.decode(null, null, binary("30313337244d47563030322c3335343535303035303239323636392c4756543930302c522c3134313231352c3033313830342c412c2c532c2c452c30302c30332c30302c332e36372c302e3030302c302e30302c3131372e312c302e302c3531302c31302c2c2c2c303030302c303030302c32322c31322c302c202c202c2c312d312c39382c5057204f4e3b21")));
- Assert.assertEquals(
+ verifyFrame(
binary("244d47563030322c3031333737373030373533363433342c2c522c3031303131342c3030303035372c562c303030302e303030302c4e2c30303030302e303030302c452c30302c30302c30302c39392e392c302e3030302c302e30302c302e302c38302e3236332c3531302c38392c323334322c303330422c2c303030302c303030302c3230302c39362c302c202c202c2c2c2c54696d65723b21"),
decoder.decode(null, null, binary("244d47563030322c3031333737373030373533363433342c2c522c3031303131342c3030303035372c562c303030302e303030302c4e2c30303030302e303030302c452c30302c30302c30302c39392e392c302e3030302c302e30302c302e302c38302e3236332c3531302c38392c323334322c303330422c2c303030302c303030302c3230302c39362c302c202c202c2c2c2c54696d65723b210d0a")));
- Assert.assertEquals(
+ verifyFrame(
binary("53545832363034373520202020202020202020024f244750524d432c3133313131302e30302c562c2c2c2c2c2c2c3036303931332c2c2c4e2a37362c3232322c30312c383135412c443435352c31312c39372c303030302c303030312c302c54696d65723b3735"),
decoder.decode(null, null, binary("53545832363034373520202020202020202020024f244750524d432c3133313131302e30302c562c2c2c2c2c2c2c3036303931332c2c2c4e2a37362c3232322c30312c383135412c443435352c31312c39372c303030302c303030312c302c54696d65723b37350d0a")));
diff --git a/test/org/traccar/protocol/MegastekProtocolDecoderTest.java b/test/org/traccar/protocol/MegastekProtocolDecoderTest.java
index a20a0b69b..9bb705f17 100644
--- a/test/org/traccar/protocol/MegastekProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MegastekProtocolDecoderTest.java
@@ -10,6 +10,15 @@ public class MegastekProtocolDecoderTest extends ProtocolTest {
MegastekProtocolDecoder decoder = new MegastekProtocolDecoder(new MegastekProtocol());
+ verifyNull(decoder, text(
+ "0112$MGV002,,GVT900-3,S,010114,000003,,,,,,00,00,00,,0.000,0.00,,0.0,,,,,,0000,0000,14,10,0, , ,,1-0,0,Low Ext Vol;!"));
+
+ verifyPosition(decoder, text(
+ "0170$MGV002,354550056642321,GVT900-3,S,011017,090208,A,1635.8484,N,10446.6095,E,00,09,00,0.91,16.980,257.73,177.6,0.0,457,01,0741,00C0,21,0000,0000,20,10,0, , ,,1-1,54,Dist;!"));
+
+ verifyNull(decoder, text(
+ "0140$MGV002,354550056642321,GVT900-3,S,300917,071731,V,,,,,00,00,00,99.9,0.000,0.00,,0.0,457,01,0741,00CD,,0000,0000,20,10,0, , ,,1-1,94,PW ON;!"));
+
verifyPosition(decoder, text(
"$MGV002,869152024446923,,S,290816,200627,V,5056.21059,N,00439.25034,E,00,00,00,99.9,,,-25.1,,206,01,0BBB,4418,28,,,,,,,,,01,093,Timer;"));
diff --git a/test/org/traccar/protocol/MeiligaoProtocolEncoderTest.java b/test/org/traccar/protocol/MeiligaoProtocolEncoderTest.java
index f9d77f8a6..ee4a869f9 100644
--- a/test/org/traccar/protocol/MeiligaoProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/MeiligaoProtocolEncoderTest.java
@@ -10,7 +10,7 @@ public class MeiligaoProtocolEncoderTest extends ProtocolTest {
public void testEncode() throws Exception {
MeiligaoProtocolEncoder encoder = new MeiligaoProtocolEncoder();
-
+
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_POSITION_SINGLE);
@@ -23,7 +23,7 @@ public class MeiligaoProtocolEncoderTest extends ProtocolTest {
verifyCommand(encoder, command, binary("40400013123456789012344102000a2f4f0d0a"));
command.setType(Command.TYPE_SET_TIMEZONE);
- command.set(Command.KEY_TIMEZONE, 480 * 60);
+ command.set(Command.KEY_TIMEZONE, "GMT+8");
verifyCommand(encoder, command, binary("4040001412345678901234413234383030ad0d0a"));
diff --git a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
index d50cae8bc..07411dbc8 100644
--- a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest {
MeitrackProtocolDecoder decoder = new MeitrackProtocolDecoder(new MeitrackProtocol());
+ verifyPosition(decoder, buffer(
+ "$$V177,863835026871173,AAA,35,34.516428,10.470160,170915154043,A,9,12,68,74,0.9,9,1988259,525882,605|2|008C|0007B5A6,0200,0003|0000|0000|01A6|0571,00000001,,3,0000,010A92,360,511*74"));
+
+ verifyPosition(decoder, buffer(
+ "$$B136,011691002364761,AAA,29,47.055220,28.893193,170914144240,V,0,7,0,0,0,132,129754946,129793197,259|2|02F8|413F,0000,000D|000C||028C|,*9E"));
+
verifyNotNull(decoder, buffer(
"$$F153,863835026880190,AAA,29,25.313160,55.422473,170628150902,V,0,0,0,0,0.0,0,6553,6697,0|0|0000|00000000,0000,0002|0000|0000|018B|0000,,,3,0000,,110,386*22"));
diff --git a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java
index fd16df779..b9003a25d 100644
--- a/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MiniFinderProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class MiniFinderProtocolDecoderTest extends ProtocolTest {
MiniFinderProtocolDecoder decoder = new MiniFinderProtocolDecoder(new MiniFinderProtocol());
verifyNull(decoder, text(
+ "!1,867273023933661,V07S.5701.1621,100"));
+
+ verifyNull(decoder, text(
"!1,123456789012345"));
verifyNull(decoder, text(
diff --git a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java
index 99b250ebc..360ea0008 100644
--- a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java
@@ -11,12 +11,12 @@ public class MiniFinderProtocolEncoderTest extends ProtocolTest {
public void testEncode() throws Exception {
MiniFinderProtocolEncoder encoder = new MiniFinderProtocolEncoder();
-
+
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_SET_TIMEZONE);
- command.set(Command.KEY_TIMEZONE, 3600);
-
+ command.set(Command.KEY_TIMEZONE, "GMT+1");
+
Assert.assertEquals("123456L+01", encoder.encodeCommand(command));
command = new Command();
diff --git a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
index 2d0ef0adf..af860f371 100644
--- a/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OsmAndProtocolDecoderTest.java
@@ -37,6 +37,9 @@ public class OsmAndProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, request(
"/?id=123456&timestamp=1377177267&location=60.0,30.0"));
+ verifyPosition(decoder, request(
+ "/?id=123456789012345&timestamp=1504763810&lat=40.7232948571&lon=-74.0061408571&bearing=7.19889788244&speed=40&ignition=true&rpm=933&fuel=24"));
+
}
}
diff --git a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java
index 62b3bbdaa..24b570937 100644
--- a/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Pt502ProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class Pt502ProtocolDecoderTest extends ProtocolTest {
Pt502ProtocolDecoder decoder = new Pt502ProtocolDecoder(new Pt502Protocol());
verifyPosition(decoder, text(
+ "$PHO0-1,1360000260,123012.000,A,0913.9644,N,07548.8345,W,0.0,309.8,111017,,,A/00000,10000/0,0,0,0/64551600//f98//"));
+
+ verifyPosition(decoder, text(
"$POS,865328026243864,151105.000,A,1332.7096,N,204.6787,E,0.0,10.00,050517,,,A/00000,10/1,0/234//FD9/"));
verifyNull(decoder, text(
diff --git a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java
index ab6446010..62406d3f2 100644
--- a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java
@@ -30,7 +30,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest {
Command command = new Command();
command.setDeviceId(1);
command.setType(Command.TYPE_SET_TIMEZONE);
- command.set(Command.KEY_TIMEZONE, 8);
+ command.set(Command.KEY_TIMEZONE, "GMT+8");
Assert.assertEquals("#TMZ8\r\n", encoder.encodeCommand(command));
diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
index a9b13b3e6..45230a339 100644
--- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -6,11 +6,43 @@ import org.traccar.ProtocolTest;
public class SuntechProtocolDecoderTest extends ProtocolTest {
@Test
+ public void testDecodeTemperature() throws Exception {
+
+ SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(new SuntechProtocol());
+
+ decoder.setHbm(true);
+ decoder.setIncludeAdc(true);
+ decoder.setIncludeTemp(true);
+
+ /*verifyPosition(decoder, text(
+ "ST300STT;205170303;12;561;20170816;09:10:34;173f53;+19.082370;-098.214287;006.776;000.00;0;0;52982186;12.75;100000;2;6328;155747;4.2;1;0.00;0;0.00;0.00;00000000000000;0;28F2B7600600005D:+5.2;:;:"));*/
+
+ verifyPosition(decoder, text(
+ "ST300STT;205173382;07;564;20160322;23:23:18;232e19;+19.288278;-099.128750;000.122;000.00;9;1;478391;11.53;000100;1;9498;079324;4.3;1;0.00;0.00;0.00;00000000000000;0;2898E16006000058:-20.8;2861626006000039:+2.5;:"));
+
+ verifyPosition(decoder, text(
+ "ST300EVT;205173382;07;564;20160322;23:23:18;232e19;+19.288278;-099.128750;000.122;000.00;9;1;478391;11.53;000100;2;1;9498;079324;4.3;1;0.00;0.00;0.00;00000000000000;0;2898E16006000058:-20.8;2861626006000039:+2.5;:"));
+
+ }
+
+ @Test
public void testDecode() throws Exception {
SuntechProtocolDecoder decoder = new SuntechProtocolDecoder(new SuntechProtocol());
verifyPosition(decoder, text(
+ "STT;100850000;3FFFFF;26;010;1;20161117;08:37:39;0000004F;450;0;0014;20;+37.479323;+126.887827;62.03;65.43;10;1;00000101;00001000;1;2;0492"));
+
+ verifyPosition(decoder, text(
+ "STT;6009999006;3FFFFF;26;398;0;20170827;20:04:37;087d4760;310;410;0ba0;23;+40.123420;-074.995971;000.031;000.00;8;1;00000001;00000000;1;1;0006"));
+
+ verifyPosition(decoder, text(
+ "ST500STT;205450135;07;843;20170816;23:24:45;+19.338432;-099.179817;000.283;000.00;6;1;141121;12.89;0;0;1;4659;002.795;0;001.891;611;4.0"));
+
+ verifyPosition(decoder, text(
+ "ST300STT;205170303;12;561;20170816;09:10:34;173f53;+19.082370;-098.214287;006.776;000.00;0;0;52982186;12.75;100000;2;6328;155747;4.2;1;0.00;0;0.00;0.00;00000000000000;0;28F2B7600600005D:+5.2;:;:"));
+
+ verifyPosition(decoder, text(
"ST910;Location;205576803;500;20170319;12:18:17;-22.846014;-046.322176;000.000;000.00;0;3.8;0;1;9159"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/TaipProtocolDecoderTest.java b/test/org/traccar/protocol/TaipProtocolDecoderTest.java
index 2251763cc..beba54d74 100644
--- a/test/org/traccar/protocol/TaipProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TaipProtocolDecoderTest.java
@@ -11,6 +11,18 @@ public class TaipProtocolDecoderTest extends ProtocolTest {
TaipProtocolDecoder decoder = new TaipProtocolDecoder(new TaipProtocol());
verifyPosition(decoder, text(
+ ">RPV46640+4197412-0752857900015802;ID=5102;*71<"));
+
+ verifyNull(decoder, text(
+ ">RCP46640+419741-075285802;ID=5102;*6C<"));
+
+ verifyPosition(decoder, text(
+ ">REV001958003965+0307178+1016144900031532;IO=300;SV=8;BL=4159;CF=8161,C,13;AD=14145;IX=10233040;FF=0,0,0,0;VO=338578;ID=357042063052352<"));
+
+ verifyPosition(decoder, text(
+ ">REV011958000369+0307185+1016144400000032;IO=200;SV=9;BL=4158;CF=0,0,0;AD=12347;IX=10213040;FF=0,0,0,0;VO=338572;ID=357042063052352<"));
+
+ verifyPosition(decoder, text(
">REV421942237017+1170957-0701880200000032;ID=356612022463055<"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/TelicFrameDecoderTest.java b/test/org/traccar/protocol/TelicFrameDecoderTest.java
index a091891df..711014c46 100644
--- a/test/org/traccar/protocol/TelicFrameDecoderTest.java
+++ b/test/org/traccar/protocol/TelicFrameDecoderTest.java
@@ -14,30 +14,30 @@ public class TelicFrameDecoderTest extends ProtocolTest {
TelicFrameDecoder decoder = new TelicFrameDecoder();
- Assert.assertEquals(
+ verifyFrame(
binary(ByteOrder.LITTLE_ENDIAN, "303032363230333339337c3232367c31307c303032303034303130"),
decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "303032363230333339337c3232367c31307c30303230303430313000")));
- Assert.assertEquals(
+ verifyFrame(
binary(ByteOrder.LITTLE_ENDIAN, "3030333032303333393332352c3139303331373038333035322c302c3138303331373130333132372c3235393932342c3434353133332c332c302c302c392c2c2c39332c31323231303134312c2c303031302c30302c34302c3234302c302c30343036"),
decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "630000003030333032303333393332352c3139303331373038333035322c302c3138303331373130333132372c3235393932342c3434353133332c332c302c302c392c2c2c39332c31323231303134312c2c303031302c30302c34302c3234302c302c3034303600")));
- Assert.assertEquals(
+ verifyFrame(
binary(ByteOrder.LITTLE_ENDIAN, "303032363239363231385343434530315f534343457c3232367c31307c30323637"),
decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "303032363239363231385343434530315f534343457c3232367c31307c3032363700")));
- Assert.assertEquals(
+ verifyFrame(
binary(ByteOrder.LITTLE_ENDIAN, "30303434323936323138544c4f43303236372c30302c3031313030393030303239363231382c3139303331373038333033362c3235353137382c3434353037322c332c302c38322c2c2c2c3136382c31343734313239362c2c30302c30302c302c323137"),
decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "6400000030303434323936323138544c4f43303236372c30302c3031313030393030303239363231382c3139303331373038333033362c3235353137382c3434353037322c332c302c38322c2c2c2c3136382c31343734313239362c2c30302c30302c302c32313700")));
- Assert.assertNull(
+ verifyNull(
decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "00303032363937393238317c3233327c30337c30303230303430313000")));
- Assert.assertEquals(
+ verifyFrame(
binary(ByteOrder.LITTLE_ENDIAN, "303032363937393238317c3233327c30337c303032303034303130"),
decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "303032363937393238317c3233327c30337c30303230303430313000")));
- Assert.assertEquals(
+ verifyFrame(
binary(ByteOrder.LITTLE_ENDIAN, "3030323039373932383139392c3231303231363038313930302c302c3231303231363038313835392c3031333839333338352c34363635383639352c332c302c302c382c2c2c3534312c36313239382c2c303030302c30302c302c3139362c302c30343037"),
decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "650000003030323039373932383139392c3231303231363038313930302c302c3231303231363038313835392c3031333839333338352c34363635383639352c332c302c302c382c2c2c3534312c36313239382c2c303030302c30302c302c3139362c302c3034303700")));
diff --git a/test/org/traccar/protocol/TelicProtocolDecoderTest.java b/test/org/traccar/protocol/TelicProtocolDecoderTest.java
index 85d6f70ac..ed8245e1f 100644
--- a/test/org/traccar/protocol/TelicProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TelicProtocolDecoderTest.java
@@ -10,6 +10,18 @@ public class TelicProtocolDecoderTest extends ProtocolTest {
TelicProtocolDecoder decoder = new TelicProtocolDecoder(new TelicProtocol());
+ verifyNull(decoder, text(
+ "0026355565071347499|206|01|001002008"));
+
+ verifyPosition(decoder, text(
+ "052028495198,160917073641,0,160917073642,43879,511958,3,24,223,17,,,-3,142379,,0010,00,64,205,0,0499"));
+
+ verifyPosition(decoder, text(
+ "01302849516,160917073503,0,160917073504,43907,512006,3,11,160,14,,,-7,141811,,0010,00,64,206,0,0499"));
+
+ verifyPosition(decoder, text(
+ "002135556507134749999,010817171138,0,010817171138,004560973,50667173,3,0,0,11,1,1,100,958071,20601,000000,00,4142,0000,0000,0208,10395,0"));
+
verifyPosition(decoder, text(
"442045993198,290317131935,0,290317131935,269158,465748,3,26,183,,,,184,85316567,226,01,00,68,218"));
diff --git a/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
index dd484cad7..beae48d67 100644
--- a/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TeltonikaProtocolDecoderTest.java
@@ -1,5 +1,6 @@
package org.traccar.protocol;
+import org.junit.Ignore;
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -8,7 +9,7 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest {
@Test
public void testDecode() throws Exception {
- TeltonikaProtocolDecoder decoder = new TeltonikaProtocolDecoder(new TeltonikaProtocol());
+ TeltonikaProtocolDecoder decoder = new TeltonikaProtocolDecoder(new TeltonikaProtocol(), false);
verifyNull(decoder, binary(
"000F313233343536373839303132333435"));
@@ -57,7 +58,32 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest {
verifyPositions(decoder, binary(
"00000000000000a608010000013f14a1d1ce000f0eb790209a778000ab010c0500000000000000000100003390"));
-
+
+ verifyPositions(decoder, binary(
+ "000000000000004508010000015eb70a86d00024089d4d21dee3860137005f12005f000e06ef01f00150011503c800450108b5000bb6000642382718005fcd057ace19d3430f57440000000001000002bf"));
+
+ verifyPositions(decoder, binary(
+ "000000000000004a08010000015ebc1da508002411926621f15246010b00b913005e000f06ef01f00150011505c800450108b5000bb6000642381b18005ecd0318ce19cd430f5844000001f1000061a900010000c8e1"));
+
+ decoder.setExtended(true);
+
+ verifyPositions(decoder, false, binary(
+ "0000000000000158080b0000015d4b4dc07a00d5dbd13eec04324e020e0000120000000000000000000000015d4b4cd5e800d5dbd13eec04324e020e0000120000000000000000000000015d4b4beb8800d5dbd13eec04324e020e0000130000000000000000000000015d4b4b012800d5dbd13eec04324e020e0000120000000000000000000000015d4b4a16c800d5dbd13eec04324e020f0000110000000000000000000000015d4b492c6800d5dbd13eec04324e020f0000110000000000000000000000015d4b48420800d5dbd13eec04324e020f0000120000000000000000000000015d4b4757a800d5dbd13eec04324e020f00000f0000000000000000000000015d4b466d4800d5dbd13eec04324e020f0000100000000000000000000000015d4b4582e800d5dbd13eec04324e020f0000110000000000000000000000015d4b44988800d5dbd13eec04324e020f0000110000000000000000000b0000ec10"));
+
+ verifyPositions(decoder, false, binary(
+ "00000000000003b5080b0000015ab5642a8800d5db1769ec01d70a020a00e3040004000e0501010200030004006000060900100a00010b0000130000422f1318000302c700000000f7000000000001cb000000000000000000000000000000000000015ab5642e7000d5db178aec01d6d6020a0070040003000e0501010200030004006000060900100a00000b0000130000422f1318000302c700000000f7000000000001cb000000000000000000000000000000000000015ab567050000d5db1805ec01da3c02060101040006000e05010102000300040060000609000f0a00010b0000130000422f0c18000302c700000046f7000000000001cb000000000000000000000000000000000000015ab56708e800d5db1723ec01d9ec020600e5040006000e05010102000300040060000609000f0a00010b0000130000422f1018000502c700000003f7000000000001cb000000000000000000000000000000000000015ab5685cc000d5db20f7ec01d8fa02080033050007000e05010102000300040060000609000f0a00010b0000130000422f0a18000502c700000030f7000000000001cb000000000000000000000000000000000000015ab5693b6800d5db2367ec01d9430211011b040006000e05010102000300040060000609000f0a00010b0000130000422f0c18000302c700000027f7000000000001cb000000000000000000000000000000000000015ab569433800d5db1fb2ec01d9310211008b040006000e0501010200030004006000060900110a00000b0000130000422f1318000402c700000009f7000000000001cb000000000000000000000000000000000000015ab56a0e5800d5db22a2ec01da5502100041050007000e05010102000300040060000609000f0a00000b0000130000422f1118000602c70000000ef7000000000001cb000000000000000000000000000000000000015ab56a700000d5db2afcec01ddb2020a0012050008000e05010102000300040060000609000e0a00000b0000130000422f0918000502c700000026f7000000000001cb000000000000000000000000000000000000015ab56a73e800d5db2ad8ec01de65020a014e050008000e05010102000300040060000609000f0a00010b0000130000422f0818000702c700000002f7000000000001cb000000000000000000000000000000000000015ab56a7bb800d5db2971ec01e00e020a013f040008000e0501010200030004006000060900100a00020b0000130000422f0b18000802c700000004f7000000000001cb000000000000000000000000000000000b00007c5f"));
+
+ }
+
+ @Ignore
+ @Test
+ public void testDecodeConnectionless() throws Exception {
+
+ TeltonikaProtocolDecoder decoder = new TeltonikaProtocolDecoder(new TeltonikaProtocol(), true);
+
+ verifyPositions(decoder, false, binary(
+ "0049cafe0122000f33353734353430373237313339373508010000015d3766f6a800003eef961ec6215e0063006d09003100070401000200f001c8000242381c18003201c7000000e10001"));
+
}
}
diff --git a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
index 4d872b082..a69ff8856 100644
--- a/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Tk103ProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest {
Tk103ProtocolDecoder decoder = new Tk103ProtocolDecoder(new Tk103Protocol());
verifyPosition(decoder, text(
+ "(007611121184BR00170816A2401.5217N07447.0788E000.0221352232.340000004FL0030F14F)"));
+
+ verifyNull(decoder, text(
+ "(027044702512BP00027044702512HSO01A4)"));
+
+ verifyPosition(decoder, text(
"(864768011069660,ZC11,250517,V,0000.0000N,00000.0000E,000.0,114725,000.0,0.00,11)"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/TlvProtocolDecoderTest.java b/test/org/traccar/protocol/TlvProtocolDecoderTest.java
new file mode 100644
index 000000000..6c37c4dbb
--- /dev/null
+++ b/test/org/traccar/protocol/TlvProtocolDecoderTest.java
@@ -0,0 +1,24 @@
+package org.traccar.protocol;
+
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class TlvProtocolDecoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ TlvProtocolDecoder decoder = new TlvProtocolDecoder(new TlvProtocol());
+
+ verifyNull(decoder, binary(
+ "30430f383630323437303330303934333931ff10393233323132323030303834353433340f533636385f415f56312e30315f454eff1130303a30433a45373a30303a30303a30300132"));
+
+ verifyNull(decoder, binary(
+ "30410f383630323437303330303934333931"));
+
+ verifyNull(decoder, binary(
+ "30420f3836303234373033303039343339310131"));
+
+ }
+
+}
diff --git a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
index 96f795172..5e1f09543 100644
--- a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
@@ -12,6 +12,18 @@ public class TramigoProtocolDecoderTest extends ProtocolTest {
TramigoProtocolDecoder decoder = new TramigoProtocolDecoder(new TramigoProtocol());
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000c426b000a6000101c557037598050d5c8a595472616d69676f3a204d6f76696e672c20302e3132206b6d2045206f66204c617275742054696e2049736c616d6963205072696d617279205363686f6f6c2c2054616970696e672c20506572616b2c204d592c20342e38333134392c203130302e37333038352c204e572077697468207370656564203130206b6d2f682c2030303a34393a30382041756720392020454f46"));
+
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000c526b000a6000101f17d03759805115c8a595472616d69676f3a204d6f76696e672c20302e3133206b6d205345206f66204c617275742054696e2049736c616d6963205072696d617279205363686f6f6c2c2054616970696e672c20506572616b2c204d592c20342e38333132322c203130302e37333037382c204e4520776974682073706565642039206b6d2f682c2030303a34383a35332041756720392020454f46"));
+
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000d426b0009f00010184f20375980593638a595472616d69676f3a204d6f76696e672c20302e3039206b6d204e57206f66204a616c616e2053696d70616e672042617475204d61726b65742c2054616970696e672c20506572616b2c204d592c20342e38333034332c203130302e37323230342c20532077697468207370656564203130206b6d2f682c2030313a32313a31322041756720392020454f46"));
+
+ verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ "8000d626b0007f0001013c0b037598051d648a595472616d69676f3a2053746f707065642c206174204a616c616e2053696d70616e672042617475204d61726b65742c2054616970696e672c20506572616b2c204d592c20342e38323937322c203130302e37323233322c2030313a32323a34342041756720392020454f46"));
+
verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
"80003d1ac0001c00010100000367152b13bc1d5970696e6720454f46"));
diff --git a/test/org/traccar/protocol/TrvProtocolDecoderTest.java b/test/org/traccar/protocol/TrvProtocolDecoderTest.java
index 319455b9f..a4c0d3343 100644
--- a/test/org/traccar/protocol/TrvProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TrvProtocolDecoderTest.java
@@ -11,6 +11,15 @@ public class TrvProtocolDecoderTest extends ProtocolTest {
TrvProtocolDecoder decoder = new TrvProtocolDecoder(new TrvProtocol());
verifyNull(decoder, text(
+ "TRVAP00352121088015548"));
+
+ verifyPosition(decoder, text(
+ "TRVAP01170905A5227.1382N00541.4256E001.7095844000.0008100610020100,204,8,3230,13007"));
+
+ verifyAttributes(decoder, text(
+ "TRVCP01,07800010010000602001206001120124"));
+
+ verifyNull(decoder, text(
"IWAP00353456789012345"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java
index aa8f61772..68c8bbdbc 100644
--- a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class TzoneProtocolDecoderTest extends ProtocolTest {
TzoneProtocolDecoder decoder = new TzoneProtocolDecoder(new TzoneProtocol());
verifyPosition(decoder, binary(
+ "545a005624240111010e0000086169303626931411091b151d2600160801de26ec002f633411091b151d2500000000160c0000040d2a34df000eaa4000001b37016000000000319c0000000000000000000000000000003a84240d0a"));
+
+ verifyPosition(decoder, binary(
"545a005024240153011000000863835025559464110103080a22001609011bed79245964a9110103080a22000a0000550c00000604396f04222c000daac000151701a204870000000000000003000959000546190d0a"));
verifyPosition(decoder, binary(
diff --git a/test/org/traccar/protocol/Vt200FrameDecoderTest.java b/test/org/traccar/protocol/Vt200FrameDecoderTest.java
index b31e14b7d..a9fff6c33 100644
--- a/test/org/traccar/protocol/Vt200FrameDecoderTest.java
+++ b/test/org/traccar/protocol/Vt200FrameDecoderTest.java
@@ -11,11 +11,11 @@ public class Vt200FrameDecoderTest extends ProtocolTest {
Vt200FrameDecoder decoder = new Vt200FrameDecoder();
- Assert.assertEquals(
+ verifyFrame(
binary("28631037309456208400340102dc0906171616454415760201144494473f920a0c0000030500200100417c1f383a9d1090510000006a00007000000e00180ee129"),
decoder.decode(null, null, binary("28631037309456208400340102dc0906171616454415760201144494473f920a0c0000030500200100417c1f383a9d1090510000006a00007000000e00180ee129")));
- Assert.assertEquals(
+ verifyFrame(
binary("28631037309456208400340102f51306171327294418267501208948170231071f0000044300200100005f02180000667500000000000000000000080000624629"),
decoder.decode(null, null, binary("28631037309456208400340102f513061713273d144418267501208948170231071f0000044300200100005f02180000667500000000000000000000080000624629")));
diff --git a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java
index e61c5f9f2..42ed4a652 100644
--- a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java
@@ -10,6 +10,42 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest {
Vt200ProtocolDecoder decoder = new Vt200ProtocolDecoder(new Vt200Protocol());
+ verifyNull(decoder, binary(
+ "286310373094563082002701033d010817143327c68a14841e00c27f550e9a000000000c000000084700200120007d01af260b29"));
+
+ verifyAttributes(decoder, binary(
+ "2863103730945630880062033d862631037309456f222014604362936f010817140954010817144135076b00002a3800003b7d6127cc91040000000000000000000000005a0000088e000001ce02630000263b000009b401ff00000cb40000069c02af000018190200000102019729"));
+
+ verifyPosition(decoder, binary(
+ "286310373094562086002101033d010817143328441790420114817637207d090a00000847002001207f00d6f229"));
+
+ verifyPosition(decoder, binary(
+ "286310373094562086002101033d0108171433354417932101148139772c9d080a00000847002001207f00dc6729"));
+
+ verifyNull(decoder, binary(
+ "2863103730945600880012180108171433004418103801148375470000dd29"));
+
+ verifyNull(decoder, binary(
+ "28631037309456108800002e29"));
+
+ verifyAttributes(decoder, binary(
+ "2863103730945630880062033c862631037309456f222014604362936f01081713365601081713571904c800001b2c000034f66827f0840000000000000000000000000047000006e7000001b9022a000023ff000007f2018a00000a10000003f300cd00000d8d0300000302002729"));
+
+ verifyNull(decoder, binary(
+ "28631037309456008e000801042307171804584229"));
+
+ verifyNull(decoder, binary(
+ "28631037309456108800002e29"));
+
+ verifyPosition(decoder, binary(
+ "28631037309456208200210103302307171805444417097301147188170198090f0000073a002000007e00074429"));
+
+ verifyNull(decoder, binary(
+ "286310373094563089001200032f2107171740144417075001147188872c29"));
+
+ verifyAttributes(decoder, binary(
+ "2863103730945630880062032f862631037309456f222014604362936f21071717373221071717401400a100000cd700000004020d3c8e0000000000000000000000000000000000000000000000000000000000000000000a000000040000000e009700000cc9000000000000e929"));
+
verifyPosition(decoder, binary(
"28631037309456208400340102dc0906171616454415760201144494473f920a0c0000030500200100417c1f383a9d1090510000006a00007000000e00180ee129"));
diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
index 23e1e35fb..c960ccc25 100644
--- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -11,6 +11,12 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
WatchProtocolDecoder decoder = new WatchProtocolDecoder(new WatchProtocol());
verifyPosition(decoder, buffer(
+ "[3G*8308373902*0080*AL,230817,095346,A,47.083950,N,15.4821850,E,7.60,273.8,0.0,4,15,44,0,0,00200010,2,255,232,1,7605,42530,118,7605,58036,119,0,65.8]"));
+
+ verifyPosition(decoder, buffer(
+ "[SG*9051007430*006C*UD,150817,132115,V,28.435142,N,81.354333,W,2.2038,000,99,00,70,100,0,50,00000000,1,1,310,260,1091,30082,139,,00]"));
+
+ verifyPosition(decoder, buffer(
"[3G*6005412902*011F*WT,170517,133811,V,18.512200,N,73.7750283,E,0.00,0.0,0.0,0,92,82,4262,0,00000010,2,1,404,22,10125,8301,141,10125,13921,122,5,Skynet,28:c6:8e:be:87:c0,-60,Intel Wi-Fi,4c:60:de:32:3d:38,-70,Nirvanic-2,40:e3:d6:4a:d9:c2,-73,A4-Guest,40:e3:d6:4a:d9:c4,-73,A4Idatix,40:e3:d6:4a:d9:c3,-73,13.8]"));
verifyPosition(decoder, buffer(
diff --git a/test/org/traccar/protocol/WatchProtocolEncoderTest.java b/test/org/traccar/protocol/WatchProtocolEncoderTest.java
index a7c360d7f..cffe373cf 100644
--- a/test/org/traccar/protocol/WatchProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolEncoderTest.java
@@ -34,18 +34,25 @@ public class WatchProtocolEncoderTest extends ProtocolTest {
command = new Command();
command.setDeviceId(1);
+ command.setType(Command.TYPE_CUSTOM);
+ command.set(Command.KEY_DATA, "WORK,6-9,11-13,13-15,17-19");
+ Assert.assertEquals("[CS*123456789012345*001a*WORK,6-9,11-13,13-15,17-19]", encoder.encodeCommand(command));
+
+ command = new Command();
+ command.setDeviceId(1);
command.setType(Command.TYPE_SET_TIMEZONE);
- command.set(Command.KEY_TIMEZONE, 60 * 60);
+ command.set(Command.KEY_TIMEZONE, "Europe/Amsterdam");
Assert.assertEquals("[CS*123456789012345*0006*LZ,,+1]", encoder.encodeCommand(command));
- command.set(Command.KEY_TIMEZONE, 90 * 60);
+ command.set(Command.KEY_TIMEZONE, "GMT+01:30");
Assert.assertEquals("[CS*123456789012345*0008*LZ,,+1.5]", encoder.encodeCommand(command));
- command.set(Command.KEY_TIMEZONE, -60 * 60);
+ command.set(Command.KEY_TIMEZONE, "Atlantic/Azores");
Assert.assertEquals("[CS*123456789012345*0006*LZ,,-1]", encoder.encodeCommand(command));
- command.set(Command.KEY_TIMEZONE, -11 * 60 * 60 - 30 * 60);
+ command.set(Command.KEY_TIMEZONE, "GMT-11:30");
Assert.assertEquals("[CS*123456789012345*0009*LZ,,-11.5]", encoder.encodeCommand(command));
+
}
}
diff --git a/test/org/traccar/protocol/XexunProtocolDecoderTest.java b/test/org/traccar/protocol/XexunProtocolDecoderTest.java
index 686d3f53f..8587ee295 100644
--- a/test/org/traccar/protocol/XexunProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/XexunProtocolDecoderTest.java
@@ -56,6 +56,12 @@ public class XexunProtocolDecoderTest extends ProtocolTest {
decoder = new XexunProtocolDecoder(new XexunProtocol(), true);
verifyPosition(decoder, text(
+ "171007160505,,GPRMC,160505.000,A,5323.4680,N,00252.4202,W,000.0,129.7,071017,,,A*7A,F,ACCStart, imei:864504031916915,10,41.1,F:4.28V,1,135,19824,234,15,0062,B7D5"));
+
+ verifyPosition(decoder, text(
+ "171007160525,,GPRMC,160525.000,A,5323.4680,N,00252.4202,W,000.0,129.7,071017,,,A*78,F,ACCStop, imei:864504031916915,10,41.1,F:4.28V,1,134,42896,234,15,0062,B7D5"));
+
+ verifyPosition(decoder, text(
"170505103845,TELKOMSEL,GPRMC,103845.000,A,0340.2482,N,09841.9689,E,0.00,68.23,050517,,,A*5D,F,ACC On, imei:013227002782161,05,-8.2,F:4.22V,1,141,44712,510,10,2BE5,EC47"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java b/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java
index 3cc0c22ec..35ca282b2 100644
--- a/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Xt2400ProtocolDecoderTest.java
@@ -10,6 +10,11 @@ public class Xt2400ProtocolDecoderTest extends ProtocolTest {
Xt2400ProtocolDecoder decoder = new Xt2400ProtocolDecoder(new Xt2400Protocol());
+ decoder.setConfig("\n:wycfg pcr[0] 001001030406070809570a13121714100565\n");
+
+ verifyPosition(decoder, binary(
+ "000a344f1f0259766ae002074289f8f1c4b200e80000026712068000130000029300883559464255524845364650323433343235"));
+
decoder.setConfig("\n:wycfg pcr[0] 000f01030406070809570a131217141005\n");
verifyPosition(decoder, binary(
diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java
index adcdf5875..4f7a4eb68 100644
--- a/test/org/traccar/reports/ReportUtilsTest.java
+++ b/test/org/traccar/reports/ReportUtilsTest.java
@@ -11,13 +11,14 @@ import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
import java.util.TimeZone;
import org.junit.Assert;
import org.junit.Test;
import org.traccar.BaseTest;
import org.traccar.model.Position;
-import org.traccar.reports.model.BaseReport;
import org.traccar.reports.model.StopReport;
import org.traccar.reports.model.TripReport;
import org.traccar.reports.model.TripsConfig;
@@ -69,7 +70,7 @@ public class ReportUtilsTest extends BaseTest {
@Test
public void testDetectTripsSimple() throws ParseException {
- Collection<Position> data = Arrays.asList(
+ List<Position> data = Arrays.asList(
position("2016-01-01 00:00:00.000", 0, 0),
position("2016-01-01 00:01:00.000", 0, 0),
position("2016-01-01 00:02:00.000", 10, 0),
@@ -79,14 +80,14 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:06:00.000", 0, 3000),
position("2016-01-01 00:07:00.000", 0, 3000));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, false, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
- Collection<? extends BaseReport> result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, true);
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
- assertNotNull(result);
- assertFalse(result.isEmpty());
+ assertNotNull(trips);
+ assertFalse(trips.isEmpty());
- TripReport itemTrip = (TripReport) result.iterator().next();
+ TripReport itemTrip = trips.iterator().next();
assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime());
@@ -95,12 +96,20 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
assertEquals(3000, itemTrip.getDistance(), 0.01);
- result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, false);
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
- assertNotNull(result);
- assertFalse(result.isEmpty());
+ assertNotNull(stops);
+ assertFalse(stops.isEmpty());
+
+ Iterator<StopReport> iterator = stops.iterator();
- StopReport itemStop = (StopReport) result.iterator().next();
+ StopReport itemStop = iterator.next();
+
+ assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
+ assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime());
+ assertEquals(120000, itemStop.getDuration());
+
+ itemStop = iterator.next();
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:07:00.000"), itemStop.getEndTime());
@@ -109,6 +118,126 @@ public class ReportUtilsTest extends BaseTest {
}
@Test
+ public void testDetectTripsSimpleWithIgnition() throws ParseException {
+
+ List<Position> data = Arrays.asList(
+ position("2016-01-01 00:00:00.000", 0, 0),
+ position("2016-01-01 00:01:00.000", 0, 0),
+ position("2016-01-01 00:02:00.000", 10, 0),
+ position("2016-01-01 00:03:00.000", 10, 1000),
+ position("2016-01-01 00:04:00.000", 10, 2000),
+ position("2016-01-01 00:05:00.000", 0, 3000),
+ position("2016-01-01 00:06:00.000", 0, 3000),
+ position("2016-01-01 00:07:00.000", 0, 3000));
+
+ data.get(5).set(Position.KEY_IGNITION, false);
+
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false, 0.01);
+
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+
+ assertNotNull(trips);
+ assertFalse(trips.isEmpty());
+
+ TripReport itemTrip = trips.iterator().next();
+
+ assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
+ assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime());
+ assertEquals(180000, itemTrip.getDuration());
+ assertEquals(10, itemTrip.getAverageSpeed(), 0.01);
+ assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
+ assertEquals(3000, itemTrip.getDistance(), 0.01);
+
+ trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+
+ assertNotNull(trips);
+ assertFalse(trips.isEmpty());
+
+ itemTrip = trips.iterator().next();
+
+ assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
+ assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime());
+ assertEquals(180000, itemTrip.getDuration());
+ assertEquals(10, itemTrip.getAverageSpeed(), 0.01);
+ assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
+ assertEquals(3000, itemTrip.getDistance(), 0.01);
+
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+
+ assertNotNull(stops);
+ assertFalse(stops.isEmpty());
+
+ Iterator<StopReport> iterator = stops.iterator();
+
+ StopReport itemStop = iterator.next();
+
+ assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
+ assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime());
+ assertEquals(120000, itemStop.getDuration());
+
+ itemStop = iterator.next();
+
+ assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getStartTime());
+ assertEquals(date("2016-01-01 00:07:00.000"), itemStop.getEndTime());
+ assertEquals(120000, itemStop.getDuration());
+
+ }
+
+ @Test
+ public void testDetectTripsWithFluctuation() throws ParseException {
+
+ List<Position> data = Arrays.asList(
+ position("2016-01-01 00:00:00.000", 0, 0),
+ position("2016-01-01 00:01:00.000", 0, 0),
+ position("2016-01-01 00:02:00.000", 10, 0),
+ position("2016-01-01 00:03:00.000", 10, 1000),
+ position("2016-01-01 00:04:00.000", 10, 2000),
+ position("2016-01-01 00:05:00.000", 10, 3000),
+ position("2016-01-01 00:06:00.000", 10, 4000),
+ position("2016-01-01 00:07:00.000", 0, 5000),
+ position("2016-01-01 00:08:00.000", 10, 6000),
+ position("2016-01-01 00:09:00.000", 0, 7000),
+ position("2016-01-01 00:10:00.000", 0, 7000),
+ position("2016-01-01 00:11:00.000", 0, 7000));
+
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
+
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+
+ assertNotNull(trips);
+ assertFalse(trips.isEmpty());
+
+ TripReport itemTrip = trips.iterator().next();
+
+ assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
+ assertEquals(date("2016-01-01 00:09:00.000"), itemTrip.getEndTime());
+ assertEquals(420000, itemTrip.getDuration());
+ assertEquals(8.57, itemTrip.getAverageSpeed(), 0.01);
+ assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
+ assertEquals(7000, itemTrip.getDistance(), 0.01);
+
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+
+ assertNotNull(stops);
+ assertFalse(stops.isEmpty());
+
+ Iterator<StopReport> iterator = stops.iterator();
+
+ StopReport itemStop = iterator.next();
+
+ assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
+ assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime());
+ assertEquals(120000, itemStop.getDuration());
+
+ itemStop = iterator.next();
+
+ assertEquals(date("2016-01-01 00:09:00.000"), itemStop.getStartTime());
+ assertEquals(date("2016-01-01 00:11:00.000"), itemStop.getEndTime());
+ assertEquals(120000, itemStop.getDuration());
+
+ }
+
+ @Test
public void testDetectStopsOnly() throws ParseException {
Collection<Position> data = Arrays.asList(
@@ -119,14 +248,14 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 1, 0),
position("2016-01-01 00:05:00.000", 0, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, false, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<? extends BaseReport> result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, false);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
- StopReport itemStop = (StopReport) result.iterator().next();
+ StopReport itemStop = result.iterator().next();
assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime());
@@ -145,34 +274,21 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 1, 0),
position("2016-01-01 00:05:00.000", 2, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, false, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<? extends BaseReport> result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, false);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
- StopReport itemStop = (StopReport) result.iterator().next();
+ StopReport itemStop = result.iterator().next();
assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:04:00.000"), itemStop.getEndTime());
assertEquals(240000, itemStop.getDuration());
- tripsConfig.setGreedyParking(true);
-
- result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, false);
-
- assertNotNull(result);
- assertFalse(result.isEmpty());
-
- itemStop = (StopReport) result.iterator().next();
-
- assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
- assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime());
- assertEquals(300000, itemStop.getDuration());
-
}
-
+
@Test
public void testDetectStopsStartedFromTrip() throws ParseException {
@@ -184,18 +300,18 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 0, 0),
position("2016-01-01 00:05:00.000", 0, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, false, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<? extends BaseReport> result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, false);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
- StopReport itemStop = (StopReport) result.iterator().next();
+ StopReport itemStop = result.iterator().next();
- assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
+ assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime());
- assertEquals(300000, itemStop.getDuration());
+ assertEquals(180000, itemStop.getDuration());
}
@@ -210,9 +326,9 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 5, 0),
position("2016-01-01 00:05:00.000", 5, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, false, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<? extends BaseReport> result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, false);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertTrue(result.isEmpty());
@@ -232,14 +348,14 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:24:00.000", 5, 800),
position("2016-01-01 00:25:00.000", 5, 900));
- TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, false, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false, 0.01);
- Collection<? extends BaseReport> result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, true);
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
- assertNotNull(result);
- assertFalse(result.isEmpty());
+ assertNotNull(trips);
+ assertFalse(trips.isEmpty());
- TripReport itemTrip = (TripReport) result.iterator().next();
+ TripReport itemTrip = trips.iterator().next();
assertEquals(date("2016-01-01 00:00:00.000"), itemTrip.getStartTime());
assertEquals(date("2016-01-01 00:04:00.000"), itemTrip.getEndTime());
@@ -248,16 +364,16 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(7, itemTrip.getMaxSpeed(), 0.01);
assertEquals(600, itemTrip.getDistance(), 0.01);
- result = ReportUtils.detectTripsAndStops(tripsConfig, false, 0.01, data, false);
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
- assertNotNull(result);
- assertFalse(result.isEmpty());
+ assertNotNull(stops);
+ assertFalse(stops.isEmpty());
- StopReport itemStop = (StopReport) result.iterator().next();
+ StopReport itemStop = stops.iterator().next();
assertEquals(date("2016-01-01 00:04:00.000"), itemStop.getStartTime());
- assertEquals(date("2016-01-01 00:23:00.000"), itemStop.getEndTime());
- assertEquals(1140000, itemStop.getDuration());
+ assertEquals(date("2016-01-01 00:24:00.000"), itemStop.getEndTime());
+ assertEquals(1200000, itemStop.getDuration());
}
}