aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/protocol/WatchProtocolDecoderTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-18 13:43:41 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-18 13:43:41 -0800
commite6b1c27e6aba0e338a278a09d5e085a7d53d4f52 (patch)
treec888d13c0a0f1b528eac803c0000851d49db51ec /test/org/traccar/protocol/WatchProtocolDecoderTest.java
parent0e209e80f03e72095e5b449679925066b01403d2 (diff)
downloadtrackermap-server-e6b1c27e6aba0e338a278a09d5e085a7d53d4f52.tar.gz
trackermap-server-e6b1c27e6aba0e338a278a09d5e085a7d53d4f52.tar.bz2
trackermap-server-e6b1c27e6aba0e338a278a09d5e085a7d53d4f52.zip
Minor watch tests cleanup
Diffstat (limited to 'test/org/traccar/protocol/WatchProtocolDecoderTest.java')
-rw-r--r--test/org/traccar/protocol/WatchProtocolDecoderTest.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
index 51846f51a..539e63253 100644
--- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java
@@ -4,14 +4,9 @@ import io.netty.buffer.ByteBuf;
import org.junit.Test;
import org.traccar.Context;
import org.traccar.ProtocolTest;
-import org.traccar.database.MediaManager;
import org.traccar.model.Position;
-import java.util.HashMap;
-import java.util.Map;
-
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
public class WatchProtocolDecoderTest extends ProtocolTest {
@@ -111,19 +106,23 @@ public class WatchProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, buffer(
"[ZJ*014111001350304*0038*008a*UD,070318,021027,V,00.000000,N,000.000000,E,0,0,0,0,100,18,1000,50,00000000,4,255,460,0,9346,5223,42,9346,5214,20,9784,4083,11,9346,5221,5]"));
+
}
@Test
public void testDecodeVoiceMessage() throws Exception {
+
WatchProtocolDecoder decoder = new WatchProtocolDecoder(null);
verifyNull(decoder.decode(null, null, buffer("[CS*1234567890*0004*TK,1]")));
- String hex = "7d5b5d2c2aff";
- Object decodedObject = decoder.decode(null, null, concatenateBuffers(buffer("[CS*1234567890*000e*TK,#!AMR"), binary(hex), buffer("]")));
- assertTrue("not a position", decodedObject instanceof Position);
- Position position = (Position) decodedObject;
- assertEquals("1234567890/mock.amr", position.getAttributes().get("audio"));
- verifyFrame(concatenateBuffers(buffer("#!AMR"), binary(hex)), ((MockMediaManager) Context.getMediaManager()).readFile("1234567890/mock.amr"));
+ ByteBuf data = binary("7d5b5d2c2aff");
+
+ Object decodedObject = decoder.decode(null, null, concatenateBuffers(buffer("[CS*1234567890*000e*TK,#!AMR"), data.resetReaderIndex(), buffer("]")));
+ assertEquals("1234567890/mock.amr", ((Position) decodedObject).getAttributes().get("audio"));
+
+ verifyFrame(concatenateBuffers(buffer("#!AMR"), data.resetReaderIndex()), ((MockMediaManager) Context.getMediaManager()).readFile("1234567890/mock.amr"));
+
}
+
}