aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/calendar/CalendarTest.java58
-rw-r--r--test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/H02ProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/UproProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/WialonProtocolDecoderTest.java6
5 files changed, 73 insertions, 0 deletions
diff --git a/test/org/traccar/calendar/CalendarTest.java b/test/org/traccar/calendar/CalendarTest.java
new file mode 100644
index 000000000..7f5bd7d29
--- /dev/null
+++ b/test/org/traccar/calendar/CalendarTest.java
@@ -0,0 +1,58 @@
+package org.traccar.calendar;
+
+import java.io.IOException;
+import java.sql.SQLException;
+import java.text.DateFormat;
+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;
+
+import net.fortuna.ical4j.data.ParserException;
+
+public class CalendarTest {
+
+ @Test
+ public void testCalendar() throws IOException, ParserException, ParseException, SQLException {
+ String calendarString = "BEGIN:VCALENDAR\n" +
+ "PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN\n" +
+ "VERSION:2.0\n" +
+ "BEGIN:VTIMEZONE\n" +
+ "TZID:Asia/Yekaterinburg\n" +
+ "BEGIN:STANDARD\n" +
+ "TZOFFSETFROM:+0500\n" +
+ "TZOFFSETTO:+0500\n" +
+ "TZNAME:YEKT\n" +
+ "DTSTART:19700101T000000\n" +
+ "END:STANDARD\n" +
+ "END:VTIMEZONE\n" +
+ "BEGIN:VEVENT\n" +
+ "CREATED:20161213T045151Z\n" +
+ "LAST-MODIFIED:20161213T045242Z\n" +
+ "DTSTAMP:20161213T045242Z\n" +
+ "UID:9d000df0-6354-479d-a407-218dac62c7c9\n" +
+ "SUMMARY:Every night\n" +
+ "RRULE:FREQ=DAILY\n" +
+ "DTSTART;TZID=Asia/Yekaterinburg:20161130T230000\n" +
+ "DTEND;TZID=Asia/Yekaterinburg:20161201T070000\n" +
+ "TRANSP:OPAQUE\n" +
+ "END:VEVENT\n" +
+ "END:VCALENDAR";
+ Calendar calendar = new Calendar();
+ calendar.setCalendarData(calendarString.getBytes());
+ 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));
+ date = format.parse("2016-12-13 23:00:01+05");
+ Assert.assertTrue(calendar.checkMoment(date));
+
+ date = format.parse("2016-12-13 06:59:59+05");
+ Assert.assertTrue(calendar.checkMoment(date));
+ date = format.parse("2016-12-13 07:00:01+05");
+ Assert.assertTrue(!calendar.checkMoment(date));
+ }
+}
diff --git a/test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java b/test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java
index 58e2e4065..a1b715f1c 100644
--- a/test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/AutoGradeProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class AutoGradeProtocolDecoderTest extends ProtocolTest {
AutoGradeProtocolDecoder decoder = new AutoGradeProtocolDecoder(new AutoGradeProtocol());
verifyPosition(decoder, text(
+ "(000000001637868324027912356171116A2250.7611N07556.9425E000.9024427197.36\u008eA0000B0000C0000D0000E0000K0000L0000M0000N0000O0000)"));
+
+ verifyPosition(decoder, text(
"(000000007322865733022629240170415A1001.1971N07618.1375E0.000145312128.59?A0024B0024C0000D0000E0000K0000L0000M0000N0000O0000"));
}
diff --git a/test/org/traccar/protocol/H02ProtocolDecoderTest.java b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
index d1b2d3198..62c4320e8 100644
--- a/test/org/traccar/protocol/H02ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/H02ProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class H02ProtocolDecoderTest extends ProtocolTest {
H02ProtocolDecoder decoder = new H02ProtocolDecoder(new H02Protocol());
+ verifyAttributes(decoder, buffer(
+ "*HQ,1600068812,NBR,141335,262,02,255,6,431,17003,26,431,11101,13,431,6353,13,431,22172,13,431,11093,13,431,60861,10,151216,FFFFFBFF#"));
+
verifyPosition(decoder, buffer(
"*HQ,353588020068342,V1,084436,A,3257.01525,N,00655.03865,W,57.78,40,011216,FFFBFFFF,25c,a, 154,b04c#"));
diff --git a/test/org/traccar/protocol/UproProtocolDecoderTest.java b/test/org/traccar/protocol/UproProtocolDecoderTest.java
index 3af62da08..270caeab5 100644
--- a/test/org/traccar/protocol/UproProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/UproProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class UproProtocolDecoderTest extends ProtocolTest {
UproProtocolDecoder decoder = new UproProtocolDecoder(new UproProtocol());
verifyPosition(decoder, binary(
+ "2a4d473230313836383530303032303030343836372c414226413035303032343138313438373536303636303131373732323030303031313132313626583331302c3236302c34383837322c353639312c37333b34383837322c3732322c38363b34383837322c353639332c38383b34383837322c323336332c39303b34383837322c323336322c393726423030303030303030303026573030264e3230265a31342659313430303323"));
+
+ verifyPosition(decoder, binary(
"2a4d473230303639333530323030303033353537332c42412641303834313237333332363334353230373033383933373630303030303235313131362642303130303030303030302647303036323030264d393930264e3235264f3035303026433030313a363b363926510411058c0c125c0d0a2fff4237ee614d66454c140826555f50000000000300000000000000000026543139333723"));
verifyPosition(decoder, buffer(
diff --git a/test/org/traccar/protocol/WialonProtocolDecoderTest.java b/test/org/traccar/protocol/WialonProtocolDecoderTest.java
index dd5ffd3a1..79eb2d009 100644
--- a/test/org/traccar/protocol/WialonProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/WialonProtocolDecoderTest.java
@@ -20,6 +20,12 @@ public class WialonProtocolDecoderTest extends ProtocolTest {
"#P#"));
verifyPosition(decoder, text(
+ "#D#151216;135910;5321.1466;N;04441.7929;E;87;156;265.000000;12;1.000000;241;NA;NA;NA;odo:2:0.000000,total_fuel:1:430087,can_fls:1:201,can_taho:1:11623,can_mileage:1:140367515"));
+
+ verifyPosition(decoder, text(
+ "#D#151216;140203;5312.59514;N;04830.37834;E;53;273;NA;10;NA;NA;NA;NA;NA;EvId:1:1,Board:2:12.81,Accum:2:4.28"));
+
+ verifyPosition(decoder, text(
"#SD#270413;205601;5544.6025;N;03739.6834;E;1;2;3;4"),
position("2013-04-27 20:56:01.000", true, 55.74338, 37.66139));