diff options
Diffstat (limited to 'test/org/traccar/helper')
-rw-r--r-- | test/org/traccar/helper/BcdUtilTest.java | 24 | ||||
-rw-r--r-- | test/org/traccar/helper/BitBufferTest.java | 23 | ||||
-rw-r--r-- | test/org/traccar/helper/BitUtilTest.java | 38 | ||||
-rw-r--r-- | test/org/traccar/helper/ChecksumTest.java | 39 | ||||
-rw-r--r-- | test/org/traccar/helper/DateBuilderTest.java | 27 | ||||
-rw-r--r-- | test/org/traccar/helper/DateUtilTest.java | 30 | ||||
-rw-r--r-- | test/org/traccar/helper/DistanceCalculatorTest.java | 24 | ||||
-rw-r--r-- | test/org/traccar/helper/LocationTreeTest.java | 30 | ||||
-rw-r--r-- | test/org/traccar/helper/LogTest.java | 14 | ||||
-rw-r--r-- | test/org/traccar/helper/ObdDecoderTest.java | 26 | ||||
-rw-r--r-- | test/org/traccar/helper/PatternBuilderTest.java | 20 | ||||
-rw-r--r-- | test/org/traccar/helper/PatternUtilTest.java | 18 |
12 files changed, 0 insertions, 313 deletions
diff --git a/test/org/traccar/helper/BcdUtilTest.java b/test/org/traccar/helper/BcdUtilTest.java deleted file mode 100644 index 86a32f725..000000000 --- a/test/org/traccar/helper/BcdUtilTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.traccar.helper; - -import io.netty.buffer.Unpooled; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class BcdUtilTest { - - @Test - public void testReadInteger() { - byte[] buf = {0x01, (byte) 0x90, 0x34}; - int result = BcdUtil.readInteger(Unpooled.wrappedBuffer(buf), 5); - assertEquals(1903, result); - } - - @Test - public void testReadCoordinate() { - byte[] buf = {0x03, (byte) 0x85, 0x22, 0x59, 0x34}; - double result = BcdUtil.readCoordinate(Unpooled.wrappedBuffer(buf)); - assertEquals(38.870989, result, 0.00001); - } - -} diff --git a/test/org/traccar/helper/BitBufferTest.java b/test/org/traccar/helper/BitBufferTest.java deleted file mode 100644 index c2abad36d..000000000 --- a/test/org/traccar/helper/BitBufferTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class BitBufferTest { - - @Test - public void test() { - BitBuffer buffer = new BitBuffer(); - - buffer.write(0b100100); - buffer.write(0b110110); - buffer.write(0b111111); - buffer.write(0b111111); - - assertEquals(0b100, buffer.readUnsigned(3)); - assertEquals(-7, buffer.readSigned(4)); - assertEquals(0b10110, buffer.readUnsigned(5)); - } - -} diff --git a/test/org/traccar/helper/BitUtilTest.java b/test/org/traccar/helper/BitUtilTest.java deleted file mode 100644 index 90431bf55..000000000 --- a/test/org/traccar/helper/BitUtilTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class BitUtilTest { - - @Test - public void testCheck() { - assertFalse(BitUtil.check(0, 0)); - assertTrue(BitUtil.check(1, 0)); - assertFalse(BitUtil.check(2, 0)); - } - - @Test - public void testBetween() { - assertEquals(0, BitUtil.between(0, 0, 0)); - assertEquals(1, BitUtil.between(1, 0, 1)); - assertEquals(2, BitUtil.between(2, 0, 2)); - assertEquals(2, BitUtil.between(6, 0, 2)); - } - - @Test - public void testFrom() { - assertEquals(1, BitUtil.from(1, 0)); - assertEquals(0, BitUtil.from(1, 1)); - } - - @Test - public void testTo() { - assertEquals(2, BitUtil.to(2, 2)); - assertEquals(0, BitUtil.to(2, 1)); - } - -} diff --git a/test/org/traccar/helper/ChecksumTest.java b/test/org/traccar/helper/ChecksumTest.java deleted file mode 100644 index 5737b9ff5..000000000 --- a/test/org/traccar/helper/ChecksumTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.traccar.helper; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import org.junit.Test; - -import java.nio.charset.StandardCharsets; - -import static org.junit.Assert.assertEquals; - -public class ChecksumTest { - - @Test - public void testCrc8() { - ByteBuf buf = Unpooled.copiedBuffer("123456789", StandardCharsets.US_ASCII); - - assertEquals(0xF7, Checksum.crc8(Checksum.CRC8_EGTS, buf.nioBuffer())); - assertEquals(0xD0, Checksum.crc8(Checksum.CRC8_ROHC, buf.nioBuffer())); - } - - @Test - public void testCrc16() { - ByteBuf buf = Unpooled.copiedBuffer("123456789", StandardCharsets.US_ASCII); - - assertEquals(0xBB3D, Checksum.crc16(Checksum.CRC16_IBM, buf.nioBuffer())); - assertEquals(0x4B37, Checksum.crc16(Checksum.CRC16_MODBUS, buf.nioBuffer())); - assertEquals(0x906e, Checksum.crc16(Checksum.CRC16_X25, buf.nioBuffer())); - assertEquals(0x29b1, Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.nioBuffer())); - assertEquals(0x2189, Checksum.crc16(Checksum.CRC16_KERMIT, buf.nioBuffer())); - assertEquals(0x31c3, Checksum.crc16(Checksum.CRC16_XMODEM, buf.nioBuffer())); - } - - @Test - public void testLuhn() { - assertEquals(7, Checksum.luhn(12345678901234L)); - assertEquals(0, Checksum.luhn(63070019470771L)); - } - -} diff --git a/test/org/traccar/helper/DateBuilderTest.java b/test/org/traccar/helper/DateBuilderTest.java deleted file mode 100644 index b6323cc1d..000000000 --- a/test/org/traccar/helper/DateBuilderTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.TimeZone; - -import static org.junit.Assert.assertEquals; - -public class DateBuilderTest { - - @Test - public void testDateBuilder() throws ParseException { - - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - - DateBuilder dateBuilder = new DateBuilder() - .setDate(2015, 10, 20).setTime(1, 21, 11); - - assertEquals(dateFormat.parse("2015-10-20 01:21:11"), dateBuilder.getDate()); - - } - -} diff --git a/test/org/traccar/helper/DateUtilTest.java b/test/org/traccar/helper/DateUtilTest.java deleted file mode 100644 index ec42e71ae..000000000 --- a/test/org/traccar/helper/DateUtilTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Calendar; - -import static org.junit.Assert.assertEquals; - -public class DateUtilTest { - - @Test - public void testCorrectDate() throws ParseException { - - DateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - assertEquals(f.parse("2015-12-31 23:59:59"), - DateUtil.correctDate(f.parse("2016-01-01 00:00:01"), f.parse("2016-01-01 23:59:59"), Calendar.DAY_OF_MONTH)); - - assertEquals(f.parse("2016-01-01 00:00:02"), - DateUtil.correctDate(f.parse("2016-01-01 00:00:01"), f.parse("2016-01-01 00:00:02"), Calendar.DAY_OF_MONTH)); - - assertEquals(f.parse("2016-01-01 00:00:02"), - DateUtil.correctDate(f.parse("2016-01-01 00:00:01"), f.parse("2015-12-31 00:00:02"), Calendar.DAY_OF_MONTH)); - - } - -} diff --git a/test/org/traccar/helper/DistanceCalculatorTest.java b/test/org/traccar/helper/DistanceCalculatorTest.java deleted file mode 100644 index a7457b6c4..000000000 --- a/test/org/traccar/helper/DistanceCalculatorTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class DistanceCalculatorTest { - - @Test - public void testDistance() { - assertEquals( - DistanceCalculator.distance(0.0, 0.0, 0.05, 0.05), 7863.0, 10.0); - } - - @Test - public void testDistanceToLine() { - assertEquals(DistanceCalculator.distanceToLine( - 56.83801, 60.59748, 56.83777, 60.59833, 56.83766, 60.5968), 33.0, 5.0); - - assertEquals(DistanceCalculator.distanceToLine( - 56.83753, 60.59508, 56.83777, 60.59833, 56.83766, 60.5968), 105.0, 5.0); - } - -} diff --git a/test/org/traccar/helper/LocationTreeTest.java b/test/org/traccar/helper/LocationTreeTest.java deleted file mode 100644 index 21604144a..000000000 --- a/test/org/traccar/helper/LocationTreeTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class LocationTreeTest { - - @Test - public void testLocationTree() { - - List<LocationTree.Item> items = new ArrayList<>(); - items.add(new LocationTree.Item(1, 1, "a")); - items.add(new LocationTree.Item(3, 2, "b")); - items.add(new LocationTree.Item(1, 3, "c")); - items.add(new LocationTree.Item(4, 3, "d")); - - LocationTree tree = new LocationTree(items); - - assertEquals("a", tree.findNearest(new LocationTree.Item(1f, 1f)).getData()); - assertEquals("d", tree.findNearest(new LocationTree.Item(10f, 10f)).getData()); - assertEquals("c", tree.findNearest(new LocationTree.Item(1f, 2.5f)).getData()); - assertEquals("a", tree.findNearest(new LocationTree.Item(1.5f, 1.5f)).getData()); - - } - -} diff --git a/test/org/traccar/helper/LogTest.java b/test/org/traccar/helper/LogTest.java deleted file mode 100644 index 853eb05c9..000000000 --- a/test/org/traccar/helper/LogTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class LogTest { - - @Test - public void testLog() { - assertEquals("test - Exception (LogTest:11 < ...)", Log.exceptionStack(new Exception("test"))); - } - -} diff --git a/test/org/traccar/helper/ObdDecoderTest.java b/test/org/traccar/helper/ObdDecoderTest.java deleted file mode 100644 index 1ffe68c8b..000000000 --- a/test/org/traccar/helper/ObdDecoderTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ObdDecoderTest { - - @Test - public void testDecode() { - - assertEquals(83, ObdDecoder.decode(0x01, "057b").getValue()); - assertEquals(1225, ObdDecoder.decode(0x01, "0C1324").getValue()); - assertEquals(20, ObdDecoder.decode(0x01, "0D14").getValue()); - assertEquals(64050, ObdDecoder.decode(0x01, "31fa32").getValue()); - assertEquals(25, ObdDecoder.decode(0x01, "2F41").getValue()); - - } - - @Test - public void testDecodeCodes() throws Exception { - assertEquals("P0D14", ObdDecoder.decodeCodes("0D14").getValue()); - assertEquals("dtcs", ObdDecoder.decodeCodes("0D14").getKey()); - } - -} diff --git a/test/org/traccar/helper/PatternBuilderTest.java b/test/org/traccar/helper/PatternBuilderTest.java deleted file mode 100644 index 4c76bc463..000000000 --- a/test/org/traccar/helper/PatternBuilderTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.traccar.helper; - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PatternBuilderTest { - - @Test - public void testPatternBuilder() { - assertEquals("\\$GPRMC", new PatternBuilder().text("$GPRMC").toString()); - assertEquals("(\\d{2}\\.[0-9a-fA-F]+)", new PatternBuilder().number("(dd.x+)").toString()); - assertEquals("a(?:bc)?", new PatternBuilder().text("a").text("b").text("c").optional(2).toString()); - assertEquals("a|b", new PatternBuilder().expression("a|b").toString()); - assertEquals("ab\\|", new PatternBuilder().expression("ab|").toString()); - assertEquals("|", new PatternBuilder().or().toString()); - assertEquals("\\|\\d|\\d\\|", new PatternBuilder().number("|d|d|").toString()); - } - -} diff --git a/test/org/traccar/helper/PatternUtilTest.java b/test/org/traccar/helper/PatternUtilTest.java deleted file mode 100644 index 77660078a..000000000 --- a/test/org/traccar/helper/PatternUtilTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.traccar.helper; - -import org.junit.Ignore; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class PatternUtilTest { - - @Ignore - @Test - public void testCheckPattern() { - - assertEquals("ab", PatternUtil.checkPattern("abc", "abd").getPatternMatch()); - - } - -} |