aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/helper
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/traccar/helper')
-rw-r--r--test/org/traccar/helper/BcdUtilTest.java25
-rw-r--r--test/org/traccar/helper/BitBufferTest.java23
-rw-r--r--test/org/traccar/helper/BitUtilTest.java35
-rw-r--r--test/org/traccar/helper/ChecksumTest.java38
-rw-r--r--test/org/traccar/helper/DateBuilderTest.java26
-rw-r--r--test/org/traccar/helper/DateUtilTest.java29
-rw-r--r--test/org/traccar/helper/DistanceCalculatorTest.java23
-rw-r--r--test/org/traccar/helper/LocationTreeTest.java29
-rw-r--r--test/org/traccar/helper/LogTest.java13
-rw-r--r--test/org/traccar/helper/ObdDecoderTest.java25
-rw-r--r--test/org/traccar/helper/PatternBuilderTest.java19
-rw-r--r--test/org/traccar/helper/PatternUtilTest.java18
-rw-r--r--test/org/traccar/helper/StringFinderTest.java30
13 files changed, 0 insertions, 333 deletions
diff --git a/test/org/traccar/helper/BcdUtilTest.java b/test/org/traccar/helper/BcdUtilTest.java
deleted file mode 100644
index 8767ac890..000000000
--- a/test/org/traccar/helper/BcdUtilTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.traccar.helper;
-
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class BcdUtilTest {
-
- @Test
- public void testReadInteger() {
- byte[] buf = {0x01, (byte) 0x90, 0x34};
- int result = BcdUtil.readInteger(
- ChannelBuffers.wrappedBuffer(buf), 5);
- Assert.assertEquals(1903, result);
- }
-
- @Test
- public void testReadCoordinate() {
- byte[] buf = {0x03, (byte) 0x85, 0x22, 0x59, 0x34};
- double result = BcdUtil.readCoordinate(
- ChannelBuffers.wrappedBuffer(buf));
- Assert.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 4aa295e12..000000000
--- a/test/org/traccar/helper/BitUtilTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class BitUtilTest {
-
- @Test
- public void testCheck() {
- Assert.assertFalse(BitUtil.check(0, 0));
- Assert.assertTrue(BitUtil.check(1, 0));
- Assert.assertFalse(BitUtil.check(2, 0));
- }
-
- @Test
- public void testBetween() {
- Assert.assertEquals(0, BitUtil.between(0, 0, 0));
- Assert.assertEquals(1, BitUtil.between(1, 0, 1));
- Assert.assertEquals(2, BitUtil.between(2, 0, 2));
- Assert.assertEquals(2, BitUtil.between(6, 0, 2));
- }
-
- @Test
- public void testFrom() {
- Assert.assertEquals(1, BitUtil.from(1, 0));
- Assert.assertEquals(0, BitUtil.from(1, 1));
- }
-
- @Test
- public void testTo() {
- Assert.assertEquals(2, BitUtil.to(2, 2));
- Assert.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 c7c5031df..000000000
--- a/test/org/traccar/helper/ChecksumTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.traccar.helper;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.nio.charset.StandardCharsets;
-
-public class ChecksumTest {
-
- @Test
- public void testCrc16() {
- ChannelBuffer buf = ChannelBuffers.copiedBuffer("123456789", StandardCharsets.US_ASCII);
-
- Assert.assertEquals(0x906e, Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer()));
- Assert.assertEquals(0x29b1, Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.toByteBuffer()));
- Assert.assertEquals(0x2189, Checksum.crc16(Checksum.CRC16_KERMIT, buf.toByteBuffer()));
- Assert.assertEquals(0x31c3, Checksum.crc16(Checksum.CRC16_XMODEM, buf.toByteBuffer()));
- Assert.assertEquals(0xe5cc, Checksum.crc16(Checksum.CRC16_AUG_CCITT, buf.toByteBuffer()));
- Assert.assertEquals(0xd64e, Checksum.crc16(Checksum.CRC16_GENIBUS, buf.toByteBuffer()));
- Assert.assertEquals(0x6f91, Checksum.crc16(Checksum.CRC16_MCRF4XX, buf.toByteBuffer()));
- }
-
- @Test
- public void testLuhn() {
- Assert.assertEquals(7, Checksum.luhn(12345678901234L));
- Assert.assertEquals(0, Checksum.luhn(63070019470771L));
- }
-
- @Test
- public void testModulo256() {
- Assert.assertEquals(0x00, Checksum.modulo256(new byte[] {0x00}));
- Assert.assertEquals(0x00, Checksum.modulo256(new byte[] {0x00, 0x00, 0x00}));
- Assert.assertEquals(0x06, Checksum.modulo256(new byte[] {0x01, 0x02, 0x03}));
- }
-
-}
diff --git a/test/org/traccar/helper/DateBuilderTest.java b/test/org/traccar/helper/DateBuilderTest.java
deleted file mode 100644
index 74936208b..000000000
--- a/test/org/traccar/helper/DateBuilderTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.TimeZone;
-
-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);
-
- Assert.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 ae5f20696..000000000
--- a/test/org/traccar/helper/DateUtilTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-public class DateUtilTest {
-
- @Test
- public void testCorrectDate() throws ParseException {
-
- DateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
- Assert.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));
-
- Assert.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));
-
- Assert.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 22e41c9a3..000000000
--- a/test/org/traccar/helper/DistanceCalculatorTest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class DistanceCalculatorTest {
-
- @Test
- public void testDistance() {
- Assert.assertEquals(
- DistanceCalculator.distance(0.0, 0.0, 0.05, 0.05), 7863.0, 10.0);
- }
-
- @Test
- public void testDistanceToLine() {
- Assert.assertEquals(DistanceCalculator.distanceToLine(
- 56.83801, 60.59748, 56.83777, 60.59833, 56.83766, 60.5968), 33.0, 5.0);
-
- Assert.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 afbbbc94c..000000000
--- a/test/org/traccar/helper/LocationTreeTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-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);
-
- Assert.assertEquals("a", tree.findNearest(new LocationTree.Item(1f, 1f)).getData());
- Assert.assertEquals("d", tree.findNearest(new LocationTree.Item(10f, 10f)).getData());
- Assert.assertEquals("c", tree.findNearest(new LocationTree.Item(1f, 2.5f)).getData());
- Assert.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 579c13e7d..000000000
--- a/test/org/traccar/helper/LogTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class LogTest {
-
- @Test
- public void testLog() {
- Assert.assertEquals("test - Exception (LogTest:10 < ...)", 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 db84d46d7..000000000
--- a/test/org/traccar/helper/ObdDecoderTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class ObdDecoderTest {
-
- @Test
- public void testDecode() {
-
- Assert.assertEquals(83, ObdDecoder.decode(0x01, "057b").getValue());
- Assert.assertEquals(1225, ObdDecoder.decode(0x01, "0C1324").getValue());
- Assert.assertEquals(20, ObdDecoder.decode(0x01, "0D14").getValue());
- Assert.assertEquals(64050, ObdDecoder.decode(0x01, "31fa32").getValue());
- Assert.assertEquals(25, ObdDecoder.decode(0x01, "2F41").getValue());
-
- }
-
- @Test
- public void testDecodeCodes() throws Exception {
- Assert.assertEquals("P0D14", ObdDecoder.decodeCodes("0D14").getValue());
- Assert.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 975cc1621..000000000
--- a/test/org/traccar/helper/PatternBuilderTest.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.traccar.helper;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class PatternBuilderTest {
-
- @Test
- public void testPatternBuilder() {
- Assert.assertEquals("\\$GPRMC", new PatternBuilder().text("$GPRMC").toString());
- Assert.assertEquals("(\\d{2}\\.[0-9a-fA-F]+)", new PatternBuilder().number("(dd.x+)").toString());
- Assert.assertEquals("a(?:bc)?", new PatternBuilder().text("a").text("b").text("c").optional(2).toString());
- Assert.assertEquals("a|b", new PatternBuilder().expression("a|b").toString());
- Assert.assertEquals("ab\\|", new PatternBuilder().expression("ab|").toString());
- Assert.assertEquals("|", new PatternBuilder().or().toString());
- Assert.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());
-
- }
-
-}
diff --git a/test/org/traccar/helper/StringFinderTest.java b/test/org/traccar/helper/StringFinderTest.java
deleted file mode 100644
index 1c8234db1..000000000
--- a/test/org/traccar/helper/StringFinderTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.traccar.helper;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBufferFactory;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.buffer.HeapChannelBufferFactory;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-public class StringFinderTest {
-
- @Test
- public void testFind() {
-
- ChannelBuffer buf = ChannelBuffers.copiedBuffer("hello world", StandardCharsets.US_ASCII);
-
- Assert.assertEquals(-1, buf.indexOf(0, buf.writerIndex(), new StringFinder("bar")));
- Assert.assertEquals(6, buf.indexOf(0, buf.writerIndex(), new StringFinder("world")));
- Assert.assertEquals(-1, buf.indexOf(0, buf.writerIndex(), new StringFinder("worlds")));
- Assert.assertEquals(0, buf.indexOf(0, buf.writerIndex(), new StringFinder("hell")));
-
- }
-
-}