diff options
Diffstat (limited to 'test/org/traccar/ProtocolTest.java')
-rw-r--r-- | test/org/traccar/ProtocolTest.java | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 75a98000b..e6a718d22 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -1,16 +1,16 @@ package org.traccar; -import org.jboss.netty.buffer.ChannelBuffer; -import org.jboss.netty.buffer.ChannelBuffers; -import org.jboss.netty.handler.codec.http.DefaultHttpRequest; -import org.jboss.netty.handler.codec.http.HttpMethod; -import org.jboss.netty.handler.codec.http.HttpVersion; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; +import io.netty.handler.codec.http.DefaultFullHttpRequest; +import io.netty.handler.codec.http.HttpMethod; +import io.netty.handler.codec.http.HttpVersion; import org.traccar.helper.DataConverter; import org.traccar.model.CellTower; import org.traccar.model.Command; import org.traccar.model.Position; -import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.text.DateFormat; import java.text.ParseException; @@ -50,35 +50,28 @@ public class ProtocolTest extends BaseTest { 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, DataConverter.parseHex(concatenateStrings(data))); + protected ByteBuf binary(String... data) { + return Unpooled.wrappedBuffer(DataConverter.parseHex(concatenateStrings(data))); } protected String text(String... data) { return concatenateStrings(data); } - protected ChannelBuffer buffer(String... data) { - return ChannelBuffers.copiedBuffer(concatenateStrings(data), StandardCharsets.ISO_8859_1); + protected ByteBuf buffer(String... data) { + return Unpooled.copiedBuffer(concatenateStrings(data), StandardCharsets.ISO_8859_1); } - protected DefaultHttpRequest request(String url) { + protected DefaultFullHttpRequest request(String url) { return request(HttpMethod.GET, url); } - protected DefaultHttpRequest request(HttpMethod method, String url) { - return new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, url); + protected DefaultFullHttpRequest request(HttpMethod method, String url) { + return new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, url); } - protected DefaultHttpRequest request(HttpMethod method, String url, ChannelBuffer data) { - DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, url); - request.setContent(data); - return request; + protected DefaultFullHttpRequest request(HttpMethod method, String url, ByteBuf data) { + return new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, url, data); } protected void verifyNotNull(BaseProtocolDecoder decoder, Object object) throws Exception { @@ -268,6 +261,10 @@ public class ProtocolTest extends BaseTest { assertTrue(attributes.get(Position.KEY_ROAMING) instanceof Boolean); } + if (attributes.containsKey(Position.KEY_HOURS)) { + assertTrue(attributes.get(Position.KEY_HOURS) instanceof Number); + } + if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) { for (CellTower cellTower : position.getNetwork().getCellTowers()) { checkInteger(cellTower.getMobileCountryCode(), 0, 999); @@ -288,14 +285,14 @@ public class ProtocolTest extends BaseTest { } protected void verifyCommand( - BaseProtocolEncoder encoder, Command command, ChannelBuffer expected) throws Exception { + BaseProtocolEncoder encoder, Command command, ByteBuf expected) throws Exception { verifyFrame(expected, encoder.encodeCommand(command)); } - protected void verifyFrame(ChannelBuffer expected, Object object) { + protected void verifyFrame(ByteBuf expected, Object object) { assertNotNull("buffer is null", object); - assertTrue("not a buffer", object instanceof ChannelBuffer); - assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) object)); + assertTrue("not a buffer", object instanceof ByteBuf); + assertEquals(ByteBufUtil.hexDump(expected), ByteBufUtil.hexDump((ByteBuf) object)); } } |