aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-12-07 15:01:12 +1300
committerGitHub <noreply@github.com>2017-12-07 15:01:12 +1300
commit4d903ef0ef21cd6575ed9a55426b18f6b94e63ef (patch)
treed3467073a73fec96cccae3b1c864a6adcf23e669 /test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
parente3f7a20c29a38dae64ffe0ab7724cc9df29a03f1 (diff)
parentb9c78ab2c6ac9f2e7598743114864aae04404ac1 (diff)
downloadtrackermap-server-4d903ef0ef21cd6575ed9a55426b18f6b94e63ef.tar.gz
trackermap-server-4d903ef0ef21cd6575ed9a55426b18f6b94e63ef.tar.bz2
trackermap-server-4d903ef0ef21cd6575ed9a55426b18f6b94e63ef.zip
Merge pull request #3643 from ValeraVi/t580w
T580w protocol implementation
Diffstat (limited to 'test/org/traccar/protocol/Tk103ProtocolEncoderTest.java')
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolEncoderTest.java153
1 files changed, 153 insertions, 0 deletions
diff --git a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
index afc3b2387..a99889e3b 100644
--- a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
+++ b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
@@ -3,7 +3,9 @@ package org.traccar.protocol;
import org.junit.Assert;
import org.junit.Test;
import org.traccar.ProtocolTest;
+import org.traccar.TestIdentityManager;
import org.traccar.model.Command;
+import org.traccar.model.Device;
public class Tk103ProtocolEncoderTest extends ProtocolTest {
@@ -99,4 +101,155 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
}
+ @Test
+ public void testEncodePositionSingleAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_POSITION_SINGLE);
+
+ Assert.assertEquals("[begin]sms2,*getposl*,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodePositionPeriodicAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_POSITION_PERIODIC);
+
+ Assert.assertEquals("[begin]sms2,*routetrack*99*,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodePositionStopAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_POSITION_STOP);
+
+ Assert.assertEquals("[begin]sms2,*routetrackoff*,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeGetVersionAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_GET_VERSION);
+
+ Assert.assertEquals("[begin]sms2,*about*,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeRebootDeviceAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_REBOOT_DEVICE);
+
+ Assert.assertEquals("[begin]sms2,88888888,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeIdentificationAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_IDENTIFICATION);
+
+ Assert.assertEquals("[begin]sms2,999999,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeSosOnAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_ALARM_SOS);
+ command.set(Command.KEY_ENABLE, true);
+
+ Assert.assertEquals("[begin]sms2,*soson*,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeSosOffAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_ALARM_SOS);
+ command.set(Command.KEY_ENABLE, false);
+
+ Assert.assertEquals("[begin]sms2,*sosoff*,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeCustomAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_CUSTOM);
+ command.set(Command.KEY_DATA, "any text is ok");
+
+ Assert.assertEquals("[begin]sms2,any text is ok,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeSetConnectionAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_SET_CONNECTION);
+ command.set(Command.KEY_SERVER, "1.2.3.4");
+ command.set(Command.KEY_PORT, "5555");
+
+ Assert.assertEquals("[begin]sms2,*setip*1*2*3*4*5555*,[end]", encoder.encodeCommand(command));
+
+ }
+
+ @Test
+ public void testEncodeSosNumberAlternative() throws Exception {
+
+ Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder(true);
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_SOS_NUMBER);
+ command.set(Command.KEY_INDEX, "0");
+ command.set(Command.KEY_PHONE, "+55555555555");
+ command.set(Command.KEY_DEVICE_PASSWORD, "232323");
+
+ Assert.assertEquals("[begin]sms2,*master*232323*+55555555555*,[end]", encoder.encodeCommand(command));
+
+ }
+
}