From 48a5bd364b496de70a1a3eff8dd5c57c5d8fec9d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 22 Jan 2018 19:53:48 +1300 Subject: Optimize date assignment --- test/org/traccar/ProtocolTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'test/org/traccar/ProtocolTest.java') diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 1daefabd6..5cbb651bf 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -27,11 +27,9 @@ public class ProtocolTest extends BaseTest { Position position = new Position(); - if (time != null) { - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - position.setTime(dateFormat.parse(time)); - } + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); + position.setTime(dateFormat.parse(time)); position.setValid(valid); position.setLatitude(lat); position.setLongitude(lon); -- cgit v1.2.3 From 87bdccbe9843e38174ad345b8e474b1cded9f985 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 25 Jan 2018 20:14:42 +1300 Subject: Static imports for junit --- test/org/traccar/ProtocolTest.java | 118 +++++++++++---------- test/org/traccar/WebDataHandlerTest.java | 4 +- test/org/traccar/calendar/CalendarTest.java | 10 +- test/org/traccar/database/DataManagerTest.java | 52 ++++----- test/org/traccar/database/GroupTreeTest.java | 16 +-- test/org/traccar/geocoder/AddressFormatTest.java | 4 +- test/org/traccar/geocoder/GeocoderTest.java | 22 ++-- test/org/traccar/geofence/GeofenceCircleTest.java | 9 +- test/org/traccar/geofence/GeofencePolygonTest.java | 21 ++-- .../org/traccar/geofence/GeofencePolylineTest.java | 21 ++-- .../geolocation/GeolocationProviderTest.java | 9 +- test/org/traccar/helper/BcdUtilTest.java | 6 +- test/org/traccar/helper/BitUtilTest.java | 26 +++-- test/org/traccar/helper/ChecksumTest.java | 20 ++-- test/org/traccar/helper/DateBuilderTest.java | 4 +- test/org/traccar/helper/DateUtilTest.java | 8 +- .../org/traccar/helper/DistanceCalculatorTest.java | 8 +- test/org/traccar/helper/LocationTreeTest.java | 10 +- test/org/traccar/helper/LogTest.java | 5 +- test/org/traccar/helper/ObdDecoderTest.java | 16 +-- test/org/traccar/helper/PatternBuilderTest.java | 16 +-- test/org/traccar/helper/StringFinderTest.java | 8 +- .../traccar/processing/ComputedAttributesTest.java | 24 +++-- .../traccar/protocol/AdmProtocolEncoderTest.java | 6 +- .../traccar/protocol/AplicomFrameDecoderTest.java | 6 +- .../traccar/protocol/At2000FrameDecoderTest.java | 6 +- .../traccar/protocol/AtrackFrameDecoderTest.java | 8 +- .../traccar/protocol/GalileoFrameDecoderTest.java | 6 +- .../traccar/protocol/GatorProtocolDecoderTest.java | 4 +- .../traccar/protocol/Gl200FrameDecoderTest.java | 8 +- .../traccar/protocol/Gps056FrameDecoderTest.java | 6 +- .../protocol/Gps103ProtocolEncoderTest.java | 6 +- .../traccar/protocol/GranitFrameDecoderTest.java | 16 +-- test/org/traccar/protocol/H02FrameDecoderTest.java | 22 ++-- .../traccar/protocol/H02ProtocolEncoderTest.java | 12 ++- .../traccar/protocol/HuaShengFrameDecoderTest.java | 10 +- .../traccar/protocol/HuabaoFrameDecoderTest.java | 4 +- .../org/traccar/protocol/L100FrameDecoderTest.java | 6 +- .../traccar/protocol/MeiligaoFrameDecoderTest.java | 9 +- .../traccar/protocol/MeitrackFrameDecoderTest.java | 4 +- .../protocol/MeitrackProtocolEncoderTest.java | 6 +- .../protocol/MiniFinderProtocolEncoderTest.java | 6 +- test/org/traccar/protocol/NvsFrameDecoderTest.java | 6 +- .../traccar/protocol/Pt502ProtocolEncoderTest.java | 10 +- .../traccar/protocol/Tk103ProtocolEncoderTest.java | 38 +++---- .../traccar/protocol/TotemProtocolEncoderTest.java | 4 +- .../traccar/protocol/UlbotechFrameDecoderTest.java | 8 +- .../traccar/protocol/VtfmsFrameDecoderTest.java | 4 +- .../traccar/protocol/WatchProtocolEncoderTest.java | 18 ++-- .../traccar/protocol/WondexFrameDecoderTest.java | 9 +- .../protocol/WondexProtocolEncoderTest.java | 4 +- .../traccar/protocol/XexunFrameDecoderTest.java | 6 +- test/org/traccar/reports/ReportUtilsTest.java | 8 +- 53 files changed, 408 insertions(+), 295 deletions(-) (limited to 'test/org/traccar/ProtocolTest.java') diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 5cbb651bf..246e3d0e7 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -21,6 +21,12 @@ 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; + public class ProtocolTest extends BaseTest { protected Position position(String time, boolean valid, double lat, double lon) throws ParseException { @@ -77,19 +83,19 @@ public class ProtocolTest extends BaseTest { } protected void verifyNotNull(BaseProtocolDecoder decoder, Object object) throws Exception { - Assert.assertNotNull(decoder.decode(null, null, object)); + assertNotNull(decoder.decode(null, null, object)); } protected void verifyNull(Object object) throws Exception { - Assert.assertNull(object); + assertNull(object); } protected void verifyNull(BaseProtocolDecoder decoder, Object object) throws Exception { - Assert.assertNull(decoder.decode(null, null, object)); + assertNull(decoder.decode(null, null, object)); } protected void verifyAttribute(BaseProtocolDecoder decoder, Object object, String key, Object expected) throws Exception { - Assert.assertEquals(expected, ((Position) decoder.decode(null, null, object)).getAttributes().get(key)); + assertEquals(expected, ((Position) decoder.decode(null, null, object)).getAttributes().get(key)); } protected void verifyAttributes(BaseProtocolDecoder decoder, Object object) throws Exception { @@ -118,9 +124,9 @@ public class ProtocolTest extends BaseTest { private void verifyDecodedList(Object decodedObject, boolean checkLocation, Position expected) { - Assert.assertNotNull("list is null", decodedObject); - Assert.assertTrue("not a list", decodedObject instanceof List); - Assert.assertFalse("list is empty", ((List) decodedObject).isEmpty()); + assertNotNull("list is null", decodedObject); + assertTrue("not a list", decodedObject instanceof List); + assertFalse("list is empty", ((List) decodedObject).isEmpty()); for (Object item : (List) decodedObject) { verifyDecodedPosition(item, checkLocation, false, expected); @@ -130,8 +136,8 @@ public class ProtocolTest extends BaseTest { private void verifyDecodedPosition(Object decodedObject, boolean checkLocation, boolean checkAttributes, Position expected) { - Assert.assertNotNull("position is null", decodedObject); - Assert.assertTrue("not a position", decodedObject instanceof Position); + assertNotNull("position is null", decodedObject); + assertTrue("not a position", decodedObject instanceof Position); Position position = (Position) decodedObject; @@ -142,125 +148,125 @@ public class ProtocolTest extends BaseTest { if (expected.getFixTime() != null) { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - Assert.assertEquals("time", dateFormat.format(expected.getFixTime()), dateFormat.format(position.getFixTime())); + assertEquals("time", dateFormat.format(expected.getFixTime()), dateFormat.format(position.getFixTime())); } - Assert.assertEquals("valid", expected.getValid(), position.getValid()); - Assert.assertEquals("latitude", expected.getLatitude(), position.getLatitude(), 0.00001); - Assert.assertEquals("longitude", expected.getLongitude(), position.getLongitude(), 0.00001); + assertEquals("valid", expected.getValid(), position.getValid()); + assertEquals("latitude", expected.getLatitude(), position.getLatitude(), 0.00001); + assertEquals("longitude", expected.getLongitude(), position.getLongitude(), 0.00001); } else { - Assert.assertNotNull(position.getFixTime()); - Assert.assertTrue("year > 1999", position.getFixTime().after(new Date(915148800000L))); - Assert.assertTrue("time < +25 hours", + assertNotNull(position.getFixTime()); + assertTrue("year > 1999", position.getFixTime().after(new Date(915148800000L))); + assertTrue("time < +25 hours", position.getFixTime().getTime() < System.currentTimeMillis() + 25 * 3600000); - Assert.assertTrue("latitude >= -90", position.getLatitude() >= -90); - Assert.assertTrue("latitude <= 90", position.getLatitude() <= 90); + assertTrue("latitude >= -90", position.getLatitude() >= -90); + assertTrue("latitude <= 90", position.getLatitude() <= 90); - Assert.assertTrue("longitude >= -180", position.getLongitude() >= -180); - Assert.assertTrue("longitude <= 180", position.getLongitude() <= 180); + assertTrue("longitude >= -180", position.getLongitude() >= -180); + assertTrue("longitude <= 180", position.getLongitude() <= 180); } - Assert.assertTrue("altitude >= -12262", position.getAltitude() >= -12262); - Assert.assertTrue("altitude <= 18000", position.getAltitude() <= 18000); + assertTrue("altitude >= -12262", position.getAltitude() >= -12262); + assertTrue("altitude <= 18000", position.getAltitude() <= 18000); - Assert.assertTrue("speed >= 0", position.getSpeed() >= 0); - Assert.assertTrue("speed <= 869", position.getSpeed() <= 869); + assertTrue("speed >= 0", position.getSpeed() >= 0); + assertTrue("speed <= 869", position.getSpeed() <= 869); - Assert.assertTrue("course >= 0", position.getCourse() >= 0); - Assert.assertTrue("course <= 360", position.getCourse() <= 360); + assertTrue("course >= 0", position.getCourse() >= 0); + assertTrue("course <= 360", position.getCourse() <= 360); - Assert.assertNotNull("protocol is null", position.getProtocol()); + assertNotNull("protocol is null", position.getProtocol()); } Map attributes = position.getAttributes(); if (checkAttributes) { - Assert.assertFalse("no attributes", attributes.isEmpty()); + assertFalse("no attributes", attributes.isEmpty()); } if (attributes.containsKey(Position.KEY_INDEX)) { - Assert.assertTrue(attributes.get(Position.KEY_INDEX) instanceof Number); + assertTrue(attributes.get(Position.KEY_INDEX) instanceof Number); } if (attributes.containsKey(Position.KEY_HDOP)) { - Assert.assertTrue(attributes.get(Position.KEY_HDOP) instanceof Number); + assertTrue(attributes.get(Position.KEY_HDOP) instanceof Number); } if (attributes.containsKey(Position.KEY_VDOP)) { - Assert.assertTrue(attributes.get(Position.KEY_VDOP) instanceof Number); + assertTrue(attributes.get(Position.KEY_VDOP) instanceof Number); } if (attributes.containsKey(Position.KEY_PDOP)) { - Assert.assertTrue(attributes.get(Position.KEY_PDOP) instanceof Number); + assertTrue(attributes.get(Position.KEY_PDOP) instanceof Number); } if (attributes.containsKey(Position.KEY_SATELLITES)) { - Assert.assertTrue(attributes.get(Position.KEY_SATELLITES) instanceof Number); + assertTrue(attributes.get(Position.KEY_SATELLITES) instanceof Number); } if (attributes.containsKey(Position.KEY_SATELLITES_VISIBLE)) { - Assert.assertTrue(attributes.get(Position.KEY_SATELLITES_VISIBLE) instanceof Number); + assertTrue(attributes.get(Position.KEY_SATELLITES_VISIBLE) instanceof Number); } if (attributes.containsKey(Position.KEY_RSSI)) { - Assert.assertTrue(attributes.get(Position.KEY_RSSI) instanceof Number); + assertTrue(attributes.get(Position.KEY_RSSI) instanceof Number); } if (attributes.containsKey(Position.KEY_ODOMETER)) { - Assert.assertTrue(attributes.get(Position.KEY_ODOMETER) instanceof Number); + assertTrue(attributes.get(Position.KEY_ODOMETER) instanceof Number); } if (attributes.containsKey(Position.KEY_RPM)) { - Assert.assertTrue(attributes.get(Position.KEY_RPM) instanceof Number); + assertTrue(attributes.get(Position.KEY_RPM) instanceof Number); } if (attributes.containsKey(Position.KEY_FUEL_LEVEL)) { - Assert.assertTrue(attributes.get(Position.KEY_FUEL_LEVEL) instanceof Number); + assertTrue(attributes.get(Position.KEY_FUEL_LEVEL) instanceof Number); } if (attributes.containsKey(Position.KEY_POWER)) { - Assert.assertTrue(attributes.get(Position.KEY_POWER) instanceof Number); + assertTrue(attributes.get(Position.KEY_POWER) instanceof Number); } if (attributes.containsKey(Position.KEY_BATTERY)) { - Assert.assertTrue(attributes.get(Position.KEY_BATTERY) instanceof Number); + assertTrue(attributes.get(Position.KEY_BATTERY) instanceof Number); } if (attributes.containsKey(Position.KEY_BATTERY_LEVEL)) { int batteryLevel = ((Number) attributes.get(Position.KEY_BATTERY_LEVEL)).intValue(); - Assert.assertTrue(batteryLevel <= 100 && batteryLevel >= 0); + assertTrue(batteryLevel <= 100 && batteryLevel >= 0); } if (attributes.containsKey(Position.KEY_CHARGE)) { - Assert.assertTrue(attributes.get(Position.KEY_CHARGE) instanceof Boolean); + assertTrue(attributes.get(Position.KEY_CHARGE) instanceof Boolean); } if (attributes.containsKey(Position.KEY_IGNITION)) { - Assert.assertTrue(attributes.get(Position.KEY_IGNITION) instanceof Boolean); + assertTrue(attributes.get(Position.KEY_IGNITION) instanceof Boolean); } if (attributes.containsKey(Position.KEY_MOTION)) { - Assert.assertTrue(attributes.get(Position.KEY_MOTION) instanceof Boolean); + assertTrue(attributes.get(Position.KEY_MOTION) instanceof Boolean); } if (attributes.containsKey(Position.KEY_ARCHIVE)) { - Assert.assertTrue(attributes.get(Position.KEY_ARCHIVE) instanceof Boolean); + assertTrue(attributes.get(Position.KEY_ARCHIVE) instanceof Boolean); } if (attributes.containsKey(Position.KEY_DRIVER_UNIQUE_ID)) { - Assert.assertTrue(attributes.get(Position.KEY_DRIVER_UNIQUE_ID) instanceof String); + assertTrue(attributes.get(Position.KEY_DRIVER_UNIQUE_ID) instanceof String); } if (attributes.containsKey(Position.KEY_STEPS)) { - Assert.assertTrue(attributes.get(Position.KEY_STEPS) instanceof Number); + assertTrue(attributes.get(Position.KEY_STEPS) instanceof Number); } if (attributes.containsKey(Position.KEY_ROAMING)) { - Assert.assertTrue(attributes.get(Position.KEY_ROAMING) instanceof Boolean); + assertTrue(attributes.get(Position.KEY_ROAMING) instanceof Boolean); } if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) { @@ -275,11 +281,11 @@ public class ProtocolTest extends BaseTest { } private void checkInteger(Object value, int min, int max) { - Assert.assertNotNull("value is null", value); - Assert.assertTrue("not int or long", value instanceof Integer || value instanceof Long); + assertNotNull("value is null", value); + assertTrue("not int or long", value instanceof Integer || value instanceof Long); long number = ((Number) value).longValue(); - Assert.assertTrue("value too low", number >= min); - Assert.assertTrue("value too high", number <= max); + assertTrue("value too low", number >= min); + assertTrue("value too high", number <= max); } protected void verifyCommand( @@ -288,11 +294,9 @@ public class ProtocolTest extends BaseTest { } protected void verifyFrame(ChannelBuffer expected, Object object) { - - Assert.assertNotNull("buffer is null", object); - Assert.assertTrue("not a buffer", object instanceof ChannelBuffer); - Assert.assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) object)); - + assertNotNull("buffer is null", object); + assertTrue("not a buffer", object instanceof ChannelBuffer); + assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) object)); } } diff --git a/test/org/traccar/WebDataHandlerTest.java b/test/org/traccar/WebDataHandlerTest.java index 2a8205ad1..be05e0855 100644 --- a/test/org/traccar/WebDataHandlerTest.java +++ b/test/org/traccar/WebDataHandlerTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.model.Position; +import static org.junit.Assert.assertEquals; + public class WebDataHandlerTest extends ProtocolTest { @Test @@ -13,7 +15,7 @@ public class WebDataHandlerTest extends ProtocolTest { WebDataHandler handler = new WebDataHandler("http://localhost/?fixTime={fixTime}&gprmc={gprmc}&name={name}"); - Assert.assertEquals( + assertEquals( "http://localhost/?fixTime=1451610123000&gprmc=$GPRMC,010203.000,A,2000.0000,N,03000.0000,E,0.00,0.00,010116,,*05&name=test", handler.formatRequest(p)); diff --git a/test/org/traccar/calendar/CalendarTest.java b/test/org/traccar/calendar/CalendarTest.java index 0c8e1830b..ae68af9c0 100644 --- a/test/org/traccar/calendar/CalendarTest.java +++ b/test/org/traccar/calendar/CalendarTest.java @@ -13,6 +13,8 @@ import org.traccar.model.Calendar; import net.fortuna.ical4j.data.ParserException; +import static org.junit.Assert.assertTrue; + public class CalendarTest { @Test @@ -46,13 +48,13 @@ public class CalendarTest { DateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ssX"); Date date = format.parse("2016-12-13 22:59:59+05"); - Assert.assertTrue(!calendar.checkMoment(date)); + assertTrue(!calendar.checkMoment(date)); date = format.parse("2016-12-13 23:00:01+05"); - Assert.assertTrue(calendar.checkMoment(date)); + assertTrue(calendar.checkMoment(date)); date = format.parse("2016-12-13 06:59:59+05"); - Assert.assertTrue(calendar.checkMoment(date)); + assertTrue(calendar.checkMoment(date)); date = format.parse("2016-12-13 07:00:01+05"); - Assert.assertTrue(!calendar.checkMoment(date)); + assertTrue(!calendar.checkMoment(date)); } } diff --git a/test/org/traccar/database/DataManagerTest.java b/test/org/traccar/database/DataManagerTest.java index 3d6f5201e..3e3dcab6c 100644 --- a/test/org/traccar/database/DataManagerTest.java +++ b/test/org/traccar/database/DataManagerTest.java @@ -11,66 +11,70 @@ import org.traccar.model.ManagedUser; import org.traccar.model.Position; import org.traccar.model.User; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class DataManagerTest { @Test public void constructObjectQuery() { - Assert.assertEquals("SELECT * FROM users", + assertEquals("SELECT * FROM users", DataManager.constructObjectQuery(DataManager.ACTION_SELECT_ALL, User.class, false)); - Assert.assertEquals("DELETE FROM groups WHERE id = :id", + assertEquals("DELETE FROM groups WHERE id = :id", DataManager.constructObjectQuery(DataManager.ACTION_DELETE, Group.class, false)); - Assert.assertEquals("SELECT * FROM positions WHERE id = :id", + assertEquals("SELECT * FROM positions WHERE id = :id", DataManager.constructObjectQuery(DataManager.ACTION_SELECT, Position.class, false)); String insertDevice = DataManager.constructObjectQuery(DataManager.ACTION_INSERT, Device.class, false); - Assert.assertFalse(insertDevice.contains("class")); - Assert.assertFalse(insertDevice.contains("id")); - Assert.assertFalse(insertDevice.contains("status")); - Assert.assertFalse(insertDevice.contains("geofenceIds")); + assertFalse(insertDevice.contains("class")); + assertFalse(insertDevice.contains("id")); + assertFalse(insertDevice.contains("status")); + assertFalse(insertDevice.contains("geofenceIds")); String updateDeviceStatus = DataManager.constructObjectQuery("update", Device.class, true); - Assert.assertTrue(updateDeviceStatus.contains("lastUpdate")); + assertTrue(updateDeviceStatus.contains("lastUpdate")); String updateUser = DataManager.constructObjectQuery(DataManager.ACTION_UPDATE, User.class, false); - Assert.assertFalse(updateUser.contains("class")); - Assert.assertFalse(updateUser.contains("password")); - Assert.assertFalse(updateUser.contains("salt")); + assertFalse(updateUser.contains("class")); + assertFalse(updateUser.contains("password")); + assertFalse(updateUser.contains("salt")); String updateUserPassword = DataManager.constructObjectQuery(DataManager.ACTION_UPDATE, User.class, true); - Assert.assertFalse(updateUserPassword.contains("name")); - Assert.assertTrue(updateUserPassword.contains("hashedPassword")); - Assert.assertTrue(updateUserPassword.contains("salt")); + assertFalse(updateUserPassword.contains("name")); + assertTrue(updateUserPassword.contains("hashedPassword")); + assertTrue(updateUserPassword.contains("salt")); String insertPosition = DataManager.constructObjectQuery(DataManager.ACTION_INSERT, Position.class, false); - Assert.assertFalse(insertPosition.contains("type")); - Assert.assertFalse(insertPosition.contains("outdated")); + assertFalse(insertPosition.contains("type")); + assertFalse(insertPosition.contains("outdated")); } @Test public void constructPermissionsQuery() { - Assert.assertEquals("SELECT userId, deviceId FROM user_device", + assertEquals("SELECT userId, deviceId FROM user_device", DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, User.class, Device.class)); - Assert.assertEquals("SELECT userId, managedUserId FROM user_user", + assertEquals("SELECT userId, managedUserId FROM user_user", DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, User.class, ManagedUser.class)); - Assert.assertEquals("SELECT deviceId, driverId FROM device_driver", + assertEquals("SELECT deviceId, driverId FROM device_driver", DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, Device.class, Driver.class)); - Assert.assertEquals("SELECT groupId, geofenceId FROM group_geofence", + assertEquals("SELECT groupId, geofenceId FROM group_geofence", DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, Group.class, Geofence.class)); - Assert.assertEquals("INSERT INTO user_device (userId, deviceId) VALUES (:userId, :deviceId)", + assertEquals("INSERT INTO user_device (userId, deviceId) VALUES (:userId, :deviceId)", DataManager.constructPermissionQuery(DataManager.ACTION_INSERT, User.class, Device.class)); - Assert.assertEquals("DELETE FROM user_user WHERE userId = :userId AND managedUserId = :managedUserId", + assertEquals("DELETE FROM user_user WHERE userId = :userId AND managedUserId = :managedUserId", DataManager.constructPermissionQuery(DataManager.ACTION_DELETE, User.class, ManagedUser.class)); - Assert.assertEquals("INSERT INTO device_geofence (deviceId, geofenceId) VALUES (:deviceId, :geofenceId)", + assertEquals("INSERT INTO device_geofence (deviceId, geofenceId) VALUES (:deviceId, :geofenceId)", DataManager.constructPermissionQuery(DataManager.ACTION_INSERT, Device.class, Geofence.class)); - Assert.assertEquals("DELETE FROM group_attribute WHERE groupId = :groupId AND attributeId = :attributeId", + assertEquals("DELETE FROM group_attribute WHERE groupId = :groupId AND attributeId = :attributeId", DataManager.constructPermissionQuery(DataManager.ACTION_DELETE, Group.class, Attribute.class)); } diff --git a/test/org/traccar/database/GroupTreeTest.java b/test/org/traccar/database/GroupTreeTest.java index f73cb75b6..3e75f9073 100644 --- a/test/org/traccar/database/GroupTreeTest.java +++ b/test/org/traccar/database/GroupTreeTest.java @@ -8,6 +8,8 @@ import org.traccar.model.Group; import java.util.ArrayList; import java.util.Collection; +import static org.junit.Assert.assertEquals; + public class GroupTreeTest { private static Group createGroup(long id, String name, long parent) { @@ -42,14 +44,14 @@ public class GroupTreeTest { GroupTree groupTree = new GroupTree(groups, devices); - Assert.assertEquals(4, groupTree.getGroups(1).size()); - Assert.assertEquals(3, groupTree.getGroups(2).size()); - Assert.assertEquals(0, groupTree.getGroups(3).size()); - Assert.assertEquals(1, groupTree.getGroups(4).size()); + assertEquals(4, groupTree.getGroups(1).size()); + assertEquals(3, groupTree.getGroups(2).size()); + assertEquals(0, groupTree.getGroups(3).size()); + assertEquals(1, groupTree.getGroups(4).size()); - Assert.assertEquals(3, groupTree.getDevices(1).size()); - Assert.assertEquals(1, groupTree.getDevices(3).size()); - Assert.assertEquals(2, groupTree.getDevices(4).size()); + assertEquals(3, groupTree.getDevices(1).size()); + assertEquals(1, groupTree.getDevices(3).size()); + assertEquals(2, groupTree.getDevices(4).size()); } } diff --git a/test/org/traccar/geocoder/AddressFormatTest.java b/test/org/traccar/geocoder/AddressFormatTest.java index 85bb44fd1..12f38fca4 100644 --- a/test/org/traccar/geocoder/AddressFormatTest.java +++ b/test/org/traccar/geocoder/AddressFormatTest.java @@ -3,10 +3,12 @@ package org.traccar.geocoder; import org.junit.Assert; import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class AddressFormatTest { private void test(Address address, String format, String expected) { - Assert.assertEquals(expected, new AddressFormat(format).format(address)); + assertEquals(expected, new AddressFormat(format).format(address)); } @Test diff --git a/test/org/traccar/geocoder/GeocoderTest.java b/test/org/traccar/geocoder/GeocoderTest.java index 7c6208048..3b53495c4 100644 --- a/test/org/traccar/geocoder/GeocoderTest.java +++ b/test/org/traccar/geocoder/GeocoderTest.java @@ -6,6 +6,8 @@ import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; +import static org.junit.Assert.assertEquals; + public class GeocoderTest { @Ignore @@ -44,9 +46,9 @@ public class GeocoderTest { public void onFailure(final Throwable e) { } }); - Assert.assertEquals("1 Ibn Shaprut St, Jerusalem, Jerusalem District, IL", waitAddress()); + assertEquals("1 Ibn Shaprut St, Jerusalem, Jerusalem District, IL", waitAddress()); - Assert.assertEquals("1 Ibn Shaprut St, Jerusalem, Jerusalem District, IL", + assertEquals("1 Ibn Shaprut St, Jerusalem, Jerusalem District, IL", geocoder.getAddress(31.776797, 35.211489, null)); } @@ -63,9 +65,9 @@ public class GeocoderTest { public void onFailure(Throwable e) { } }); - Assert.assertEquals("35 West 9th Street, NYC, New York, US", waitAddress()); + assertEquals("35 West 9th Street, NYC, New York, US", waitAddress()); - Assert.assertEquals("35 West 9th Street, NYC, New York, US", + assertEquals("35 West 9th Street, NYC, New York, US", geocoder.getAddress(40.7337807, -73.9974401, null)); } @@ -82,9 +84,9 @@ public class GeocoderTest { public void onFailure(Throwable e) { } }); - Assert.assertEquals("Rue du Jardinet, Paris, FR", waitAddress()); + assertEquals("Rue du Jardinet, Paris, FR", waitAddress()); - Assert.assertEquals("Rue du Jardinet, Paris, FR", geocoder.getAddress(48.8530000, 2.3400000, null)); + assertEquals("Rue du Jardinet, Paris, FR", geocoder.getAddress(48.8530000, 2.3400000, null)); } public void testOpenCage() throws InterruptedException { @@ -101,9 +103,9 @@ public class GeocoderTest { public void onFailure(Throwable e) { } }); - Assert.assertEquals("Charleston Road, California, US", waitAddress()); + assertEquals("Charleston Road, California, US", waitAddress()); - Assert.assertEquals("Charleston Road, California, US", geocoder.getAddress(34.116302, -118.051519, null)); + assertEquals("Charleston Road, California, US", geocoder.getAddress(34.116302, -118.051519, null)); } public void testGeocodeFarm() throws InterruptedException { @@ -119,9 +121,9 @@ public class GeocoderTest { public void onFailure(Throwable e) { } }); - Assert.assertEquals("Estrella Avenue, Arcadia, California, United States", waitAddress()); + assertEquals("Estrella Avenue, Arcadia, California, United States", waitAddress()); - Assert.assertEquals("Estrella Avenue, Arcadia, California, United States", + assertEquals("Estrella Avenue, Arcadia, California, United States", geocoder.getAddress(34.116302, -118.051519, null)); } diff --git a/test/org/traccar/geofence/GeofenceCircleTest.java b/test/org/traccar/geofence/GeofenceCircleTest.java index 133ca1db8..020b10a0b 100644 --- a/test/org/traccar/geofence/GeofenceCircleTest.java +++ b/test/org/traccar/geofence/GeofenceCircleTest.java @@ -5,6 +5,9 @@ import java.text.ParseException; import org.junit.Assert; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class GeofenceCircleTest { @Test @@ -12,7 +15,7 @@ public class GeofenceCircleTest { String test = "CIRCLE (55.75414 37.6204, 100)"; GeofenceGeometry geofenceGeometry = new GeofenceCircle(); geofenceGeometry.fromWkt(test); - Assert.assertEquals(geofenceGeometry.toWkt(), test); + assertEquals(geofenceGeometry.toWkt(), test); } @Test @@ -20,7 +23,7 @@ public class GeofenceCircleTest { String test = "CIRCLE (55.75414 37.6204, 100)"; GeofenceGeometry geofenceGeometry = new GeofenceCircle(); geofenceGeometry.fromWkt(test); - Assert.assertTrue(geofenceGeometry.containsPoint(55.75477, 37.62025)); - Assert.assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921)); + assertTrue(geofenceGeometry.containsPoint(55.75477, 37.62025)); + assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921)); } } diff --git a/test/org/traccar/geofence/GeofencePolygonTest.java b/test/org/traccar/geofence/GeofencePolygonTest.java index 361e7b70f..31f35120f 100644 --- a/test/org/traccar/geofence/GeofencePolygonTest.java +++ b/test/org/traccar/geofence/GeofencePolygonTest.java @@ -5,6 +5,9 @@ import java.text.ParseException; import org.junit.Assert; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class GeofencePolygonTest { @Test @@ -12,7 +15,7 @@ public class GeofencePolygonTest { String test = "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"; GeofenceGeometry geofenceGeometry = new GeofencePolygon(); geofenceGeometry.fromWkt(test); - Assert.assertEquals(geofenceGeometry.toWkt(), test); + assertEquals(geofenceGeometry.toWkt(), test); } @Test @@ -20,8 +23,8 @@ public class GeofencePolygonTest { String test = "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"; GeofenceGeometry geofenceGeometry = new GeofencePolygon(); geofenceGeometry.fromWkt(test); - Assert.assertTrue(geofenceGeometry.containsPoint(55.75476, 37.61915)); - Assert.assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921)); + assertTrue(geofenceGeometry.containsPoint(55.75476, 37.61915)); + assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921)); } @@ -30,9 +33,9 @@ public class GeofencePolygonTest { String test = "POLYGON ((66.9494 179.838, 66.9508 -179.8496, 66.8406 -180.0014))"; GeofenceGeometry geofenceGeometry = new GeofencePolygon(); geofenceGeometry.fromWkt(test); - Assert.assertTrue(geofenceGeometry.containsPoint(66.9015, -180.0096)); - Assert.assertTrue(geofenceGeometry.containsPoint(66.9015, 179.991)); - Assert.assertTrue(!geofenceGeometry.containsPoint(66.8368, -179.8792)); + assertTrue(geofenceGeometry.containsPoint(66.9015, -180.0096)); + assertTrue(geofenceGeometry.containsPoint(66.9015, 179.991)); + assertTrue(!geofenceGeometry.containsPoint(66.8368, -179.8792)); } @@ -41,9 +44,9 @@ public class GeofencePolygonTest { String test = "POLYGON ((51.1966 -0.6207, 51.1897 0.4147, 50.9377 0.5136, 50.8675 -0.6082))"; GeofenceGeometry geofenceGeometry = new GeofencePolygon(); geofenceGeometry.fromWkt(test); - Assert.assertTrue(geofenceGeometry.containsPoint(51.0466, -0.0165)); - Assert.assertTrue(geofenceGeometry.containsPoint(51.0466, 0.018)); - Assert.assertTrue(!geofenceGeometry.containsPoint(50.9477, 0.5836)); + assertTrue(geofenceGeometry.containsPoint(51.0466, -0.0165)); + assertTrue(geofenceGeometry.containsPoint(51.0466, 0.018)); + assertTrue(!geofenceGeometry.containsPoint(50.9477, 0.5836)); } diff --git a/test/org/traccar/geofence/GeofencePolylineTest.java b/test/org/traccar/geofence/GeofencePolylineTest.java index 71aeb4081..1b51c17f6 100644 --- a/test/org/traccar/geofence/GeofencePolylineTest.java +++ b/test/org/traccar/geofence/GeofencePolylineTest.java @@ -5,6 +5,9 @@ import java.text.ParseException; import org.junit.Assert; import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class GeofencePolylineTest { @Test @@ -12,25 +15,25 @@ public class GeofencePolylineTest { String test = "LINESTRING (55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165)"; GeofenceGeometry geofenceGeometry = new GeofencePolyline(); geofenceGeometry.fromWkt(test); - Assert.assertEquals(geofenceGeometry.toWkt(), test); + assertEquals(geofenceGeometry.toWkt(), test); } @Test public void testContainsPolyline1Interval() throws ParseException { String test = "LINESTRING (56.83777 60.59833, 56.83766 60.5968)"; GeofenceGeometry geofenceGeometry = new GeofencePolyline(test, 35); - Assert.assertTrue(geofenceGeometry.containsPoint(56.83801, 60.59748)); + assertTrue(geofenceGeometry.containsPoint(56.83801, 60.59748)); ((GeofencePolyline) geofenceGeometry).setDistance(15); - Assert.assertTrue(!geofenceGeometry.containsPoint(56.83801, 60.59748)); + assertTrue(!geofenceGeometry.containsPoint(56.83801, 60.59748)); } @Test public void testContainsPolyline3Intervals() throws ParseException { String test = "LINESTRING (56.836 60.6126, 56.8393 60.6114, 56.83887 60.60811, 56.83782 60.5988)"; GeofenceGeometry geofenceGeometry = new GeofencePolyline(test, 15); - Assert.assertTrue(geofenceGeometry.containsPoint(56.83847, 60.60458)); - Assert.assertTrue(!geofenceGeometry.containsPoint(56.83764, 60.59725)); - Assert.assertTrue(!geofenceGeometry.containsPoint(56.83861, 60.60822)); + assertTrue(geofenceGeometry.containsPoint(56.83847, 60.60458)); + assertTrue(!geofenceGeometry.containsPoint(56.83764, 60.59725)); + assertTrue(!geofenceGeometry.containsPoint(56.83861, 60.60822)); } @@ -38,8 +41,8 @@ public class GeofencePolylineTest { public void testContainsPolylineNear180() throws ParseException { String test = "LINESTRING (66.9494 179.838, 66.9508 -179.8496)"; GeofenceGeometry geofenceGeometry = new GeofencePolyline(test, 25); - Assert.assertTrue(geofenceGeometry.containsPoint(66.95, 180.0)); - Assert.assertTrue(!geofenceGeometry.containsPoint(66.96, 180.0)); - Assert.assertTrue(!geofenceGeometry.containsPoint(66.9509, -179.83)); + assertTrue(geofenceGeometry.containsPoint(66.95, 180.0)); + assertTrue(!geofenceGeometry.containsPoint(66.96, 180.0)); + assertTrue(!geofenceGeometry.containsPoint(66.9509, -179.83)); } } diff --git a/test/org/traccar/geolocation/GeolocationProviderTest.java b/test/org/traccar/geolocation/GeolocationProviderTest.java index 6a557e5c2..97b5b32da 100644 --- a/test/org/traccar/geolocation/GeolocationProviderTest.java +++ b/test/org/traccar/geolocation/GeolocationProviderTest.java @@ -7,6 +7,9 @@ import org.traccar.BaseTest; import org.traccar.model.CellTower; import org.traccar.model.Network; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + public class GeolocationProviderTest extends BaseTest { @Ignore @@ -23,13 +26,13 @@ public class GeolocationProviderTest extends BaseTest { provider.getLocation(network, new GeolocationProvider.LocationProviderCallback() { @Override public void onSuccess(double latitude, double longitude, double accuracy) { - Assert.assertEquals(60.07254, latitude, 0.00001); - Assert.assertEquals(30.30996, longitude, 0.00001); + assertEquals(60.07254, latitude, 0.00001); + assertEquals(30.30996, longitude, 0.00001); } @Override public void onFailure(Throwable e) { - Assert.fail(); + fail(); } }); 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"))); } diff --git a/test/org/traccar/processing/ComputedAttributesTest.java b/test/org/traccar/processing/ComputedAttributesTest.java index fe898ff54..88ebfd9a9 100644 --- a/test/org/traccar/processing/ComputedAttributesTest.java +++ b/test/org/traccar/processing/ComputedAttributesTest.java @@ -7,6 +7,8 @@ import org.junit.Test; import org.traccar.model.Attribute; import org.traccar.model.Position; +import static org.junit.Assert.assertEquals; + public class ComputedAttributesTest { @Test @@ -26,41 +28,41 @@ public class ComputedAttributesTest { Attribute attribute = new Attribute(); attribute.setExpression("adc1"); - Assert.assertEquals(128, computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals(128, computedAttributesHandler.computeAttribute(attribute, position)); attribute.setExpression("!booleanFlag"); - Assert.assertEquals(false, computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals(false, computedAttributesHandler.computeAttribute(attribute, position)); attribute.setExpression("adc2 * 2 + 50"); - Assert.assertEquals(250, computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals(250, computedAttributesHandler.computeAttribute(attribute, position)); attribute.setExpression("(bitFlag & 4) != 0"); - Assert.assertEquals(true, computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals(true, computedAttributesHandler.computeAttribute(attribute, position)); attribute.setExpression("if (event == 42) \"lowBattery\""); - Assert.assertEquals("lowBattery", computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals("lowBattery", computedAttributesHandler.computeAttribute(attribute, position)); attribute.setExpression("speed > 5 && valid"); - Assert.assertEquals(false, computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals(false, computedAttributesHandler.computeAttribute(attribute, position)); attribute.setExpression("fixTime"); - Assert.assertEquals(date, computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals(date, computedAttributesHandler.computeAttribute(attribute, position)); attribute.setExpression("math:pow(adc1, 2)"); - Assert.assertEquals(16384.0, computedAttributesHandler.computeAttribute(attribute, position)); + assertEquals(16384.0, computedAttributesHandler.computeAttribute(attribute, position)); // modification tests attribute.setExpression("adc1 = 256"); computedAttributesHandler.computeAttribute(attribute, position); - Assert.assertEquals(128, position.getInteger("adc1")); + assertEquals(128, position.getInteger("adc1")); attribute.setExpression("result = \"fail\""); computedAttributesHandler.computeAttribute(attribute, position); - Assert.assertEquals("success", position.getString("result")); + assertEquals("success", position.getString("result")); attribute.setExpression("fixTime = \"2017-10-18 10:00:01\""); computedAttributesHandler.computeAttribute(attribute, position); - Assert.assertEquals(date, position.getFixTime()); + assertEquals(date, position.getFixTime()); } diff --git a/test/org/traccar/protocol/AdmProtocolEncoderTest.java b/test/org/traccar/protocol/AdmProtocolEncoderTest.java index 6d2452e26..fd4ea4af0 100644 --- a/test/org/traccar/protocol/AdmProtocolEncoderTest.java +++ b/test/org/traccar/protocol/AdmProtocolEncoderTest.java @@ -21,6 +21,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class AdmProtocolEncoderTest extends ProtocolTest { @Test @@ -31,13 +33,13 @@ public class AdmProtocolEncoderTest extends ProtocolTest { Command command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_GET_DEVICE_STATUS); - Assert.assertEquals("STATUS\r\n", encoder.encodeCommand(command)); + assertEquals("STATUS\r\n", encoder.encodeCommand(command)); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_CUSTOM); command.set(Command.KEY_DATA, "INPUT 0"); - Assert.assertEquals("INPUT 0\r\n", encoder.encodeCommand(command)); + assertEquals("INPUT 0\r\n", encoder.encodeCommand(command)); } } diff --git a/test/org/traccar/protocol/AplicomFrameDecoderTest.java b/test/org/traccar/protocol/AplicomFrameDecoderTest.java index e000674db..6ba8f9334 100644 --- a/test/org/traccar/protocol/AplicomFrameDecoderTest.java +++ b/test/org/traccar/protocol/AplicomFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class AplicomFrameDecoderTest extends ProtocolTest { @Test @@ -11,11 +13,11 @@ public class AplicomFrameDecoderTest extends ProtocolTest { AplicomFrameDecoder decoder = new AplicomFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("44C20146B710C158DA009500B09F7700C054CA0EA454CA0EA403BE0BF6015D706B070000142A600000000000000002434946010801000754CA0EA4000000000000008400000000000000000000000000000000300000FE00FE0000000000000000000000000000000000000000000000000000000000000000000040502035000000000000020D0000030D0000040C0000040D0000050C0000050D0000058C0000060C"), decoder.decode(null, null, binary("33353733303030373030393233333644C20146B710C158DA009500B09F7700C054CA0EA454CA0EA403BE0BF6015D706B070000142A600000000000000002434946010801000754CA0EA4000000000000008400000000000000000000000000000000300000FE00FE0000000000000000000000000000000000000000000000000000000000000000000040502035000000000000020D0000030D0000040C0000040D0000050C0000050D0000058C0000060C"))); - Assert.assertEquals( + assertEquals( binary("44C20146B710C158DA009500B09F7700C054CA0EA454CA0EA403BE0BF6015D706B070000142A600000000000000002434946010801000754CA0EA4000000000000008400000000000000000000000000000000300000FE00FE0000000000000000000000000000000000000000000000000000000000000000000040502035000000000000020D0000030D0000040C0000040D0000050C0000050D0000058C0000060C"), decoder.decode(null, null, binary("44C20146B710C158DA009500B09F7700C054CA0EA454CA0EA403BE0BF6015D706B070000142A600000000000000002434946010801000754CA0EA4000000000000008400000000000000000000000000000000300000FE00FE0000000000000000000000000000000000000000000000000000000000000000000040502035000000000000020D0000030D0000040C0000040D0000050C0000050D0000058C0000060C"))); diff --git a/test/org/traccar/protocol/At2000FrameDecoderTest.java b/test/org/traccar/protocol/At2000FrameDecoderTest.java index c7a3dc0b1..52490c107 100644 --- a/test/org/traccar/protocol/At2000FrameDecoderTest.java +++ b/test/org/traccar/protocol/At2000FrameDecoderTest.java @@ -6,6 +6,8 @@ import org.traccar.ProtocolTest; import java.nio.ByteOrder; +import static org.junit.Assert.assertEquals; + public class At2000FrameDecoderTest extends ProtocolTest { @Test @@ -13,11 +15,11 @@ public class At2000FrameDecoderTest extends ProtocolTest { At2000FrameDecoder decoder = new At2000FrameDecoder(); - Assert.assertEquals( + assertEquals( binary(ByteOrder.LITTLE_ENDIAN, "01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"))); - Assert.assertEquals( + assertEquals( binary(ByteOrder.LITTLE_ENDIAN, "893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e"))); diff --git a/test/org/traccar/protocol/AtrackFrameDecoderTest.java b/test/org/traccar/protocol/AtrackFrameDecoderTest.java index 93e804dc9..12ce783ad 100644 --- a/test/org/traccar/protocol/AtrackFrameDecoderTest.java +++ b/test/org/traccar/protocol/AtrackFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class AtrackFrameDecoderTest extends ProtocolTest { @Test @@ -11,15 +13,15 @@ public class AtrackFrameDecoderTest extends ProtocolTest { AtrackFrameDecoder decoder = new AtrackFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("244F4B0D0A"), decoder.decode(null, null, binary("244F4B0D0A"))); - Assert.assertEquals( + assertEquals( binary("fe0200014104d8f196820001"), decoder.decode(null, null, binary("fe0200014104d8f196820001"))); - Assert.assertEquals( + assertEquals( binary("40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000"), decoder.decode(null, null, binary("40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000"))); diff --git a/test/org/traccar/protocol/GalileoFrameDecoderTest.java b/test/org/traccar/protocol/GalileoFrameDecoderTest.java index 1decd73d3..049c16efa 100644 --- a/test/org/traccar/protocol/GalileoFrameDecoderTest.java +++ b/test/org/traccar/protocol/GalileoFrameDecoderTest.java @@ -6,6 +6,8 @@ import org.traccar.ProtocolTest; import java.nio.ByteOrder; +import static org.junit.Assert.assertEquals; + public class GalileoFrameDecoderTest extends ProtocolTest { @Test @@ -13,11 +15,11 @@ public class GalileoFrameDecoderTest extends ProtocolTest { GalileoFrameDecoder decoder = new GalileoFrameDecoder(); - Assert.assertEquals( + assertEquals( binary(ByteOrder.LITTLE_ENDIAN, "011780011102e603383633353931303238393630323437043200801c"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "011780011102e603383633353931303238393630323437043200801c"))); - Assert.assertEquals( + assertEquals( binary(ByteOrder.LITTLE_ENDIAN, "01d48304320010020520a5829f58300f50dc8a024c0965013300000000344102350740003a41e14b426610431b4459fa672a4500004601a050364c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e293000000043200100105202d829f58300f50dc8a024c0965013300000000344102350740003a41d04b426110431b445702882a4500004601a050374c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29400000004320010000520b5819f58300f50dc8a024c0965013300000000344102350740003a419e4b426a10431c4456fab72a4500004601a050434c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010ff04203d819f58300f50dc8a024c0965013300000000344102350740003a41874b426310431c4454fe572a4500004601a050334c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29600000004320010fe0420c5809f58300f50dc8a024c0965013300000000344102350840003a41a24b426710431c4457fea72a4500004601a050214c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fd04204d809f58300f50dc8a024c0965013300000000344102350840003a41a34b426310431c4455f6772a4500004601a0502e4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29900000004320010fc0420d57f9f58300f50dc8a024c0965013300000000344102350840003a41bd4b426510431d4458fe672a4500004601a0501f4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fb04205d7f9f58300f50dc8a024c0965013300000000344102350840003a41b54b426310431d4456fa772a4500004601a0502d4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010fa0420e57e9f58300f50dc8a024c0965013300000000344102350840003a41b24b426210431e4454fa872a4500004601a050fe4b510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29000000004320010f904206d7e9f58300f50dc8a024c0965013300000000344102350a40003a41af4b426710431f4458fea72a4500004601a0500a4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e28900000067c5"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "01d48304320010020520a5829f58300f50dc8a024c0965013300000000344102350740003a41e14b426610431b4459fa672a4500004601a050364c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e293000000043200100105202d829f58300f50dc8a024c0965013300000000344102350740003a41d04b426110431b445702882a4500004601a050374c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29400000004320010000520b5819f58300f50dc8a024c0965013300000000344102350740003a419e4b426a10431c4456fab72a4500004601a050434c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010ff04203d819f58300f50dc8a024c0965013300000000344102350740003a41874b426310431c4454fe572a4500004601a050334c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29600000004320010fe0420c5809f58300f50dc8a024c0965013300000000344102350840003a41a24b426710431c4457fea72a4500004601a050214c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fd04204d809f58300f50dc8a024c0965013300000000344102350840003a41a34b426310431c4455f6772a4500004601a0502e4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29900000004320010fc0420d57f9f58300f50dc8a024c0965013300000000344102350840003a41bd4b426510431d4458fe672a4500004601a0501f4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fb04205d7f9f58300f50dc8a024c0965013300000000344102350840003a41b54b426310431d4456fa772a4500004601a0502d4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010fa0420e57e9f58300f50dc8a024c0965013300000000344102350840003a41b24b426210431e4454fa872a4500004601a050fe4b510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29000000004320010f904206d7e9f58300f50dc8a024c0965013300000000344102350a40003a41af4b426710431f4458fea72a4500004601a0500a4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e28900000067c5"))); diff --git a/test/org/traccar/protocol/GatorProtocolDecoderTest.java b/test/org/traccar/protocol/GatorProtocolDecoderTest.java index 6d4dc06e8..ae6240b3e 100644 --- a/test/org/traccar/protocol/GatorProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GatorProtocolDecoderTest.java @@ -4,12 +4,14 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class GatorProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeId() { - Assert.assertEquals("3512345006", GatorProtocolDecoder.decodeId(12, 162, 50, 134)); + assertEquals("3512345006", GatorProtocolDecoder.decodeId(12, 162, 50, 134)); } diff --git a/test/org/traccar/protocol/Gl200FrameDecoderTest.java b/test/org/traccar/protocol/Gl200FrameDecoderTest.java index 54c35f084..2112ce466 100644 --- a/test/org/traccar/protocol/Gl200FrameDecoderTest.java +++ b/test/org/traccar/protocol/Gl200FrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class Gl200FrameDecoderTest extends ProtocolTest { @Test @@ -11,15 +13,15 @@ public class Gl200FrameDecoderTest extends ProtocolTest { Gl200FrameDecoder decoder = new Gl200FrameDecoder(); - Assert.assertEquals( + assertEquals( binary("2b41434b017f244501010108676231303000000000ffff07e1070b03112d054dfe030d0a"), decoder.decode(null, null, binary("2b41434b017f244501010108676231303000000000ffff07e1070b03112d054dfe030d0a"))); - Assert.assertEquals( + assertEquals( binary("2b4556540c00fc1fbf005c4501010108563254030003430564312a41090100000000003f007dff75a11a025c6a7807e1070a14041202680003189c1ac500000000000000000000000000000000000007e1070b041134054e5c6e0d0a"), decoder.decode(null, null, binary("2b4556540c00fc1fbf005c4501010108563254030003430564312a41090100000000003f007dff75a11a025c6a7807e1070a14041202680003189c1ac500000000000000000000000000000000000007e1070b041134054e5c6e0d0a"))); - Assert.assertEquals( + assertEquals( binary("2b524553503a47545354522c3430303330302c3836323336353033303134323238392c474c3530302c302c302c302c33392e342c39332c312c302e332c31372c3130352e382c32352e3934343234302c34342e3430333733362c32303137303532393134303533302c303232362c303030312c353643322c373038342c2c2c2c32303137303532393136303533302c30324441"), decoder.decode(null, null, binary("2b524553503a47545354522c3430303330302c3836323336353033303134323238392c474c3530302c302c302c302c33392e342c39332c312c302e332c31372c3130352e382c32352e3934343234302c34342e3430333733362c32303137303532393134303533302c303232362c303030312c353643322c373038342c2c2c2c32303137303532393136303533302c3032444124"))); diff --git a/test/org/traccar/protocol/Gps056FrameDecoderTest.java b/test/org/traccar/protocol/Gps056FrameDecoderTest.java index a5b5c5bbd..58c64f59e 100644 --- a/test/org/traccar/protocol/Gps056FrameDecoderTest.java +++ b/test/org/traccar/protocol/Gps056FrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class Gps056FrameDecoderTest extends ProtocolTest { @Test @@ -11,11 +13,11 @@ public class Gps056FrameDecoderTest extends ProtocolTest { Gps056FrameDecoder decoder = new Gps056FrameDecoder(); - Assert.assertEquals( + assertEquals( binary("242435314750534c5f30323836323436323033333738323934361905110f160b0b7710584e1cbd1b9b4500005b100300fb0a071700ffff23"), decoder.decode(null, null, binary("242435314750534c5f30323836323436323033333738323934361905110f160b0b7710584e1cbd1b9b4500005b100300fb0a071700ffff230030"))); - Assert.assertEquals( + assertEquals( binary("242432354c4f474e5f3131383632343632303333373832393436322e3123"), decoder.decode(null, null, binary("242432354c4f474e5f3131383632343632303333373832393436322e3123"))); diff --git a/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java index 54c520c21..cfb1d5b90 100644 --- a/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class Gps103ProtocolEncoderTest extends ProtocolTest { @Test @@ -17,7 +19,7 @@ public class Gps103ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_POSITION_PERIODIC); command.set(Command.KEY_FREQUENCY, 300); - Assert.assertEquals("**,imei:123456789012345,C,05m", encoder.encodeCommand(command)); + assertEquals("**,imei:123456789012345,C,05m", encoder.encodeCommand(command)); } @@ -31,7 +33,7 @@ public class Gps103ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_CUSTOM); command.set(Command.KEY_DATA, "H,080"); - Assert.assertEquals("**,imei:123456789012345,H,080", encoder.encodeCommand(command)); + assertEquals("**,imei:123456789012345,H,080", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/GranitFrameDecoderTest.java b/test/org/traccar/protocol/GranitFrameDecoderTest.java index cf84c2026..aa5a5b580 100644 --- a/test/org/traccar/protocol/GranitFrameDecoderTest.java +++ b/test/org/traccar/protocol/GranitFrameDecoderTest.java @@ -6,6 +6,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class GranitFrameDecoderTest extends ProtocolTest { @Test @@ -13,33 +15,33 @@ public class GranitFrameDecoderTest extends ProtocolTest { GranitFrameDecoder decoder = new GranitFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("2b525243427e1a003e2934757c57b8b03c38d279b4e61e9bd7006b000000001c00002a4533"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b525243427e1a003e2934757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a"))); - Assert.assertEquals( + assertEquals( binary("2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a4533"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a"))); - Assert.assertEquals( + assertEquals( binary("4f4b"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "4f4b0d0a2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a"))); - Assert.assertEquals( + assertEquals( binary("2b444441547e84003e290401d01690737c57b8903c383c7fa0e5081b64006b000000001c0000b8803c388e7fe7e5102197006c000000001c0000b8813c38ad7f02e6042035006c000000001d0000b8813c38bf7f13e6001d1e006c000000001d0000b8813c38bf7f13e6001d00006c000000001d0000b8903c38977f34e6091065006c000000001e000014002a3932"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b444441547e84003e290401d01690737c57b8903c383c7fa0e5081b64006b000000001c0000b8803c388e7fe7e5102197006c000000001c0000b8813c38ad7f02e6042035006c000000001d0000b8813c38bf7f13e6001d1e006c000000001d0000b8813c38bf7f13e6001d00006c000000001d0000b8903c38977f34e6091065006c000000001e000014002a39320d0a"))); - Assert.assertEquals( + assertEquals( binary("2b444441547e84003e290401d41680747c57f8a03c38987f50e6005300006c000000001c0000f8b03c38987f50e6005300006c000000001c0000fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe14002a4346"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b444441547e84003e290401d41680747c57f8a03c38987f50e6005300006c000000001c0000f8b03c38987f50e6005300006c000000001c0000fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe14002a43460d0a"))); - Assert.assertEquals( + assertEquals( binary("2b49444e543a204e6176696761746f722e30347820204669726d776172652076657273696f6e202030373132474c4e202a3231"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b49444e543a204e6176696761746f722e30347820204669726d776172652076657273696f6e202030373132474c4e202a32310d0a"))); - Assert.assertEquals( + assertEquals( binary("4552524f522057524f4e4720434845434b53554d5f31"), decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "4552524f522057524f4e4720434845434b53554d5f310d0a"))); diff --git a/test/org/traccar/protocol/H02FrameDecoderTest.java b/test/org/traccar/protocol/H02FrameDecoderTest.java index 3ced35d53..214f1c9fa 100644 --- a/test/org/traccar/protocol/H02FrameDecoderTest.java +++ b/test/org/traccar/protocol/H02FrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class H02FrameDecoderTest extends ProtocolTest { @Test @@ -11,23 +13,23 @@ public class H02FrameDecoderTest extends ProtocolTest { H02FrameDecoder decoder = new H02FrameDecoder(0); - Assert.assertEquals( + assertEquals( binary("2a48512c3335353438383032303131333931312c56312c3031323934352c412c353233312e37393238332c4e2c30313332342e31303731382c452c302e30352c302c3137303231372c464646464646464623"), decoder.decode(null, null, binary("2a48512c3335353438383032303131333931312c56312c3031323934352c412c353233312e37393238332c4e2c30313332342e31303731382c452c302e30352c302c3137303231372c4646464646464646230d0a"))); - Assert.assertEquals( + assertEquals( binary("2441060116601245431311165035313006004318210e000000fffffbffff0024"), decoder.decode(null, null, binary("2441060116601245431311165035313006004318210e000000fffffbffff0024"))); - Assert.assertEquals( + assertEquals( binary("2441060116601245431311165035313006004318210e000000fffffbffff0024"), decoder.decode(null, null, binary("2441060116601245431311165035313006004318210e000000fffffbffff00242a48512c343130363031313636302c56312c3132343535322c412c353033352e333132392c4e2c30303433312e383231312c452c3030302e32302c3030302c3133313131362c464646464642464623"))); - Assert.assertEquals( + assertEquals( binary("2a48512c3335333538383036303031353536382c56312c3139333530352c412c3830392e303031302c532c333435342e383939372c572c302e30302c302e30302c3239313031332c65666666666266662c3030303264342c3030303030622c3030353338352c3030353261612c323523"), decoder.decode(null, null, binary("2a48512c3335333538383036303031353536382c56312c3139333530352c412c3830392e303031302c532c333435342e383939372c572c302e30302c302e30302c3239313031332c65666666666266662c3030303264342c3030303030622c3030353338352c3030353261612c323523"))); - Assert.assertEquals( + assertEquals( binary("24430025645511183817091319355128000465632432000100ffe7fbffff0000"), decoder.decode(null, null, binary("24430025645511183817091319355128000465632432000100ffe7fbffff0000"))); @@ -38,7 +40,7 @@ public class H02FrameDecoderTest extends ProtocolTest { H02FrameDecoder decoder = new H02FrameDecoder(0); - Assert.assertEquals( + assertEquals( binary("24410600082621532131081504419390060740418306000000fffffbfdff0015060000002c02dc0c000000001f"), decoder.decode(null, null, binary("24410600082621532131081504419390060740418306000000fffffbfdff0015060000002c02dc0c000000001f"))); @@ -49,19 +51,19 @@ public class H02FrameDecoderTest extends ProtocolTest { H02FrameDecoder decoder = new H02FrameDecoder(0); - Assert.assertEquals( + assertEquals( binary("2a48512c343230363131393133302c4e42522c3130323430332c3233382c312c302c372c313131312c323236342c36332c313131312c323236352c35382c313131312c323236362c35302c313131312c333133352c33372c313131312c3630352c33332c313131312c343932302c33302c313131312c3630372c32382c3131303131372c46464646444646462c3623"), decoder.decode(null, null, binary("2a48512c343230363131393133302c4e42522c3130323430332c3233382c312c302c372c313131312c323236342c36332c313131312c323236352c35382c313131312c323236362c35302c313131312c333133352c33372c313131312c3630352c33332c313131312c343932302c33302c313131312c3630372c32382c3131303131372c46464646444646462c3623"))); - Assert.assertEquals( + assertEquals( binary("2442061191301024031101175540227006012321670c000095fffffbffff001f00000001f800ee010000000032"), decoder.decode(null, null, binary("2442061191301024031101175540227006012321670c000095fffffbffff001f00000001f800ee010000000032"))); - Assert.assertEquals( + assertEquals( binary("5800009814991024031101175540227006012321670c000095fffffbffff0033"), decoder.decode(null, null, binary("5800009814991024031101175540227006012321670c000095fffffbffff0033"))); - Assert.assertEquals( + assertEquals( binary("2a48512c343230363131393133302c4e42522c3130323431362c3233382c312c302c372c313131312c323236342c35332c313131312c323236352c36302c313131312c323236362c34342c313131312c333133352c34332c313131312c3630352c33392c313131312c343932302c32392c313131312c3630372c32342c3131303131372c46464646464246462c3623"), decoder.decode(null, null, binary("2a48512c343230363131393133302c4e42522c3130323431362c3233382c312c302c372c313131312c323236342c35332c313131312c323236352c36302c313131312c323236362c34342c313131312c333133352c34332c313131312c3630352c33392c313131312c343932302c32392c313131312c3630372c32342c3131303131372c46464646464246462c3623"))); diff --git a/test/org/traccar/protocol/H02ProtocolEncoderTest.java b/test/org/traccar/protocol/H02ProtocolEncoderTest.java index f0369eeeb..bf3978385 100644 --- a/test/org/traccar/protocol/H02ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/H02ProtocolEncoderTest.java @@ -6,6 +6,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class H02ProtocolEncoderTest extends ProtocolTest { private H02ProtocolEncoder encoder = new H02ProtocolEncoder(); @@ -18,7 +20,7 @@ public class H02ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_ALARM_ARM); - Assert.assertEquals("*HQ,123456789012345,SCF,010203,0,0#", encoder.encodeCommand(command, time)); + assertEquals("*HQ,123456789012345,SCF,010203,0,0#", encoder.encodeCommand(command, time)); } @Test @@ -28,7 +30,7 @@ public class H02ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_ALARM_DISARM); - Assert.assertEquals("*HQ,123456789012345,SCF,010203,1,1#", encoder.encodeCommand(command, time)); + assertEquals("*HQ,123456789012345,SCF,010203,1,1#", encoder.encodeCommand(command, time)); } @Test @@ -38,7 +40,7 @@ public class H02ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_ENGINE_STOP); - Assert.assertEquals("*HQ,123456789012345,S20,010203,1,3,10,3,5,5,3,5,3,5,3,5#", encoder.encodeCommand(command, time)); + assertEquals("*HQ,123456789012345,S20,010203,1,3,10,3,5,5,3,5,3,5,3,5#", encoder.encodeCommand(command, time)); } @Test @@ -48,7 +50,7 @@ public class H02ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_ENGINE_RESUME); - Assert.assertEquals("*HQ,123456789012345,S20,010203,0,0#", encoder.encodeCommand(command, time)); + assertEquals("*HQ,123456789012345,S20,010203,0,0#", encoder.encodeCommand(command, time)); } @Test @@ -59,7 +61,7 @@ public class H02ProtocolEncoderTest extends ProtocolTest { command.set(Command.KEY_FREQUENCY, 10); command.setType(Command.TYPE_POSITION_PERIODIC); - Assert.assertEquals("*HQ,123456789012345,S71,010203,22,10#", encoder.encodeCommand(command, time)); + assertEquals("*HQ,123456789012345,S71,010203,22,10#", encoder.encodeCommand(command, time)); } } diff --git a/test/org/traccar/protocol/HuaShengFrameDecoderTest.java b/test/org/traccar/protocol/HuaShengFrameDecoderTest.java index c3f5c585f..dc2536319 100644 --- a/test/org/traccar/protocol/HuaShengFrameDecoderTest.java +++ b/test/org/traccar/protocol/HuaShengFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class HuaShengFrameDecoderTest extends ProtocolTest { @Test @@ -11,19 +13,19 @@ public class HuaShengFrameDecoderTest extends ProtocolTest { HuaShengFrameDecoder decoder = new HuaShengFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("c0010c00120060000000000004000600010100c0"), decoder.decode(null, null, binary("c0010c00120060000000000004000600010100c0"))); - Assert.assertEquals( + assertEquals( binary("c0010c003e0002000000000010020012a0014f42445f3347315f56312e302e330013a0043335353835353035303434303635380006a08701000006a0a1035fc0"), decoder.decode(null, null, binary("c0010c003e0002000000000010020012a0014f42445f3347315f56312e302e330013a0043335353835353035303434303635380006a08701000006a0a1035fc0"))); - Assert.assertEquals( + assertEquals( binary("c00000003faa0000000000003ea5a5005a3f00c000000031363037303530373132353700e6d186ffcc7a25002201160010000000010015000000000000000000c0"), decoder.decode(null, null, binary("c00000003faa0000000000003ea5a5005a3f00dbdc00000031363037303530373132353700e6d186ffcc7a25002201160010000000010015000000000000000000c0"))); - Assert.assertEquals( + assertEquals( binary("C000000041AA00000000000030C000000031353035323630373538323800ADDCC100226AEF0000000000120005000100151206EF0504E99975002903EB80556492CEC0"), decoder.decode(null, null, binary("C000000041AA00000000000030DBDC00000031353035323630373538323800ADDCC100226AEF0000000000120005000100151206EF0504E99975002903EB80556492CEC0"))); diff --git a/test/org/traccar/protocol/HuabaoFrameDecoderTest.java b/test/org/traccar/protocol/HuabaoFrameDecoderTest.java index ad828bdb4..98caf1dca 100644 --- a/test/org/traccar/protocol/HuabaoFrameDecoderTest.java +++ b/test/org/traccar/protocol/HuabaoFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class HuabaoFrameDecoderTest extends ProtocolTest { @Test @@ -11,7 +13,7 @@ public class HuabaoFrameDecoderTest extends ProtocolTest { HuabaoFrameDecoder decoder = new HuabaoFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("7e307e087d557e"), decoder.decode(null, null, binary("7e307d02087d01557e"))); diff --git a/test/org/traccar/protocol/L100FrameDecoderTest.java b/test/org/traccar/protocol/L100FrameDecoderTest.java index f474fa678..ab70678d5 100644 --- a/test/org/traccar/protocol/L100FrameDecoderTest.java +++ b/test/org/traccar/protocol/L100FrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class L100FrameDecoderTest extends ProtocolTest { @Test @@ -11,11 +13,11 @@ public class L100FrameDecoderTest extends ProtocolTest { L100FrameDecoder decoder = new L100FrameDecoder(); - Assert.assertEquals( + assertEquals( binary("200141544c3335363839353033373533333734352c244750524d432c3131313731392e3030302c412c323833382e303034352c4e2c30373731332e333730372c452c302e30302c2c3132303831302c2c2c412a3735242c2330313130303131313030313031302c4e2e432c4e2e432c4e2e432c31323334352e36372c33312e342c342e322c32312c4d43432c4d4e432c4c41432c43656c6c494441544c027a"), decoder.decode(null, null, binary("200141544c3335363839353033373533333734352c244750524d432c3131313731392e3030302c412c323833382e303034352c4e2c30373731332e333730372c452c302e30302c2c3132303831302c2c2c412a3735242c2330313130303131313030313031302c4e2e432c4e2e432c4e2e432c31323334352e36372c33312e342c342e322c32312c4d43432c4d4e432c4c41432c43656c6c494441544c027a"))); - Assert.assertEquals( + assertEquals( binary("200341544c3335363839353033373533333734352c244750524d432c3131313731392e3030302c412c323833382e303034352c4e2c30373731332e333730372c452c302e30302c2c3132303831302c2c2c412a3735244c4f432c436f6e6e61756768742043697263757320c2a0436f6e6e617567687420506c61636520c2a04e65772044656c686920c2a044656c6869c2a0496e6469612c2330313130303130313130313031302c322e332c33352e36372c38302c31323334352e36372c33312e342c342e322c32312c4d43432c4d4e432c4c41432c43656c6c494441544c047a"), decoder.decode(null, null, binary("200341544c3335363839353033373533333734352c244750524d432c3131313731392e3030302c412c323833382e303034352c4e2c30373731332e333730372c452c302e30302c2c3132303831302c2c2c412a3735244c4f432c436f6e6e61756768742043697263757320c2a0436f6e6e617567687420506c61636520c2a04e65772044656c686920c2a044656c6869c2a0496e6469612c2330313130303130313130313031302c322e332c33352e36372c38302c31323334352e36372c33312e342c342e322c32312c4d43432c4d4e432c4c41432c43656c6c494441544c047a"))); diff --git a/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java b/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java index 9b02b646c..214936514 100644 --- a/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java +++ b/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java @@ -4,6 +4,9 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + public class MeiligaoFrameDecoderTest extends ProtocolTest { @Test @@ -11,14 +14,14 @@ public class MeiligaoFrameDecoderTest extends ProtocolTest { MeiligaoFrameDecoder decoder = new MeiligaoFrameDecoder(); - Assert.assertNull( + assertNull( decoder.decode(null, null, binary("00"))); - Assert.assertEquals( + assertEquals( binary("2424007b8621700151517899553233323835372e3030302c562c333632372e313835342c4e2c30313034352e323130392c452c302e30302c372c3239303131332c2c2a31347c302e307c347c303030307c303030382c303030357c303235443030303230303541374432327c30367c303030314530353527f40d0a"), decoder.decode(null, null, binary("2424007B8621700151517899553233323835372E3030302C562C333632372E313835342C4E2C30313034352E323130392C452C302E30302C372C3239303131332C2C2A31347C302E307C347C303030307C303030382C303030357C303235443030303230303541374432327C30367C303030314530353527F40D0A"))); - Assert.assertEquals( + assertEquals( binary("2424007b8621700151517899553233323835372e3030302c562c333632372e313835342c4e2c30313034352e323130392c452c302e30302c372c3239303131332c2c2a31347c302e307c347c303030307c303030382c303030357c303235443030303230303541374432327c30367c303030314530353527f40d0a"), decoder.decode(null, null, binary("002424007B8621700151517899553233323835372E3030302C562C333632372E313835342C4E2C30313034352E323130392C452C302E30302C372C3239303131332C2C2A31347C302E307C347C303030307C303030382C303030357C303235443030303230303541374432327C30367C303030314530353527F40D0A"))); diff --git a/test/org/traccar/protocol/MeitrackFrameDecoderTest.java b/test/org/traccar/protocol/MeitrackFrameDecoderTest.java index d86e532c3..f0afee02e 100644 --- a/test/org/traccar/protocol/MeitrackFrameDecoderTest.java +++ b/test/org/traccar/protocol/MeitrackFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class MeitrackFrameDecoderTest extends ProtocolTest { @Test @@ -11,7 +13,7 @@ public class MeitrackFrameDecoderTest extends ProtocolTest { MeitrackFrameDecoder decoder = new MeitrackFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("24244e3132372c3836333037313031333830333036362c4141412c33352c2d312e3330323638302c33362e3835323133352c3135303430393231313032362c412c392c302c302e312c302c352c313635332c343039362c33323634382c3633397c30327c313030347c3930432c303030302c307c307c307c3346467c3330302c2a37430d0a"), decoder.decode(null, null, binary("24244e3132372c3836333037313031333830333036362c4141412c33352c2d312e3330323638302c33362e3835323133352c3135303430393231313032362c412c392c302c302e312c302c352c313635332c343039362c33323634382c3633397c30327c313030347c3930432c303030302c307c307c307c3346467c3330302c2a37430d0a"))); diff --git a/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java b/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java index 771712420..a2b0ae6fd 100644 --- a/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java +++ b/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class MeitrackProtocolEncoderTest extends ProtocolTest { @Test @@ -16,14 +18,14 @@ public class MeitrackProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_POSITION_SINGLE); - Assert.assertEquals("@@Q25,123456789012345,A10*68\r\n", encoder.encodeCommand(command)); + assertEquals("@@Q25,123456789012345,A10*68\r\n", encoder.encodeCommand(command)); command.setDeviceId(1); command.setType(Command.TYPE_SEND_SMS); command.set(Command.KEY_PHONE, "15360853789"); command.set(Command.KEY_MESSAGE, "Meitrack"); - Assert.assertEquals("@@f48,123456789012345,C02,0,15360853789,Meitrack*B0\r\n", encoder.encodeCommand(command)); + assertEquals("@@f48,123456789012345,C02,0,15360853789,Meitrack*B0\r\n", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java index 360ea0008..d446c228c 100644 --- a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java +++ b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class MiniFinderProtocolEncoderTest extends ProtocolTest { @Test @@ -17,7 +19,7 @@ public class MiniFinderProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_SET_TIMEZONE); command.set(Command.KEY_TIMEZONE, "GMT+1"); - Assert.assertEquals("123456L+01", encoder.encodeCommand(command)); + assertEquals("123456L+01", encoder.encodeCommand(command)); command = new Command(); command.setDeviceId(1); @@ -25,7 +27,7 @@ public class MiniFinderProtocolEncoderTest extends ProtocolTest { command.set(Command.KEY_INDEX, 2); command.set(Command.KEY_PHONE, "1111111111"); - Assert.assertEquals("123456C1,1111111111", encoder.encodeCommand(command)); + assertEquals("123456C1,1111111111", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/NvsFrameDecoderTest.java b/test/org/traccar/protocol/NvsFrameDecoderTest.java index 54dc0fbdd..b03e3826c 100644 --- a/test/org/traccar/protocol/NvsFrameDecoderTest.java +++ b/test/org/traccar/protocol/NvsFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class NvsFrameDecoderTest extends ProtocolTest { @Test @@ -11,11 +13,11 @@ public class NvsFrameDecoderTest extends ProtocolTest { NvsFrameDecoder decoder = new NvsFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("0012333537303430303630303137383234312e38"), decoder.decode(null, null, binary("0012333537303430303630303137383234312e38"))); - Assert.assertEquals( + assertEquals( binary("cccccccc0073000144b9ddf2aca002015694823d1f165d80902139a44f00aa001e1400000103000a080115001a001d001e0141004001f00065001301061600001700001800004231da430000440000085000000000480000000049000000004a0000000047ffffffff6900000004c700000000e10000000100954a"), decoder.decode(null, null, binary("cccccccc0073000144b9ddf2aca002015694823d1f165d80902139a44f00aa001e1400000103000a080115001a001d001e0141004001f00065001301061600001700001800004231da430000440000085000000000480000000049000000004a0000000047ffffffff6900000004c700000000e10000000100954a"))); diff --git a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java index 39ca2fe65..5438eb366 100644 --- a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class Pt502ProtocolEncoderTest extends ProtocolTest { @Test @@ -17,7 +19,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_CUSTOM); command.set(Command.KEY_DATA, "#PTI300"); - Assert.assertEquals("#PTI300\r\n", encoder.encodeCommand(command)); + assertEquals("#PTI300\r\n", encoder.encodeCommand(command)); } @@ -32,7 +34,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { command.set(Command.KEY_INDEX, 2); command.set(Command.KEY_DATA, 1); - Assert.assertEquals("#OPC2,1\r\n", encoder.encodeCommand(command)); + assertEquals("#OPC2,1\r\n", encoder.encodeCommand(command)); } @@ -46,7 +48,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_SET_TIMEZONE); command.set(Command.KEY_TIMEZONE, "GMT+8"); - Assert.assertEquals("#TMZ8\r\n", encoder.encodeCommand(command)); + assertEquals("#TMZ8\r\n", encoder.encodeCommand(command)); } @@ -61,7 +63,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_ALARM_SPEED); command.set(Command.KEY_DATA, 120); - Assert.assertEquals("#SPD120\r\n", encoder.encodeCommand(command)); + assertEquals("#SPD120\r\n", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java index 7e04dcb81..6b38035ed 100644 --- a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java @@ -7,6 +7,8 @@ import org.traccar.TestIdentityManager; import org.traccar.model.Command; import org.traccar.model.Device; +import static org.junit.Assert.assertEquals; + public class Tk103ProtocolEncoderTest extends ProtocolTest { @Test @@ -18,7 +20,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_ENGINE_STOP); - Assert.assertEquals("(123456789012345AV010)", encoder.encodeCommand(command)); + assertEquals("(123456789012345AV010)", encoder.encodeCommand(command)); } @@ -31,7 +33,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_POSITION_SINGLE); - Assert.assertEquals("(123456789012345AP00)", encoder.encodeCommand(command)); + assertEquals("(123456789012345AP00)", encoder.encodeCommand(command)); } @@ -45,7 +47,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_POSITION_PERIODIC); command.set(Command.KEY_FREQUENCY, 60); - Assert.assertEquals("(123456789012345AR00003C0000)", encoder.encodeCommand(command)); + assertEquals("(123456789012345AR00003C0000)", encoder.encodeCommand(command)); } @@ -58,7 +60,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_POSITION_STOP); - Assert.assertEquals("(123456789012345AR0000000000)", encoder.encodeCommand(command)); + assertEquals("(123456789012345AR0000000000)", encoder.encodeCommand(command)); } @@ -71,7 +73,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_GET_VERSION); - Assert.assertEquals("(123456789012345AP07)", encoder.encodeCommand(command)); + assertEquals("(123456789012345AP07)", encoder.encodeCommand(command)); } @@ -84,7 +86,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_REBOOT_DEVICE); - Assert.assertEquals("(123456789012345AT00)", encoder.encodeCommand(command)); + assertEquals("(123456789012345AT00)", encoder.encodeCommand(command)); } @@ -97,7 +99,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_SET_ODOMETER); - Assert.assertEquals("(123456789012345AX01)", encoder.encodeCommand(command)); + assertEquals("(123456789012345AX01)", encoder.encodeCommand(command)); } @@ -110,7 +112,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_POSITION_SINGLE); - Assert.assertEquals("[begin]sms2,*getposl*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*getposl*,[end]", encoder.encodeCommand(command)); } @@ -123,7 +125,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_POSITION_PERIODIC); - Assert.assertEquals("[begin]sms2,*routetrack*99*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*routetrack*99*,[end]", encoder.encodeCommand(command)); } @@ -136,7 +138,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_POSITION_STOP); - Assert.assertEquals("[begin]sms2,*routetrackoff*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*routetrackoff*,[end]", encoder.encodeCommand(command)); } @@ -149,7 +151,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_GET_VERSION); - Assert.assertEquals("[begin]sms2,*about*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*about*,[end]", encoder.encodeCommand(command)); } @@ -162,7 +164,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_REBOOT_DEVICE); - Assert.assertEquals("[begin]sms2,88888888,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,88888888,[end]", encoder.encodeCommand(command)); } @@ -175,7 +177,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setDeviceId(1); command.setType(Command.TYPE_IDENTIFICATION); - Assert.assertEquals("[begin]sms2,999999,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,999999,[end]", encoder.encodeCommand(command)); } @@ -189,7 +191,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_ALARM_SOS); command.set(Command.KEY_ENABLE, true); - Assert.assertEquals("[begin]sms2,*soson*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*soson*,[end]", encoder.encodeCommand(command)); } @@ -203,7 +205,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_ALARM_SOS); command.set(Command.KEY_ENABLE, false); - Assert.assertEquals("[begin]sms2,*sosoff*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*sosoff*,[end]", encoder.encodeCommand(command)); } @@ -217,7 +219,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_CUSTOM); command.set(Command.KEY_DATA, "any text is ok"); - Assert.assertEquals("[begin]sms2,any text is ok,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,any text is ok,[end]", encoder.encodeCommand(command)); } @@ -232,7 +234,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.set(Command.KEY_SERVER, "1.2.3.4"); command.set(Command.KEY_PORT, "5555"); - Assert.assertEquals("[begin]sms2,*setip*1*2*3*4*5555*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*setip*1*2*3*4*5555*,[end]", encoder.encodeCommand(command)); } @@ -248,7 +250,7 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { command.set(Command.KEY_PHONE, "+55555555555"); command.set(Command.KEY_DEVICE_PASSWORD, "232323"); - Assert.assertEquals("[begin]sms2,*master*232323*+55555555555*,[end]", encoder.encodeCommand(command)); + assertEquals("[begin]sms2,*master*232323*+55555555555*,[end]", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/TotemProtocolEncoderTest.java b/test/org/traccar/protocol/TotemProtocolEncoderTest.java index 4415f6c0a..d17f70405 100644 --- a/test/org/traccar/protocol/TotemProtocolEncoderTest.java +++ b/test/org/traccar/protocol/TotemProtocolEncoderTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class TotemProtocolEncoderTest extends ProtocolTest { @Test @@ -17,7 +19,7 @@ public class TotemProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_ENGINE_STOP); command.set(Command.KEY_DEVICE_PASSWORD, "000000"); - Assert.assertEquals("*000000,025,C,1#", encoder.encodeCommand(command)); + assertEquals("*000000,025,C,1#", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/UlbotechFrameDecoderTest.java b/test/org/traccar/protocol/UlbotechFrameDecoderTest.java index 03a4fb336..b0af435b8 100644 --- a/test/org/traccar/protocol/UlbotechFrameDecoderTest.java +++ b/test/org/traccar/protocol/UlbotechFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class UlbotechFrameDecoderTest extends ProtocolTest { @Test @@ -11,15 +13,15 @@ public class UlbotechFrameDecoderTest extends ProtocolTest { UlbotechFrameDecoder decoder = new UlbotechFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("f8010103515810532780699f7e2e3f010e015ee4c906bde45c00000000008b0304004000000404002c776005060373193622110b00240b00fee8ffff807dffff606d0b00fee9af000000af0000000b00feee7d78807dffffffff100101cc2af8"), decoder.decode(null, null, binary("f8010103515810532780699f7e2e3f010e015ee4c906bde45c00000000008b0304004000000404002c776005060373193622110b00240b00fee8ffff807dffff606d0b00fee9af000000af0000000b00feee7d78807dffffffff100101cc2af8"))); - Assert.assertEquals( + assertEquals( binary("2a545330312c33353430343330353133383934363023"), decoder.decode(null, null, binary("2a545330312c33353430343330353133383934363023"))); - Assert.assertEquals( + assertEquals( binary("f8010108679650230646339de69054010e015ee17506bde2c60000000000ac0304024000000404000009f705060390181422170711310583410c0000310d00312f834131018608040003130a100101136cf8"), decoder.decode(null, null, binary("f8010108679650230646339de69054010e015ee17506bde2c60000000000ac0304024000000404000009f70005060390181422170711310583410c0000310d00312f834131018608040003130a100101136cf8"))); diff --git a/test/org/traccar/protocol/VtfmsFrameDecoderTest.java b/test/org/traccar/protocol/VtfmsFrameDecoderTest.java index e5897549b..c9ee8ae20 100644 --- a/test/org/traccar/protocol/VtfmsFrameDecoderTest.java +++ b/test/org/traccar/protocol/VtfmsFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class VtfmsFrameDecoderTest extends ProtocolTest { @Test @@ -11,7 +13,7 @@ public class VtfmsFrameDecoderTest extends ProtocolTest { VtfmsFrameDecoder decoder = new VtfmsFrameDecoder(); - Assert.assertEquals( + assertEquals( buffer("(863071010087648,0HK44,00,000,14,2,9,,A,114946,180313,11.0244,076.9768,282,000,00000,00000,K,0000128,1,12.8,,200,2.501,,4.001,0,0,0,0,0,0,0,,)105"), decoder.decode(null, null, buffer("(863071010087648,0HK44,00,000,14,2,9,,A,114946,180313,11.0244,076.9768,282,000,00000,00000,K,0000128,1,12.8,,200,2.501,,4.001,0,0,0,0,0,0,0,,)105"))); diff --git a/test/org/traccar/protocol/WatchProtocolEncoderTest.java b/test/org/traccar/protocol/WatchProtocolEncoderTest.java index cffe373cf..a87afbfc5 100644 --- a/test/org/traccar/protocol/WatchProtocolEncoderTest.java +++ b/test/org/traccar/protocol/WatchProtocolEncoderTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class WatchProtocolEncoderTest extends ProtocolTest { @Test @@ -17,41 +19,41 @@ public class WatchProtocolEncoderTest extends ProtocolTest { command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_REBOOT_DEVICE); - Assert.assertEquals("[CS*123456789012345*0005*RESET]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*0005*RESET]", encoder.encodeCommand(command)); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_SOS_NUMBER); command.set(Command.KEY_INDEX, 1); command.set(Command.KEY_PHONE, "123456789"); - Assert.assertEquals("[CS*123456789012345*000e*SOS1,123456789]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*000e*SOS1,123456789]", encoder.encodeCommand(command)); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_VOICE_MESSAGE); command.set(Command.KEY_DATA, "3333"); - Assert.assertEquals("[CS*123456789012345*0005*TK,33]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*0005*TK,33]", encoder.encodeCommand(command)); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_CUSTOM); command.set(Command.KEY_DATA, "WORK,6-9,11-13,13-15,17-19"); - Assert.assertEquals("[CS*123456789012345*001a*WORK,6-9,11-13,13-15,17-19]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*001a*WORK,6-9,11-13,13-15,17-19]", encoder.encodeCommand(command)); command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_SET_TIMEZONE); command.set(Command.KEY_TIMEZONE, "Europe/Amsterdam"); - Assert.assertEquals("[CS*123456789012345*0006*LZ,,+1]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*0006*LZ,,+1]", encoder.encodeCommand(command)); command.set(Command.KEY_TIMEZONE, "GMT+01:30"); - Assert.assertEquals("[CS*123456789012345*0008*LZ,,+1.5]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*0008*LZ,,+1.5]", encoder.encodeCommand(command)); command.set(Command.KEY_TIMEZONE, "Atlantic/Azores"); - Assert.assertEquals("[CS*123456789012345*0006*LZ,,-1]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*0006*LZ,,-1]", encoder.encodeCommand(command)); command.set(Command.KEY_TIMEZONE, "GMT-11:30"); - Assert.assertEquals("[CS*123456789012345*0009*LZ,,-11.5]", encoder.encodeCommand(command)); + assertEquals("[CS*123456789012345*0009*LZ,,-11.5]", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/WondexFrameDecoderTest.java b/test/org/traccar/protocol/WondexFrameDecoderTest.java index 2b401aa18..8eb80da9a 100644 --- a/test/org/traccar/protocol/WondexFrameDecoderTest.java +++ b/test/org/traccar/protocol/WondexFrameDecoderTest.java @@ -4,6 +4,9 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + public class WondexFrameDecoderTest extends ProtocolTest { @Test @@ -11,14 +14,14 @@ public class WondexFrameDecoderTest extends ProtocolTest { WondexFrameDecoder decoder = new WondexFrameDecoder(); - Assert.assertNull( + assertNull( decoder.decode(null, null, binary("f0d70b0001ca9a3b"))); - Assert.assertEquals( + assertEquals( binary("313034343938393630312c32303133303332333039353531352c31332e3537323737362c35322e3430303833382c302c3030302c37322c302c32"), decoder.decode(null, null, binary("313034343938393630312c32303133303332333039353531352c31332e3537323737362c35322e3430303833382c302c3030302c37322c302c320d0a"))); - Assert.assertEquals(binary("d0d70b0001ca9a3b"), + assertEquals(binary("d0d70b0001ca9a3b"), decoder.decode(null, null, binary("d0d70b0001ca9a3b"))); } diff --git a/test/org/traccar/protocol/WondexProtocolEncoderTest.java b/test/org/traccar/protocol/WondexProtocolEncoderTest.java index fb038a18b..7c5fa572c 100644 --- a/test/org/traccar/protocol/WondexProtocolEncoderTest.java +++ b/test/org/traccar/protocol/WondexProtocolEncoderTest.java @@ -5,6 +5,8 @@ import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class WondexProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { @@ -16,7 +18,7 @@ public class WondexProtocolEncoderTest extends ProtocolTest { command.setType(Command.TYPE_POSITION_SINGLE); command.set(Command.KEY_DEVICE_PASSWORD, "0000"); - Assert.assertEquals("$WP+GETLOCATION=0000", encoder.encodeCommand(command)); + assertEquals("$WP+GETLOCATION=0000", encoder.encodeCommand(command)); } diff --git a/test/org/traccar/protocol/XexunFrameDecoderTest.java b/test/org/traccar/protocol/XexunFrameDecoderTest.java index 5627623ba..cdf30965c 100644 --- a/test/org/traccar/protocol/XexunFrameDecoderTest.java +++ b/test/org/traccar/protocol/XexunFrameDecoderTest.java @@ -4,6 +4,8 @@ import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; +import static org.junit.Assert.assertEquals; + public class XexunFrameDecoderTest extends ProtocolTest { @Test @@ -11,11 +13,11 @@ public class XexunFrameDecoderTest extends ProtocolTest { XexunFrameDecoder decoder = new XexunFrameDecoder(); - Assert.assertEquals( + assertEquals( binary("4750524d432c3230353933352e3030302c412c353134302e343335302c4e2c3530312e303638362c452c302e30302c302e30302c3132313031352c30302c303030302e302c412a37302c462c2c696d65693a3335393538373031343731383339322c"), decoder.decode(null, null, binary("313531303132313435392c2b33313635323435343932372c4750524d432c3230353933352e3030302c412c353134302e343335302c4e2c3530312e303638362c452c302e30302c302e30302c3132313031352c30302c303030302e302c412a37302c462c2c696d65693a3335393538373031343731383339322c31323249"))); - Assert.assertEquals( + assertEquals( binary("4750524d432c3130333733312e3633362c412c343534352e353236362c4e2c30303434382e383235392c452c32312e31322c3237362e30312c3135303631352c2c2c412a35372c4c2c2c20696d65693a3031333934393030323032363637352c"), decoder.decode(null, null, binary("3135303631353132333733312c2b33333634373338343631312c4750524d432c3130333733312e3633362c412c343534352e353236362c4e2c30303434382e383235392c452c32312e31322c3237362e30312c3135303631352c2c2c412a35372c4c2c2c20696d65693a3031333934393030323032363637352c30342c333532322e392c463a332e3732562c302c3134322c32313734342c3230382c30312c303730322c394338430a0d"))); diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java index 0e26c7e75..bdf45e9d5 100644 --- a/test/org/traccar/reports/ReportUtilsTest.java +++ b/test/org/traccar/reports/ReportUtilsTest.java @@ -49,20 +49,20 @@ public class ReportUtilsTest extends BaseTest { startPosition.set(Position.KEY_TOTAL_DISTANCE, 500.0); Position endPosition = new Position(); endPosition.set(Position.KEY_TOTAL_DISTANCE, 700.0); - Assert.assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 200.0, 10); + assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 200.0, 10); startPosition.set(Position.KEY_ODOMETER, 50000); endPosition.set(Position.KEY_ODOMETER, 51000); - Assert.assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 1000.0, 10); + assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 1000.0, 10); } @Test public void testCalculateSpentFuel() { Position startPosition = new Position(); Position endPosition = new Position(); - Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.0, 0.01); + assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.0, 0.01); startPosition.set(Position.KEY_FUEL_LEVEL, 0.7); endPosition.set(Position.KEY_FUEL_LEVEL, 0.5); - Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.2, 0.01); + assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.2, 0.01); } @Test -- cgit v1.2.3 From 0f87445428a831e0f0d3b69f6f07f2a60272f2fb Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 25 Jan 2018 20:24:40 +1300 Subject: Clean up unused imports --- src/org/traccar/api/resource/DeviceResource.java | 2 +- src/org/traccar/api/resource/SessionResource.java | 11 +++++------ src/org/traccar/notification/EventForwarder.java | 4 ++-- src/org/traccar/web/CsvBuilder.java | 2 +- test/org/traccar/FilterHandlerTest.java | 2 -- test/org/traccar/ProtocolTest.java | 1 - test/org/traccar/WebDataHandlerTest.java | 1 - test/org/traccar/calendar/CalendarTest.java | 1 - test/org/traccar/database/DataManagerTest.java | 1 - test/org/traccar/database/GroupTreeTest.java | 1 - test/org/traccar/geocoder/AddressFormatTest.java | 1 - test/org/traccar/geocoder/GeocoderTest.java | 1 - test/org/traccar/geofence/GeofenceCircleTest.java | 1 - test/org/traccar/geofence/GeofencePolygonTest.java | 1 - test/org/traccar/geofence/GeofencePolylineTest.java | 1 - test/org/traccar/geolocation/GeolocationProviderTest.java | 1 - test/org/traccar/helper/BcdUtilTest.java | 1 - test/org/traccar/helper/BitUtilTest.java | 1 - test/org/traccar/helper/ChecksumTest.java | 1 - test/org/traccar/helper/DateBuilderTest.java | 1 - test/org/traccar/helper/DateUtilTest.java | 1 - test/org/traccar/helper/DistanceCalculatorTest.java | 1 - test/org/traccar/helper/LocationTreeTest.java | 1 - test/org/traccar/helper/ObdDecoderTest.java | 1 - test/org/traccar/helper/PatternBuilderTest.java | 1 - test/org/traccar/helper/StringFinderTest.java | 5 ----- test/org/traccar/notification/NotificiationMailTest.java | 4 +++- test/org/traccar/processing/ComputedAttributesTest.java | 1 - test/org/traccar/protocol/AdmProtocolEncoderTest.java | 1 - test/org/traccar/protocol/AplicomFrameDecoderTest.java | 1 - test/org/traccar/protocol/At2000FrameDecoderTest.java | 1 - test/org/traccar/protocol/AtrackFrameDecoderTest.java | 1 - test/org/traccar/protocol/EskyFrameDecoderTest.java | 1 - test/org/traccar/protocol/GalileoFrameDecoderTest.java | 1 - test/org/traccar/protocol/GatorProtocolDecoderTest.java | 1 - test/org/traccar/protocol/Gl200FrameDecoderTest.java | 1 - test/org/traccar/protocol/Gps056FrameDecoderTest.java | 1 - test/org/traccar/protocol/Gps103ProtocolEncoderTest.java | 1 - test/org/traccar/protocol/GranitFrameDecoderTest.java | 1 - test/org/traccar/protocol/Gt06FrameDecoderTest.java | 1 - test/org/traccar/protocol/H02FrameDecoderTest.java | 1 - test/org/traccar/protocol/H02ProtocolEncoderTest.java | 1 - test/org/traccar/protocol/HuaShengFrameDecoderTest.java | 1 - test/org/traccar/protocol/HuabaoFrameDecoderTest.java | 1 - test/org/traccar/protocol/Jt600FrameDecoderTest.java | 1 - test/org/traccar/protocol/L100FrameDecoderTest.java | 1 - test/org/traccar/protocol/MegastekFrameDecoderTest.java | 1 - test/org/traccar/protocol/MeiligaoFrameDecoderTest.java | 1 - test/org/traccar/protocol/MeitrackFrameDecoderTest.java | 1 - test/org/traccar/protocol/MeitrackProtocolEncoderTest.java | 1 - test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java | 1 - test/org/traccar/protocol/NvsFrameDecoderTest.java | 1 - test/org/traccar/protocol/Pt502FrameDecoderTest.java | 1 - test/org/traccar/protocol/Pt502ProtocolEncoderTest.java | 1 - test/org/traccar/protocol/TelicFrameDecoderTest.java | 2 -- test/org/traccar/protocol/Tk103ProtocolEncoderTest.java | 3 --- test/org/traccar/protocol/TmgFrameDecoderTest.java | 1 - test/org/traccar/protocol/TotemFrameDecoderTest.java | 1 - test/org/traccar/protocol/TotemProtocolEncoderTest.java | 1 - test/org/traccar/protocol/TzoneProtocolDecoderTest.java | 1 - test/org/traccar/protocol/UlbotechFrameDecoderTest.java | 1 - test/org/traccar/protocol/Vt200FrameDecoderTest.java | 1 - test/org/traccar/protocol/VtfmsFrameDecoderTest.java | 1 - test/org/traccar/protocol/WatchProtocolEncoderTest.java | 1 - test/org/traccar/protocol/WondexFrameDecoderTest.java | 1 - test/org/traccar/protocol/WondexProtocolEncoderTest.java | 1 - test/org/traccar/protocol/XexunFrameDecoderTest.java | 1 - test/org/traccar/reports/ReportUtilsTest.java | 1 - 68 files changed, 12 insertions(+), 82 deletions(-) (limited to 'test/org/traccar/ProtocolTest.java') diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index ddf8832ed..87927e45b 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -71,7 +71,7 @@ public class DeviceResource extends BaseObjectResource { result = deviceManager.getUserItems(userId); } } else { - result = new HashSet(); + result = new HashSet<>(); for (String uniqueId : uniqueIds) { Device device = deviceManager.getByUniqueId(uniqueId); Context.getPermissionsManager().checkDevice(getUserId(), device.getId()); diff --git a/src/org/traccar/api/resource/SessionResource.java b/src/org/traccar/api/resource/SessionResource.java index 3f7842626..2a0bd4364 100644 --- a/src/org/traccar/api/resource/SessionResource.java +++ b/src/org/traccar/api/resource/SessionResource.java @@ -61,15 +61,14 @@ public class SessionResource extends BaseResource { Cookie[] cookies = request.getCookies(); String email = null, password = null; if (cookies != null) { - for (int i = 0; i < cookies.length; i++) { - if (cookies[i].getName().equals(USER_COOKIE_KEY)) { + for (Cookie cookie : cookies) { + if (cookie.getName().equals(USER_COOKIE_KEY)) { byte[] emailBytes = DatatypeConverter.parseBase64Binary( - URLDecoder.decode(cookies[i].getValue(), StandardCharsets.US_ASCII.name())); + URLDecoder.decode(cookie.getValue(), StandardCharsets.US_ASCII.name())); email = new String(emailBytes, StandardCharsets.UTF_8); - } - if (cookies[i].getName().equals(PASS_COOKIE_KEY)) { + } else if (cookie.getName().equals(PASS_COOKIE_KEY)) { byte[] passwordBytes = DatatypeConverter.parseBase64Binary( - URLDecoder.decode(cookies[i].getValue(), StandardCharsets.US_ASCII.name())); + URLDecoder.decode(cookie.getValue(), StandardCharsets.US_ASCII.name())); password = new String(passwordBytes, StandardCharsets.UTF_8); } } diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java index ad8134f18..d1bdd4aba 100644 --- a/src/org/traccar/notification/EventForwarder.java +++ b/src/org/traccar/notification/EventForwarder.java @@ -17,7 +17,7 @@ package org.traccar.notification; import com.fasterxml.jackson.core.JsonProcessingException; import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import org.traccar.Context; @@ -73,7 +73,7 @@ public abstract class EventForwarder { for (String paramLine: paramsLines) { splitedLine = paramLine.split(separator, 2); if (splitedLine.length == 2) { - paramsMap.put(splitedLine[0].trim(), Arrays.asList(splitedLine[1].trim())); + paramsMap.put(splitedLine[0].trim(), Collections.singletonList(splitedLine[1].trim())); } } return paramsMap; diff --git a/src/org/traccar/web/CsvBuilder.java b/src/org/traccar/web/CsvBuilder.java index 2bbe89788..fa99f1b18 100644 --- a/src/org/traccar/web/CsvBuilder.java +++ b/src/org/traccar/web/CsvBuilder.java @@ -51,7 +51,7 @@ public class CsvBuilder { private SortedSet getSortedMethods(Object object) { Method[] methodArray = object.getClass().getMethods(); - SortedSet methods = new TreeSet(new Comparator() { + SortedSet methods = new TreeSet<>(new Comparator() { @Override public int compare(Method m1, Method m2) { if (m1.getName().equals("getAttributes") && !m1.getName().equals(m2.getName())) { diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java index 0d488a7fb..8b1ba3b1f 100644 --- a/test/org/traccar/FilterHandlerTest.java +++ b/test/org/traccar/FilterHandlerTest.java @@ -3,8 +3,6 @@ package org.traccar; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.traccar.database.IdentityManager; -import org.traccar.model.Device; import org.traccar.model.Position; import java.util.Date; diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index 246e3d0e7..e67b53aa8 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -5,7 +5,6 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.handler.codec.http.DefaultHttpRequest; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpVersion; -import org.junit.Assert; import org.traccar.model.CellTower; import org.traccar.model.Command; import org.traccar.model.Position; diff --git a/test/org/traccar/WebDataHandlerTest.java b/test/org/traccar/WebDataHandlerTest.java index be05e0855..70b098b0f 100644 --- a/test/org/traccar/WebDataHandlerTest.java +++ b/test/org/traccar/WebDataHandlerTest.java @@ -1,6 +1,5 @@ package org.traccar; -import org.junit.Assert; import org.junit.Test; import org.traccar.model.Position; diff --git a/test/org/traccar/calendar/CalendarTest.java b/test/org/traccar/calendar/CalendarTest.java index ae68af9c0..0de89f97f 100644 --- a/test/org/traccar/calendar/CalendarTest.java +++ b/test/org/traccar/calendar/CalendarTest.java @@ -7,7 +7,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -import org.junit.Assert; import org.junit.Test; import org.traccar.model.Calendar; diff --git a/test/org/traccar/database/DataManagerTest.java b/test/org/traccar/database/DataManagerTest.java index 3e3dcab6c..f9945c994 100644 --- a/test/org/traccar/database/DataManagerTest.java +++ b/test/org/traccar/database/DataManagerTest.java @@ -1,6 +1,5 @@ package org.traccar.database; -import org.junit.Assert; import org.junit.Test; import org.traccar.model.Attribute; import org.traccar.model.Device; diff --git a/test/org/traccar/database/GroupTreeTest.java b/test/org/traccar/database/GroupTreeTest.java index 3e75f9073..b547aab60 100644 --- a/test/org/traccar/database/GroupTreeTest.java +++ b/test/org/traccar/database/GroupTreeTest.java @@ -1,6 +1,5 @@ package org.traccar.database; -import org.junit.Assert; import org.junit.Test; import org.traccar.model.Device; import org.traccar.model.Group; diff --git a/test/org/traccar/geocoder/AddressFormatTest.java b/test/org/traccar/geocoder/AddressFormatTest.java index 12f38fca4..0cc5168ef 100644 --- a/test/org/traccar/geocoder/AddressFormatTest.java +++ b/test/org/traccar/geocoder/AddressFormatTest.java @@ -1,6 +1,5 @@ package org.traccar.geocoder; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/geocoder/GeocoderTest.java b/test/org/traccar/geocoder/GeocoderTest.java index 3b53495c4..1ddc43ad2 100644 --- a/test/org/traccar/geocoder/GeocoderTest.java +++ b/test/org/traccar/geocoder/GeocoderTest.java @@ -2,7 +2,6 @@ package org.traccar.geocoder; import java.util.Locale; -import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; diff --git a/test/org/traccar/geofence/GeofenceCircleTest.java b/test/org/traccar/geofence/GeofenceCircleTest.java index 020b10a0b..259a8fb77 100644 --- a/test/org/traccar/geofence/GeofenceCircleTest.java +++ b/test/org/traccar/geofence/GeofenceCircleTest.java @@ -2,7 +2,6 @@ package org.traccar.geofence; import java.text.ParseException; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/geofence/GeofencePolygonTest.java b/test/org/traccar/geofence/GeofencePolygonTest.java index 31f35120f..94b73af3a 100644 --- a/test/org/traccar/geofence/GeofencePolygonTest.java +++ b/test/org/traccar/geofence/GeofencePolygonTest.java @@ -2,7 +2,6 @@ package org.traccar.geofence; import java.text.ParseException; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/geofence/GeofencePolylineTest.java b/test/org/traccar/geofence/GeofencePolylineTest.java index 1b51c17f6..1e9dcb7c3 100644 --- a/test/org/traccar/geofence/GeofencePolylineTest.java +++ b/test/org/traccar/geofence/GeofencePolylineTest.java @@ -2,7 +2,6 @@ package org.traccar.geofence; import java.text.ParseException; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/geolocation/GeolocationProviderTest.java b/test/org/traccar/geolocation/GeolocationProviderTest.java index 97b5b32da..2729052d6 100644 --- a/test/org/traccar/geolocation/GeolocationProviderTest.java +++ b/test/org/traccar/geolocation/GeolocationProviderTest.java @@ -1,6 +1,5 @@ package org.traccar.geolocation; -import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.traccar.BaseTest; diff --git a/test/org/traccar/helper/BcdUtilTest.java b/test/org/traccar/helper/BcdUtilTest.java index 9ffceacd9..e97aad09f 100644 --- a/test/org/traccar/helper/BcdUtilTest.java +++ b/test/org/traccar/helper/BcdUtilTest.java @@ -1,7 +1,6 @@ package org.traccar.helper; import org.jboss.netty.buffer.ChannelBuffers; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/helper/BitUtilTest.java b/test/org/traccar/helper/BitUtilTest.java index 683c4e6b8..90431bf55 100644 --- a/test/org/traccar/helper/BitUtilTest.java +++ b/test/org/traccar/helper/BitUtilTest.java @@ -1,6 +1,5 @@ package org.traccar.helper; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/helper/ChecksumTest.java b/test/org/traccar/helper/ChecksumTest.java index 1c20ba899..a7c66a2a2 100644 --- a/test/org/traccar/helper/ChecksumTest.java +++ b/test/org/traccar/helper/ChecksumTest.java @@ -2,7 +2,6 @@ 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; diff --git a/test/org/traccar/helper/DateBuilderTest.java b/test/org/traccar/helper/DateBuilderTest.java index 8b2898fed..b6323cc1d 100644 --- a/test/org/traccar/helper/DateBuilderTest.java +++ b/test/org/traccar/helper/DateBuilderTest.java @@ -1,6 +1,5 @@ package org.traccar.helper; -import org.junit.Assert; import org.junit.Test; import java.text.DateFormat; diff --git a/test/org/traccar/helper/DateUtilTest.java b/test/org/traccar/helper/DateUtilTest.java index b0bae4d11..ec42e71ae 100644 --- a/test/org/traccar/helper/DateUtilTest.java +++ b/test/org/traccar/helper/DateUtilTest.java @@ -1,6 +1,5 @@ package org.traccar.helper; -import org.junit.Assert; import org.junit.Test; import java.text.DateFormat; diff --git a/test/org/traccar/helper/DistanceCalculatorTest.java b/test/org/traccar/helper/DistanceCalculatorTest.java index f12a1ec83..a7457b6c4 100644 --- a/test/org/traccar/helper/DistanceCalculatorTest.java +++ b/test/org/traccar/helper/DistanceCalculatorTest.java @@ -1,6 +1,5 @@ package org.traccar.helper; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/helper/LocationTreeTest.java b/test/org/traccar/helper/LocationTreeTest.java index 3984b1142..21604144a 100644 --- a/test/org/traccar/helper/LocationTreeTest.java +++ b/test/org/traccar/helper/LocationTreeTest.java @@ -1,6 +1,5 @@ package org.traccar.helper; -import org.junit.Assert; import org.junit.Test; import java.util.ArrayList; diff --git a/test/org/traccar/helper/ObdDecoderTest.java b/test/org/traccar/helper/ObdDecoderTest.java index d9cc2ed6b..1ffe68c8b 100644 --- a/test/org/traccar/helper/ObdDecoderTest.java +++ b/test/org/traccar/helper/ObdDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.helper; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/helper/PatternBuilderTest.java b/test/org/traccar/helper/PatternBuilderTest.java index a8fb1aa93..4c76bc463 100644 --- a/test/org/traccar/helper/PatternBuilderTest.java +++ b/test/org/traccar/helper/PatternBuilderTest.java @@ -1,6 +1,5 @@ package org.traccar.helper; -import org.junit.Assert; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/helper/StringFinderTest.java b/test/org/traccar/helper/StringFinderTest.java index 6bc78ea82..f35f9a759 100644 --- a/test/org/traccar/helper/StringFinderTest.java +++ b/test/org/traccar/helper/StringFinderTest.java @@ -1,16 +1,11 @@ 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 { diff --git a/test/org/traccar/notification/NotificiationMailTest.java b/test/org/traccar/notification/NotificiationMailTest.java index 975505a3a..b82bec02e 100644 --- a/test/org/traccar/notification/NotificiationMailTest.java +++ b/test/org/traccar/notification/NotificiationMailTest.java @@ -1,5 +1,6 @@ package org.traccar.notification; +import org.junit.Ignore; import org.junit.Test; import javax.mail.Message; @@ -24,7 +25,8 @@ public class NotificiationMailTest { private static final int PORT = 25; - //@Test + @Ignore + @Test public void test() throws Exception { Properties props = System.getProperties(); diff --git a/test/org/traccar/processing/ComputedAttributesTest.java b/test/org/traccar/processing/ComputedAttributesTest.java index 88ebfd9a9..160067915 100644 --- a/test/org/traccar/processing/ComputedAttributesTest.java +++ b/test/org/traccar/processing/ComputedAttributesTest.java @@ -2,7 +2,6 @@ package org.traccar.processing; import java.util.Date; -import org.junit.Assert; import org.junit.Test; import org.traccar.model.Attribute; import org.traccar.model.Position; diff --git a/test/org/traccar/protocol/AdmProtocolEncoderTest.java b/test/org/traccar/protocol/AdmProtocolEncoderTest.java index fd4ea4af0..cb0a31ceb 100644 --- a/test/org/traccar/protocol/AdmProtocolEncoderTest.java +++ b/test/org/traccar/protocol/AdmProtocolEncoderTest.java @@ -16,7 +16,6 @@ */ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/AplicomFrameDecoderTest.java b/test/org/traccar/protocol/AplicomFrameDecoderTest.java index 6ba8f9334..581f7696f 100644 --- a/test/org/traccar/protocol/AplicomFrameDecoderTest.java +++ b/test/org/traccar/protocol/AplicomFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/At2000FrameDecoderTest.java b/test/org/traccar/protocol/At2000FrameDecoderTest.java index 52490c107..5613f832e 100644 --- a/test/org/traccar/protocol/At2000FrameDecoderTest.java +++ b/test/org/traccar/protocol/At2000FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/AtrackFrameDecoderTest.java b/test/org/traccar/protocol/AtrackFrameDecoderTest.java index 12ce783ad..9db4fd052 100644 --- a/test/org/traccar/protocol/AtrackFrameDecoderTest.java +++ b/test/org/traccar/protocol/AtrackFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/EskyFrameDecoderTest.java b/test/org/traccar/protocol/EskyFrameDecoderTest.java index e8902e8be..3b16a9051 100644 --- a/test/org/traccar/protocol/EskyFrameDecoderTest.java +++ b/test/org/traccar/protocol/EskyFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/GalileoFrameDecoderTest.java b/test/org/traccar/protocol/GalileoFrameDecoderTest.java index 049c16efa..7a7c97ba6 100644 --- a/test/org/traccar/protocol/GalileoFrameDecoderTest.java +++ b/test/org/traccar/protocol/GalileoFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/GatorProtocolDecoderTest.java b/test/org/traccar/protocol/GatorProtocolDecoderTest.java index ae6240b3e..360a3abed 100644 --- a/test/org/traccar/protocol/GatorProtocolDecoderTest.java +++ b/test/org/traccar/protocol/GatorProtocolDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Gl200FrameDecoderTest.java b/test/org/traccar/protocol/Gl200FrameDecoderTest.java index 2112ce466..e90c6495a 100644 --- a/test/org/traccar/protocol/Gl200FrameDecoderTest.java +++ b/test/org/traccar/protocol/Gl200FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Gps056FrameDecoderTest.java b/test/org/traccar/protocol/Gps056FrameDecoderTest.java index 58c64f59e..ce21f733f 100644 --- a/test/org/traccar/protocol/Gps056FrameDecoderTest.java +++ b/test/org/traccar/protocol/Gps056FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java index cfb1d5b90..f888ee252 100644 --- a/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/GranitFrameDecoderTest.java b/test/org/traccar/protocol/GranitFrameDecoderTest.java index aa5a5b580..130b9dbd7 100644 --- a/test/org/traccar/protocol/GranitFrameDecoderTest.java +++ b/test/org/traccar/protocol/GranitFrameDecoderTest.java @@ -2,7 +2,6 @@ package org.traccar.protocol; import java.nio.ByteOrder; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Gt06FrameDecoderTest.java b/test/org/traccar/protocol/Gt06FrameDecoderTest.java index 97230695a..cf6d1cfd7 100644 --- a/test/org/traccar/protocol/Gt06FrameDecoderTest.java +++ b/test/org/traccar/protocol/Gt06FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/H02FrameDecoderTest.java b/test/org/traccar/protocol/H02FrameDecoderTest.java index 214f1c9fa..bdb2ff37b 100644 --- a/test/org/traccar/protocol/H02FrameDecoderTest.java +++ b/test/org/traccar/protocol/H02FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/H02ProtocolEncoderTest.java b/test/org/traccar/protocol/H02ProtocolEncoderTest.java index bf3978385..e7b409a88 100644 --- a/test/org/traccar/protocol/H02ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/H02ProtocolEncoderTest.java @@ -1,7 +1,6 @@ package org.traccar.protocol; import org.joda.time.DateTime; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/HuaShengFrameDecoderTest.java b/test/org/traccar/protocol/HuaShengFrameDecoderTest.java index dc2536319..0f24d4b5c 100644 --- a/test/org/traccar/protocol/HuaShengFrameDecoderTest.java +++ b/test/org/traccar/protocol/HuaShengFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/HuabaoFrameDecoderTest.java b/test/org/traccar/protocol/HuabaoFrameDecoderTest.java index 98caf1dca..2d3937903 100644 --- a/test/org/traccar/protocol/HuabaoFrameDecoderTest.java +++ b/test/org/traccar/protocol/HuabaoFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Jt600FrameDecoderTest.java b/test/org/traccar/protocol/Jt600FrameDecoderTest.java index 15e6ec18c..ae0948987 100644 --- a/test/org/traccar/protocol/Jt600FrameDecoderTest.java +++ b/test/org/traccar/protocol/Jt600FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/L100FrameDecoderTest.java b/test/org/traccar/protocol/L100FrameDecoderTest.java index ab70678d5..fc6a892dc 100644 --- a/test/org/traccar/protocol/L100FrameDecoderTest.java +++ b/test/org/traccar/protocol/L100FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/MegastekFrameDecoderTest.java b/test/org/traccar/protocol/MegastekFrameDecoderTest.java index 9a327bb1f..68606a98a 100644 --- a/test/org/traccar/protocol/MegastekFrameDecoderTest.java +++ b/test/org/traccar/protocol/MegastekFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java b/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java index 214936514..2d09c626b 100644 --- a/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java +++ b/test/org/traccar/protocol/MeiligaoFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/MeitrackFrameDecoderTest.java b/test/org/traccar/protocol/MeitrackFrameDecoderTest.java index f0afee02e..53749816e 100644 --- a/test/org/traccar/protocol/MeitrackFrameDecoderTest.java +++ b/test/org/traccar/protocol/MeitrackFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java b/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java index a2b0ae6fd..d5ecbb488 100644 --- a/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java +++ b/test/org/traccar/protocol/MeitrackProtocolEncoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java index d446c228c..e9422da9f 100644 --- a/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java +++ b/test/org/traccar/protocol/MiniFinderProtocolEncoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/NvsFrameDecoderTest.java b/test/org/traccar/protocol/NvsFrameDecoderTest.java index b03e3826c..8a00207eb 100644 --- a/test/org/traccar/protocol/NvsFrameDecoderTest.java +++ b/test/org/traccar/protocol/NvsFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Pt502FrameDecoderTest.java b/test/org/traccar/protocol/Pt502FrameDecoderTest.java index d654c0c61..04180abb0 100644 --- a/test/org/traccar/protocol/Pt502FrameDecoderTest.java +++ b/test/org/traccar/protocol/Pt502FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java index 5438eb366..9d591bceb 100644 --- a/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Pt502ProtocolEncoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/TelicFrameDecoderTest.java b/test/org/traccar/protocol/TelicFrameDecoderTest.java index 711014c46..dd0efacb6 100644 --- a/test/org/traccar/protocol/TelicFrameDecoderTest.java +++ b/test/org/traccar/protocol/TelicFrameDecoderTest.java @@ -1,7 +1,5 @@ package org.traccar.protocol; -import org.jboss.netty.buffer.ChannelBuffer; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java index 6b38035ed..565f6bb88 100644 --- a/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java +++ b/test/org/traccar/protocol/Tk103ProtocolEncoderTest.java @@ -1,11 +1,8 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; -import org.traccar.TestIdentityManager; import org.traccar.model.Command; -import org.traccar.model.Device; import static org.junit.Assert.assertEquals; diff --git a/test/org/traccar/protocol/TmgFrameDecoderTest.java b/test/org/traccar/protocol/TmgFrameDecoderTest.java index 7a6c47fb9..4f7be1b28 100644 --- a/test/org/traccar/protocol/TmgFrameDecoderTest.java +++ b/test/org/traccar/protocol/TmgFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/TotemFrameDecoderTest.java b/test/org/traccar/protocol/TotemFrameDecoderTest.java index 0d3e69465..8fb5f8d54 100644 --- a/test/org/traccar/protocol/TotemFrameDecoderTest.java +++ b/test/org/traccar/protocol/TotemFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/TotemProtocolEncoderTest.java b/test/org/traccar/protocol/TotemProtocolEncoderTest.java index d17f70405..5a47f74cc 100644 --- a/test/org/traccar/protocol/TotemProtocolEncoderTest.java +++ b/test/org/traccar/protocol/TotemProtocolEncoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java index 68c8bbdbc..c309abce1 100644 --- a/test/org/traccar/protocol/TzoneProtocolDecoderTest.java +++ b/test/org/traccar/protocol/TzoneProtocolDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import static org.junit.Assert.assertNotNull; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/UlbotechFrameDecoderTest.java b/test/org/traccar/protocol/UlbotechFrameDecoderTest.java index b0af435b8..d3d0429d6 100644 --- a/test/org/traccar/protocol/UlbotechFrameDecoderTest.java +++ b/test/org/traccar/protocol/UlbotechFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/Vt200FrameDecoderTest.java b/test/org/traccar/protocol/Vt200FrameDecoderTest.java index a9fff6c33..9422f6d74 100644 --- a/test/org/traccar/protocol/Vt200FrameDecoderTest.java +++ b/test/org/traccar/protocol/Vt200FrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/VtfmsFrameDecoderTest.java b/test/org/traccar/protocol/VtfmsFrameDecoderTest.java index c9ee8ae20..a5eb0b49b 100644 --- a/test/org/traccar/protocol/VtfmsFrameDecoderTest.java +++ b/test/org/traccar/protocol/VtfmsFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/WatchProtocolEncoderTest.java b/test/org/traccar/protocol/WatchProtocolEncoderTest.java index a87afbfc5..a201b7860 100644 --- a/test/org/traccar/protocol/WatchProtocolEncoderTest.java +++ b/test/org/traccar/protocol/WatchProtocolEncoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/WondexFrameDecoderTest.java b/test/org/traccar/protocol/WondexFrameDecoderTest.java index 8eb80da9a..642473f2d 100644 --- a/test/org/traccar/protocol/WondexFrameDecoderTest.java +++ b/test/org/traccar/protocol/WondexFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/protocol/WondexProtocolEncoderTest.java b/test/org/traccar/protocol/WondexProtocolEncoderTest.java index 7c5fa572c..3d76cb677 100644 --- a/test/org/traccar/protocol/WondexProtocolEncoderTest.java +++ b/test/org/traccar/protocol/WondexProtocolEncoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; diff --git a/test/org/traccar/protocol/XexunFrameDecoderTest.java b/test/org/traccar/protocol/XexunFrameDecoderTest.java index cdf30965c..8fc628bdb 100644 --- a/test/org/traccar/protocol/XexunFrameDecoderTest.java +++ b/test/org/traccar/protocol/XexunFrameDecoderTest.java @@ -1,6 +1,5 @@ package org.traccar.protocol; -import org.junit.Assert; import org.junit.Test; import org.traccar.ProtocolTest; diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java index bdf45e9d5..a8ff653c9 100644 --- a/test/org/traccar/reports/ReportUtilsTest.java +++ b/test/org/traccar/reports/ReportUtilsTest.java @@ -15,7 +15,6 @@ import java.util.Iterator; import java.util.List; import java.util.TimeZone; -import org.junit.Assert; import org.junit.Test; import org.traccar.BaseTest; import org.traccar.model.Position; -- cgit v1.2.3 From a58b40a49e96f8fc876b88b6b10489f8532893d9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 10 Mar 2018 16:23:06 +1300 Subject: Replace deprecated classes --- pom.xml | 5 +++ src/org/traccar/BaseProtocol.java | 4 +- src/org/traccar/ExtendedObjectDecoder.java | 4 +- src/org/traccar/api/SecurityRequestFilter.java | 4 +- src/org/traccar/api/resource/SessionResource.java | 6 +-- src/org/traccar/helper/DataConverter.java | 47 ++++++++++++++++++++++ src/org/traccar/helper/Hashing.java | 9 ++--- .../traccar/protocol/At2000ProtocolDecoder.java | 4 +- .../traccar/protocol/EelinkProtocolEncoder.java | 4 +- .../traccar/protocol/HuabaoProtocolEncoder.java | 6 +-- .../traccar/protocol/MeiligaoProtocolEncoder.java | 4 +- .../traccar/protocol/RuptelaProtocolDecoder.java | 6 +-- .../traccar/protocol/SigfoxProtocolDecoder.java | 4 +- src/org/traccar/protocol/T800xProtocolEncoder.java | 4 +- src/org/traccar/protocol/WatchProtocolEncoder.java | 4 +- .../traccar/protocol/Xt2400ProtocolDecoder.java | 4 +- test/org/traccar/ProtocolTest.java | 4 +- 17 files changed, 87 insertions(+), 36 deletions(-) create mode 100644 src/org/traccar/helper/DataConverter.java (limited to 'test/org/traccar/ProtocolTest.java') diff --git a/pom.xml b/pom.xml index 81e9d49c2..14de784f3 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,11 @@ joda-time 2.9.9 + + commons-codec + commons-codec + 1.11 + com.h2database h2 diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java index 90b9f21f2..07adbea5e 100644 --- a/src/org/traccar/BaseProtocol.java +++ b/src/org/traccar/BaseProtocol.java @@ -18,9 +18,9 @@ package org.traccar; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.handler.codec.string.StringEncoder; import org.traccar.database.ActiveDevice; +import org.traccar.helper.DataConverter; import org.traccar.model.Command; -import javax.xml.bind.DatatypeConverter; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; @@ -79,7 +79,7 @@ public abstract class BaseProtocol implements Protocol { if (activeDevice.getChannel().getPipeline().get(StringEncoder.class) != null) { activeDevice.write(data); } else { - activeDevice.write(ChannelBuffers.wrappedBuffer(DatatypeConverter.parseHexBinary(data))); + activeDevice.write(ChannelBuffers.wrappedBuffer(DataConverter.parseHex(data))); } } else { throw new RuntimeException("Command " + command.getType() + " is not supported in protocol " + getName()); diff --git a/src/org/traccar/ExtendedObjectDecoder.java b/src/org/traccar/ExtendedObjectDecoder.java index 268e6f688..75a24212f 100644 --- a/src/org/traccar/ExtendedObjectDecoder.java +++ b/src/org/traccar/ExtendedObjectDecoder.java @@ -23,9 +23,9 @@ import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelUpstreamHandler; import org.jboss.netty.channel.Channels; import org.jboss.netty.channel.MessageEvent; +import org.traccar.helper.DataConverter; import org.traccar.model.Position; -import javax.xml.bind.DatatypeConverter; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.util.Collection; @@ -39,7 +39,7 @@ public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler { ChannelBuffer buf = (ChannelBuffer) originalMessage; position.set(Position.KEY_ORIGINAL, ChannelBuffers.hexDump(buf, 0, buf.writerIndex())); } else if (originalMessage instanceof String) { - position.set(Position.KEY_ORIGINAL, DatatypeConverter.printHexBinary( + position.set(Position.KEY_ORIGINAL, DataConverter.printHex( ((String) originalMessage).getBytes(StandardCharsets.US_ASCII))); } } diff --git a/src/org/traccar/api/SecurityRequestFilter.java b/src/org/traccar/api/SecurityRequestFilter.java index 7024bdbc9..aace9f705 100644 --- a/src/org/traccar/api/SecurityRequestFilter.java +++ b/src/org/traccar/api/SecurityRequestFilter.java @@ -17,6 +17,7 @@ package org.traccar.api; import org.traccar.Context; import org.traccar.api.resource.SessionResource; +import org.traccar.helper.DataConverter; import org.traccar.helper.Log; import org.traccar.model.User; @@ -28,7 +29,6 @@ import javax.ws.rs.container.ContainerRequestFilter; import javax.ws.rs.container.ResourceInfo; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; -import javax.xml.bind.DatatypeConverter; import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.sql.SQLException; @@ -43,7 +43,7 @@ public class SecurityRequestFilter implements ContainerRequestFilter { public static String[] decodeBasicAuth(String auth) { auth = auth.replaceFirst("[B|b]asic ", ""); - byte[] decodedBytes = DatatypeConverter.parseBase64Binary(auth); + byte[] decodedBytes = DataConverter.parseBase64(auth); if (decodedBytes != null && decodedBytes.length > 0) { return new String(decodedBytes, StandardCharsets.US_ASCII).split(":", 2); } diff --git a/src/org/traccar/api/resource/SessionResource.java b/src/org/traccar/api/resource/SessionResource.java index 2a0bd4364..fd331c766 100644 --- a/src/org/traccar/api/resource/SessionResource.java +++ b/src/org/traccar/api/resource/SessionResource.java @@ -17,6 +17,7 @@ package org.traccar.api.resource; import org.traccar.Context; import org.traccar.api.BaseResource; +import org.traccar.helper.DataConverter; import org.traccar.helper.LogAction; import org.traccar.model.User; @@ -34,7 +35,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import javax.xml.bind.DatatypeConverter; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; @@ -63,11 +63,11 @@ public class SessionResource extends BaseResource { if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals(USER_COOKIE_KEY)) { - byte[] emailBytes = DatatypeConverter.parseBase64Binary( + byte[] emailBytes = DataConverter.parseBase64( URLDecoder.decode(cookie.getValue(), StandardCharsets.US_ASCII.name())); email = new String(emailBytes, StandardCharsets.UTF_8); } else if (cookie.getName().equals(PASS_COOKIE_KEY)) { - byte[] passwordBytes = DatatypeConverter.parseBase64Binary( + byte[] passwordBytes = DataConverter.parseBase64( URLDecoder.decode(cookie.getValue(), StandardCharsets.US_ASCII.name())); password = new String(passwordBytes, StandardCharsets.UTF_8); } diff --git a/src/org/traccar/helper/DataConverter.java b/src/org/traccar/helper/DataConverter.java new file mode 100644 index 000000000..7abd4ae93 --- /dev/null +++ b/src/org/traccar/helper/DataConverter.java @@ -0,0 +1,47 @@ +/* + * Copyright 2018 Anton Tananaev (anton@traccar.org) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.traccar.helper; + +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.codec.binary.Hex; + +public final class DataConverter { + + private DataConverter() { + } + + public static byte[] parseHex(String string) { + try { + return Hex.decodeHex(string); + } catch (DecoderException e) { + throw new RuntimeException(e); + } + } + + public static String printHex(byte[] data) { + return Hex.encodeHexString(data); + } + + public static byte[] parseBase64(String string) { + return Base64.decodeBase64(string); + } + + public static String printBase64(byte[] data) { + return Base64.encodeBase64String(data); + } + +} diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java index 3fcc124fa..e91310eda 100644 --- a/src/org/traccar/helper/Hashing.java +++ b/src/org/traccar/helper/Hashing.java @@ -17,7 +17,6 @@ package org.traccar.helper; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; -import javax.xml.bind.DatatypeConverter; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.spec.InvalidKeySpecException; @@ -75,13 +74,13 @@ public final class Hashing { RANDOM.nextBytes(salt); byte[] hash = function(password.toCharArray(), salt); return new HashingResult( - DatatypeConverter.printHexBinary(hash), - DatatypeConverter.printHexBinary(salt)); + DataConverter.printHex(hash), + DataConverter.printHex(salt)); } public static boolean validatePassword(String password, String hashHex, String saltHex) { - byte[] hash = DatatypeConverter.parseHexBinary(hashHex); - byte[] salt = DatatypeConverter.parseHexBinary(saltHex); + byte[] hash = DataConverter.parseHex(hashHex); + byte[] salt = DataConverter.parseHex(saltHex); return slowEquals(hash, function(password.toCharArray(), salt)); } diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java index 06d80c497..e0f2b4278 100644 --- a/src/org/traccar/protocol/At2000ProtocolDecoder.java +++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java @@ -20,13 +20,13 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.helper.DataConverter; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import javax.crypto.Cipher; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -import javax.xml.bind.DatatypeConverter; import java.net.SocketAddress; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; @@ -84,7 +84,7 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder { IvParameterSpec ivSpec = new IvParameterSpec(iv); SecretKeySpec keySpec = new SecretKeySpec( - DatatypeConverter.parseHexBinary("000102030405060708090a0b0c0d0e0f"), "AES"); + DataConverter.parseHex("000102030405060708090a0b0c0d0e0f"), "AES"); cipher = Cipher.getInstance("AES/CBC/NoPadding"); cipher.init(Cipher.DECRYPT_MODE, keySpec, ivSpec); diff --git a/src/org/traccar/protocol/EelinkProtocolEncoder.java b/src/org/traccar/protocol/EelinkProtocolEncoder.java index 76865a039..4d2d86e68 100644 --- a/src/org/traccar/protocol/EelinkProtocolEncoder.java +++ b/src/org/traccar/protocol/EelinkProtocolEncoder.java @@ -18,10 +18,10 @@ package org.traccar.protocol; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.traccar.BaseProtocolEncoder; +import org.traccar.helper.DataConverter; import org.traccar.helper.Log; import org.traccar.model.Command; -import javax.xml.bind.DatatypeConverter; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -47,7 +47,7 @@ public class EelinkProtocolEncoder extends BaseProtocolEncoder { ChannelBuffer buf = ChannelBuffers.dynamicBuffer(); if (connectionless) { - buf.writeBytes(ChannelBuffers.wrappedBuffer(DatatypeConverter.parseHexBinary('0' + uniqueId))); + buf.writeBytes(ChannelBuffers.wrappedBuffer(DataConverter.parseHex('0' + uniqueId))); } buf.writeByte(0x67); diff --git a/src/org/traccar/protocol/HuabaoProtocolEncoder.java b/src/org/traccar/protocol/HuabaoProtocolEncoder.java index 7d6f0510d..d1889bf5e 100644 --- a/src/org/traccar/protocol/HuabaoProtocolEncoder.java +++ b/src/org/traccar/protocol/HuabaoProtocolEncoder.java @@ -18,10 +18,10 @@ package org.traccar.protocol; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.traccar.BaseProtocolEncoder; +import org.traccar.helper.DataConverter; import org.traccar.helper.Log; import org.traccar.model.Command; -import javax.xml.bind.DatatypeConverter; import java.text.SimpleDateFormat; import java.util.Date; @@ -31,10 +31,10 @@ public class HuabaoProtocolEncoder extends BaseProtocolEncoder { protected Object encodeCommand(Command command) { ChannelBuffer id = ChannelBuffers.wrappedBuffer( - DatatypeConverter.parseHexBinary(getUniqueId(command.getDeviceId()))); + DataConverter.parseHex(getUniqueId(command.getDeviceId()))); ChannelBuffer data = ChannelBuffers.dynamicBuffer(); - byte[] time = DatatypeConverter.parseHexBinary(new SimpleDateFormat("yyMMddHHmmss").format(new Date())); + byte[] time = DataConverter.parseHex(new SimpleDateFormat("yyMMddHHmmss").format(new Date())); switch (command.getType()) { case Command.TYPE_ENGINE_STOP: diff --git a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java index 2e0a1e84c..340d947e3 100644 --- a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java +++ b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java @@ -19,10 +19,10 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.traccar.BaseProtocolEncoder; import org.traccar.helper.Checksum; +import org.traccar.helper.DataConverter; import org.traccar.helper.Log; import org.traccar.model.Command; -import javax.xml.bind.DatatypeConverter; import java.nio.charset.StandardCharsets; import java.util.TimeZone; @@ -44,7 +44,7 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder { buf.writeShort(2 + 2 + 7 + 2 + content.readableBytes() + 2 + 2); // message length - buf.writeBytes(DatatypeConverter.parseHexBinary((getUniqueId(deviceId) + "FFFFFFFFFFFFFF").substring(0, 14))); + buf.writeBytes(DataConverter.parseHex((getUniqueId(deviceId) + "FFFFFFFFFFFFFF").substring(0, 14))); buf.writeShort(type); diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java index 87ee8246a..7b11cc5c3 100644 --- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java +++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java @@ -20,10 +20,10 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.helper.DataConverter; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; -import javax.xml.bind.DatatypeConverter; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.util.Date; @@ -196,7 +196,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { } if (channel != null) { - channel.write(ChannelBuffers.wrappedBuffer(DatatypeConverter.parseHexBinary("0002640113bc"))); + channel.write(ChannelBuffers.wrappedBuffer(DataConverter.parseHex("0002640113bc"))); } return positions; @@ -229,7 +229,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder { } if (channel != null) { - channel.write(ChannelBuffers.wrappedBuffer(DatatypeConverter.parseHexBinary("00026d01c4a4"))); + channel.write(ChannelBuffers.wrappedBuffer(DataConverter.parseHex("00026d01c4a4"))); } return positions; diff --git a/src/org/traccar/protocol/SigfoxProtocolDecoder.java b/src/org/traccar/protocol/SigfoxProtocolDecoder.java index 65ab2cc55..b454e00fa 100644 --- a/src/org/traccar/protocol/SigfoxProtocolDecoder.java +++ b/src/org/traccar/protocol/SigfoxProtocolDecoder.java @@ -22,12 +22,12 @@ import org.jboss.netty.handler.codec.http.HttpRequest; import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.traccar.BaseHttpProtocolDecoder; import org.traccar.DeviceSession; +import org.traccar.helper.DataConverter; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; import javax.json.Json; import javax.json.JsonObject; -import javax.xml.bind.DatatypeConverter; import java.io.StringReader; import java.net.SocketAddress; import java.net.URLDecoder; @@ -61,7 +61,7 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder { position.setTime(new Date(json.getInt("time") * 1000L)); ChannelBuffer buf = ChannelBuffers.wrappedBuffer( - ByteOrder.LITTLE_ENDIAN, DatatypeConverter.parseHexBinary(json.getString("data"))); + ByteOrder.LITTLE_ENDIAN, DataConverter.parseHex(json.getString("data"))); int type = buf.readUnsignedByte() >> 4; if (type == 0) { diff --git a/src/org/traccar/protocol/T800xProtocolEncoder.java b/src/org/traccar/protocol/T800xProtocolEncoder.java index 6ed5dbccd..038a5e51a 100644 --- a/src/org/traccar/protocol/T800xProtocolEncoder.java +++ b/src/org/traccar/protocol/T800xProtocolEncoder.java @@ -18,10 +18,10 @@ package org.traccar.protocol; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.traccar.BaseProtocolEncoder; +import org.traccar.helper.DataConverter; import org.traccar.helper.Log; import org.traccar.model.Command; -import javax.xml.bind.DatatypeConverter; import java.nio.charset.StandardCharsets; public class T800xProtocolEncoder extends BaseProtocolEncoder { @@ -39,7 +39,7 @@ public class T800xProtocolEncoder extends BaseProtocolEncoder { buf.writeByte(T800xProtocolDecoder.MSG_COMMAND); buf.writeShort(7 + 8 + 1 + content.length()); buf.writeShort(1); // serial number - buf.writeBytes(DatatypeConverter.parseHexBinary("0" + getUniqueId(command.getDeviceId()))); + buf.writeBytes(DataConverter.parseHex("0" + getUniqueId(command.getDeviceId()))); buf.writeByte(MODE_SETTING); buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII)); diff --git a/src/org/traccar/protocol/WatchProtocolEncoder.java b/src/org/traccar/protocol/WatchProtocolEncoder.java index d2d3b52d1..5206fbf10 100644 --- a/src/org/traccar/protocol/WatchProtocolEncoder.java +++ b/src/org/traccar/protocol/WatchProtocolEncoder.java @@ -16,10 +16,10 @@ package org.traccar.protocol; import org.traccar.StringProtocolEncoder; +import org.traccar.helper.DataConverter; import org.traccar.helper.Log; import org.traccar.model.Command; -import javax.xml.bind.DatatypeConverter; import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -68,7 +68,7 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin } private String getBinaryData(Command command) { - byte[] data = DatatypeConverter.parseHexBinary(command.getString(Command.KEY_DATA)); + byte[] data = DataConverter.parseHex(command.getString(Command.KEY_DATA)); int encodedLength = data.length; for (byte b : data) { diff --git a/src/org/traccar/protocol/Xt2400ProtocolDecoder.java b/src/org/traccar/protocol/Xt2400ProtocolDecoder.java index 72be473c1..1be943e98 100644 --- a/src/org/traccar/protocol/Xt2400ProtocolDecoder.java +++ b/src/org/traccar/protocol/Xt2400ProtocolDecoder.java @@ -20,10 +20,10 @@ import org.jboss.netty.channel.Channel; import org.traccar.BaseProtocolDecoder; import org.traccar.Context; import org.traccar.DeviceSession; +import org.traccar.helper.DataConverter; import org.traccar.helper.UnitsConverter; import org.traccar.model.Position; -import javax.xml.bind.DatatypeConverter; import java.net.SocketAddress; import java.nio.charset.StandardCharsets; import java.util.Date; @@ -95,7 +95,7 @@ public class Xt2400ProtocolDecoder extends BaseProtocolDecoder { Pattern pattern = Pattern.compile(":wycfg pcr\\[\\d+\\] ([0-9a-fA-F]{2})[0-9a-fA-F]{2}([0-9a-fA-F]+)"); Matcher matcher = pattern.matcher(configString); while (matcher.find()) { - formats.put(Short.parseShort(matcher.group(1), 16), DatatypeConverter.parseHexBinary(matcher.group(2))); + formats.put(Short.parseShort(matcher.group(1), 16), DataConverter.parseHex(matcher.group(2))); } } diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java index e67b53aa8..75a98000b 100644 --- a/test/org/traccar/ProtocolTest.java +++ b/test/org/traccar/ProtocolTest.java @@ -5,11 +5,11 @@ import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.handler.codec.http.DefaultHttpRequest; import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpVersion; +import org.traccar.helper.DataConverter; import org.traccar.model.CellTower; import org.traccar.model.Command; import org.traccar.model.Position; -import javax.xml.bind.DatatypeConverter; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.text.DateFormat; @@ -56,7 +56,7 @@ public class ProtocolTest extends BaseTest { protected ChannelBuffer binary(ByteOrder endianness, String... data) { return ChannelBuffers.wrappedBuffer( - endianness, DatatypeConverter.parseHexBinary(concatenateStrings(data))); + endianness, DataConverter.parseHex(concatenateStrings(data))); } protected String text(String... data) { -- cgit v1.2.3