aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/ProtocolTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-03-06 10:56:23 -0800
committerAnton Tananaev <anton@traccar.org>2023-03-06 10:56:23 -0800
commit5505721ed5327eb65cfbbf64ad95bc956d588ba4 (patch)
tree60efdb732849e2f798f0cbc90290f6e227dbfa80 /src/test/java/org/traccar/ProtocolTest.java
parent240fa0061368d27d950443ebf571aa2b6bf9dae3 (diff)
downloadtrackermap-server-5505721ed5327eb65cfbbf64ad95bc956d588ba4.tar.gz
trackermap-server-5505721ed5327eb65cfbbf64ad95bc956d588ba4.tar.bz2
trackermap-server-5505721ed5327eb65cfbbf64ad95bc956d588ba4.zip
Upgrade junit framework
Diffstat (limited to 'src/test/java/org/traccar/ProtocolTest.java')
-rw-r--r--src/test/java/org/traccar/ProtocolTest.java73
1 files changed, 36 insertions, 37 deletions
diff --git a/src/test/java/org/traccar/ProtocolTest.java b/src/test/java/org/traccar/ProtocolTest.java
index 5e37f44b9..ce005e93f 100644
--- a/src/test/java/org/traccar/ProtocolTest.java
+++ b/src/test/java/org/traccar/ProtocolTest.java
@@ -26,11 +26,11 @@ import java.util.List;
import java.util.Map;
import java.util.TimeZone;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ProtocolTest extends BaseTest {
@@ -112,7 +112,7 @@ public class ProtocolTest extends BaseTest {
Object decodedObject = decoder.decode(null, null, object);
Position position;
if (decodedObject instanceof Collection) {
- position = (Position) ((Collection) decodedObject).iterator().next();
+ position = (Position) ((Collection<?>) decodedObject).iterator().next();
} else {
position = (Position) decodedObject;
}
@@ -155,11 +155,11 @@ public class ProtocolTest extends BaseTest {
private void verifyDecodedList(Object decodedObject, boolean checkLocation, Position expected) {
- assertNotNull("list is null", decodedObject);
- assertTrue("not a list", decodedObject instanceof List);
- assertFalse("list is empty", ((List) decodedObject).isEmpty());
+ assertNotNull(decodedObject, "list is null");
+ assertTrue(decodedObject instanceof List, "not a list");
+ assertFalse(((List<?>) decodedObject).isEmpty(), "list is empty");
- for (Object item : (List) decodedObject) {
+ for (Object item : (List<?>) decodedObject) {
verifyDecodedPosition(item, checkLocation, false, expected);
}
@@ -167,8 +167,8 @@ public class ProtocolTest extends BaseTest {
private void verifyDecodedPosition(Object decodedObject, boolean checkLocation, boolean checkAttributes, Position expected) {
- assertNotNull("position is null", decodedObject);
- assertTrue("not a position", decodedObject instanceof Position);
+ assertNotNull(decodedObject, "position is null");
+ assertTrue(decodedObject instanceof Position, "not a position");
Position position = (Position) decodedObject;
@@ -181,45 +181,44 @@ public class ProtocolTest extends BaseTest {
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
assertEquals("time", dateFormat.format(expected.getFixTime()), dateFormat.format(position.getFixTime()));
}
- assertEquals("valid", expected.getValid(), position.getValid());
- assertEquals("latitude", expected.getLatitude(), position.getLatitude(), 0.00001);
- assertEquals("longitude", expected.getLongitude(), position.getLongitude(), 0.00001);
+ assertEquals(expected.getValid(), position.getValid(), "valid");
+ assertEquals(expected.getLatitude(), position.getLatitude(), 0.00001, "latitude");
+ assertEquals(expected.getLongitude(), position.getLongitude(), 0.00001, "longitude");
} else {
assertNotNull(position.getServerTime());
assertNotNull(position.getFixTime());
- assertTrue("year > 1999", position.getFixTime().after(new Date(915148800000L)));
- assertTrue("time < +25 hours",
- position.getFixTime().getTime() < System.currentTimeMillis() + 25 * 3600000);
+ assertTrue(position.getFixTime().after(new Date(915148800000L)), "year > 1999");
+ assertTrue(position.getFixTime().getTime() < System.currentTimeMillis() + 25 * 3600000, "time < +25 h");
- assertTrue("latitude >= -90", position.getLatitude() >= -90);
- assertTrue("latitude <= 90", position.getLatitude() <= 90);
+ assertTrue(position.getLatitude() >= -90, "latitude >= -90");
+ assertTrue(position.getLatitude() <= 90, "latitude <= 90");
- assertTrue("longitude >= -180", position.getLongitude() >= -180);
- assertTrue("longitude <= 180", position.getLongitude() <= 180);
+ assertTrue(position.getLongitude() >= -180, "longitude >= -180");
+ assertTrue(position.getLongitude() <= 180, "longitude <= 180");
}
- assertTrue("altitude >= -12262", position.getAltitude() >= -12262);
- assertTrue("altitude <= 18000", position.getAltitude() <= 18000);
+ assertTrue(position.getAltitude() >= -12262, "altitude >= -12262");
+ assertTrue(position.getAltitude() <= 18000, "altitude <= 18000");
- assertTrue("speed >= 0", position.getSpeed() >= 0);
- assertTrue("speed <= 869", position.getSpeed() <= 869);
+ assertTrue(position.getSpeed() >= 0, "speed >= 0");
+ assertTrue(position.getSpeed() <= 869, "speed <= 869");
- assertTrue("course >= 0", position.getCourse() >= 0);
- assertTrue("course <= 360", position.getCourse() <= 360);
+ assertTrue(position.getCourse() >= 0, "course >= 0");
+ assertTrue(position.getCourse() <= 360, "course <= 360");
- assertNotNull("protocol is null", position.getProtocol());
+ assertNotNull(position.getProtocol(), "protocol is null");
- assertTrue("deviceId > 0", position.getDeviceId() > 0);
+ assertTrue(position.getDeviceId() > 0, "deviceId > 0");
}
Map<String, Object> attributes = position.getAttributes();
if (checkAttributes) {
- assertFalse("no attributes", attributes.isEmpty());
+ assertFalse(attributes.isEmpty(), "no attributes");
}
if (attributes.containsKey(Position.KEY_INDEX)) {
@@ -331,11 +330,11 @@ public class ProtocolTest extends BaseTest {
}
private void checkInteger(Object value, int min, int max) {
- assertNotNull("value is null", value);
- assertTrue("not int or long", value instanceof Integer || value instanceof Long);
+ assertNotNull(value, "value is null");
+ assertTrue(value instanceof Integer || value instanceof Long, "not int or long");
long number = ((Number) value).longValue();
- assertTrue("value too low", number >= min);
- assertTrue("value too high", number <= max);
+ assertTrue(number >= min, "value too low");
+ assertTrue(number <= max, "value too high");
}
protected void verifyCommand(
@@ -344,8 +343,8 @@ public class ProtocolTest extends BaseTest {
}
protected void verifyFrame(ByteBuf expected, Object object) {
- assertNotNull("buffer is null", object);
- assertTrue("not a buffer", object instanceof ByteBuf);
+ assertNotNull(object, "buffer is null");
+ assertTrue(object instanceof ByteBuf, "not a buffer");
assertEquals(ByteBufUtil.hexDump(expected), ByteBufUtil.hexDump((ByteBuf) object));
}