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.java6
-rw-r--r--test/org/traccar/helper/BitUtilTest.java26
-rw-r--r--test/org/traccar/helper/ChecksumTest.java20
-rw-r--r--test/org/traccar/helper/DateBuilderTest.java4
-rw-r--r--test/org/traccar/helper/DateUtilTest.java8
-rw-r--r--test/org/traccar/helper/DistanceCalculatorTest.java8
-rw-r--r--test/org/traccar/helper/LocationTreeTest.java10
-rw-r--r--test/org/traccar/helper/LogTest.java5
-rw-r--r--test/org/traccar/helper/ObdDecoderTest.java16
-rw-r--r--test/org/traccar/helper/PatternBuilderTest.java16
-rw-r--r--test/org/traccar/helper/StringFinderTest.java8
11 files changed, 74 insertions, 53 deletions
diff --git a/test/org/traccar/helper/BcdUtilTest.java b/test/org/traccar/helper/BcdUtilTest.java
index 8767ac890..9ffceacd9 100644
--- a/test/org/traccar/helper/BcdUtilTest.java
+++ b/test/org/traccar/helper/BcdUtilTest.java
@@ -4,6 +4,8 @@ import org.jboss.netty.buffer.ChannelBuffers;
import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class BcdUtilTest {
@Test
@@ -11,7 +13,7 @@ public class BcdUtilTest {
byte[] buf = {0x01, (byte) 0x90, 0x34};
int result = BcdUtil.readInteger(
ChannelBuffers.wrappedBuffer(buf), 5);
- Assert.assertEquals(1903, result);
+ assertEquals(1903, result);
}
@Test
@@ -19,7 +21,7 @@ public class BcdUtilTest {
byte[] buf = {0x03, (byte) 0x85, 0x22, 0x59, 0x34};
double result = BcdUtil.readCoordinate(
ChannelBuffers.wrappedBuffer(buf));
- Assert.assertEquals(38.870989, result, 0.00001);
+ assertEquals(38.870989, result, 0.00001);
}
}
diff --git a/test/org/traccar/helper/BitUtilTest.java b/test/org/traccar/helper/BitUtilTest.java
index 4aa295e12..683c4e6b8 100644
--- a/test/org/traccar/helper/BitUtilTest.java
+++ b/test/org/traccar/helper/BitUtilTest.java
@@ -3,33 +3,37 @@ package org.traccar.helper;
import org.junit.Assert;
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() {
- Assert.assertFalse(BitUtil.check(0, 0));
- Assert.assertTrue(BitUtil.check(1, 0));
- Assert.assertFalse(BitUtil.check(2, 0));
+ assertFalse(BitUtil.check(0, 0));
+ assertTrue(BitUtil.check(1, 0));
+ 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));
+ 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() {
- Assert.assertEquals(1, BitUtil.from(1, 0));
- Assert.assertEquals(0, BitUtil.from(1, 1));
+ assertEquals(1, BitUtil.from(1, 0));
+ assertEquals(0, BitUtil.from(1, 1));
}
@Test
public void testTo() {
- Assert.assertEquals(2, BitUtil.to(2, 2));
- Assert.assertEquals(0, BitUtil.to(2, 1));
+ 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
index c37eda88d..1c20ba899 100644
--- a/test/org/traccar/helper/ChecksumTest.java
+++ b/test/org/traccar/helper/ChecksumTest.java
@@ -7,25 +7,27 @@ import org.junit.Test;
import java.nio.charset.StandardCharsets;
+import static org.junit.Assert.assertEquals;
+
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()));
+ assertEquals(0x906e, Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer()));
+ assertEquals(0x29b1, Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.toByteBuffer()));
+ assertEquals(0x2189, Checksum.crc16(Checksum.CRC16_KERMIT, buf.toByteBuffer()));
+ assertEquals(0x31c3, Checksum.crc16(Checksum.CRC16_XMODEM, buf.toByteBuffer()));
+ assertEquals(0xe5cc, Checksum.crc16(Checksum.CRC16_AUG_CCITT, buf.toByteBuffer()));
+ assertEquals(0xd64e, Checksum.crc16(Checksum.CRC16_GENIBUS, buf.toByteBuffer()));
+ 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));
+ 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
index 74936208b..8b2898fed 100644
--- a/test/org/traccar/helper/DateBuilderTest.java
+++ b/test/org/traccar/helper/DateBuilderTest.java
@@ -8,6 +8,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
+import static org.junit.Assert.assertEquals;
+
public class DateBuilderTest {
@Test
@@ -19,7 +21,7 @@ public class DateBuilderTest {
DateBuilder dateBuilder = new DateBuilder()
.setDate(2015, 10, 20).setTime(1, 21, 11);
- Assert.assertEquals(dateFormat.parse("2015-10-20 01:21:11"), dateBuilder.getDate());
+ 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
index ae5f20696..b0bae4d11 100644
--- a/test/org/traccar/helper/DateUtilTest.java
+++ b/test/org/traccar/helper/DateUtilTest.java
@@ -8,6 +8,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
+import static org.junit.Assert.assertEquals;
+
public class DateUtilTest {
@Test
@@ -15,13 +17,13 @@ public class DateUtilTest {
DateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Assert.assertEquals(f.parse("2015-12-31 23:59:59"),
+ 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"),
+ 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"),
+ 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
index 22e41c9a3..f12a1ec83 100644
--- a/test/org/traccar/helper/DistanceCalculatorTest.java
+++ b/test/org/traccar/helper/DistanceCalculatorTest.java
@@ -3,20 +3,22 @@ package org.traccar.helper;
import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class DistanceCalculatorTest {
@Test
public void testDistance() {
- Assert.assertEquals(
+ assertEquals(
DistanceCalculator.distance(0.0, 0.0, 0.05, 0.05), 7863.0, 10.0);
}
@Test
public void testDistanceToLine() {
- Assert.assertEquals(DistanceCalculator.distanceToLine(
+ assertEquals(DistanceCalculator.distanceToLine(
56.83801, 60.59748, 56.83777, 60.59833, 56.83766, 60.5968), 33.0, 5.0);
- Assert.assertEquals(DistanceCalculator.distanceToLine(
+ 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
index afbbbc94c..3984b1142 100644
--- a/test/org/traccar/helper/LocationTreeTest.java
+++ b/test/org/traccar/helper/LocationTreeTest.java
@@ -6,6 +6,8 @@ import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
+import static org.junit.Assert.assertEquals;
+
public class LocationTreeTest {
@Test
@@ -19,10 +21,10 @@ public class LocationTreeTest {
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());
+ 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
index 579c13e7d..853eb05c9 100644
--- a/test/org/traccar/helper/LogTest.java
+++ b/test/org/traccar/helper/LogTest.java
@@ -1,13 +1,14 @@
package org.traccar.helper;
-import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class LogTest {
@Test
public void testLog() {
- Assert.assertEquals("test - Exception (LogTest:10 < ...)", Log.exceptionStack(new Exception("test")));
+ 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
index db84d46d7..d9cc2ed6b 100644
--- a/test/org/traccar/helper/ObdDecoderTest.java
+++ b/test/org/traccar/helper/ObdDecoderTest.java
@@ -3,23 +3,25 @@ package org.traccar.helper;
import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
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());
+ 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 {
- Assert.assertEquals("P0D14", ObdDecoder.decodeCodes("0D14").getValue());
- Assert.assertEquals("dtcs", ObdDecoder.decodeCodes("0D14").getKey());
+ 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
index 975cc1621..a8fb1aa93 100644
--- a/test/org/traccar/helper/PatternBuilderTest.java
+++ b/test/org/traccar/helper/PatternBuilderTest.java
@@ -3,17 +3,19 @@ package org.traccar.helper;
import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
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());
+ 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/StringFinderTest.java b/test/org/traccar/helper/StringFinderTest.java
index 1c8234db1..6bc78ea82 100644
--- a/test/org/traccar/helper/StringFinderTest.java
+++ b/test/org/traccar/helper/StringFinderTest.java
@@ -20,10 +20,10 @@ public class StringFinderTest {
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")));
+ assertEquals(-1, buf.indexOf(0, buf.writerIndex(), new StringFinder("bar")));
+ assertEquals(6, buf.indexOf(0, buf.writerIndex(), new StringFinder("world")));
+ assertEquals(-1, buf.indexOf(0, buf.writerIndex(), new StringFinder("worlds")));
+ assertEquals(0, buf.indexOf(0, buf.writerIndex(), new StringFinder("hell")));
}