aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2022-09-21 09:57:52 -0700
committerGitHub <noreply@github.com>2022-09-21 09:57:52 -0700
commitd5b1385596f79da2514ea7cccf27e9bdeebcacae (patch)
treef7b2d44f09dee52c09c2c7e2384f0c27f1e65fa1 /src/test/java/org
parent561647947118a86256dbb584f6da450334462739 (diff)
parent7aa230b9ddcd5540e7ff9c9b3d9bcf5119175c46 (diff)
downloadtrackermap-server-d5b1385596f79da2514ea7cccf27e9bdeebcacae.tar.gz
trackermap-server-d5b1385596f79da2514ea7cccf27e9bdeebcacae.tar.bz2
trackermap-server-d5b1385596f79da2514ea7cccf27e9bdeebcacae.zip
Merge pull request #4912 from stefanclark/Xexun2Encoder
Implement Xexun2 encoder
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java4
-rw-r--r--src/test/java/org/traccar/protocol/Xexun2FrameEncoderTest.java20
-rw-r--r--src/test/java/org/traccar/protocol/Xexun2ProtocolEncoderTest.java29
3 files changed, 53 insertions, 0 deletions
diff --git a/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java
index 7209a423b..34437862c 100644
--- a/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java
+++ b/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java
@@ -14,6 +14,10 @@ public class Xexun2FrameDecoderTest extends ProtocolTest {
binary("faaf0014000286147503139003400032f2b001002f4260b0d6a0008019104a3378323130333135317c323130333132303100704020308715758089502023015648643670faaf"),
decoder.decode(null, null, binary("faaf0014000286147503139003400032f2b001002f4260b0d6a0008019104a3378323130333135317c323130333132303100704020308715758089502023015648643670faaf")));
+ verifyFrame(
+ binary("FAAF123456FAAF123456FBBF123456FAAF"),
+ decoder.decode(null, null, binary("FAAF123456FBBF01123456FBBF02123456FAAF")));
+
}
}
diff --git a/src/test/java/org/traccar/protocol/Xexun2FrameEncoderTest.java b/src/test/java/org/traccar/protocol/Xexun2FrameEncoderTest.java
new file mode 100644
index 000000000..54a8aaa14
--- /dev/null
+++ b/src/test/java/org/traccar/protocol/Xexun2FrameEncoderTest.java
@@ -0,0 +1,20 @@
+package org.traccar.protocol;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+
+public class Xexun2FrameEncoderTest extends ProtocolTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ Xexun2FrameEncoder encoder = new Xexun2FrameEncoder();
+
+ ByteBuf result = Unpooled.buffer();
+ encoder.encode(null, binary("FAAF123456FAAF123456FBBF123456FAAF"), result);
+ verifyFrame(binary("FAAF123456FBBF01123456FBBF02123456FAAF"), result);
+ }
+
+}
diff --git a/src/test/java/org/traccar/protocol/Xexun2ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Xexun2ProtocolEncoderTest.java
new file mode 100644
index 000000000..483bc85fa
--- /dev/null
+++ b/src/test/java/org/traccar/protocol/Xexun2ProtocolEncoderTest.java
@@ -0,0 +1,29 @@
+package org.traccar.protocol;
+
+import org.junit.Test;
+import org.traccar.ProtocolTest;
+import org.traccar.model.Command;
+
+public class Xexun2ProtocolEncoderTest extends ProtocolTest {
+
+ @Test
+ public void testEncode() throws Exception {
+
+ var encoder = inject(new Xexun2ProtocolEncoder(null));
+
+ Command command;
+
+ command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_POWER_OFF);
+ verifyCommand(encoder, command, binary("FAAF0007000112345678901234500004FEBC6F663D31FAAF"));
+
+ command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_POSITION_PERIODIC);
+ command.set(Command.KEY_FREQUENCY, 150);
+ verifyCommand(encoder, command, binary("FAAF0007000112345678901234500015F90E747261636B696E675F73656E643D3135302C313530FAAF"));
+
+ }
+
+}