diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2014-08-23 21:50:04 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2014-08-23 21:50:04 +1200 |
commit | c4f8eb50fb65d1e4872685073c1d934734cb3e30 (patch) | |
tree | a65d14d5b30ad3d20570aa0229e9ae0770f0dfdc | |
parent | 4d62f1b57100c95dcc62a72362978cd544c987c7 (diff) | |
download | traccar-server-c4f8eb50fb65d1e4872685073c1d934734cb3e30.tar.gz traccar-server-c4f8eb50fb65d1e4872685073c1d934734cb3e30.tar.bz2 traccar-server-c4f8eb50fb65d1e4872685073c1d934734cb3e30.zip |
Fix enfora regex pattern (fix #837)
-rw-r--r-- | src/org/traccar/protocol/EnforaProtocolDecoder.java | 12 | ||||
-rw-r--r-- | test/org/traccar/protocol/EnforaProtocolDecoderTest.java | 24 |
2 files changed, 21 insertions, 15 deletions
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java index a4c581979..eec724e30 100644 --- a/src/org/traccar/protocol/EnforaProtocolDecoder.java +++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 - 2013 Anton Tananaev (anton.tananaev@gmail.com) + * Copyright 2012 - 2014 Anton Tananaev (anton.tananaev@gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,14 +38,14 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder { private static final Pattern pattern = Pattern.compile( "GPRMC," + - "(\\d{2})(\\d{2})(\\d{2}).(\\d{2})," + // Time (HHMMSS.SS) + "(\\d{2})(\\d{2})(\\d{2}).(\\d+)," + // Time (HHMMSS.SS) "([AV])," + // Validity - "(\\d{2})(\\d{2}.\\d{6})," + // Latitude (DDMM.MMMMMM) + "(\\d{2})(\\d{2}.\\d+)," + // Latitude (DDMM.MMMMMM) "([NS])," + - "(\\d{3})(\\d{2}.\\d{6})," + // Longitude (DDDMM.MMMMMM) + "(\\d{3})(\\d{2}.\\d+)," + // Longitude (DDDMM.MMMMMM) "([EW])," + - "(\\d+.\\d)?," + // Speed - "(\\d+.\\d)?," + // Course + "(\\d+.\\d+)?," + // Speed + "(\\d+.\\d+)?," + // Course "(\\d{2})(\\d{2})(\\d{2})," + // Date (DDMMYY) ".*[\r\n\u0000]*"); diff --git a/test/org/traccar/protocol/EnforaProtocolDecoderTest.java b/test/org/traccar/protocol/EnforaProtocolDecoderTest.java index 4e79c1cf0..77efb6475 100644 --- a/test/org/traccar/protocol/EnforaProtocolDecoderTest.java +++ b/test/org/traccar/protocol/EnforaProtocolDecoderTest.java @@ -2,10 +2,12 @@ package org.traccar.protocol; import org.traccar.helper.TestDataManager; import org.jboss.netty.buffer.ChannelBufferFactory; +import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.buffer.HeapChannelBufferFactory; -import static org.traccar.helper.DecoderVerifier.verify; import static org.junit.Assert.assertNull; import org.junit.Test; +import org.traccar.helper.ChannelBufferTools; +import static org.traccar.helper.DecoderVerifier.verify; public class EnforaProtocolDecoderTest { @@ -16,17 +18,21 @@ public class EnforaProtocolDecoderTest { decoder.setDataManager(new TestDataManager()); ChannelBufferFactory factory = new HeapChannelBufferFactory(); - byte[] buf1 = {0x00,0x0A,0x08,0x00,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x30,0x37,0x30,0x30,0x30,0x30,0x35,0x37,0x30,0x32,0x36,0x37}; - assertNull(decoder.decode(null, null, factory.getBuffer(buf1, 0, buf1.length))); + /*assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x00,0x0A,0x08,0x00,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x30,0x37,0x30,0x30,0x30,0x30,0x35,0x37,0x30,0x32,0x36,0x37})))); + + assertNull(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x00,0x3B,0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x08,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x30,0x37,0x30,0x30,0x30,0x30,0x35,0x37,0x30,0x32,0x36,0x37,0x20,0x38,0x3A,0x00,0x00,0x00,0x00,0x0D,0x00,0x50,0x84,0x01,0x35,0x8E,0x64,0x00,0x32,0xB3,0x77,0x00,0x00,0x03,0x67,0xB0,0x00,0x00,0xA8,0x04})))); + + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x00,0x71,0x00,0x04,0x02,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x31,0x32,0x33,0x34,0x35,0x20,0x31,0x33,0x20,0x24,0x47,0x50,0x52,0x4D,0x43,0x2C,0x32,0x32,0x33,0x31,0x35,0x32,0x2E,0x30,0x30,0x2C,0x41,0x2C,0x33,0x35,0x30,0x39,0x2E,0x38,0x36,0x30,0x35,0x39,0x34,0x2C,0x4E,0x2C,0x30,0x33,0x33,0x32,0x32,0x2E,0x37,0x34,0x33,0x38,0x38,0x37,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x32,0x30,0x36,0x31,0x32,0x2C,0x2C,0x2C,0x41,0x2A,0x35,0x32,0x0D,0x0A})))); - byte[] buf2 = {0x00,0x3B,0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x08,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x30,0x37,0x30,0x30,0x30,0x30,0x35,0x37,0x30,0x32,0x36,0x37,0x20,0x38,0x3A,0x00,0x00,0x00,0x00,0x0D,0x00,0x50,(byte)0x84,0x01,0x35,(byte)0x8E,0x64,0x00,0x32,(byte)0xB3,0x77,0x00,0x00,0x03,0x67,(byte)0xB0,0x00,0x00,(byte)0xA8,0x04}; - assertNull(decoder.decode(null, null, factory.getBuffer(buf2, 0, buf2.length))); + verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x00,0x76,0x00,0x04,0x02,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x38,0x39,0x32,0x30,0x30,0x30,0x36,0x30,0x38,0x31,0x38,0x39,0x20,0x31,0x33,0x20,0x24,0x47,0x50,0x52,0x4D,0x43,0x2C,0x31,0x37,0x31,0x38,0x34,0x31,0x2E,0x30,0x30,0x2C,0x41,0x2C,0x33,0x35,0x30,0x39,0x2E,0x38,0x35,0x32,0x34,0x31,0x30,0x2C,0x4E,0x2C,0x30,0x33,0x33,0x32,0x32,0x2E,0x37,0x35,0x39,0x31,0x31,0x33,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x2E,0x30,0x2C,0x31,0x37,0x30,0x37,0x31,0x32,0x2C,0x33,0x2E,0x34,0x2C,0x57,0x2C,0x41,0x2A,0x32,0x35,0x0D,0x0A,0x00})))); - byte[] buf3 = {0x00,0x71,0x00,0x04,0x02,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x31,0x32,0x33,0x34,0x35,0x20,0x31,0x33,0x20,0x24,0x47,0x50,0x52,0x4D,0x43,0x2C,0x32,0x32,0x33,0x31,0x35,0x32,0x2E,0x30,0x30,0x2C,0x41,0x2C,0x33,0x35,0x30,0x39,0x2E,0x38,0x36,0x30,0x35,0x39,0x34,0x2C,0x4E,0x2C,0x30,0x33,0x33,0x32,0x32,0x2E,0x37,0x34,0x33,0x38,0x38,0x37,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x32,0x30,0x36,0x31,0x32,0x2C,0x2C,0x2C,0x41,0x2A,0x35,0x32,0x0D,0x0A}; - verify(decoder.decode(null, null, factory.getBuffer(buf3, 0, buf3.length))); + */verify(decoder.decode(null, null, ChannelBuffers.wrappedBuffer(ChannelBufferTools.convertArray( + new int[] {0x00,0x6a,0x00,0x0a,0x08,0x10,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x33,0x33,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x36,0x31,0x30,0x37,0x34,0x30,0x32,0x31,0x37,0x31,0x39,0x36,0x35,0x36,0x20,0x20,0x47,0x50,0x52,0x4d,0x43,0x2c,0x31,0x36,0x31,0x32,0x34,0x38,0x2e,0x30,0x30,0x2c,0x41,0x2c,0x33,0x34,0x33,0x32,0x2e,0x36,0x39,0x32,0x31,0x31,0x2c,0x53,0x2c,0x30,0x35,0x38,0x33,0x31,0x2e,0x30,0x32,0x32,0x31,0x37,0x2c,0x57,0x2c,0x30,0x2e,0x30,0x34,0x38,0x2c,0x2c,0x32,0x32,0x30,0x38,0x31,0x34,0x2c,0x2c,0x2c,0x41,0x2a,0x37,0x34})))); - byte[] buf4 = {0x00,0x76,0x00,0x04,0x02,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x38,0x39,0x32,0x30,0x30,0x30,0x36,0x30,0x38,0x31,0x38,0x39,0x20,0x31,0x33,0x20,0x24,0x47,0x50,0x52,0x4D,0x43,0x2C,0x31,0x37,0x31,0x38,0x34,0x31,0x2E,0x30,0x30,0x2C,0x41,0x2C,0x33,0x35,0x30,0x39,0x2E,0x38,0x35,0x32,0x34,0x31,0x30,0x2C,0x4E,0x2C,0x30,0x33,0x33,0x32,0x32,0x2E,0x37,0x35,0x39,0x31,0x31,0x33,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x2E,0x30,0x2C,0x31,0x37,0x30,0x37,0x31,0x32,0x2C,0x33,0x2E,0x34,0x2C,0x57,0x2C,0x41,0x2A,0x32,0x35,0x0D,0x0A,0x00}; - verify(decoder.decode(null, null, factory.getBuffer(buf4, 0, buf4.length))); } } |