aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/ProtocolTest.java
diff options
context:
space:
mode:
authorIvan Muratov <binakot@gmail.com>2017-10-24 14:52:48 +0300
committerGitHub <noreply@github.com>2017-10-24 14:52:48 +0300
commitdb02157dbb29539dda4b51a5e8b317293cfc536c (patch)
treeb974f082172406e16a92cb9da8136ef856f571a5 /test/org/traccar/ProtocolTest.java
parent09d3cf2b5416327700ad22b652cf4a0dca09aaf2 (diff)
parent96e15853b9c28bd31295ca2c014e226e4a50aaa1 (diff)
downloadtrackermap-server-db02157dbb29539dda4b51a5e8b317293cfc536c.tar.gz
trackermap-server-db02157dbb29539dda4b51a5e8b317293cfc536c.tar.bz2
trackermap-server-db02157dbb29539dda4b51a5e8b317293cfc536c.zip
Merge branch 'master' into master
Diffstat (limited to 'test/org/traccar/ProtocolTest.java')
-rw-r--r--test/org/traccar/ProtocolTest.java32
1 files changed, 26 insertions, 6 deletions
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));
}