diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-02-18 13:18:28 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-18 13:18:28 -0800 |
commit | 0e209e80f03e72095e5b449679925066b01403d2 (patch) | |
tree | 881ab37ce5867fd8358d4bdf0195824c47e26be2 | |
parent | 774d560ecb5f8da9e64059a4d25622c4fba55bf2 (diff) | |
parent | c82be0541481955a0832948574244f31757f7067 (diff) | |
download | trackermap-server-0e209e80f03e72095e5b449679925066b01403d2.tar.gz trackermap-server-0e209e80f03e72095e5b449679925066b01403d2.tar.bz2 trackermap-server-0e209e80f03e72095e5b449679925066b01403d2.zip |
Merge pull request #4221 from flocsy/8bit-voice-message
Fixed 8bit voice message
-rw-r--r-- | src/org/traccar/Context.java | 3 | ||||
-rw-r--r-- | src/org/traccar/protocol/WatchFrameDecoder.java | 12 | ||||
-rw-r--r-- | src/org/traccar/protocol/WatchProtocol.java | 3 | ||||
-rw-r--r-- | src/org/traccar/protocol/WatchProtocolDecoder.java | 36 | ||||
-rw-r--r-- | src/org/traccar/protocol/WatchProtocolEncoder.java | 77 | ||||
-rw-r--r-- | test/org/traccar/BaseTest.java | 29 | ||||
-rw-r--r-- | test/org/traccar/ProtocolTest.java | 12 | ||||
-rw-r--r-- | test/org/traccar/protocol/WatchFrameDecoderTest.java | 4 | ||||
-rw-r--r-- | test/org/traccar/protocol/WatchProtocolDecoderTest.java | 24 | ||||
-rw-r--r-- | test/org/traccar/protocol/WatchProtocolEncoderTest.java | 31 |
10 files changed, 164 insertions, 67 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 95d433795..d679842cd 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -508,12 +508,13 @@ public final class Context { Context.getConfig().getBoolean("event.overspeed.preferLowest")); } - public static void init(IdentityManager testIdentityManager) { + public static void init(IdentityManager testIdentityManager, MediaManager testMediaManager) { config = new Config(); objectMapper = new ObjectMapper(); objectMapper.registerModule(new JSR353Module()); client = ClientBuilder.newClient().register(new ObjectMapperContextResolver()); identityManager = testIdentityManager; + mediaManager = testMediaManager; } public static <T extends BaseModel> BaseObjectManager<T> getManager(Class<T> clazz) { diff --git a/src/org/traccar/protocol/WatchFrameDecoder.java b/src/org/traccar/protocol/WatchFrameDecoder.java index b2ac5b4f7..f99bd52e2 100644 --- a/src/org/traccar/protocol/WatchFrameDecoder.java +++ b/src/org/traccar/protocol/WatchFrameDecoder.java @@ -31,9 +31,10 @@ public class WatchFrameDecoder extends BaseFrameDecoder { if (endIndex > 0) { ByteBuf frame = Unpooled.buffer(); while (buf.readerIndex() < endIndex) { - byte b = buf.readByte(); - if (b == '}') { - switch (buf.readByte()) { + byte b1 = buf.readByte(); + if (b1 == '}') { + byte b2 = buf.readByte(); + switch (b2) { case 0x01: frame.writeByte('}'); break; @@ -50,10 +51,11 @@ public class WatchFrameDecoder extends BaseFrameDecoder { frame.writeByte('*'); break; default: - throw new IllegalArgumentException(); + throw new IllegalArgumentException(String.format( + "unexpected byte at %d: 0x%02x", buf.readerIndex() - 1, b2)); } } else { - frame.writeByte(b); + frame.writeByte(b1); } } return frame; diff --git a/src/org/traccar/protocol/WatchProtocol.java b/src/org/traccar/protocol/WatchProtocol.java index 5d923106d..b8c990b84 100644 --- a/src/org/traccar/protocol/WatchProtocol.java +++ b/src/org/traccar/protocol/WatchProtocol.java @@ -20,8 +20,6 @@ import org.traccar.PipelineBuilder; import org.traccar.TrackerServer; import org.traccar.model.Command; -import io.netty.handler.codec.string.StringEncoder; - public class WatchProtocol extends BaseProtocol { public WatchProtocol() { @@ -45,7 +43,6 @@ public class WatchProtocol extends BaseProtocol { @Override protected void addProtocolHandlers(PipelineBuilder pipeline) { pipeline.addLast(new WatchFrameDecoder()); - pipeline.addLast(new StringEncoder()); pipeline.addLast(new WatchProtocolEncoder()); pipeline.addLast(new WatchProtocolDecoder(WatchProtocol.this)); } diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java index 78b190030..70b207e9b 100644 --- a/src/org/traccar/protocol/WatchProtocolDecoder.java +++ b/src/org/traccar/protocol/WatchProtocolDecoder.java @@ -16,7 +16,10 @@ package org.traccar.protocol; import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import io.netty.channel.Channel; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; import org.traccar.DeviceSession; @@ -38,6 +41,8 @@ import java.util.regex.Pattern; public class WatchProtocolDecoder extends BaseProtocolDecoder { + private static final Logger LOGGER = LoggerFactory.getLogger(WatchProtocolDecoder.class); + public WatchProtocolDecoder(Protocol protocol) { super(protocol); } @@ -64,13 +69,16 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { private void sendResponse(Channel channel, String id, String index, String content) { if (channel != null) { + String response; if (index != null) { - channel.writeAndFlush(new NetworkMessage(String.format("[%s*%s*%s*%04x*%s]", - manufacturer, id, index, content.length(), content), channel.remoteAddress())); + response = String.format("[%s*%s*%s*%04x*%s]", + manufacturer, id, index, content.length(), content); } else { - channel.writeAndFlush(new NetworkMessage(String.format("[%s*%s*%04x*%s]", - manufacturer, id, content.length(), content), channel.remoteAddress())); + response = String.format("[%s*%s*%04x*%s]", + manufacturer, id, content.length(), content); } + ByteBuf buf = Unpooled.copiedBuffer(response, StandardCharsets.US_ASCII); + channel.writeAndFlush(new NetworkMessage(buf, channel.remoteAddress())); } } @@ -180,9 +188,9 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { ByteBuf buf = (ByteBuf) msg; - buf.skipBytes(1); // header + buf.skipBytes(1); // '[' header manufacturer = buf.readSlice(2).toString(StandardCharsets.US_ASCII); - buf.skipBytes(1); // delimiter + buf.skipBytes(1); // '*' delimiter int idIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); String id = buf.readSlice(idIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII); @@ -191,7 +199,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { return null; } - buf.skipBytes(1); // delimiter + buf.skipBytes(1); // '*' delimiter String index = null; int contentIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*'); @@ -200,13 +208,13 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { int indexLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*') - buf.readerIndex(); hasIndex = true; index = buf.readSlice(indexLength).toString(StandardCharsets.US_ASCII); - buf.skipBytes(1); // delimiter + buf.skipBytes(1); // '*' delimiter } buf.skipBytes(4); // length - buf.skipBytes(1); // delimiter + buf.skipBytes(1); // '*' delimiter - buf.writerIndex(buf.writerIndex() - 1); // ignore ending + buf.writerIndex(buf.writerIndex() - 1); // ']' ignore ending contentIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ','); if (contentIndex < 0) { @@ -296,6 +304,14 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder { } else if (type.equals("TK")) { + if (buf.readableBytes() == 1) { + byte result = buf.readByte(); + if (result != '1') { + LOGGER.warn(type + "," + result); + } + return null; + } + Position position = new Position(getProtocolName()); position.setDeviceId(deviceSession.getDeviceId()); diff --git a/src/org/traccar/protocol/WatchProtocolEncoder.java b/src/org/traccar/protocol/WatchProtocolEncoder.java index 431b0455a..df29d83a9 100644 --- a/src/org/traccar/protocol/WatchProtocolEncoder.java +++ b/src/org/traccar/protocol/WatchProtocolEncoder.java @@ -15,6 +15,8 @@ */ package org.traccar.protocol; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import io.netty.channel.Channel; import org.traccar.StringProtocolEncoder; import org.traccar.helper.DataConverter; @@ -38,13 +40,21 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin return fmt.format(offset); } else if (key.equals(Command.KEY_MESSAGE)) { return DataConverter.printHex(value.toString().getBytes(StandardCharsets.UTF_16BE)); + } else if (key.equals(Command.KEY_ENABLE)) { + return (boolean) value ? "1" : "0"; } return null; } - protected String formatCommand(Channel channel, Command command, String format, String... keys) { + protected ByteBuf formatTextCommand(Channel channel, Command command, String format, String... keys) { + String content = formatCommand(command, format, this, keys); + ByteBuf buf = Unpooled.copiedBuffer(content, StandardCharsets.US_ASCII); + + return formatBinaryCommand(channel, command, "", buf); + } + protected ByteBuf formatBinaryCommand(Channel channel, Command command, String textPrefix, ByteBuf data) { boolean hasIndex = false; String manufacturer = "CS"; if (channel != null) { @@ -55,23 +65,24 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin } } - String content = formatCommand(command, format, this, keys); - + ByteBuf buf = Unpooled.buffer(); + buf.writeByte('['); + buf.writeCharSequence(manufacturer, StandardCharsets.US_ASCII); + buf.writeByte('*'); + buf.writeCharSequence(getUniqueId(command.getDeviceId()), StandardCharsets.US_ASCII); + buf.writeByte('*'); if (hasIndex) { - return String.format("[%s*%s*0001*%04x*%s]", - manufacturer, getUniqueId(command.getDeviceId()), content.length(), content); - } else { - return String.format("[%s*%s*%04x*%s]", - manufacturer, getUniqueId(command.getDeviceId()), content.length(), content); - } - } - - private int getEnableFlag(Command command) { - if (command.getBoolean(Command.KEY_ENABLE)) { - return 1; - } else { - return 0; + buf.writeCharSequence("0001", StandardCharsets.US_ASCII); + buf.writeByte('*'); } + buf.writeCharSequence(String.format("%04x", data.readableBytes() + textPrefix.length()), + StandardCharsets.US_ASCII); + buf.writeByte('*'); + buf.writeCharSequence(textPrefix, StandardCharsets.US_ASCII); + buf.writeBytes(data); + buf.writeByte(']'); + + return buf; } private static Map<Byte, Byte> mapping = new HashMap<>(); @@ -84,7 +95,7 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin mapping.put((byte) 0x2A, (byte) 0x05); } - private String getBinaryData(Command command) { + private ByteBuf getBinaryData(Command command) { byte[] data = DataConverter.parseHex(command.getString(Command.KEY_DATA)); int encodedLength = data.length; @@ -109,7 +120,7 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin index += 1; } - return new String(encodedData, StandardCharsets.US_ASCII); + return Unpooled.copiedBuffer(encodedData); } @Override @@ -117,35 +128,35 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin switch (command.getType()) { case Command.TYPE_CUSTOM: - return formatCommand(channel, command, command.getString(Command.KEY_DATA)); + return formatTextCommand(channel, command, command.getString(Command.KEY_DATA)); case Command.TYPE_POSITION_SINGLE: - return formatCommand(channel, command, "RG"); + return formatTextCommand(channel, command, "RG"); case Command.TYPE_SOS_NUMBER: - return formatCommand(channel, command, "SOS{%s},{%s}", Command.KEY_INDEX, Command.KEY_PHONE); + return formatTextCommand(channel, command, "SOS{%s},{%s}", Command.KEY_INDEX, Command.KEY_PHONE); case Command.TYPE_ALARM_SOS: - return formatCommand(channel, command, "SOSSMS," + getEnableFlag(command)); + return formatTextCommand(channel, command, "SOSSMS,{%s}", Command.KEY_ENABLE); case Command.TYPE_ALARM_BATTERY: - return formatCommand(channel, command, "LOWBAT," + getEnableFlag(command)); + return formatTextCommand(channel, command, "LOWBAT,{%s}", Command.KEY_ENABLE); case Command.TYPE_REBOOT_DEVICE: - return formatCommand(channel, command, "RESET"); + return formatTextCommand(channel, command, "RESET"); case Command.TYPE_ALARM_REMOVE: - return formatCommand(channel, command, "REMOVE," + getEnableFlag(command)); + return formatTextCommand(channel, command, "REMOVE,{%s}", Command.KEY_ENABLE); case Command.TYPE_SILENCE_TIME: - return formatCommand(channel, command, "SILENCETIME,{%s}", Command.KEY_DATA); + return formatTextCommand(channel, command, "SILENCETIME,{%s}", Command.KEY_DATA); case Command.TYPE_ALARM_CLOCK: - return formatCommand(channel, command, "REMIND,{%s}", Command.KEY_DATA); + return formatTextCommand(channel, command, "REMIND,{%s}", Command.KEY_DATA); case Command.TYPE_SET_PHONEBOOK: - return formatCommand(channel, command, "PHB,{%s}", Command.KEY_DATA); + return formatTextCommand(channel, command, "PHB,{%s}", Command.KEY_DATA); case Command.TYPE_MESSAGE: - return formatCommand(channel, command, "MESSAGE,{%s}", Command.KEY_MESSAGE); + return formatTextCommand(channel, command, "MESSAGE,{%s}", Command.KEY_MESSAGE); case Command.TYPE_VOICE_MESSAGE: - return formatCommand(channel, command, "TK,%s", getBinaryData(command)); + return formatBinaryCommand(channel, command, "TK,", getBinaryData(command)); case Command.TYPE_POSITION_PERIODIC: - return formatCommand(channel, command, "UPLOAD,{%s}", Command.KEY_FREQUENCY); + return formatTextCommand(channel, command, "UPLOAD,{%s}", Command.KEY_FREQUENCY); case Command.TYPE_SET_TIMEZONE: - return formatCommand(channel, command, "LZ,,{%s}", Command.KEY_TIMEZONE); + return formatTextCommand(channel, command, "LZ,,{%s}", Command.KEY_TIMEZONE); case Command.TYPE_SET_INDICATOR: - return formatCommand(channel, command, "FLOWER,{%s}", Command.KEY_DATA); + return formatTextCommand(channel, command, "FLOWER,{%s}", Command.KEY_DATA); default: return null; } diff --git a/test/org/traccar/BaseTest.java b/test/org/traccar/BaseTest.java index fb1b5de8f..0b2c616ce 100644 --- a/test/org/traccar/BaseTest.java +++ b/test/org/traccar/BaseTest.java @@ -1,9 +1,34 @@ package org.traccar; +import io.netty.buffer.ByteBuf; +import org.traccar.database.MediaManager; + +import java.util.HashMap; +import java.util.Map; + public class BaseTest { - + + public static class MockMediaManager extends MediaManager { + Map<String, ByteBuf> files = new HashMap<>(); + + MockMediaManager() { + super(""); + } + + @Override + public String writeFile(String uniqueId, ByteBuf buf, String extension) { + String fileName = uniqueId + "/mock." + extension; + files.put(fileName, buf); + return fileName; + } + + public ByteBuf readFile(String fileName) { + return files.get(fileName); + } + } + static { - Context.init(new TestIdentityManager()); + Context.init(new TestIdentityManager(), new MockMediaManager()); } } diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 1b5c0ea00..377474556 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -52,6 +52,14 @@ public class ProtocolTest extends BaseTest { return builder.toString(); } + protected ByteBuf concatenateBuffers(ByteBuf... buffers) { + ByteBuf result = Unpooled.buffer(); + for (ByteBuf buf : buffers) { + result.writeBytes(buf); + } + return result; + } + protected ByteBuf binary(String... data) { return Unpooled.wrappedBuffer(DataConverter.parseHex(concatenateStrings(data))); } @@ -60,6 +68,10 @@ public class ProtocolTest extends BaseTest { return concatenateStrings(data); } + protected String text(ByteBuf data) { + return data.toString(StandardCharsets.ISO_8859_1); + } + protected ByteBuf buffer(String... data) { return Unpooled.copiedBuffer(concatenateStrings(data), StandardCharsets.ISO_8859_1); } diff --git a/test/org/traccar/protocol/WatchFrameDecoderTest.java b/test/org/traccar/protocol/WatchFrameDecoderTest.java index 741807de2..4e40eea86 100644 --- a/test/org/traccar/protocol/WatchFrameDecoderTest.java +++ b/test/org/traccar/protocol/WatchFrameDecoderTest.java @@ -26,6 +26,10 @@ public class WatchFrameDecoderTest extends ProtocolTest { binary("5b5a4a2a3031343131313030313335303330342a303033342a303030392a4c4b2c302c302c31395d"), decoder.decode(null, null, binary("5b5a4a2a3031343131313030313335303330342a303033342a303030392a4c4b2c302c302c31395d"))); + verifyFrame( + concatenateBuffers(buffer("[CS*1234567890*000e*TK,#!AMR"), binary("7d5b5d2c2aff"), buffer("]")), + decoder.decode(null, null, concatenateBuffers(buffer("[CS*1234567890*000e*TK,#!AMR"), binary("7d017d027d037d047d05ff"), buffer("]")))); + } } diff --git a/test/org/traccar/protocol/WatchProtocolDecoderTest.java b/test/org/traccar/protocol/WatchProtocolDecoderTest.java index b7c8d83f9..51846f51a 100644 --- a/test/org/traccar/protocol/WatchProtocolDecoderTest.java +++ b/test/org/traccar/protocol/WatchProtocolDecoderTest.java @@ -1,7 +1,17 @@ package org.traccar.protocol; +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 { @@ -101,7 +111,19 @@ 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")); + } } diff --git a/test/org/traccar/protocol/WatchProtocolEncoderTest.java b/test/org/traccar/protocol/WatchProtocolEncoderTest.java index f55086082..649f5a10d 100644 --- a/test/org/traccar/protocol/WatchProtocolEncoderTest.java +++ b/test/org/traccar/protocol/WatchProtocolEncoderTest.java @@ -1,5 +1,6 @@ package org.traccar.protocol; +import io.netty.buffer.ByteBuf; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; @@ -18,53 +19,59 @@ public class WatchProtocolEncoderTest extends ProtocolTest { command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_REBOOT_DEVICE); - assertEquals("[CS*123456789012345*0005*RESET]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*0005*RESET]", text((ByteBuf)encoder.encodeCommand(null, command))); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_SOS_NUMBER); command.set(Command.KEY_INDEX, 1); command.set(Command.KEY_PHONE, "123456789"); - assertEquals("[CS*123456789012345*000e*SOS1,123456789]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*000e*SOS1,123456789]", text((ByteBuf)encoder.encodeCommand(null, command))); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_VOICE_MESSAGE); - command.set(Command.KEY_DATA, "3333"); - assertEquals("[CS*123456789012345*0005*TK,33]", encoder.encodeCommand(null, command)); + command.set(Command.KEY_DATA, "2321414d520a2573"); + assertEquals(buffer("[CS*123456789012345*000b*TK,#!AMR\n%s]"), encoder.encodeCommand(null, command)); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_VOICE_MESSAGE); - command.set(Command.KEY_DATA, "2321414d520a2573"); - assertEquals("[CS*123456789012345*000b*TK,#!AMR\n%s]", encoder.encodeCommand(null, command)); + command.set(Command.KEY_DATA, "7d5b5d2c2a"); + verifyFrame(concatenateBuffers(buffer("[CS*123456789012345*000d*TK,"), binary("7d017d027d037d047d05"), buffer("]")), encoder.encodeCommand(null, command)); + + command = new Command(); + command.setDeviceId(1); + command.setType(Command.TYPE_VOICE_MESSAGE); + command.set(Command.KEY_DATA, "ff"); + verifyFrame(concatenateBuffers(buffer("[CS*123456789012345*0004*TK,"), binary("ff"), buffer("]")), encoder.encodeCommand(null, command)); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_MESSAGE); command.set(Command.KEY_MESSAGE, "text"); - assertEquals("[CS*123456789012345*0018*MESSAGE,0074006500780074]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*0018*MESSAGE,0074006500780074]", text((ByteBuf)encoder.encodeCommand(null, command))); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_CUSTOM); command.set(Command.KEY_DATA, "WORK,6-9,11-13,13-15,17-19"); - assertEquals("[CS*123456789012345*001a*WORK,6-9,11-13,13-15,17-19]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*001a*WORK,6-9,11-13,13-15,17-19]", text((ByteBuf)encoder.encodeCommand(null, command))); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_SET_TIMEZONE); command.set(Command.KEY_TIMEZONE, "Europe/Amsterdam"); - assertEquals("[CS*123456789012345*0006*LZ,,+1]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*0006*LZ,,+1]", text((ByteBuf)encoder.encodeCommand(null, command))); command.set(Command.KEY_TIMEZONE, "GMT+01:30"); - assertEquals("[CS*123456789012345*0008*LZ,,+1.5]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*0008*LZ,,+1.5]", text((ByteBuf)encoder.encodeCommand(null, command))); command.set(Command.KEY_TIMEZONE, "Atlantic/Azores"); - assertEquals("[CS*123456789012345*0006*LZ,,-1]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*0006*LZ,,-1]", text((ByteBuf)encoder.encodeCommand(null, command))); command.set(Command.KEY_TIMEZONE, "GMT-11:30"); - assertEquals("[CS*123456789012345*0009*LZ,,-11.5]", encoder.encodeCommand(null, command)); + assertEquals("[CS*123456789012345*0009*LZ,,-11.5]", text((ByteBuf)encoder.encodeCommand(null, command))); } |