aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/ProtocolEncoderTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-06 14:57:47 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-06 14:57:47 +1300
commitc2fd8d145eb45ceb96fad3c84605e8c39adf81fe (patch)
tree48e13b0cf37bf6bb2f6bdb2be3d591f48b1a9b3a /test/org/traccar/ProtocolEncoderTest.java
parent1e2d7682880e57cde051d2e54c0f792aa3fc5ec3 (diff)
downloadtraccar-server-c2fd8d145eb45ceb96fad3c84605e8c39adf81fe.tar.gz
traccar-server-c2fd8d145eb45ceb96fad3c84605e8c39adf81fe.tar.bz2
traccar-server-c2fd8d145eb45ceb96fad3c84605e8c39adf81fe.zip
Combine decoder and encoder test utils
Diffstat (limited to 'test/org/traccar/ProtocolEncoderTest.java')
-rw-r--r--test/org/traccar/ProtocolEncoderTest.java52
1 files changed, 0 insertions, 52 deletions
diff --git a/test/org/traccar/ProtocolEncoderTest.java b/test/org/traccar/ProtocolEncoderTest.java
deleted file mode 100644
index e8b5bb4eb..000000000
--- a/test/org/traccar/ProtocolEncoderTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.traccar;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Assert;
-import org.traccar.model.Command;
-
-import javax.xml.bind.DatatypeConverter;
-import java.nio.ByteOrder;
-import java.nio.charset.Charset;
-
-public class ProtocolEncoderTest {
-
- private String concatenateStrings(String... strings) {
- StringBuilder builder = new StringBuilder();
- for (String s : strings) {
- builder.append(s);
- }
- return builder.toString();
- }
-
- protected ChannelBuffer binary(String... data) {
- return binary(ByteOrder.BIG_ENDIAN, data);
- }
-
- protected ChannelBuffer binary(ByteOrder endianness, String... data) {
- return ChannelBuffers.wrappedBuffer(
- endianness, DatatypeConverter.parseHexBinary(concatenateStrings(data)));
- }
-
- protected String text(String... data) {
- return concatenateStrings(data);
- }
-
- protected ChannelBuffer buffer(String... data) {
- return ChannelBuffers.copiedBuffer(concatenateStrings(data), Charset.defaultCharset());
- }
-
- protected void verifyCommand(
- BaseProtocolEncoder encoder, Command command, ChannelBuffer expected) throws Exception {
- verifyDecodedCommand(encoder.encodeCommand(command), expected);
- }
-
- private void verifyDecodedCommand(Object decodedObject, ChannelBuffer expected) {
-
- Assert.assertNotNull("command is null", decodedObject);
- Assert.assertTrue("not a buffer", decodedObject instanceof ChannelBuffer);
- Assert.assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) decodedObject));
-
- }
-
-}