diff options
Diffstat (limited to 'test/org/traccar/ProtocolTest.java')
-rw-r--r-- | test/org/traccar/ProtocolTest.java | 32 |
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)); } |