aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
diff options
context:
space:
mode:
authorValerii Vyshniak <valeravi@vi-soft.com.ua>2017-11-23 12:23:05 +0100
committerValerii Vyshniak <valeravi@vi-soft.com.ua>2017-11-23 12:23:05 +0100
commit3efb847ba93f5983cb8235d7b14ae6b116417407 (patch)
treecd6564be739301124ab21f6ec57c056dfd847ec4 /test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
parentd0a55d5a5c52e2f668e7c74952fca59019b0c405 (diff)
downloadtrackermap-server-3efb847ba93f5983cb8235d7b14ae6b116417407.tar.gz
trackermap-server-3efb847ba93f5983cb8235d7b14ae6b116417407.tar.bz2
trackermap-server-3efb847ba93f5983cb8235d7b14ae6b116417407.zip
Added possibility to test with different Device attributes
Diffstat (limited to 'test/org/traccar/protocol/Tk103ProtocolEncoderTest.java')
-rw-r--r--test/org/traccar/protocol/Tk103ProtocolEncoderTest.java65
1 files changed, 58 insertions, 7 deletions
diff --git a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java
index 0c16ccee6..a58cd9ee1 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 {
@@ -31,6 +33,12 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Assert.assertEquals("(123456789012345AP00)", encoder.encodeCommand(command));
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+ command.setDeviceId(device.getId());
+
+ Assert.assertEquals("[begin]sms2,*getposl*,[end]", encoder.encodeCommand(command));
+
}
@Test
@@ -45,6 +53,12 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Assert.assertEquals("(123456789012345AR00003C0000)", encoder.encodeCommand(command));
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+ command.setDeviceId(device.getId());
+
+ Assert.assertEquals("[begin]sms2,*routetrack*99*,[end]", encoder.encodeCommand(command));
+
}
@Test
@@ -58,6 +72,12 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Assert.assertEquals("(123456789012345AR0000000000)", encoder.encodeCommand(command));
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+ command.setDeviceId(device.getId());
+
+ Assert.assertEquals("[begin]sms2,*routetrackoff*,[end]", encoder.encodeCommand(command));
+
}
@Test
@@ -71,6 +91,12 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Assert.assertEquals("(123456789012345AP07)", encoder.encodeCommand(command));
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+ command.setDeviceId(device.getId());
+
+ Assert.assertEquals("[begin]sms2,*about*,[end]", encoder.encodeCommand(command));
+
}
@Test
@@ -84,6 +110,12 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Assert.assertEquals("(123456789012345AT00)", encoder.encodeCommand(command));
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+ command.setDeviceId(device.getId());
+
+ Assert.assertEquals("[begin]sms2,88888888,[end]", encoder.encodeCommand(command));
+
}
@Test
@@ -104,8 +136,11 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder();
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+
Command command = new Command();
- command.setDeviceId(1);
+ command.setDeviceId(device.getId());
command.setType(Command.TYPE_IDENTIFICATION);
Assert.assertEquals("[begin]sms2,999999,[end]", encoder.encodeCommand(command));
@@ -117,8 +152,11 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder();
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+
Command command = new Command();
- command.setDeviceId(1);
+ command.setDeviceId(device.getId());
command.setType(Command.TYPE_ALARM_SOS);
command.set(Command.KEY_ENABLE, true);
@@ -131,8 +169,11 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder();
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+
Command command = new Command();
- command.setDeviceId(1);
+ command.setDeviceId(device.getId());
command.setType(Command.TYPE_ALARM_SOS);
command.set(Command.KEY_ENABLE, false);
@@ -145,8 +186,11 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder();
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+
Command command = new Command();
- command.setDeviceId(1);
+ command.setDeviceId(device.getId());
command.setType(Command.TYPE_CUSTOM);
command.set(Command.KEY_DATA, "any text is ok");
@@ -159,8 +203,11 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder();
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+
Command command = new Command();
- command.setDeviceId(1);
+ command.setDeviceId(device.getId());
command.setType(Command.TYPE_SET_CONNECTION);
command.set(Command.KEY_SERVER, "1.2.3.4");
command.set(Command.KEY_PORT, "5555");
@@ -174,13 +221,17 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest {
Tk103ProtocolEncoder encoder = new Tk103ProtocolEncoder();
+ Device device = TestIdentityManager.createTestDevice();
+ device.set("tk103.alternative", true);
+ device.set(Command.KEY_DEVICE_PASSWORD, "232323");
+
Command command = new Command();
- command.setDeviceId(1);
+ command.setDeviceId(device.getId());
command.setType(Command.TYPE_SOS_NUMBER);
command.set(Command.KEY_INDEX, "0");
command.set(Command.KEY_PHONE, "+55555555555");
- Assert.assertEquals("[begin]sms2,*master*123456*+55555555555*,[end]", encoder.encodeCommand(command));
+ Assert.assertEquals("[begin]sms2,*master*232323*+55555555555*,[end]", encoder.encodeCommand(command));
}