summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorCGantert345 <57003061+CGantert345@users.noreply.github.com>2022-04-13 17:57:16 +0200
committerGitHub <noreply@github.com>2022-04-13 17:57:16 +0200
commit7a5f15e2b958dca771b83594669401be2b84f2b6 (patch)
treed96492a7b1958f9822cd994c86d0b0a9f3c6c59f /src/test/java/org
parentMerge pull request #45 from UnionInternationalCheminsdeFer/1.3.1 (diff)
parentunit test for fcb version 1 including all elements (diff)
downloadUIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.gz
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.bz2
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.lz
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.xz
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.tar.zst
UIC-barcode-7a5f15e2b958dca771b83594669401be2b84f2b6.zip
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java (renamed from src/test/java/org/uic/barcode/test/BinaryStringTest.java)9
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeBitStringTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceExtensionTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumExtensionTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeExtensionFieldOrderTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeFieldOrderTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerExtensionTest.java7
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeOctetStringTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeOptionalSequenceExtensionTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedStringLengthTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceExtensionTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringListTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringTest.java7
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfUtf8StringTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeStringCustomAlphabetTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeStringDefaultTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeStringLengthTest.java6
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java5
-rw-r--r--src/test/java/org/uic/barcode/asn1/test/UperEncodeVarBitStringTest.java5
-rw-r--r--src/test/java/org/uic/barcode/test/AlgorithmNameResolverTest.java122
-rw-r--r--src/test/java/org/uic/barcode/test/AsnLevelDynamicContentTest.java5
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java3
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureBCelipticTest2.java167
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java167
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java16
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java32
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java5
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java7
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java5
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java13
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameLOwLevelTest.java3
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java5
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java5
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java5
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java5
-rw-r--r--src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java5
-rw-r--r--src/test/java/org/uic/barcode/test/SecurityUtilsTest.java222
-rw-r--r--src/test/java/org/uic/barcode/test/SignatureSplitTest.java17
-rw-r--r--src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java3
-rw-r--r--src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java3
-rw-r--r--src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB3.java3
-rw-r--r--src/test/java/org/uic/barcode/test/TicketLayoutTest.java5
-rw-r--r--src/test/java/org/uic/barcode/test/TimeStampTest.java55
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV1.java1094
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java1140
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelAllElementsTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java167
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java8
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV1.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV2.java4
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV3.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/DelayConfirmationTestV3.java180
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV3.java697
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketINcludedTicketDateTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV3.java697
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTrainLinkDateTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV1.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV2.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV3.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV3.java697
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/PassTrainValidityTestV3.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV3.java631
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java7
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java3
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV3.java630
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java14
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java14
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java9
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java6
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/UperEncodeUICTicketExtensionTest.java20
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV1.java12
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV2.java14
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV3.java14
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/testtickets/AllElementsTestTicketV1.java1409
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java5
-rw-r--r--src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java10
-rw-r--r--src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java7
-rw-r--r--src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java4
-rw-r--r--src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java3
109 files changed, 6857 insertions, 1801 deletions
diff --git a/src/test/java/org/uic/barcode/test/BinaryStringTest.java b/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java
index d5533fa..bb06eae 100644
--- a/src/test/java/org/uic/barcode/test/BinaryStringTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java
@@ -1,13 +1,18 @@
-package org.uic.barcode.test;
+package org.uic.barcode.asn1.test;
import java.io.IOException;
+
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.AsnUtils;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
public class BinaryStringTest {
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testBinaryString() throws IOException, EncodingFormatException{
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBitStringTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBitStringTest.java
index 94f29c2..9906fa0 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBitStringTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBitStringTest.java
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.Bitstring;
@@ -12,6 +13,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.FixedSize;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeBitStringTest {
@@ -55,6 +57,10 @@ public class UperEncodeBitStringTest {
booleans.add(value3);
}
}
+
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java
index b5e73b0..dea2716 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeBooleanTest {
@@ -36,6 +38,9 @@ public class UperEncodeBooleanTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testTrue() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord(new Boolean(true));
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceExtensionTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceExtensionTest.java
index 3833ff2..94fbee7 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceExtensionTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceExtensionTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -13,6 +14,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IsExtension;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeChoiceExtensionTest {
@@ -58,6 +60,9 @@ public class UperEncodeChoiceExtensionTest {
public TestRecord() { }
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
TestRecordExtended record = new TestRecordExtended();
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceTest.java
index 69b92d1..ebd994f 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeChoiceTest.java
@@ -4,12 +4,14 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.Choice;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeChoiceTest {
@@ -48,6 +50,10 @@ public class UperEncodeChoiceTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
+
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord(null, "Meier");
byte[] encoded = UperEncoder.encode(record);
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumExtensionTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumExtensionTest.java
index a2ecbe1..fdbcd5c 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumExtensionTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumExtensionTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.FieldOrder;
@@ -11,6 +12,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IsExtension;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeEnumExtensionTest {
@@ -105,6 +107,9 @@ public class UperEncodeEnumExtensionTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testExtension() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumTest.java
index d1d2d82..a99a1b9 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeEnumTest.java
@@ -4,12 +4,14 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Default;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeEnumTest {
@@ -79,7 +81,9 @@ public class UperEncodeEnumTest {
}
}
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testNonDefaultValue() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeExtensionFieldOrderTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeExtensionFieldOrderTest.java
index ff97c27..6a7680d 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeExtensionFieldOrderTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeExtensionFieldOrderTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
import org.uic.barcode.asn1.datatypes.FieldOrder;
@@ -11,6 +12,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IsExtension;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeExtensionFieldOrderTest {
@@ -69,6 +71,10 @@ Encoded successfully in 21 bytes:
}
+
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeFieldOrderTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeFieldOrderTest.java
index d86b4cd..9f38d69 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeFieldOrderTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeFieldOrderTest.java
@@ -2,6 +2,7 @@ package org.uic.barcode.asn1.test;
import static org.junit.Assert.assertEquals;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -9,6 +10,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeFieldOrderTest {
@@ -46,6 +48,9 @@ public class UperEncodeFieldOrderTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java
index 575597f..2f46046 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeIntegerConstrainedTest {
@@ -50,7 +52,9 @@ public class UperEncodeIntegerConstrainedTest {
}
}
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerExtensionTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerExtensionTest.java
index acec756..bde0683 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerExtensionTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerExtensionTest.java
@@ -2,6 +2,7 @@ package org.uic.barcode.asn1.test;
import static org.junit.Assert.assertEquals;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
import org.uic.barcode.asn1.datatypes.FieldOrder;
@@ -9,6 +10,7 @@ import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
import org.uic.barcode.asn1.datatypes.IsExtension;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeIntegerExtensionTest {
@@ -69,7 +71,10 @@ Encoded successfully in 21 bytes:
}
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
+
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord();
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java
index 5ada54d..39bfb32 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java
@@ -4,10 +4,12 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeIntegerSmallTest {
@@ -40,6 +42,9 @@ public class UperEncodeIntegerSmallTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test1() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java
index d57fd00..412689b 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeIntegerTest {
@@ -36,6 +38,9 @@ public class UperEncodeIntegerTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java
index 4b09604..f3a23a3 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java
@@ -3,12 +3,14 @@ package org.uic.barcode.asn1.test;
import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeObjectIdentifierTest {
@@ -49,6 +51,10 @@ public class UperEncodeObjectIdentifierTest {
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
+
@Test
public void testEncode() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord();
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeOctetStringTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeOctetStringTest.java
index 24896f0..89041cc 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeOctetStringTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeOctetStringTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.OctetString;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeOctetStringTest {
@@ -40,6 +42,9 @@ public class UperEncodeOctetStringTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeOptionalSequenceExtensionTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeOptionalSequenceExtensionTest.java
index 55e6026..bfb6a74 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeOptionalSequenceExtensionTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeOptionalSequenceExtensionTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -13,6 +14,7 @@ import org.uic.barcode.asn1.datatypes.IsExtension;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeOptionalSequenceExtensionTest {
@@ -69,6 +71,9 @@ public class UperEncodeOptionalSequenceExtensionTest {
public TestRecord() { }
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
TestRecordExtended record = new TestRecordExtended();
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java
index bc82621..f806c88 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeRestrictedIntegerTest {
@@ -36,6 +38,10 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE {
value = num;
}
}
+
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedStringLengthTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedStringLengthTest.java
index 6e3d4ee..9dffd3a 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedStringLengthTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedStringLengthTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -12,6 +13,7 @@ import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeRestrictedStringLengthTest {
@@ -51,6 +53,9 @@ public class UperEncodeRestrictedStringLengthTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode1() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord("A");
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceExtensionTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceExtensionTest.java
index 29d203b..4ee42c5 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceExtensionTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceExtensionTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -13,6 +14,7 @@ import org.uic.barcode.asn1.datatypes.IsExtension;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeSequenceExtensionTest {
@@ -57,6 +59,9 @@ public class UperEncodeSequenceExtensionTest {
public TestRecord() { }
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
TestRecordExtended record = new TestRecordExtended();
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java
index 9194dca..3213b1e 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java
@@ -6,11 +6,13 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeSequenceOfIntegerTest {
@@ -37,6 +39,9 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java
index d1834d0..33e9b9f 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.IntRange;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeSequenceOfRestrictedIntegerTest {
@@ -39,6 +41,9 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringListTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringListTest.java
index 49350cc..e038d51 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringListTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringListTest.java
@@ -6,12 +6,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeSequenceOfStringListTest {
@@ -41,6 +43,9 @@ public class UperEncodeSequenceOfStringListTest {
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringTest.java
index f3bff6d..8c9cd70 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfStringTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeSequenceOfStringTest {
@@ -37,7 +39,10 @@ public class UperEncodeSequenceOfStringTest {
}
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
+
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord();
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfUtf8StringTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfUtf8StringTest.java
index ab8fa2a..a39a4be 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfUtf8StringTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfUtf8StringTest.java
@@ -4,11 +4,13 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeSequenceOfUtf8StringTest {
@@ -59,6 +61,9 @@ Encoded successfully in 19 bytes:
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void test() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringCustomAlphabetTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringCustomAlphabetTest.java
index 03b8bac..557fad1 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringCustomAlphabetTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringCustomAlphabetTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -11,6 +12,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeStringCustomAlphabetTest {
@@ -52,6 +54,9 @@ public class UperEncodeStringCustomAlphabetTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringDefaultTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringDefaultTest.java
index d8e5029..9023d51 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringDefaultTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringDefaultTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Default;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
@@ -12,6 +13,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeStringDefaultTest {
@@ -45,6 +47,9 @@ public class UperEncodeStringDefaultTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord("Müller", "testString");
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringLengthTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringLengthTest.java
index 9dd4389..0b24cb7 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringLengthTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringLengthTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -11,6 +12,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeStringLengthTest {
@@ -32,7 +34,9 @@ public class UperEncodeStringLengthTest {
</pre>
*/
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Sequence
public static class TestRecord {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java
index 75ace32..68eccc8 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
@@ -11,6 +12,7 @@ import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeStringTest {
@@ -47,6 +49,9 @@ public class UperEncodeStringTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeVarBitStringTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeVarBitStringTest.java
index d6212e2..7b0f943 100644
--- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeVarBitStringTest.java
+++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeVarBitStringTest.java
@@ -6,12 +6,14 @@ import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.Asn1VarSizeBitstring;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
public class UperEncodeVarBitStringTest {
@@ -55,6 +57,9 @@ public class UperEncodeVarBitStringTest {
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncode() throws IllegalArgumentException, IllegalAccessException {
TestRecord record = new TestRecord(false,false,true);
diff --git a/src/test/java/org/uic/barcode/test/AlgorithmNameResolverTest.java b/src/test/java/org/uic/barcode/test/AlgorithmNameResolverTest.java
new file mode 100644
index 0000000..6e245e8
--- /dev/null
+++ b/src/test/java/org/uic/barcode/test/AlgorithmNameResolverTest.java
@@ -0,0 +1,122 @@
+package org.uic.barcode.test;
+
+import java.security.Provider;
+import java.security.Security;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.utils.AlgorithmNameResolver;
+
+public class AlgorithmNameResolverTest {
+
+ public String signatureAlgorithmOID = null;
+ public String elipticCurve = null;
+ public String keyPairAlgorithmOID = null;
+
+
+ public Provider provider = null;
+
+
+ @Before public void initialize() {
+
+
+
+ signatureAlgorithmOID = Constants.ECDSA_SHA256;
+ keyPairAlgorithmOID = Constants.KG_EC_256;
+ elipticCurve = "secp256k1";
+
+
+ provider = new BouncyCastleProvider();
+ Security.addProvider(new BouncyCastleProvider());
+
+ }
+
+
+
+ @Test public void testSignatureAlgorithmName() {
+
+ String name = null;
+
+ try {
+ name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_SIGNATURE_ALG, signatureAlgorithmOID, null);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(name.equals("SHA256withECDSA"));
+
+ //default values:
+
+ try {
+ name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_SIGNATURE_ALG, "1.2.840.10045", null);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(name.equals("ECDSA"));
+
+ try {
+ name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_SIGNATURE_ALG, "1.2.840.10040", null);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(name.equals("DSA"));
+
+ //custom value
+
+ AlgorithmNameResolver.addMap(AlgorithmNameResolver.TYPE_SIGNATURE_ALG, "1.2.3.4.5", "TEST");
+
+ try {
+ name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_SIGNATURE_ALG, "1.2.3.4.5", null);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(name.equals("TEST"));
+
+
+ }
+
+ @Test public void testKeyGeneratorAlgorithmName() {
+
+ String name = null;
+
+ try {
+ name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_KEY_GENERATOR_ALG, keyPairAlgorithmOID, null);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(name.equals("EC"));
+
+ //default values:
+
+ try {
+ name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_SIGNATURE_ALG, "1.2.840.10045.3", null);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(name.equals("EC"));
+
+
+
+ //custom value
+
+ AlgorithmNameResolver.addMap(AlgorithmNameResolver.TYPE_KEY_GENERATOR_ALG, "1.2.3.4.5", "TEST");
+
+ try {
+ name = AlgorithmNameResolver.getAlgorithmName(AlgorithmNameResolver.TYPE_KEY_GENERATOR_ALG, "1.2.3.4.5", null);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(name.equals("TEST"));
+
+
+ }
+
+
+}
diff --git a/src/test/java/org/uic/barcode/test/AsnLevelDynamicContentTest.java b/src/test/java/org/uic/barcode/test/AsnLevelDynamicContentTest.java
index 955066d..7e36489 100644
--- a/src/test/java/org/uic/barcode/test/AsnLevelDynamicContentTest.java
+++ b/src/test/java/org/uic/barcode/test/AsnLevelDynamicContentTest.java
@@ -6,6 +6,7 @@ import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.dynamicContent.fdc1.ExtensionData;
import org.uic.barcode.dynamicContent.fdc1.TimeStamp;
import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.dynamicContent.fdc1.GeoCoordinateType;
public class AsnLevelDynamicContentTest {
@@ -53,6 +54,10 @@ public class AsnLevelDynamicContentTest {
}
+
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testDynamicContentEncoding() {
diff --git a/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java b/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java
index 5355d5d..c6a693f 100644
--- a/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java
@@ -9,6 +9,7 @@ import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.dynamicContent.api.DynamicContentCoder;
import org.uic.barcode.dynamicContent.api.IUicDynamicContent;
import org.uic.barcode.dynamicContent.api.SimpleUicDynamicContent;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.impl.SimpleExtension;
import org.uic.barcode.ticket.api.impl.SimpleGeoCoordinate;
@@ -21,6 +22,8 @@ public class DynamicContentCoderTest {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
content = new SimpleUicDynamicContent();
content.setAppId("appID");
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureBCelipticTest2.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureBCelipticTest2.java
new file mode 100644
index 0000000..f5d0729
--- /dev/null
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureBCelipticTest2.java
@@ -0,0 +1,167 @@
+package org.uic.barcode.test;
+
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.SignatureException;
+import java.security.spec.ECGenParameterSpec;
+import java.util.Arrays;
+import java.util.zip.DataFormatException;
+
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.Decoder;
+import org.uic.barcode.Encoder;
+import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.test.utils.Level2TestDataFactory;
+import org.uic.barcode.test.utils.SimpleUICTestTicket;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.utils.SecurityUtils;
+
+public class DynamicFrameDoubleSignatureBCelipticTest2 {
+
+ public String signatureAlgorithmOID = null;
+ public String elipticCurve = null;
+ public String keyPairAlgorithmOID = null;
+
+ public KeyPair keyPairLevel1 = null;
+ public KeyPair keyPairLevel2 = null;
+
+ public IUicRailTicket testFCBticket = null;
+
+ public Provider provider = null;
+
+
+ @Before public void initialize() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ signatureAlgorithmOID = Constants.ECDSA_SHA256;
+ keyPairAlgorithmOID = Constants.KG_EC_256;
+ elipticCurve = "secp256k1";
+
+ testFCBticket = SimpleUICTestTicket.getUicTestTicket();
+
+ provider = new BouncyCastleProvider();
+ Security.addProvider(new BouncyCastleProvider());
+
+ try {
+ keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
+ keyPairLevel2 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(keyPairLevel1 != null);
+
+ assert(keyPairLevel2 != null);
+
+ }
+
+
+
+ @Test public void testDynamicHeaderBarcodeDecoding() {
+
+ IUicRailTicket ticket = testFCBticket;
+
+ Encoder enc = null;
+
+ try {
+ enc = new Encoder(ticket, null, Encoder.UIC_BARCODE_TYPE_DOSIPAS, 1, 13);
+ } catch (IOException | EncodingFormatException e1) {
+ assert(false);
+ }
+
+ assert(enc != null);
+
+ try {
+ enc.setLevel1Algs(signatureAlgorithmOID, keyPairAlgorithmOID);
+ enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID,keyPairLevel2.getPublic());
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(enc != null);
+
+
+ IData level2Data = Level2TestDataFactory.getLevel2SimpleTestData();
+ try {
+ enc.setLevel2Data(level2Data);
+ enc.signLevel2(keyPairLevel2.getPrivate());
+ } catch (Exception e) {
+ assert(false);
+ }
+
+
+ byte[] encoded = null;
+ try {
+ encoded = enc.encode();
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(encoded != null);
+
+ Decoder dec = null;
+ try {
+ dec = new Decoder(encoded);
+ } catch (IOException e) {
+ assert(false);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ } catch (DataFormatException e) {
+ assert(false);
+ }
+ assert(dec != null);
+
+ int signatureCheck = 0;
+ try {
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null);
+ } catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
+ | UnsupportedOperationException | IOException | EncodingFormatException e) {
+ assert(false);
+ }
+ assert(signatureCheck == Constants.LEVEL1_VALIDATION_OK);
+
+ signatureCheck = 0;
+ try {
+ signatureCheck = dec.validateLevel2();
+ } catch (Exception e) {
+ assert(false);
+ }
+ assert(signatureCheck == Constants.LEVEL2_VALIDATION_OK);
+
+ IData level2DataDec = dec.getLevel2Data();
+
+ assert(level2Data.getFormat().equals(level2DataDec.getFormat()));
+ assert(Arrays.equals(level2Data.getData(),level2DataDec.getData()));
+
+ SimpleUICTestTicket.compare(ticket, dec.getUicTicket());
+
+ }
+
+
+ public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
+
+ //ECNamedCurveGenParameterSpec namedParamSpec = new ECNamedCurveGenParameterSpec(elipticCurve);
+
+ ECGenParameterSpec namedParamSpec = new ECGenParameterSpec(elipticCurve);
+ KeyPairGenerator ecKPGen = KeyPairGenerator.getInstance("ECDSA", "BC");
+ ecKPGen.initialize(namedParamSpec, new SecureRandom());
+ KeyPair keyPair = ecKPGen.generateKeyPair();
+ KeyPair kp = new KeyPair(SecurityUtils.convert(keyPair.getPublic(), provider),SecurityUtils.convert(keyPair.getPrivate(), provider));
+ return kp;
+ }
+
+
+}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java
new file mode 100644
index 0000000..f118026
--- /dev/null
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java
@@ -0,0 +1,167 @@
+package org.uic.barcode.test;
+
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.SignatureException;
+import java.security.spec.ECGenParameterSpec;
+import java.util.Arrays;
+import java.util.zip.DataFormatException;
+
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.Decoder;
+import org.uic.barcode.Encoder;
+import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.test.utils.Level2TestDataFactory;
+import org.uic.barcode.test.utils.SimpleUICTestTicket;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.utils.SecurityUtils;
+
+public class DynamicFrameDoubleSignatureCurve2Test {
+
+ public String signatureAlgorithmOID = null;
+ public String elipticCurve = null;
+ public String keyPairAlgorithmOID = null;
+
+ public KeyPair keyPairLevel1 = null;
+ public KeyPair keyPairLevel2 = null;
+
+ public IUicRailTicket testFCBticket = null;
+
+ public Provider provider = null;
+
+
+ @Before public void initialize() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ signatureAlgorithmOID = Constants.ECDSA_SHA256;
+ keyPairAlgorithmOID = Constants.KG_EC_256;
+ elipticCurve = "secp256r1";
+
+ testFCBticket = SimpleUICTestTicket.getUicTestTicket();
+
+ provider = new BouncyCastleProvider();
+ Security.addProvider(new BouncyCastleProvider());
+
+ try {
+ keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
+ keyPairLevel2 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(keyPairLevel1 != null);
+
+ assert(keyPairLevel2 != null);
+
+ }
+
+
+
+ @Test public void testDynamicHeaderBarcodeDecoding() {
+
+ IUicRailTicket ticket = testFCBticket;
+
+ Encoder enc = null;
+
+ try {
+ enc = new Encoder(ticket, null, Encoder.UIC_BARCODE_TYPE_DOSIPAS, 1, 13);
+ } catch (IOException | EncodingFormatException e1) {
+ assert(false);
+ }
+
+ assert(enc != null);
+
+ try {
+ enc.setLevel1Algs(signatureAlgorithmOID, keyPairAlgorithmOID);
+ enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID,keyPairLevel2.getPublic());
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(enc != null);
+
+
+ IData level2Data = Level2TestDataFactory.getLevel2SimpleTestData();
+ try {
+ enc.setLevel2Data(level2Data);
+ enc.signLevel2(keyPairLevel2.getPrivate());
+ } catch (Exception e) {
+ assert(false);
+ }
+
+
+ byte[] encoded = null;
+ try {
+ encoded = enc.encode();
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(encoded != null);
+
+ Decoder dec = null;
+ try {
+ dec = new Decoder(encoded);
+ } catch (IOException e) {
+ assert(false);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ } catch (DataFormatException e) {
+ assert(false);
+ }
+ assert(dec != null);
+
+ int signatureCheck = 0;
+ try {
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null);
+ } catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
+ | UnsupportedOperationException | IOException | EncodingFormatException e) {
+ assert(false);
+ }
+ assert(signatureCheck == Constants.LEVEL1_VALIDATION_OK);
+
+ signatureCheck = 0;
+ try {
+ signatureCheck = dec.validateLevel2();
+ } catch (Exception e) {
+ assert(false);
+ }
+ assert(signatureCheck == Constants.LEVEL2_VALIDATION_OK);
+
+ IData level2DataDec = dec.getLevel2Data();
+
+ assert(level2Data.getFormat().equals(level2DataDec.getFormat()));
+ assert(Arrays.equals(level2Data.getData(),level2DataDec.getData()));
+
+ SimpleUICTestTicket.compare(ticket, dec.getUicTicket());
+
+ }
+
+
+ public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
+
+ //ECNamedCurveGenParameterSpec namedParamSpec = new ECNamedCurveGenParameterSpec(elipticCurve);
+
+ ECGenParameterSpec namedParamSpec = new ECGenParameterSpec(elipticCurve);
+ KeyPairGenerator ecKPGen = KeyPairGenerator.getInstance("EC", "BC");
+ ecKPGen.initialize(namedParamSpec, new SecureRandom());
+ KeyPair keyPair = ecKPGen.generateKeyPair();
+ KeyPair kp = new KeyPair(SecurityUtils.convert(keyPair.getPublic(), provider),SecurityUtils.convert(keyPair.getPrivate(), provider));
+ return kp;
+ }
+
+
+}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java
index 0730e69..59f3b47 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureProviderSelectionTest.java
@@ -1,12 +1,10 @@
package org.uic.barcode.test;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
@@ -23,10 +21,12 @@ import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.Level2TestDataFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.utils.AlgorithmNameResolver;
public class DynamicFrameDoubleSignatureProviderSelectionTest {
@@ -43,9 +43,11 @@ public class DynamicFrameDoubleSignatureProviderSelectionTest {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
@@ -149,16 +151,10 @@ public class DynamicFrameDoubleSignatureProviderSelectionTest {
}
- public KeyPair generateECDSAKeys(String keyAlgorithmName, String paramName) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException{
- ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(paramName);
- KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
- g.initialize(ecSpec, new SecureRandom());
- return g.generateKeyPair();
- }
public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
- String keyAlgorithmName = "ECDSA";
+ String keyAlgorithmName = AlgorithmNameResolver.getName(AlgorithmNameResolver.TYPE_KEY_GENERATOR_ALG, keyAlgorithmOid);
ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(curve);
KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
g.initialize(ecSpec, new SecureRandom());
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java
index 787ebae..6533938 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureTest.java
@@ -1,31 +1,31 @@
package org.uic.barcode.test;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
+import java.security.spec.ECGenParameterSpec;
import java.util.Arrays;
import java.util.zip.DataFormatException;
-import org.bouncycastle.jce.ECNamedCurveTable;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.jce.spec.ECParameterSpec;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.Level2TestDataFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.utils.SecurityUtils;
public class DynamicFrameDoubleSignatureTest {
@@ -38,15 +38,20 @@ public class DynamicFrameDoubleSignatureTest {
public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
elipticCurve = "secp256k1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
+ provider = new BouncyCastleProvider();
Security.addProvider(new BouncyCastleProvider());
try {
@@ -145,20 +150,17 @@ public class DynamicFrameDoubleSignatureTest {
}
- public KeyPair generateECDSAKeys(String keyAlgorithmName, String paramName) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException{
- ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(paramName);
- KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
- g.initialize(ecSpec, new SecureRandom());
- return g.generateKeyPair();
- }
public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
- String keyAlgorithmName = "ECDSA";
- ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(curve);
- KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
- g.initialize(ecSpec, new SecureRandom());
- return g.generateKeyPair();
+ //ECNamedCurveGenParameterSpec namedParamSpec = new ECNamedCurveGenParameterSpec(elipticCurve);
+
+ ECGenParameterSpec namedParamSpec = new ECGenParameterSpec(elipticCurve);
+ KeyPairGenerator ecKPGen = KeyPairGenerator.getInstance("EC", "BC");
+ ecKPGen.initialize(namedParamSpec, new SecureRandom());
+ KeyPair keyPair = ecKPGen.generateKeyPair();
+ KeyPair kp = new KeyPair(SecurityUtils.convert(keyPair.getPublic(), provider),SecurityUtils.convert(keyPair.getPrivate(), provider));
+ return kp;
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java
index 4d34c1b..da701bd 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java
@@ -26,6 +26,7 @@ import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicContent.api.IUicDynamicContent;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.DynamicTestContent;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
@@ -49,9 +50,11 @@ public class DynamicFrameDynamicContentApiTest {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
index d26ab77..b91cd0c 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java
@@ -29,6 +29,7 @@ import org.uic.barcode.dynamicContent.fdc1.GeoCoordinateType;
import org.uic.barcode.dynamicContent.fdc1.TimeStamp;
import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -52,12 +53,14 @@ public class DynamicFrameDynamicContentTest {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
-
+
Security.addProvider(new BouncyCastleProvider());
try {
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java
index ea95a88..dafeb49 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java
@@ -21,6 +21,7 @@ import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -38,9 +39,11 @@ public class DynamicFrameFcbVersion1Test {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java
index 199a32d..7f03658 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java
@@ -21,6 +21,7 @@ import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -38,9 +39,11 @@ public class DynamicFrameFcbVersion3Test {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
@@ -156,13 +159,7 @@ public class DynamicFrameFcbVersion3Test {
}
- public KeyPair generateECDSAKeys(String keyAlgorithmName, String paramName) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException{
- ECParameterSpec ecSpec = ECNamedCurveTable.getParameterSpec(paramName);
- KeyPairGenerator g = KeyPairGenerator.getInstance(keyAlgorithmName, "BC");
- g.initialize(ecSpec, new SecureRandom());
- return g.generateKeyPair();
- }
-
+
public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
String keyAlgorithmName = "ECDSA";
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameLOwLevelTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameLOwLevelTest.java
index b8a851b..e1345e5 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameLOwLevelTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameLOwLevelTest.java
@@ -22,6 +22,7 @@ import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.v1.DynamicFrame;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.SimpleDynamicFrameTestBarcode;
public class DynamicFrameLOwLevelTest {
@@ -35,6 +36,8 @@ public class DynamicFrameLOwLevelTest {
@Before public void initialize() {
+
+ LoggerFactory.setActivateConsoleLog(true);
Security.addProvider(new BouncyCastleProvider());
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java
index 190924d..931324d 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java
@@ -20,6 +20,7 @@ import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -37,9 +38,11 @@ public class DynamicFrameSimpleTest {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java
index 17bccd6..ab4c39e 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java
@@ -21,6 +21,7 @@ import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -38,9 +39,11 @@ public class DynamicFrameV2FcbVersion3Test {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java
index a7d5098..5b5a8ae 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java
@@ -26,6 +26,7 @@ import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.DynamicTestContent;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
@@ -49,9 +50,11 @@ public class DynamicFrameV2SignatureInsert2Test {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java
index 8f97574..68be52e 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java
@@ -26,6 +26,7 @@ import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.DynamicTestContent;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
@@ -49,9 +50,11 @@ public class DynamicFrameV2SignatureInsertTest {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java
index 9bbd736..a198b97 100644
--- a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java
+++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java
@@ -25,6 +25,7 @@ import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
import org.uic.barcode.dynamicFrame.api.IData;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -42,9 +43,11 @@ public class DynamicFrameV2ValidityDateTest {
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
signatureAlgorithmOID = Constants.ECDSA_SHA256;
keyPairAlgorithmOID = Constants.KG_EC_256;
- elipticCurve = "secp256k1";
+ elipticCurve = "secp256r1";
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/SecurityUtilsTest.java b/src/test/java/org/uic/barcode/test/SecurityUtilsTest.java
new file mode 100644
index 0000000..e500523
--- /dev/null
+++ b/src/test/java/org/uic/barcode/test/SecurityUtilsTest.java
@@ -0,0 +1,222 @@
+package org.uic.barcode.test;
+
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.PrivateKey;
+import java.security.Provider;
+import java.security.SecureRandom;
+import java.security.Security;
+import java.security.Signature;
+import java.security.SignatureException;
+import java.security.spec.ECGenParameterSpec;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.utils.AlgorithmNameResolver;
+import org.uic.barcode.utils.SecurityUtils;
+
+public class SecurityUtilsTest {
+
+
+
+ public KeyPair keyPairCk = null;
+ public KeyPair keyPairCr = null;
+ public KeyPair keyPairDsa = null;
+ public KeyPair keyPairECDSACk = null;
+ public KeyPair keyPairECDSACr = null;
+
+
+ public Provider provider = null;
+
+
+ @Before public void initialize() {
+
+ provider = new BouncyCastleProvider();
+ Security.addProvider(new BouncyCastleProvider());
+
+ try {
+ keyPairCk = generateECKeys(Constants.KG_EC_256, "secp256k1");
+ keyPairCr = generateECKeys(Constants.KG_EC_256, "secp256r1");
+ keyPairECDSACk = generateECDSAKeys(Constants.KG_EC_256, "secp256k1");
+ keyPairECDSACr = generateECDSAKeys(Constants.KG_EC_256, "secp256r1");
+ keyPairDsa = generateDsaKeys();
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert(keyPairCk != null);
+
+ assert(keyPairCr != null);
+
+ assert(keyPairDsa != null);
+
+ }
+
+
+
+
+
+
+ @Test public void testFindPublicKeyProvider() {
+
+
+ Provider p = null;
+ boolean canSign = false;
+
+ p = SecurityUtils.findPublicKeyProvider(Constants.KG_EC_256,keyPairCk.getPublic().getEncoded());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairCk.getPrivate());
+ assert(canSign == true);
+
+ p = SecurityUtils.findPublicKeyProvider(Constants.KG_EC_256,keyPairCr.getPublic().getEncoded());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairCr.getPrivate());
+ assert(canSign == true);
+
+ p = SecurityUtils.findPublicKeyProvider(Constants.KG_EC_256,keyPairECDSACk.getPublic().getEncoded());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairECDSACk.getPrivate());
+ assert(canSign == true);
+
+ p = SecurityUtils.findPublicKeyProvider(Constants.KG_EC_256,keyPairECDSACr.getPublic().getEncoded());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairECDSACr.getPrivate());
+ assert(canSign == true);
+
+ p = SecurityUtils.findPublicKeyProvider("1.2.840.10040",keyPairDsa.getPublic().getEncoded());
+ assert (p != null);
+ canSign = testSignature(p,Constants.DSA_SHA256,keyPairDsa.getPrivate());
+ assert(canSign == true);
+
+ }
+
+
+
+
+
+
+ @Test public void testFindSignatureAlgorithmProvider() {
+
+ Provider p = null;
+ boolean canSign = false;
+
+ p = SecurityUtils.findPrivateKeyProvider(keyPairCk.getPrivate());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairCk.getPrivate());
+ assert(canSign == true);
+
+
+ p = SecurityUtils.findPrivateKeyProvider(keyPairCr.getPrivate());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairCr.getPrivate());
+ assert(canSign == true);
+
+ p = SecurityUtils.findPrivateKeyProvider(keyPairECDSACk.getPrivate());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairECDSACk.getPrivate());
+ assert(canSign == true);
+
+
+ p = SecurityUtils.findPrivateKeyProvider(keyPairECDSACr.getPrivate());
+ assert (p != null);
+ canSign = testSignature(p,Constants.ECDSA_SHA256,keyPairECDSACr.getPrivate());
+ assert(canSign == true);
+
+ p = SecurityUtils.findPrivateKeyProvider(keyPairDsa.getPrivate());
+ assert (p != null);
+ canSign = testSignature(p,Constants.DSA_SHA256,keyPairDsa.getPrivate());
+ assert(canSign == true);
+
+
+ }
+
+
+ public KeyPair generateECKeys(String keyAlgorithmOid, String curve) throws Exception{
+
+ //ECNamedCurveGenParameterSpec namedParamSpec = new ECNamedCurveGenParameterSpec(elipticCurve);
+
+ ECGenParameterSpec namedParamSpec = new ECGenParameterSpec(curve);
+ KeyPairGenerator ecKPGen = KeyPairGenerator.getInstance("EC", "BC");
+ ecKPGen.initialize(namedParamSpec, new SecureRandom());
+ KeyPair keyPair = ecKPGen.generateKeyPair();
+ KeyPair kp = new KeyPair(SecurityUtils.convert(keyPair.getPublic(), provider),SecurityUtils.convert(keyPair.getPrivate(), provider));
+ return kp;
+ }
+
+ public KeyPair generateECDSAKeys(String keyAlgorithmOid, String curve) throws Exception{
+
+ //ECNamedCurveGenParameterSpec namedParamSpec = new ECNamedCurveGenParameterSpec(elipticCurve);
+
+ ECGenParameterSpec namedParamSpec = new ECGenParameterSpec(curve);
+ KeyPairGenerator ecKPGen = KeyPairGenerator.getInstance("ECDSA", "BC");
+ ecKPGen.initialize(namedParamSpec, new SecureRandom());
+ KeyPair keyPair = ecKPGen.generateKeyPair();
+ KeyPair kp = new KeyPair(SecurityUtils.convert(keyPair.getPublic(), provider),SecurityUtils.convert(keyPair.getPrivate(), provider));
+ return kp;
+ }
+
+ private KeyPair generateDsaKeys() {
+
+ KeyPairGenerator g = null;
+ try {
+ g = KeyPairGenerator.getInstance("DSA", "BC");
+ } catch (NoSuchAlgorithmException e) {
+ assert(false);
+ } catch (NoSuchProviderException e) {
+ assert(false);
+ }
+ g.initialize(1024, new SecureRandom());
+
+ KeyPair keyPair = g.generateKeyPair();
+ KeyPair kp = new KeyPair(SecurityUtils.convert(keyPair.getPublic(), provider),SecurityUtils.convert(keyPair.getPrivate(), provider));
+ return kp;
+
+ }
+
+ private boolean testSignature(Provider provider, String signatureAlgorithmOid, PrivateKey privateKey) {
+
+ String sigAlgName = null;
+ try {
+ sigAlgName = AlgorithmNameResolver.getSignatureAlgorithmName(signatureAlgorithmOid,provider);
+ } catch (Exception e) {
+ assert(false);
+ }
+ assert(sigAlgName != null);
+
+
+ Signature sig = null;
+ try {
+ sig = Signature.getInstance(sigAlgName,provider);
+ } catch (Exception e) {
+ assert (false);
+ }
+
+ try {
+ sig.initSign(privateKey);
+ } catch (InvalidKeyException e) {
+ assert(false);
+ }
+ try {
+ sig.update("ABCDEFGHI".getBytes());
+ } catch (SignatureException e) {
+ assert(false);
+ }
+ byte[] signature = null;
+ try {
+ signature = sig.sign();
+ } catch (SignatureException e) {
+ assert(false);
+ }
+
+ assert(signature != null);
+ assert(signature.length > 5);
+
+ return true;
+ }
+
+
+}
diff --git a/src/test/java/org/uic/barcode/test/SignatureSplitTest.java b/src/test/java/org/uic/barcode/test/SignatureSplitTest.java
index 08fe3ad..300515a 100644
--- a/src/test/java/org/uic/barcode/test/SignatureSplitTest.java
+++ b/src/test/java/org/uic/barcode/test/SignatureSplitTest.java
@@ -5,7 +5,9 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.math.BigInteger;
+import org.junit.Before;
import org.junit.Test;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.staticFrame.StaticFrame;
import org.uic.barcode.test.utils.TestUtils;
import org.uic.barcode.ticket.EncodingFormatException;
@@ -27,20 +29,15 @@ public class SignatureSplitTest {
134515671861986
}
-
- Encoding using DER encoding rule
- Signature SEQUENCE OF: tag = [UNIVERSAL 16] constructed; length = 18
- INTEGER: tag = [UNIVERSAL 2] primitive; length = 8
- 340282366920938463
- INTEGER: tag = [UNIVERSAL 2] primitive; length = 6
- 134515671861986
- Encoded successfully in 20 bytes: 30120208 04B8ED02 83A6D3DF 02067A57 5ED68AE2
-
-
*
*
*/
+ @Before public void initialize() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ }
@Test public void testSplitSignature() throws IOException, EncodingFormatException{
diff --git a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java
index 9600191..0aafc3b 100644
--- a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java
+++ b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java
@@ -18,6 +18,7 @@ import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
import org.uic.barcode.test.utils.SimpleTestTicketLayout;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
@@ -53,6 +54,8 @@ public class StaticFrameBarcodeTest {
*/
@Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+
algorithmOID = Constants.DSA_SHA224;
keySize = 2048;
testFCBticket = SimpleUICTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java
index 048d684..0a0c245 100644
--- a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java
+++ b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java
@@ -18,6 +18,7 @@ import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
import org.uic.barcode.test.utils.SimpleTestTicketLayout;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
@@ -52,6 +53,8 @@ public class StaticFrameBarcodeTestFCB2 {
* for ticket and layout
*/
@Before public void initialize() {
+
+ LoggerFactory.setActivateConsoleLog(true);
algorithmOID = Constants.DSA_SHA224;
keySize = 2048;
diff --git a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB3.java b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB3.java
index 41ce365..b519308 100644
--- a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB3.java
+++ b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB3.java
@@ -18,6 +18,7 @@ import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
import org.uic.barcode.test.utils.SimpleTestTicketLayout;
import org.uic.barcode.test.utils.SimpleUICTestTicket;
@@ -52,6 +53,8 @@ public class StaticFrameBarcodeTestFCB3 {
* for ticket and layout
*/
@Before public void initialize() {
+
+ LoggerFactory.setActivateConsoleLog(true);
algorithmOID = Constants.DSA_SHA224;
keySize = 2048;
diff --git a/src/test/java/org/uic/barcode/test/TicketLayoutTest.java b/src/test/java/org/uic/barcode/test/TicketLayoutTest.java
index 3d053e7..69fddbb 100644
--- a/src/test/java/org/uic/barcode/test/TicketLayoutTest.java
+++ b/src/test/java/org/uic/barcode/test/TicketLayoutTest.java
@@ -4,7 +4,9 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
+import org.junit.Before;
import org.junit.Test;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.staticFrame.UTLAYDataRecord;
import org.uic.barcode.staticFrame.ticketLayoutBarcode.LayoutElement;
import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
@@ -15,6 +17,9 @@ import org.uic.barcode.ticket.EncodingFormatException;
public class TicketLayoutTest {
+ @Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testTicketLayout() throws IOException, EncodingFormatException{
diff --git a/src/test/java/org/uic/barcode/test/TimeStampTest.java b/src/test/java/org/uic/barcode/test/TimeStampTest.java
index b2e3ab1..f03a63c 100644
--- a/src/test/java/org/uic/barcode/test/TimeStampTest.java
+++ b/src/test/java/org/uic/barcode/test/TimeStampTest.java
@@ -1,15 +1,23 @@
package org.uic.barcode.test;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.temporal.ChronoField;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.dynamicContent.fdc1.TimeStamp;
+import org.uic.barcode.logger.LoggerFactory;
public class TimeStampTest {
+ @Before public void initialize() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testDateConversion() {
@@ -31,6 +39,51 @@ public class TimeStampTest {
}
-
+ @Test public void testDateConversion2() {
+
+
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ long day = (long) c.get(Calendar.DAY_OF_YEAR);
+ long now = c.getTimeInMillis();
+ c.set(Calendar.HOUR_OF_DAY, 0);
+ c.set(Calendar.MINUTE, 0);
+ c.set(Calendar.SECOND, 0);
+ c.set(Calendar.MILLISECOND, 0);
+ long passed = now - c.getTimeInMillis();
+ long secondOfDay = passed / 1000;
+
+ TimeStamp ts = new TimeStamp();
+ assert (ts.day == day);
+ assert (ts.secondOfDay >= secondOfDay - 1);
+ assert (ts.secondOfDay <= secondOfDay + 1);
+
+
+ }
+
+ @Test public void testDateConversion3() {
+
+ //implemntation not available on older android versions:
+ ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
+ long day = new Long(now.get(ChronoField.DAY_OF_YEAR));
+ long secondOfDay = new Long(now.get(ChronoField.SECOND_OF_DAY));
+
+ //alternative implementation
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ long day2 = (long) c.get(Calendar.DAY_OF_YEAR);
+ long now2 = c.getTimeInMillis();
+ c.set(Calendar.HOUR_OF_DAY, 0);
+ c.set(Calendar.MINUTE, 0);
+ c.set(Calendar.SECOND, 0);
+ c.set(Calendar.MILLISECOND, 0);
+ long passed = now2 - c.getTimeInMillis();
+ long secondOfDay2 = passed / 1000;
+
+
+ assert (day2 == day);
+ assert (secondOfDay2 >= secondOfDay - 1);
+ assert (secondOfDay2 <= secondOfDay + 1);
+
+
+ }
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV1.java
new file mode 100644
index 0000000..216ef77
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV1.java
@@ -0,0 +1,1094 @@
+package org.uic.barcode.ticket.api.test;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv1.ConfirmationTypeType;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IBerth;
+import org.uic.barcode.ticket.api.spec.IBerthTypeType;
+import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
+import org.uic.barcode.ticket.api.spec.ICardReference;
+import org.uic.barcode.ticket.api.spec.ICompartmentGenderType;
+import org.uic.barcode.ticket.api.spec.ICompartmentPositionType;
+import org.uic.barcode.ticket.api.spec.ICounterMark;
+import org.uic.barcode.ticket.api.spec.ICustomerCard;
+import org.uic.barcode.ticket.api.spec.ICustomerStatusDescription;
+import org.uic.barcode.ticket.api.spec.IDelayConfirmation;
+import org.uic.barcode.ticket.api.spec.IDocumentData;
+import org.uic.barcode.ticket.api.spec.IDocumentExtension;
+import org.uic.barcode.ticket.api.spec.IExtension;
+import org.uic.barcode.ticket.api.spec.IFipTicket;
+import org.uic.barcode.ticket.api.spec.IGenderType;
+import org.uic.barcode.ticket.api.spec.IGeoCoordinateSystemType;
+import org.uic.barcode.ticket.api.spec.IGeoUnitType;
+import org.uic.barcode.ticket.api.spec.IHemisphereLatitudeType;
+import org.uic.barcode.ticket.api.spec.IHemisphereLongitudeType;
+import org.uic.barcode.ticket.api.spec.IIncludedOpenTicket;
+import org.uic.barcode.ticket.api.spec.ILine;
+import org.uic.barcode.ticket.api.spec.ILinkMode;
+import org.uic.barcode.ticket.api.spec.ILoadingDeckType;
+import org.uic.barcode.ticket.api.spec.IOpenTicket;
+import org.uic.barcode.ticket.api.spec.IParkingGround;
+import org.uic.barcode.ticket.api.spec.IPass;
+import org.uic.barcode.ticket.api.spec.IPassengerType;
+import org.uic.barcode.ticket.api.spec.IPolygone;
+import org.uic.barcode.ticket.api.spec.IPriceTypeType;
+import org.uic.barcode.ticket.api.spec.IRegionalValidity;
+import org.uic.barcode.ticket.api.spec.IRegisteredLuggage;
+import org.uic.barcode.ticket.api.spec.IReservation;
+import org.uic.barcode.ticket.api.spec.IRoofRackType;
+import org.uic.barcode.ticket.api.spec.IServiceType;
+import org.uic.barcode.ticket.api.spec.IStationCodeTable;
+import org.uic.barcode.ticket.api.spec.IStationPassage;
+import org.uic.barcode.ticket.api.spec.ITariff;
+import org.uic.barcode.ticket.api.spec.ITicketLink;
+import org.uic.barcode.ticket.api.spec.ITicketType;
+import org.uic.barcode.ticket.api.spec.ITimeRange;
+import org.uic.barcode.ticket.api.spec.ITrainLink;
+import org.uic.barcode.ticket.api.spec.ITravelClassType;
+import org.uic.barcode.ticket.api.spec.ITraveler;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.spec.IValidityRange;
+import org.uic.barcode.ticket.api.spec.IVatDetail;
+import org.uic.barcode.ticket.api.spec.IViaStation;
+import org.uic.barcode.ticket.api.spec.IVoucher;
+import org.uic.barcode.ticket.api.spec.IZone;
+import org.uic.barcode.ticket.api.test.testtickets.AllElementsTestTicketV1;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoder;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
+
+
+/**
+ * The Class CarCarriageTestV1.
+ *
+ *
+ *
+ */
+public class AllElementsTestV1 {
+
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoder();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoder();
+
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testDelayConfirmation() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+
+ defaulttimeZone = TimeZone.getDefault();
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ IUicRailTicket ticketDecoded = null;
+ try {
+
+ UicRailTicketData rtd = AllElementsTestTicketV1.getUicTestTicket();
+ byte[] content = UperEncoder.encode(rtd);
+ ticketDecoded = decoder.decodeFromAsn(content);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+
+
+
+ byte[] encoded = null;
+ try {
+ encoded = encoder.encode(ticketDecoded);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ }
+
+ //decode ticket again
+ IUicRailTicket ticketDecoded2 = null;
+ try {
+ ticketDecoded2 = decoder.decodeFromAsn(encoded);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert (ticketDecoded2 != null);
+
+ //validate content
+ validateTicketContent(ticketDecoded2);
+
+
+
+
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+
+
+
+
+ private void validateTicketContent(IUicRailTicket ticket) {
+ assert (ticket != null);
+
+ assert(ticket.getControlDetails() != null);
+ assert(ticket.getControlDetails().isAgeCheckRequired() == false);
+ assert(ticket.getControlDetails().isIdentificationByPassportId() == false);
+ assert(ticket.getControlDetails().isIdentificationByIdCard() == false);
+ assert(ticket.getControlDetails().isOnlineValidationRequired() == false);
+ assert(ticket.getControlDetails().getIdentificationItem() == 12);
+ assert(ticket.getControlDetails().isPassportValidationRequired() == false);
+ assert(ticket.getControlDetails().getRandomDetailedValidationRequired() == 50);
+ assert(ticket.getControlDetails().getExtension() != null);
+ assert(ticket.getControlDetails().isReductionCardCheckRequired() == false);
+ assert(ticket.getControlDetails().getInfoText().equals("control"));
+ assert(ticket.getControlDetails().getIdentificationByCardReference() != null);
+
+ assert(ticket.getControlDetails().getIdentificationByCardReference().size() == 1);
+ ICardReference cr = ticket.getControlDetails().getIdentificationByCardReference().iterator().next();
+ assert(cr != null);
+ assert(cr.getCardId().equals("5678"));
+ assert(cr.getCardIssuer().equals("1234"));
+ assert(cr.getCardName().equals("testcard"));
+ assert(cr.getCardType() == 123);
+ assert(cr.getLeadingCardId().equals("3456"));
+ assert(cr.getTrailingCardId().equals("100"));
+
+
+ assert(ticket.getControlDetails().getLinkedTickets() != null);
+
+ ITicketLink tl = ticket.getControlDetails().getLinkedTickets().iterator().next();
+
+ assert(tl.getIssuer().equals("XYZ"));
+ assert(tl.getIssuerPNR().equals("LDWDUR45"));
+ assert(tl.getProductOwner().equals("IEFHU"));
+ assert(tl.getLinkMode().equals(ILinkMode.issuedTogether));
+ assert(tl.getReference().equals("KDJET"));
+ assert(tl.getTicketType().equals(ITicketType.openTicket));
+
+ assert(ticket.getExtensions() != null);
+ assert(ticket.getExtensions().size() == 2);
+ Iterator<IExtension> it = ticket.getExtensions().iterator();
+ IExtension e0 = it.next();
+ IExtension e1 = it.next();
+ assert(e0.getId().equals("1"));
+ assert(UperEncoder.hexStringFromBytes(e0.getBinarydata()).equals("82DA"));
+ assert(e1.getId().equals("2"));
+ assert(UperEncoder.hexStringFromBytes(e1.getBinarydata()).equals("83DA"));
+
+
+ assert(ticket.getIssuerDetails() != null);
+
+ assert(ticket.getIssuerDetails().isActivated() == true);
+ assert(ticket.getIssuerDetails().getCurrency().equals("SRF"));
+ assert(ticket.getIssuerDetails().getCurrencyFraction() == 3L);
+ assert(ticket.getIssuerDetails().getExtension() != null);
+ assert(ticket.getIssuerDetails().getIssuedOnLine() == 12);
+ assert(ticket.getIssuerDetails().getIssuedOnTrain().equals("123"));
+ assert(ticket.getIssuerDetails().getIssuerName().equals("name"));
+ assert(ticket.getIssuerDetails().getIssuer().equals("1"));
+ assert(ticket.getIssuerDetails().getIssuerPNR().equals("issuerTestPNR"));
+ assert(ticket.getIssuerDetails().getIssuingDate() != null);
+ assert(ticket.getIssuerDetails().isSecurePaperTicket() == false);
+ assert(ticket.getIssuerDetails().getSecurityProvider().equals("1"));
+ assert(ticket.getIssuerDetails().isSpecimen() == true);
+ assert(ticket.getIssuerDetails().getPointOfSale() != null);
+ assert(ticket.getIssuerDetails().getPointOfSale().getUnit().equals(IGeoUnitType.microDegree));
+ assert(ticket.getIssuerDetails().getPointOfSale().getSystem().equals(IGeoCoordinateSystemType.wgs84));
+ assert(ticket.getIssuerDetails().getPointOfSale().getAccuracy().equals(IGeoUnitType.microDegree));
+ assert(ticket.getIssuerDetails().getPointOfSale().getHemisphereLatitude().equals(IHemisphereLatitudeType.east));
+ assert(ticket.getIssuerDetails().getPointOfSale().getHemisphereLongitude().equals(IHemisphereLongitudeType.north));
+ assert(ticket.getIssuerDetails().getPointOfSale().getLatitude() == 269);
+ assert(ticket.getIssuerDetails().getPointOfSale().getLongitude() == 105);
+
+ assert(ticket.getDocumentData() != null);
+ assert(!ticket.getDocumentData().isEmpty());
+
+ Iterator<IDocumentData> i2 = ticket.getDocumentData().iterator();
+
+ int numberOfDocuments = 0;
+ while (i2.hasNext()) {
+ numberOfDocuments++;
+ IDocumentData d1 = i2.next();
+ if (d1 instanceof IReservation) {
+ validate((IReservation) d1);
+ } else if (d1 instanceof ICarCarriageReservation) {
+ validate((ICarCarriageReservation) d1);
+ } else if (d1 instanceof IPass) {
+ validate((IPass) d1);
+ } else if (d1 instanceof IOpenTicket) {
+ validate((IOpenTicket) d1);
+ } else if (d1 instanceof ICounterMark) {
+ validate((ICounterMark) d1);
+ } else if (d1 instanceof IStationPassage) {
+ validate((IStationPassage) d1);
+ } else if (d1 instanceof ICustomerCard) {
+ validate((ICustomerCard) d1);
+ } else if (d1 instanceof IDelayConfirmation) {
+ validate((IDelayConfirmation) d1);
+ } else if (d1 instanceof IParkingGround) {
+ validate((IParkingGround) d1);
+ } else if (d1 instanceof IFipTicket) {
+ validate((IFipTicket) d1);
+ } else if (d1 instanceof IVoucher) {
+ validate((IVoucher) d1);
+ } else if (d1 instanceof IDocumentExtension) {
+ assert(((IDocumentExtension) d1).getId() != null);
+ }
+ }
+ assert(numberOfDocuments == 11);
+
+
+ assert(ticket.getTravelerDetails() != null);
+ assert(ticket.getTravelerDetails().getGroupName().equals("myGroup"));
+ assert(ticket.getTravelerDetails().getPreferredLanguage().equals("EN"));
+ assert(ticket.getTravelerDetails().getTravelers() != null);
+ assert(ticket.getTravelerDetails().getTravelers().size() == 1);
+
+ ITraveler tr = ticket.getTravelerDetails().getTravelers().iterator().next();
+
+ assert(tr.getIDCardCountry() == 103);
+ assert(tr.getPassportCountry() == 102);
+ assert(tr.getCountryOfResidence() == 101);
+ assert(tr.getCustomerId().equals("DZE5gT"));
+ assert(tr.getDateOfBirth() != null);
+ assert(tr.getFirstName().equals("John"));
+ assert(tr.getGender().equals(IGenderType.male));
+ assert(tr.getIdCard().equals("12345"));
+ assert(tr.getLastName().equals("Dow"));
+ assert(tr.getPassengerType().equals(IPassengerType.senior));
+ assert(tr.isPassengerWithReducedMobility() == false);
+ assert(tr.getPassportId().equals("JDTS"));
+ assert(tr.getSecondName().equals("Little"));
+ assert(tr.getTitle().equals("PhD"));
+ assert(tr.isTicketHolder() == true);
+ assert(tr.getStatusCollection() != null);
+ assert(tr.getStatusCollection().size() == 1);
+ ICustomerStatusDescription csd = tr.getStatusCollection().iterator().next();
+ assert(csd.getStatus() == 1);
+ assert(csd.getDescription().equals("senior"));
+
+ }
+
+
+ private void validate(ICounterMark t) {
+
+ assert(t != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals( "23456"));
+ assert(t.getProductId().equals( "23456"));
+ assert(t.getTicketReference().equals( "810123456789"));
+ assert(t.getNumberOfCountermark() == 12L);
+ assert(t.getTotalOfCountermarks() == 24L);
+ assert(t.getGroupName().equals( "groupName"));
+ assert(t.isReturnIncluded() == false);
+
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getFromStation().equals("8100001"));
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ assert(t.getValidRegionDesc().equals("From A to B via C"));
+
+ assert(t.getValidRegionList() != null);
+ assert(t.getValidRegionList().size() == 1);
+
+
+ assert(t.getReturnDescription() != null);
+ assert(t.getReturnDescription().getFromStation().equals("8100001"));
+ assert(t.getReturnDescription().getToStation().equals( "8100002"));
+ assert(t.getReturnDescription().getFromStationName().equals( "A-STATION"));
+ assert(t.getReturnDescription().getToStationName().equals( "B-STATION"));
+ assert(t.getReturnDescription().getValidRegionDesc().equals( "return"));
+ assert(t.getReturnDescription().getValidRegionList() != null);
+ assert(t.getReturnDescription().getValidRegionList().size() == 1);
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+
+ assert(t.getClassCode().equals(ITravelClassType.first));
+
+ assert(t.getIncludedCarriers() != null);
+ assert(t.getIncludedCarriers().size() == 2);
+ assert(t.getIncludedCarriers().contains("1080"));
+ assert(t.getIncludedCarriers().contains("1181"));
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ assert (t.getInfoText().equals("counterMark"));
+
+ assert(t.getExtension() != null);
+
+
+ }
+
+ private void validate(IDelayConfirmation t) {
+ assert(t != null);
+
+ assert(t.getTrain().equals("100"));
+ assert(t.getArrivalDate() != null);
+ assert(t.getReference().equals("ABDJ12345"));
+ assert(t.getStation().equals("DJE"));
+ assert(t.getDelay() == 31);
+ assert(t.isTrainCancelled() == false);
+ assert(t.getConfirmationType() == ConfirmationTypeType.travelerDelayConfirmation.ordinal());
+ assert(t.getLinkedTickets() != null);
+ assert(t.getLinkedTickets().size() == 1);
+ ITicketLink tl = t.getLinkedTickets().iterator().next();
+ assert(tl.getReference().equals("KDJET"));
+ assert(tl.getIssuer().equals( "XYZ"));
+ assert(tl.getIssuerPNR().equals( "LDWDUR45"));
+ assert(tl.getProductOwner().equals( "IEFHU"));
+ assert(tl.getTicketType().equals(ITicketType.openTicket));
+ assert(tl.getLinkMode().equals( ILinkMode.issuedTogether));
+
+ assert(t.getInfoText().equals( "delay confirmation"));
+ assert(t.getExtension() != null);
+
+ }
+
+ private void validate(ICustomerCard c) {
+ assert(c != null);
+ assert (c.getExtension() != null);
+ assert (c.getCustomer() != null);
+ assert (c.getCustomer() != null);
+
+ assert (c.getCardId().equals("2345"));
+ assert (c.getValidFrom() != null);
+ assert (c.getValidUntil() != null);
+ assert (c.getClassCode().equals(ITravelClassType.second));
+ assert (c.getCardType() == 15);
+ assert (c.getCardTypeDescr().equals( "RAILPLUS"));
+ assert (c.getCustomerStatus() == 1);
+ assert (c.getCustomerStatusDescr().equals( "gold"));
+ assert (c.getIncludedServices() != null);
+ assert (c.getIncludedServices().size() == 2);
+ Iterator<Integer> i3 = c.getIncludedServices().iterator();
+ assert(i3.next() == 1);
+ assert(i3.next() == 2);
+
+ }
+
+ private void validate(IVoucher v) {
+ assert(v != null);
+ assert (v.getExtension() != null);
+
+ assert(v.getReference().equals("810123456789"));
+ assert(v.getProductOwner().equals("COFFEEMACHINE"));
+ assert(v.getProductId().equals("23456"));
+
+ assert(v.getValidFrom() != null);
+ assert(v.getValidUntil() != null);
+ assert(v.getAmount() == 500);
+ assert(v.getType() == 123);
+ assert(v.getInfoText().equals("coffee voucher"));
+
+ }
+
+ private void validate(IStationPassage t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("23456"));
+
+ assert(t.getProductName().equals("passage"));
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(t.getStations() != null);
+ assert(t.getStations().size() == 2);
+ assert(t.getStations().contains("8200001"));
+ assert(t.getStations().contains("AMS"));
+ assert(t.getStationNames() != null);
+ assert(t.getStationNames().size() == 1);
+ assert(t.getStationNames().iterator().next().equals("Amsterdam"));
+ assert(t.getAreaCodes() != null);
+ assert(t.getAreaCodes().size() == 2);
+ assert(t.getAreaCodes().contains("AMS"));
+ assert(t.getAreaCodes().contains("8200001"));
+ assert(t.getAreaNames() != null);
+ assert(t.getAreaNames().size() == 1);
+ assert(t.getAreaNames().contains("Amsterdam"));
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+ assert(t.getNumberOfdaysAllowed() == 5);
+
+ }
+
+ private void validate(IParkingGround t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("23456"));
+
+
+ assert(t.getParkingGroundId().equals( "IA5"));
+ assert(t.getFromParkingDate() != null);
+ assert(t.getToParkingDate() != null);
+
+
+ assert(t.getAccessCode().equals( "4ga"));
+ assert(t.getLocation().equals( "Parking Frankfurt Main West"));
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(t.getStation().equals( "8000001"));
+ assert(t.getSpecialInformation().equals( "outdoor parking"));
+ assert(t.getEntryTrack().equals( "left"));
+ assert(t.getNumberPlate().equals( "AA-DE-12345"));
+ assert(t.getPrice() == 500);
+ assert(t.getVatDetails() != null);
+ assert(t.getVatDetails().size() == 1);
+
+
+ }
+
+ private void validate(IFipTicket t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("23456"));
+
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+ assert(t.getActivatedDays() != null);
+ assert(t.getActivatedDays().size() == 4);
+ Iterator<Date> i5 = t.getActivatedDays().iterator();
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+
+
+
+ assert(t.getCarriers()!= null);
+ assert(t.getCarriers().size() == 2);
+ assert(t.getCarriers().contains("1080"));
+ assert(t.getCarriers().contains("1181"));
+
+
+ assert(t.getNumberOfTravelDates() == 8);
+ assert(t.isIncludesSupplements() == true);
+ assert(t.getClassCode().equals(ITravelClassType.first));
+
+ }
+
+ private void validate(IOpenTicket t) {
+
+ assert (t != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals( "23456"));
+ assert(t.getProductId().equals( "23456"));
+ assert(t.getExternalIssuer() == 12);
+ assert(t.getAuthorizationCode() == 13);
+ assert(t.isReturnIncluded() == false);
+
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getFromStation().equals("8100001"));
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ assert(t.getValidRegionDesc().equals("From A to B via C"));
+
+ assert (t.getValidRegionList() != null);
+ assert(t.getValidRegionList().size() == 5);
+ Iterator<IRegionalValidity> irv = t.getValidRegionList().iterator();
+ int checks = 0;
+ while (irv.hasNext()) {
+ IRegionalValidity v = irv.next();
+ if (v instanceof IZone) {
+ validateRegion((IZone) v);
+ checks++;
+ } else if (v instanceof IViaStation) {
+ validateRegion((IViaStation) v);
+ checks++;
+ } else if (v instanceof ITrainLink) {
+ validateRegion((ITrainLink) v);
+ checks++;
+ } else if (v instanceof IPolygone) {
+ validateRegion((IPolygone) v);
+ checks++;
+ } else if (v instanceof ILine) {
+ validateRegion((ILine) v);
+ checks++;
+ }
+ }
+ assert(checks == 5);
+
+ assert(t.getReturnDescription() != null);
+
+ assert(t.getReturnDescription().getFromStation().equals("8100001"));
+ assert(t.getReturnDescription().getToStation().equals( "8100002"));
+ assert(t.getReturnDescription().getFromStationName().equals( "A-STATION"));
+ assert(t.getReturnDescription().getToStationName().equals( "B-STATION"));
+ assert(t.getReturnDescription().getValidRegionDesc().equals( "return"));
+ assert(t.getReturnDescription().getValidRegionList() != null);
+ assert(t.getReturnDescription().getValidRegionList().size() == 1);
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+
+ assert(t.getActivatedDays() != null);
+ assert(t.getActivatedDays().size() == 2);
+
+ assert(t.getClassCode().equals(ITravelClassType.first));
+ assert(t.getServiceLevel().equals("A"));
+
+ assert(t.getIncludedCarriers() != null);
+ assert(t.getIncludedCarriers().size() == 2);
+ assert(t.getIncludedCarriers().contains("1080"));
+ assert(t.getIncludedCarriers().contains("1181"));
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ assert(t.getTariffs() != null);
+ assert(t.getTariffs().size() == 1);
+
+ assert (t.getPrice() == 12345);
+ assert (t.getVatDetails() != null);
+ assert (t.getVatDetails().size() == 1);
+
+ assert (t.getInfoText().equals("openTicketInfo"));
+
+ assert (t.getIncludedAddOns() != null);
+ assert (t.getIncludedAddOns().size() == 1);
+ validate(t.getIncludedAddOns().iterator().next());
+
+ assert(t.getLuggageRestriction() != null);
+
+
+ assert(t.getExtension() != null);
+
+ }
+
+ private void validateRegion(ITrainLink t) {
+
+ assert (t != null);
+
+ assert(t.getTrain().equals("12345"));
+ assert(t.getDepartureDateTime() != null);
+ assert(t.getFromStation().equals("8100001"));
+
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ }
+
+ private void validateRegion(IPolygone p) {
+
+ assert(p.getEdges() != null);
+ assert(p.getEdges().size() == 3);
+
+ }
+
+ private void validateRegion(IZone z) {
+
+ assert(z != null);
+
+ assert(z.getCarrier().equals("1080"));
+ assert(z.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(z.getEntryStation().equals( "1234"));
+ assert(z.getTerminatingStation().equals( "2345"));
+ assert(z.getCity() == 123456);
+ assert(z.getZoneIds() != null);
+ assert(z.getZoneIds().size() == 2);
+ Iterator<Integer> iz = z.getZoneIds().iterator();
+ assert(iz.next() == 100);
+ assert(iz.next() == 200);
+
+ assert(UperEncoder.hexStringFromBytes(z.getBinaryZoneId()).equals("82DA"));
+ assert(z.getNUTScode().equals("DE4711"));
+
+ }
+
+ private void validateRegion(ILine z) {
+
+
+ assert(z.getCarrier().equals("1080"));
+ assert(z.getStationCodeTable().equals(IStationCodeTable.stationERA));
+
+ assert(z.getEntryStation().equals( "1234"));
+
+ assert(z.getTerminatingStation().equals( "2345"));
+ assert(z.getCity() == 123456);
+ assert(z.getLineIds() != null);
+ assert(z.getLineIds().size() == 2);
+ Iterator<Integer> iz = z.getLineIds().iterator();
+ assert(iz.next() == 100);
+ assert(iz.next() == 200);
+
+
+ }
+
+ private void validateRegion(IViaStation t) {
+
+ assert( t != null);
+
+ assert(t.getRoute() != null);
+
+ assert(t.getRoute().size() == 4);
+
+ Iterator<IViaStation> iv = t.getRoute().iterator();
+ IViaStation v1 = iv.next();
+ IViaStation v2 = iv.next();
+ IViaStation v3 = iv.next();
+ IViaStation v4 = iv.next();
+
+ assert(v1.getStation().equals("123455"));
+ assert(v1.isBorder() == false);
+
+ assert(v2.getStation().equals("123456"));
+ assert(v2.isBorder() == false);
+
+ assert(v3.getAlternativeRoutes() != null);
+ assert(v3.getAlternativeRoutes().size() == 2);
+ Iterator<IViaStation> ari = v3.getAlternativeRoutes().iterator();
+ IViaStation ar1 = ari.next();
+ IViaStation ar2 = ari.next();
+ assert(ar1.getRoute().size() == 2);
+ assert(ar1.getRoute().iterator().next().getStation().equals("23455"));
+ assert(ar2.getRoute() != null);
+ assert(ar2.getRoute().size() == 2);
+ assert(ar2.getRoute().iterator().next().getStation().equals("3455"));
+
+ assert(v4.getStation().equals("123457"));
+
+ assert(t.isBorder() == false);
+
+ assert(t.getSeriesId() == 999);
+ assert(t.getRouteId() == 21);
+
+
+ }
+
+ private void validate(IIncludedOpenTicket d1) {
+
+ assert(d1.getProductOwner().equals("23456"));
+ assert(d1.getProductId().equals("23456"));
+ assert(d1.getExternalIssuer() == 12);
+ assert(d1.getAuthorizationCode() == 13);
+ assert(d1.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(d1.getValidRegionList() != null);
+ assert(d1.getValidRegionList().size() == 1);
+ assert(d1.getValidFrom() != null);
+ assert(d1.getValidUntil() != null);
+ assert(d1.getClassCode().equals(ITravelClassType.second));
+ assert(d1.getServiceLevel().equals("A"));
+
+ assert(d1.getIncludedCarriers() != null);
+ assert(d1.getIncludedCarriers().size() == 2);
+ assert(d1.getIncludedCarriers().contains("1080"));
+ assert(d1.getIncludedCarriers().contains("1181"));
+
+ assert(d1.getIncludedServiceBrands() != null);
+ assert(d1.getIncludedServiceBrands().size() == 2);
+ assert(d1.getIncludedServiceBrands().contains(108));
+ assert(d1.getIncludedServiceBrands().contains(118));
+
+
+ assert(d1.getExcludedServiceBrands() != null);
+ assert(d1.getExcludedServiceBrands().size() == 2);
+ assert(d1.getExcludedServiceBrands().contains(108));
+ assert(d1.getExcludedServiceBrands().contains(118));
+
+
+ assert(d1.getTariffs() != null);
+ assert(d1.getTariffs().size() == 1);
+
+ assert(d1.getInfoText().equals("included ticket"));
+
+ assert(d1.getExtension() != null);
+
+
+
+ }
+
+ private void validate(IPass p) {
+
+
+ assert(p.getReference().equals("810123456789"));
+ assert(p.getProductOwner().equals( "23456"));
+ assert(p.getProductId().equals( "23456"));
+ assert(p.getPassType() == 2);
+ assert(p.getPassDescription().equals( "Eurail FlexPass"));
+ assert(p.getClassCode().equals(ITravelClassType.first));
+ assert(p.getValidFrom() != null);
+ assert(p.getValidUntil() != null);
+ assert(p.getValidityDetails() != null);
+
+ assert(p.getValidityDetails() != null);
+ assert(p.getValidityDetails().getValidityRanges().size() == 1);
+ IValidityRange vr = p.getValidityDetails().getValidityRanges().iterator().next();
+ assert(vr.getFromDate() != null);
+ assert(vr.getUntilDate() != null);
+
+ assert(p.getValidityDetails().getTimeRanges() != null);
+ ITimeRange tr = p.getValidityDetails().getTimeRanges().iterator().next();
+ assert(tr.getFromTime() == 6);
+ assert(tr.getUntilTime() == 9);
+
+ assert(p.getNumberOfValidityDays() == 5);
+
+ assert(p.getNumberOfPossibleTrips() == 3);
+ assert(p.getNumberOfDaysOfTravel() == 10);
+ assert(p.getActivatedDays() != null);
+ assert(p.getActivatedDays().size() == 2);
+
+
+ assert(p.getCountries() != null);
+ assert(p.getCountries().size() == 2);
+ Iterator<Integer> i6 = p.getCountries().iterator();
+ assert(i6.next() == 10);
+ assert(i6.next() == 20);
+
+ assert(p.getIncludedCarriers() != null);
+ assert(p.getIncludedCarriers().size() == 2);
+ assert(p.getIncludedCarriers().contains("1080"));
+ assert(p.getIncludedCarriers().contains("1181"));
+
+ assert(p.getIncludedServiceBrands() != null);
+ assert(p.getIncludedServiceBrands().size() == 2);
+ assert(p.getIncludedServiceBrands().contains(108));
+ assert(p.getIncludedServiceBrands().contains(118));
+
+
+ assert(p.getExcludedServiceBrands() != null);
+ assert(p.getExcludedServiceBrands().size() == 2);
+ assert(p.getExcludedServiceBrands().contains(108));
+ assert(p.getExcludedServiceBrands().contains(118));
+
+
+
+ assert(p.getExcludedCarriers() != null);
+ assert(p.getExcludedCarriers().size() == 2);
+ assert(p.getExcludedCarriers().contains("1080"));
+ assert(p.getExcludedCarriers().contains("1181"));
+
+
+
+
+
+ assert(p.getValidRegionList() != null);
+ assert(p.getValidRegionList().size() == 1);
+ assert(p.getTariffs() != null);
+ assert(p.getTariffs().size() == 1);
+ assert(p.getPrice() == 10000);
+ assert(p.getVatDetails() != null);
+ assert(p.getVatDetails().size() == 1);
+ assert(p.getInfoText().equals("pass info"));
+ assert (p.getExtension() != null);
+
+
+ }
+
+ private void validate(IReservation r) {
+
+ assert(r.getTrain().equals("12345"));
+ assert(r.getDepartureDate() != null);
+ assert(r.getReference().equals("810123456789"));
+ assert(r.getProductOwner().equals("23456"));
+
+ assert(r.getProductId().equals("23456"));
+ assert(r.getServiceBrand().getServiceBrand() == 12);
+ assert(r.getServiceBrand().getServiceBrandAbbreviation().equals("TGV"));
+ assert(r.getServiceBrand().getServiceBrandDescription().equals("Lyria"));
+ assert(r.getService().equals(IServiceType.couchette));
+
+ assert(r.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(r.getFromStation().equals("8100001"));
+ assert(r.getToStation().equals( "8100002"));
+ assert(r.getFromStationName().equals( "A-STATION"));
+ assert(r.getToStationName().equals( "B-STATION"));
+ assert(r.getDepartureDate() != null);
+ assert(r.getArrivalDate() != null);
+ assert(r.getCarriers()!= null);
+ assert(r.getCarriers().size() == 2);
+ Iterator<String> i8 = r.getCarriers().iterator();
+ assert(i8.next().equals("1080"));
+ assert(i8.next().equals("1181"));
+
+
+ assert(r.getClassCode().equals(ITravelClassType.first));
+ assert(r.getServiceLevel().equals("A"));
+
+ assert(r.getPlaces() != null);
+ assert(r.getPlaces().getCoach().equals("31A"));
+ assert(r.getPlaces().getPlaceString().equals("31-47"));
+ assert(r.getPlaces().getPlaceDescription().equals("Window"));
+ assert(r.getPlaces().getPlaces() != null);
+ assert(r.getPlaces().getPlaces().size() == 4);
+ Iterator<String> is = r.getPlaces().getPlaces().iterator();
+ assert(is.next().equals("31"));
+ assert(is.next().equals("32"));
+
+
+ assert(r.getAdditionalPlaces() != null);
+ assert(r.getBicyclePlaces() != null);
+
+
+ assert(r.getCompartmentDetails() != null);
+ assert(r.getCompartmentDetails().getCoachType() == 1);
+ assert(r.getCompartmentDetails().getCompartmentType() == 99);
+ assert(r.getCompartmentDetails().getSpecialAllocation() == 50);
+ assert(r.getCompartmentDetails().getCoachTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getCompartmentTypeDescr().equals( "xwz"));
+ assert(r.getCompartmentDetails().getSpecialAllocationDescr().equals( "xwz"));
+ assert(r.getCompartmentDetails().getPosition().equals(ICompartmentPositionType.upperLevel));
+
+ assert(r.getNumberOfOverbooked() == 200);
+ assert(r.getBerths() != null);
+ assert(r.getBerths().size() == 1);
+ IBerth b = r.getBerths().iterator().next();
+
+ assert(b.getType().equals(IBerthTypeType.single));
+ assert(b.getGender().equals(ICompartmentGenderType.female));
+ assert(b.getNumberOfBerths() == 999);
+
+
+ assert(r.getTariffs() != null);
+ assert(r.getTariffs().size() == 1);
+ ITariff t = r.getTariffs().iterator().next();
+ assert(t.getNumberOfPassengers() == 1);
+
+
+ assert(t.getPassengerType().equals(IPassengerType.senior) );
+ assert(t.getAgeBelow() == 40);
+ assert(t.getAgeAbove() == 60);
+ assert(t.getTravelerIds() != null);
+ assert(t.getTravelerIds().size() == 1);
+ assert(t.getTravelerIds().iterator().next() == 1);
+
+ assert(t.isRestrictedToCountryOfResidence() == false);
+ assert(t.getRestrictedToRouteSection() != null);
+ assert(t.getRestrictedToRouteSection().getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getRestrictedToRouteSection().getFromStation().equals( "123"));
+ assert(t.getRestrictedToRouteSection().getToStation().equals( "234"));
+ assert(t.getRestrictedToRouteSection().getFromStationName().equals( "A"));
+ assert(t.getRestrictedToRouteSection().getToStationName().equals( "B"));
+
+ assert(t.getSeriesDataDetails() != null);
+ assert(t.getSeriesDataDetails().getSupplyingCarrier() == 2345);
+ assert(t.getSeriesDataDetails().getOfferIdentification() == 99);
+ assert(t.getSeriesDataDetails().getSeries() == 23456);
+
+
+ assert(t.getTariffId().equals( "72"));
+ assert(t.getTariffDescription().equals( "Leasure Fare"));
+ assert(t.getReductionCards() != null);
+ assert(t.getReductionCards().size() == 1);
+ ICardReference rc = t.getReductionCards().iterator().next();
+
+ assert(rc.getCardIssuer().equals( "1234"));
+ assert(rc.getCardId().equals( "5678"));
+ assert(rc.getCardName().equals( "testcard"));
+ assert(rc.getCardType() == 123);
+ assert(rc.getLeadingCardId().equals("3456"));
+ assert(rc.getTrailingCardId().equals("100"));
+
+
+ assert(r.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(r.getPrice() == 12345);
+ assert(r.getVatDetails() != null);
+ IVatDetail v = r.getVatDetails().iterator().next();
+ assert(r.getVatDetails().size() == 1);
+ assert(v.getCountry() == 80);
+ assert(v.getPercentage() == 70);
+ assert(v.getAmount() == 10);
+ assert(v.getVatId().equals("IUDGTE"));
+
+ assert(r.getTypeOfSupplement() == 9);
+ assert(r.getNumberOfSupplements() == 2);
+ assert(r.getLuggageRestriction() != null);
+
+ assert(r.getLuggageRestriction().getMaxHandLuggagePieces() == 2);
+ assert(r.getLuggageRestriction().getMaxNonHandLuggagePieces() == 1);
+ assert(r.getLuggageRestriction().getRegisteredLuggage() != null);
+ assert(r.getLuggageRestriction().getRegisteredLuggage().size() == 2);
+
+
+ Iterator<IRegisteredLuggage> il = r.getLuggageRestriction().getRegisteredLuggage().iterator();
+ IRegisteredLuggage rl1 = null;
+ IRegisteredLuggage rl2 = null;
+ while (il.hasNext()) {
+ IRegisteredLuggage l = il.next();
+ if (l.getRegistrationId().equals("IODHUV")) {
+ rl1 = l;
+ } else {
+ rl2 = l;
+ }
+ }
+ assert(rl1.getRegistrationId().equals("IODHUV"));
+ assert(rl1.getMaxWeight() == 20);
+ assert(rl1.getMaxSize() == 100);
+ assert(rl2.getRegistrationId().equals("XXDHUV"));
+ assert(rl2.getMaxWeight() == 21);
+ assert(rl2.getMaxSize() == 101);
+ assert(r.getInfoText().equals("reservation"));
+ assert(r.getExtension() != null);
+
+ }
+
+
+ private void validate(ICarCarriageReservation r) {
+
+
+ assert(r.getToken() != null);
+ assert(UperEncoder.hexStringFromBytes(r.getToken().getToken()).equals("82DA"));
+ assert(r.getToken().getTokenProvider().equals("VDV"));
+ assert(r.getToken().getTokenSpecification().equals("TEST"));
+
+
+ assert(r.getTrain().equals("123"));
+ assert(r.getReference().equals("810123456789"));
+ assert(r.getProductOwner().equals("23456"));
+ assert(r.getProductId().equals("23456"));
+ assert(r.getServiceBrand().getServiceBrand() == 100);
+ assert(r.getServiceBrand().getServiceBrandAbbreviation().equals("AZ"));
+ assert(r.getServiceBrand().getServiceBrandDescription().equals("special train"));
+
+ assert(r.getBeginLoading() != null);
+ assert(r.getEndLoading() != null);
+
+ assert(r.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(r.getFromStation().equals("8100001"));
+ assert(r.getToStation().equals( "8100002"));
+ assert(r.getFromStationName().equals( "A-STATION"));
+ assert(r.getToStationName().equals( "B-STATION"));
+
+ assert(r.getCoach().equals("21"));
+ assert(r.getPlace().equals("41"));
+ assert(r.getCompartmentDetails() != null);
+
+ assert(r.getCompartmentDetails().getCoachType() == 1L);
+ assert(r.getCompartmentDetails().getCompartmentType() == 99L);
+ assert(r.getCompartmentDetails().getSpecialAllocation() == 50L);
+ assert(r.getCompartmentDetails().getCoachTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getCompartmentTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getSpecialAllocationDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getPosition().equals(ICompartmentPositionType.upperLevel));
+
+ assert(r.getNumberPlate().equals( "AD-DE-123"));
+ assert(r.getTrailerPlate().equals( "DX-AB-123"));
+ assert(r.getCarCategory() == 3L);
+ assert(r.getBoatCategory() == 5L);
+ assert(r.isTextileRoof() == false);
+ assert(r.getRoofRackType().equals(IRoofRackType.bicycleRack));
+ assert(r.getRoofRackHeight() == 20L);
+ assert(r.getAttachedBoats() == 2L);
+ assert(r.getAttachedBicycles() == 1L);
+ assert(r.getAttachedSurfboards() == 2L);
+ assert(r.getLoadingListEntry() == 421L);
+ assert(r.getLoadingDeck().equals(ILoadingDeckType.upper));
+
+ assert(r.getCarriers()!= null);
+ assert(r.getCarriers().size() == 2);
+ Iterator<String> i9 = r.getCarriers().iterator();
+ assert(i9.next().equals("1080"));
+ assert(i9.next().equals("1181"));
+
+ assert(r.getTariff() != null);
+ assert(r.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(r.getPrice() == 12345L);
+
+ assert(r.getVatDetails() != null);
+
+ assert(r.getInfoText().equals("car carriage"));
+ assert(r.getExtension() != null);
+
+ }
+
+ public static int getIndexOfDifference(String s1, String s2) {
+
+ if (s1 == null || s2 == null) return -1;
+
+ char[] ca1 = null;
+ char[] ca2 = null;
+
+ if (s1.length() > s2.length()) {
+ ca1 = s1.toCharArray();
+ ca2 = s2.toCharArray();
+ } else {
+ ca1 = s2.toCharArray();
+ ca2 = s1.toCharArray();
+ }
+
+ int i = 0;
+ for (char c : ca2) {
+ if (c != ca1[i]) return i;
+ i++;
+ }
+ return 0;
+ }
+
+
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java
new file mode 100644
index 0000000..5719f48
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AllElementsTestV3.java
@@ -0,0 +1,1140 @@
+package org.uic.barcode.ticket.api.test;
+
+import java.text.ParseException;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.ConfirmationTypeType;
+import org.uic.barcode.ticket.api.spec.IBerth;
+import org.uic.barcode.ticket.api.spec.IBerthTypeType;
+import org.uic.barcode.ticket.api.spec.IBoardingOrArrivalType;
+import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
+import org.uic.barcode.ticket.api.spec.ICardReference;
+import org.uic.barcode.ticket.api.spec.ICompartmentGenderType;
+import org.uic.barcode.ticket.api.spec.ICompartmentPositionType;
+import org.uic.barcode.ticket.api.spec.ICounterMark;
+import org.uic.barcode.ticket.api.spec.ICustomerCard;
+import org.uic.barcode.ticket.api.spec.ICustomerStatusDescription;
+import org.uic.barcode.ticket.api.spec.IDelayConfirmation;
+import org.uic.barcode.ticket.api.spec.IDocumentData;
+import org.uic.barcode.ticket.api.spec.IDocumentExtension;
+import org.uic.barcode.ticket.api.spec.IExtension;
+import org.uic.barcode.ticket.api.spec.IFipTicket;
+import org.uic.barcode.ticket.api.spec.IGenderType;
+import org.uic.barcode.ticket.api.spec.IGeoCoordinateSystemType;
+import org.uic.barcode.ticket.api.spec.IGeoUnitType;
+import org.uic.barcode.ticket.api.spec.IHemisphereLatitudeType;
+import org.uic.barcode.ticket.api.spec.IHemisphereLongitudeType;
+import org.uic.barcode.ticket.api.spec.IIncludedOpenTicket;
+import org.uic.barcode.ticket.api.spec.ILine;
+import org.uic.barcode.ticket.api.spec.ILinkMode;
+import org.uic.barcode.ticket.api.spec.ILoadingDeckType;
+import org.uic.barcode.ticket.api.spec.IOpenTicket;
+import org.uic.barcode.ticket.api.spec.IParkingGround;
+import org.uic.barcode.ticket.api.spec.IPass;
+import org.uic.barcode.ticket.api.spec.IPassengerType;
+import org.uic.barcode.ticket.api.spec.IPolygone;
+import org.uic.barcode.ticket.api.spec.IPriceTypeType;
+import org.uic.barcode.ticket.api.spec.IRegionalValidity;
+import org.uic.barcode.ticket.api.spec.IRegisteredLuggage;
+import org.uic.barcode.ticket.api.spec.IReservation;
+import org.uic.barcode.ticket.api.spec.IRoofRackType;
+import org.uic.barcode.ticket.api.spec.IServiceType;
+import org.uic.barcode.ticket.api.spec.IStationCodeTable;
+import org.uic.barcode.ticket.api.spec.IStationPassage;
+import org.uic.barcode.ticket.api.spec.ITariff;
+import org.uic.barcode.ticket.api.spec.ITicketLink;
+import org.uic.barcode.ticket.api.spec.ITicketType;
+import org.uic.barcode.ticket.api.spec.ITimeRange;
+import org.uic.barcode.ticket.api.spec.ITrainLink;
+import org.uic.barcode.ticket.api.spec.ITravelClassType;
+import org.uic.barcode.ticket.api.spec.ITraveler;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.spec.IValidityRange;
+import org.uic.barcode.ticket.api.spec.IVatDetail;
+import org.uic.barcode.ticket.api.spec.IViaStation;
+import org.uic.barcode.ticket.api.spec.IVoucher;
+import org.uic.barcode.ticket.api.spec.IZone;
+import org.uic.barcode.ticket.api.test.testtickets.AllElementsTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class CarCarriageTestV1.
+ *
+ *
+ *
+ */
+public class AllElementsTestV3 {
+
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testDelayConfirmation() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+
+ defaulttimeZone = TimeZone.getDefault();
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ IUicRailTicket ticketDecoded = null;
+ try {
+ String hex = AllElementsTestTicketV3.getEncodingHex();
+ byte[] content = UperEncoder.bytesFromHexString(hex);
+ ticketDecoded = decoder.decodeFromAsn(content);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+
+
+
+ byte[] encoded = null;
+ try {
+ encoded = encoder.encode(ticketDecoded);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ }
+
+ //decode ticket again
+ IUicRailTicket ticketDecoded2 = null;
+ try {
+ ticketDecoded2 = decoder.decodeFromAsn(encoded);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert (ticketDecoded2 != null);
+
+ //validate content
+ validateTicketContent(ticketDecoded2);
+
+
+
+
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+
+
+
+
+ private void validateTicketContent(IUicRailTicket ticket) {
+ assert (ticket != null);
+
+ assert(ticket.getControlDetails() != null);
+ assert(ticket.getControlDetails().isAgeCheckRequired() == false);
+ assert(ticket.getControlDetails().isIdentificationByPassportId() == false);
+ assert(ticket.getControlDetails().isIdentificationByIdCard() == false);
+ assert(ticket.getControlDetails().isOnlineValidationRequired() == false);
+ assert(ticket.getControlDetails().getIdentificationItem() == 12);
+ assert(ticket.getControlDetails().isPassportValidationRequired() == false);
+ assert(ticket.getControlDetails().getRandomDetailedValidationRequired() == 50);
+ assert(ticket.getControlDetails().getExtension() != null);
+ assert(ticket.getControlDetails().isReductionCardCheckRequired() == false);
+ assert(ticket.getControlDetails().getInfoText().equals("control"));
+ assert(ticket.getControlDetails().getIdentificationByCardReference() != null);
+
+ assert(ticket.getControlDetails().getIdentificationByCardReference().size() == 1);
+ ICardReference cr = ticket.getControlDetails().getIdentificationByCardReference().iterator().next();
+ assert(cr != null);
+ assert(cr.getCardId().equals("5678"));
+ assert(cr.getCardIssuer().equals("1234"));
+ assert(cr.getCardName().equals("testcard"));
+ assert(cr.getCardType() == 123);
+ assert(cr.getLeadingCardId().equals("3456"));
+ assert(cr.getTrailingCardId().equals("100"));
+
+
+ assert(ticket.getControlDetails().getLinkedTickets() != null);
+
+ ITicketLink tl = ticket.getControlDetails().getLinkedTickets().iterator().next();
+
+ assert(tl.getIssuer().equals("XYZ"));
+ assert(tl.getIssuerPNR().equals("LDWDUR45"));
+ assert(tl.getProductOwner().equals("IEFHU"));
+ assert(tl.getLinkMode().equals(ILinkMode.issuedTogether));
+ assert(tl.getReference().equals("KDJET"));
+ assert(tl.getTicketType().equals(ITicketType.openTicket));
+
+ assert(ticket.getExtensions() != null);
+ assert(ticket.getExtensions().size() == 2);
+ Iterator<IExtension> it = ticket.getExtensions().iterator();
+ IExtension e0 = it.next();
+ IExtension e1 = it.next();
+ assert(e0.getId().equals("1"));
+ assert(UperEncoder.hexStringFromBytes(e0.getBinarydata()).equals("82DA"));
+ assert(e1.getId().equals("2"));
+ assert(UperEncoder.hexStringFromBytes(e1.getBinarydata()).equals("83DA"));
+
+
+ assert(ticket.getIssuerDetails() != null);
+
+ assert(ticket.getIssuerDetails().isActivated() == true);
+ assert(ticket.getIssuerDetails().getCurrency().equals("SRF"));
+ assert(ticket.getIssuerDetails().getCurrencyFraction() == 3L);
+ assert(ticket.getIssuerDetails().getExtension() != null);
+ assert(ticket.getIssuerDetails().getIssuedOnLine() == 12);
+ assert(ticket.getIssuerDetails().getIssuedOnTrain().equals("123"));
+ assert(ticket.getIssuerDetails().getIssuerName().equals("name"));
+ assert(ticket.getIssuerDetails().getIssuer().equals("1"));
+ assert(ticket.getIssuerDetails().getIssuerPNR().equals("issuerTestPNR"));
+ assert(ticket.getIssuerDetails().getIssuingDate() != null);
+ assert(ticket.getIssuerDetails().isSecurePaperTicket() == false);
+ assert(ticket.getIssuerDetails().getSecurityProvider().equals("1"));
+ assert(ticket.getIssuerDetails().isSpecimen() == true);
+ assert(ticket.getIssuerDetails().getPointOfSale() != null);
+ assert(ticket.getIssuerDetails().getPointOfSale().getUnit().equals(IGeoUnitType.microDegree));
+ assert(ticket.getIssuerDetails().getPointOfSale().getSystem().equals(IGeoCoordinateSystemType.wgs84));
+ assert(ticket.getIssuerDetails().getPointOfSale().getAccuracy().equals(IGeoUnitType.microDegree));
+ assert(ticket.getIssuerDetails().getPointOfSale().getHemisphereLatitude().equals(IHemisphereLatitudeType.east));
+ assert(ticket.getIssuerDetails().getPointOfSale().getHemisphereLongitude().equals(IHemisphereLongitudeType.north));
+ assert(ticket.getIssuerDetails().getPointOfSale().getLatitude() == 269);
+ assert(ticket.getIssuerDetails().getPointOfSale().getLongitude() == 105);
+
+ assert(ticket.getDocumentData() != null);
+ assert(!ticket.getDocumentData().isEmpty());
+
+ Iterator<IDocumentData> i2 = ticket.getDocumentData().iterator();
+
+ int numberOfDocuments = 0;
+ while (i2.hasNext()) {
+ numberOfDocuments++;
+ IDocumentData d1 = i2.next();
+ if (d1 instanceof IReservation) {
+ validate((IReservation) d1);
+ } else if (d1 instanceof ICarCarriageReservation) {
+ validate((ICarCarriageReservation) d1);
+ } else if (d1 instanceof IPass) {
+ validate((IPass) d1);
+ } else if (d1 instanceof IOpenTicket) {
+ validate((IOpenTicket) d1);
+ } else if (d1 instanceof ICounterMark) {
+ validate((ICounterMark) d1);
+ } else if (d1 instanceof IStationPassage) {
+ validate((IStationPassage) d1);
+ } else if (d1 instanceof ICustomerCard) {
+ validate((ICustomerCard) d1);
+ } else if (d1 instanceof IDelayConfirmation) {
+ validate((IDelayConfirmation) d1);
+ } else if (d1 instanceof IParkingGround) {
+ validate((IParkingGround) d1);
+ } else if (d1 instanceof IFipTicket) {
+ validate((IFipTicket) d1);
+ } else if (d1 instanceof IVoucher) {
+ validate((IVoucher) d1);
+ } else if (d1 instanceof IDocumentExtension) {
+ assert(((IDocumentExtension) d1).getId() != null);
+ }
+ }
+ assert(numberOfDocuments == 11);
+
+
+ assert(ticket.getTravelerDetails() != null);
+ assert(ticket.getTravelerDetails().getGroupName().equals("myGroup"));
+ assert(ticket.getTravelerDetails().getPreferredLanguage().equals("EN"));
+ assert(ticket.getTravelerDetails().getTravelers() != null);
+ assert(ticket.getTravelerDetails().getTravelers().size() == 1);
+
+ ITraveler tr = ticket.getTravelerDetails().getTravelers().iterator().next();
+
+ assert(tr.getIDCardCountry() == 103);
+ assert(tr.getPassportCountry() == 102);
+ assert(tr.getCountryOfResidence() == 101);
+ assert(tr.getCustomerId().equals("DZE5gT"));
+ assert(tr.getDateOfBirth() != null);
+ assert(tr.getFirstName().equals("John"));
+ assert(tr.getGender().equals(IGenderType.male));
+ assert(tr.getIdCard().equals("12345"));
+ assert(tr.getLastName().equals("Dow"));
+ assert(tr.getPassengerType().equals(IPassengerType.senior));
+ assert(tr.isPassengerWithReducedMobility() == false);
+ assert(tr.getPassportId().equals("JDTS"));
+ assert(tr.getSecondName().equals("Little"));
+ assert(tr.getTitle().equals("PhD"));
+ assert(tr.isTicketHolder() == true);
+ assert(tr.getStatusCollection() != null);
+ assert(tr.getStatusCollection().size() == 1);
+ ICustomerStatusDescription csd = tr.getStatusCollection().iterator().next();
+ assert(csd.getStatus() == 1);
+ assert(csd.getDescription().equals("senior"));
+
+ }
+
+
+ private void validate(ICounterMark t) {
+
+ assert(t != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals( "23456"));
+ assert(t.getProductId().equals( "123456"));
+ assert(t.getTicketReference().equals( "810123456789"));
+ assert(t.getNumberOfCountermark() == 12L);
+ assert(t.getTotalOfCountermarks() == 24L);
+ assert(t.getGroupName().equals( "groupName"));
+ assert(t.isReturnIncluded() == false);
+
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getFromStation().equals("8100001"));
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ assert(t.getValidRegionDesc().equals("From A to B via C"));
+
+ assert(t.getValidRegionList() != null);
+ assert(t.getValidRegionList().size() == 1);
+
+
+ assert(t.getReturnDescription() != null);
+ assert(t.getReturnDescription().getFromStation().equals("8100001"));
+ assert(t.getReturnDescription().getToStation().equals( "8100002"));
+ assert(t.getReturnDescription().getFromStationName().equals( "A-STATION"));
+ assert(t.getReturnDescription().getToStationName().equals( "B-STATION"));
+ assert(t.getReturnDescription().getValidRegionDesc().equals( "return"));
+ assert(t.getReturnDescription().getValidRegionList() != null);
+ assert(t.getReturnDescription().getValidRegionList().size() == 1);
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+
+ assert(t.getClassCode().equals(ITravelClassType.first));
+
+ assert(t.getIncludedCarriers() != null);
+ assert(t.getIncludedCarriers().size() == 2);
+ assert(t.getIncludedCarriers().contains("1080"));
+ assert(t.getIncludedCarriers().contains("1181"));
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ assert (t.getInfoText().equals("counterMark"));
+
+ assert(t.getExtension() != null);
+
+
+ }
+
+ private void validate(IDelayConfirmation t) {
+ assert(t != null);
+
+ assert(t.getTrain().equals("100"));
+ assert(t.getArrivalDate() != null);
+ assert(t.getReference().equals("ABDJ12345"));
+ assert(t.getStation().equals("DJE"));
+ assert(t.getDelay() == 31);
+ assert(t.isTrainCancelled() == false);
+ assert(t.getConfirmationType() == ConfirmationTypeType.travelerDelayConfirmation.ordinal());
+ assert(t.getLinkedTickets() != null);
+ assert(t.getLinkedTickets().size() == 1);
+ ITicketLink tl = t.getLinkedTickets().iterator().next();
+ assert(tl.getReference().equals("KDJET"));
+ assert(tl.getIssuer().equals( "XYZ"));
+ assert(tl.getIssuerPNR().equals( "LDWDUR45"));
+ assert(tl.getProductOwner().equals( "IEFHU"));
+ assert(tl.getTicketType().equals(ITicketType.openTicket));
+ assert(tl.getLinkMode().equals( ILinkMode.issuedTogether));
+
+ assert(t.getInfoText().equals( "delay confirmation"));
+ assert(t.getExtension() != null);
+
+ }
+
+ private void validate(ICustomerCard c) {
+ assert(c != null);
+ assert (c.getExtension() != null);
+ assert (c.getCustomer() != null);
+ assert (c.getCustomer() != null);
+
+ assert (c.getCardId().equals("2345"));
+ assert (c.getValidFrom() != null);
+ assert (c.getValidUntil() != null);
+ assert (c.getClassCode().equals(ITravelClassType.second));
+ assert (c.getCardType() == 15);
+ assert (c.getCardTypeDescr().equals( "RAILPLUS"));
+ assert (c.getCustomerStatus() == 1);
+ assert (c.getCustomerStatusDescr().equals( "gold"));
+ assert (c.getIncludedServices() != null);
+ assert (c.getIncludedServices().size() == 2);
+ Iterator<Integer> i3 = c.getIncludedServices().iterator();
+ assert(i3.next() == 1);
+ assert(i3.next() == 2);
+
+ }
+
+ private void validate(IVoucher v) {
+ assert(v != null);
+ assert (v.getExtension() != null);
+
+ assert(v.getReference().equals("810123456789"));
+ assert(v.getProductOwner().equals("COFFEEMACHINE"));
+ assert(v.getProductId().equals("123456"));
+
+ assert(v.getValidFrom() != null);
+ assert(v.getValidUntil() != null);
+ assert(v.getAmount() == 500);
+ assert(v.getType() == 123);
+ assert(v.getInfoText().equals("coffee voucher"));
+
+ }
+
+ private void validate(IStationPassage t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("123456"));
+
+ assert(t.getProductName().equals("passage"));
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(t.getStations() != null);
+ assert(t.getStations().size() == 2);
+ assert(t.getStations().contains("8200001"));
+ assert(t.getStations().contains("AMS"));
+ assert(t.getStationNames() != null);
+ assert(t.getStationNames().size() == 1);
+ assert(t.getStationNames().iterator().next().equals("Amsterdam"));
+ assert(t.getAreaCodes() != null);
+ assert(t.getAreaCodes().size() == 2);
+ assert(t.getAreaCodes().contains("AMS"));
+ assert(t.getAreaCodes().contains("8200001"));
+ assert(t.getAreaNames() != null);
+ assert(t.getAreaNames().size() == 1);
+ assert(t.getAreaNames().contains("Amsterdam"));
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+ assert(t.getNumberOfdaysAllowed() == 5);
+
+ }
+
+ private void validate(IParkingGround t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("123456"));
+
+
+ assert(t.getParkingGroundId().equals( "IA5"));
+ assert(t.getFromParkingDate() != null);
+ assert(t.getToParkingDate() != null);
+
+
+ assert(t.getAccessCode().equals( "4ga"));
+ assert(t.getLocation().equals( "Parking Frankfurt Main West"));
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(t.getStation().equals( "8000001"));
+ assert(t.getSpecialInformation().equals( "outdoor parking"));
+ assert(t.getEntryTrack().equals( "left"));
+ assert(t.getNumberPlate().equals( "AA-DE-12345"));
+ assert(t.getPrice() == 500);
+ assert(t.getVatDetails() != null);
+ assert(t.getVatDetails().size() == 1);
+
+
+ }
+
+ private void validate(IFipTicket t) {
+ assert(t != null);
+ assert(t.getExtension() != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals("23456"));
+ assert(t.getProductId().equals("123456"));
+
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+ assert(t.getActivatedDays() != null);
+ assert(t.getActivatedDays().size() == 4);
+ Iterator<Date> i5 = t.getActivatedDays().iterator();
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+ assert(i5.next() != null);
+
+
+
+ assert(t.getCarriers()!= null);
+ assert(t.getCarriers().size() == 2);
+ assert(t.getCarriers().contains("1080"));
+ assert(t.getCarriers().contains("1181"));
+
+
+ assert(t.getNumberOfTravelDates() == 8);
+ assert(t.isIncludesSupplements() == true);
+ assert(t.getClassCode().equals(ITravelClassType.first));
+
+ }
+
+ private void validate(IOpenTicket t) {
+
+ assert (t != null);
+
+ assert(t.getReference().equals("810123456789"));
+ assert(t.getProductOwner().equals( "23456"));
+ assert(t.getProductId().equals( "123456"));
+ assert(t.getExternalIssuer() == 12);
+ assert(t.getAuthorizationCode() == 13);
+ assert(t.isReturnIncluded() == false);
+
+ assert(t.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getFromStation().equals("8100001"));
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ assert(t.getValidRegionDesc().equals("From A to B via C"));
+
+ assert (t.getValidRegionList() != null);
+ assert(t.getValidRegionList().size() == 5);
+ Iterator<IRegionalValidity> irv = t.getValidRegionList().iterator();
+ int checks = 0;
+ while (irv.hasNext()) {
+ IRegionalValidity v = irv.next();
+ if (v instanceof IZone) {
+ validateRegion((IZone) v);
+ checks++;
+ } else if (v instanceof IViaStation) {
+ validateRegion((IViaStation) v);
+ checks++;
+ } else if (v instanceof ITrainLink) {
+ validateRegion((ITrainLink) v);
+ checks++;
+ } else if (v instanceof IPolygone) {
+ validateRegion((IPolygone) v);
+ checks++;
+ } else if (v instanceof ILine) {
+ validateRegion((ILine) v);
+ checks++;
+ }
+ }
+ assert(checks == 5);
+
+ assert(t.getReturnDescription() != null);
+
+ assert(t.getReturnDescription().getFromStation().equals("8100001"));
+ assert(t.getReturnDescription().getToStation().equals( "8100002"));
+ assert(t.getReturnDescription().getFromStationName().equals( "A-STATION"));
+ assert(t.getReturnDescription().getToStationName().equals( "B-STATION"));
+ assert(t.getReturnDescription().getValidRegionDesc().equals( "return"));
+ assert(t.getReturnDescription().getValidRegionList() != null);
+ assert(t.getReturnDescription().getValidRegionList().size() == 1);
+
+ assert(t.getValidFrom() != null);
+ assert(t.getValidUntil() != null);
+
+ assert(t.getActivatedDays() != null);
+ assert(t.getActivatedDays().size() == 2);
+
+ assert(t.getClassCode().equals(ITravelClassType.first));
+ assert(t.getServiceLevel().equals("A"));
+
+ assert(t.getIncludedCarriers() != null);
+ assert(t.getIncludedCarriers().size() == 2);
+ assert(t.getIncludedCarriers().contains("1080"));
+ assert(t.getIncludedCarriers().contains("1181"));
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ assert(t.getTariffs() != null);
+ assert(t.getTariffs().size() == 1);
+
+ assert (t.getPrice() == 12345);
+ assert (t.getVatDetails() != null);
+ assert (t.getVatDetails().size() == 1);
+
+ assert (t.getInfoText().equals("openTicketInfo"));
+
+ assert (t.getIncludedAddOns() != null);
+ assert (t.getIncludedAddOns().size() == 1);
+ validate(t.getIncludedAddOns().iterator().next());
+
+ assert(t.getLuggageRestriction() != null);
+
+ assert(t.getIncludedTransportTypes() != null);
+ assert(t.getIncludedTransportTypes().size() == 2);
+ assert(t.getIncludedTransportTypes().contains(10));
+ assert(t.getIncludedTransportTypes().contains(11));
+
+
+ assert(t.getExcludedTransportTypes() != null);
+ assert(t.getExcludedTransportTypes().size() == 2);
+ assert(t.getExcludedTransportTypes().contains(10));
+ assert(t.getExcludedTransportTypes().contains(18));
+
+
+
+ assert(t.getExtension() != null);
+
+ }
+
+ private void validateRegion(ITrainLink t) {
+
+ assert (t != null);
+
+ assert(t.getTrain().equals("12345"));
+ assert(t.getDepartureDateTime() != null);
+ assert(t.getFromStation().equals("8100001"));
+
+ assert(t.getToStation().equals( "8100002"));
+ assert(t.getFromStationName().equals( "A-STATION"));
+ assert(t.getToStationName().equals( "B-STATION"));
+
+ }
+
+ private void validateRegion(IPolygone p) {
+
+ assert(p.getEdges() != null);
+ assert(p.getEdges().size() == 3);
+
+ }
+
+ private void validateRegion(IZone z) {
+
+ assert(z != null);
+
+ assert(z.getCarrier().equals("1080"));
+ assert(z.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(z.getEntryStation().equals( "1234"));
+ assert(z.getTerminatingStation().equals( "2345"));
+ assert(z.getCity() == 123456);
+ assert(z.getZoneIds() != null);
+ assert(z.getZoneIds().size() == 2);
+ Iterator<Integer> iz = z.getZoneIds().iterator();
+ assert(iz.next() == 100);
+ assert(iz.next() == 200);
+
+ assert(UperEncoder.hexStringFromBytes(z.getBinaryZoneId()).equals("82DA"));
+ assert(z.getNUTScode().equals("DE4711"));
+
+ }
+
+ private void validateRegion(ILine z) {
+
+
+ assert(z.getCarrier().equals("1080"));
+ assert(z.getStationCodeTable().equals(IStationCodeTable.stationERA));
+
+ assert(z.getEntryStation().equals( "1234"));
+
+ assert(z.getTerminatingStation().equals( "2345"));
+ assert(z.getCity() == 123456);
+ assert(z.getLineIds() != null);
+ assert(z.getLineIds().size() == 2);
+ Iterator<Integer> iz = z.getLineIds().iterator();
+ assert(iz.next() == 100);
+ assert(iz.next() == 200);
+
+
+ }
+
+ private void validateRegion(IViaStation t) {
+
+ assert( t != null);
+
+ assert(t.getRoute() != null);
+
+ assert(t.getRoute().size() == 4);
+
+ Iterator<IViaStation> iv = t.getRoute().iterator();
+ IViaStation v1 = iv.next();
+ IViaStation v2 = iv.next();
+ IViaStation v3 = iv.next();
+ IViaStation v4 = iv.next();
+
+ assert(v1.getStation().equals("123455"));
+ assert(v1.isBorder() == false);
+
+ assert(v2.getStation().equals("123456"));
+ assert(v2.isBorder() == false);
+
+ assert(v3.getAlternativeRoutes() != null);
+ assert(v3.getAlternativeRoutes().size() == 2);
+ Iterator<IViaStation> ari = v3.getAlternativeRoutes().iterator();
+ IViaStation ar1 = ari.next();
+ IViaStation ar2 = ari.next();
+ assert(ar1.getRoute().size() == 2);
+ assert(ar1.getRoute().iterator().next().getStation().equals("23455"));
+ assert(ar2.getRoute() != null);
+ assert(ar2.getRoute().size() == 2);
+ assert(ar2.getRoute().iterator().next().getStation().equals("3455"));
+
+ assert(v4.getStation().equals("123457"));
+
+ assert(t.isBorder() == false);
+
+ assert(t.getSeriesId() == 999);
+ assert(t.getRouteId() == 21);
+
+
+ assert(t.getIncludedServiceBrands() != null);
+ assert(t.getIncludedServiceBrands().size() == 2);
+ Iterator<Integer> i4 = t.getIncludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+ assert(t.getExcludedServiceBrands() != null);
+ assert(t.getExcludedServiceBrands().size() == 2);
+ i4 = t.getExcludedServiceBrands().iterator();
+ assert(i4.next() == 108);
+ assert(i4.next() == 118);
+
+
+ }
+
+ private void validate(IIncludedOpenTicket d1) {
+
+ assert(d1.getProductOwner().equals("23456"));
+ assert(d1.getProductId().equals("123456"));
+ assert(d1.getExternalIssuer() == 12);
+ assert(d1.getAuthorizationCode() == 13);
+ assert(d1.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(d1.getValidRegionList() != null);
+ assert(d1.getValidRegionList().size() == 1);
+ assert(d1.getValidFrom() != null);
+ assert(d1.getValidUntil() != null);
+ assert(d1.getClassCode().equals(ITravelClassType.second));
+ assert(d1.getServiceLevel().equals("A"));
+
+ assert(d1.getIncludedCarriers() != null);
+ assert(d1.getIncludedCarriers().size() == 2);
+ assert(d1.getIncludedCarriers().contains("1080"));
+ assert(d1.getIncludedCarriers().contains("1181"));
+
+ assert(d1.getIncludedServiceBrands() != null);
+ assert(d1.getIncludedServiceBrands().size() == 2);
+ assert(d1.getIncludedServiceBrands().contains(108));
+ assert(d1.getIncludedServiceBrands().contains(118));
+
+
+ assert(d1.getExcludedServiceBrands() != null);
+ assert(d1.getExcludedServiceBrands().size() == 2);
+ assert(d1.getExcludedServiceBrands().contains(108));
+ assert(d1.getExcludedServiceBrands().contains(118));
+
+
+ assert(d1.getTariffs() != null);
+ assert(d1.getTariffs().size() == 1);
+
+ assert(d1.getInfoText().equals("included ticket"));
+
+ assert(d1.getIncludedTransportTypes() != null);
+ assert(d1.getIncludedTransportTypes().size() == 2);
+ assert(d1.getIncludedTransportTypes().contains(10));
+ assert(d1.getIncludedTransportTypes().contains(11));
+
+
+ assert(d1.getExcludedTransportTypes() != null);
+ assert(d1.getExcludedTransportTypes().size() == 2);
+ assert(d1.getExcludedTransportTypes().contains(10));
+ assert(d1.getExcludedTransportTypes().contains(18));
+
+ assert(d1.getExtension() != null);
+
+
+
+ }
+
+ private void validate(IPass p) {
+
+
+ assert(p.getReference().equals("810123456789"));
+ assert(p.getProductOwner().equals( "23456"));
+ assert(p.getProductId().equals( "123456"));
+ assert(p.getPassType() == 2);
+ assert(p.getPassDescription().equals( "Eurail FlexPass"));
+ assert(p.getClassCode().equals(ITravelClassType.first));
+ assert(p.getValidFrom() != null);
+ assert(p.getValidUntil() != null);
+ assert(p.getValidityDetails() != null);
+
+ assert(p.getValidityDetails() != null);
+ assert(p.getValidityDetails().getValidityRanges().size() == 1);
+ IValidityRange vr = p.getValidityDetails().getValidityRanges().iterator().next();
+ assert(vr.getFromDate() != null);
+ assert(vr.getUntilDate() != null);
+
+ assert(p.getValidityDetails().getTimeRanges() != null);
+ ITimeRange tr = p.getValidityDetails().getTimeRanges().iterator().next();
+ assert(tr.getFromTime() == 6);
+ assert(tr.getUntilTime() == 9);
+
+ assert(p.getNumberOfValidityDays() == 5);
+ assert(p.getTrainValidity() != null);
+
+ assert(p.getTrainValidity().getFromDate() != null);
+ assert(p.getTrainValidity().getUntilDate() != null);
+ assert(p.getTrainValidity().getIncludedCarriers() != null);
+ assert(p.getTrainValidity().getIncludedCarriers().size() == 2);
+ Iterator<String> i3 = p.getTrainValidity().getIncludedCarriers().iterator();
+ assert(i3.next().equals("1234"));
+ assert(i3.next().equals("5678"));
+
+ assert(p.getTrainValidity().getBoardingOrArrival().equals(IBoardingOrArrivalType.boarding));
+
+ assert(p.getNumberOfPossibleTrips() == 3);
+ assert(p.getNumberOfDaysOfTravel() == 10);
+ assert(p.getActivatedDays() != null);
+ assert(p.getActivatedDays().size() == 2);
+
+
+ assert(p.getCountries() != null);
+ assert(p.getCountries().size() == 2);
+ Iterator<Integer> i6 = p.getCountries().iterator();
+ assert(i6.next() == 10);
+ assert(i6.next() == 20);
+
+ assert(p.getIncludedCarriers() != null);
+ assert(p.getIncludedCarriers().size() == 2);
+ assert(p.getIncludedCarriers().contains("1080"));
+ assert(p.getIncludedCarriers().contains("1181"));
+
+ assert(p.getIncludedServiceBrands() != null);
+ assert(p.getIncludedServiceBrands().size() == 2);
+ assert(p.getIncludedServiceBrands().contains(108));
+ assert(p.getIncludedServiceBrands().contains(118));
+
+
+ assert(p.getExcludedServiceBrands() != null);
+ assert(p.getExcludedServiceBrands().size() == 2);
+ assert(p.getExcludedServiceBrands().contains(108));
+ assert(p.getExcludedServiceBrands().contains(118));
+
+
+
+ assert(p.getExcludedCarriers() != null);
+ assert(p.getExcludedCarriers().size() == 2);
+ assert(p.getExcludedCarriers().contains("1080"));
+ assert(p.getExcludedCarriers().contains("1181"));
+
+
+
+
+
+ assert(p.getValidRegionList() != null);
+ assert(p.getValidRegionList().size() == 1);
+ assert(p.getTariffs() != null);
+ assert(p.getTariffs().size() == 1);
+ assert(p.getPrice() == 10000);
+ assert(p.getVatDetails() != null);
+ assert(p.getVatDetails().size() == 1);
+ assert(p.getInfoText().equals("pass info"));
+ assert (p.getExtension() != null);
+
+
+ }
+
+ private void validate(IReservation r) {
+
+ assert(r.getTrain().equals("12345"));
+ assert(r.getDepartureDate() != null);
+ assert(r.getReference().equals("810123456789"));
+ assert(r.getProductOwner().equals("23456"));
+
+ assert(r.getProductId().equals("123456"));
+ assert(r.getServiceBrand().getServiceBrand() == 12);
+ assert(r.getServiceBrand().getServiceBrandAbbreviation().equals("TGV"));
+ assert(r.getServiceBrand().getServiceBrandDescription().equals("Lyria"));
+ assert(r.getService().equals(IServiceType.couchette));
+
+ assert(r.getStationCodeTable().equals(IStationCodeTable.stationUIC));
+ assert(r.getFromStation().equals("8100001"));
+ assert(r.getToStation().equals( "8100002"));
+ assert(r.getFromStationName().equals( "A-STATION"));
+ assert(r.getToStationName().equals( "B-STATION"));
+ assert(r.getDepartureDate() != null);
+ assert(r.getArrivalDate() != null);
+ assert(r.getCarriers()!= null);
+ assert(r.getCarriers().size() == 2);
+ Iterator<String> i8 = r.getCarriers().iterator();
+ assert(i8.next().equals("1080"));
+ assert(i8.next().equals("1181"));
+
+
+ assert(r.getClassCode().equals(ITravelClassType.first));
+ assert(r.getServiceLevel().equals("A"));
+
+ assert(r.getPlaces() != null);
+ assert(r.getPlaces().getCoach().equals("31A"));
+ assert(r.getPlaces().getPlaceString().equals("31-47"));
+ assert(r.getPlaces().getPlaceDescription().equals("Window"));
+ assert(r.getPlaces().getPlaces() != null);
+ assert(r.getPlaces().getPlaces().size() == 4);
+ Iterator<String> is = r.getPlaces().getPlaces().iterator();
+ assert(is.next().equals("31"));
+ assert(is.next().equals("32"));
+
+
+ assert(r.getAdditionalPlaces() != null);
+ assert(r.getBicyclePlaces() != null);
+
+
+ assert(r.getCompartmentDetails() != null);
+ assert(r.getCompartmentDetails().getCoachType() == 1);
+ assert(r.getCompartmentDetails().getCompartmentType() == 99);
+ assert(r.getCompartmentDetails().getSpecialAllocation() == 50);
+ assert(r.getCompartmentDetails().getCoachTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getCompartmentTypeDescr().equals( "xwz"));
+ assert(r.getCompartmentDetails().getSpecialAllocationDescr().equals( "xwz"));
+ assert(r.getCompartmentDetails().getPosition().equals(ICompartmentPositionType.upperLevel));
+
+ assert(r.getNumberOfOverbooked() == 200);
+ assert(r.getBerths() != null);
+ assert(r.getBerths().size() == 1);
+ IBerth b = r.getBerths().iterator().next();
+
+ assert(b.getType().equals(IBerthTypeType.single));
+ assert(b.getGender().equals(ICompartmentGenderType.female));
+ assert(b.getNumberOfBerths() == 999);
+
+
+ assert(r.getTariffs() != null);
+ assert(r.getTariffs().size() == 1);
+ ITariff t = r.getTariffs().iterator().next();
+ assert(t.getNumberOfPassengers() == 1);
+
+
+ assert(t.getPassengerType().equals(IPassengerType.senior) );
+ assert(t.getAgeBelow() == 64);
+ assert(t.getAgeAbove() == 60);
+ assert(t.getTravelerIds() != null);
+ assert(t.getTravelerIds().size() == 1);
+ assert(t.getTravelerIds().iterator().next() == 1);
+
+ assert(t.isRestrictedToCountryOfResidence() == false);
+ assert(t.getRestrictedToRouteSection() != null);
+ assert(t.getRestrictedToRouteSection().getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(t.getRestrictedToRouteSection().getFromStation().equals( "123"));
+ assert(t.getRestrictedToRouteSection().getToStation().equals( "234"));
+ assert(t.getRestrictedToRouteSection().getFromStationName().equals( "A"));
+ assert(t.getRestrictedToRouteSection().getToStationName().equals( "B"));
+
+ assert(t.getSeriesDataDetails() != null);
+ assert(t.getSeriesDataDetails().getSupplyingCarrier() == 12345);
+ assert(t.getSeriesDataDetails().getOfferIdentification() == 99);
+ assert(t.getSeriesDataDetails().getSeries() == 23456);
+
+
+ assert(t.getTariffId().equals( "72"));
+ assert(t.getTariffDescription().equals( "Leasure Fare"));
+ assert(t.getReductionCards() != null);
+ assert(t.getReductionCards().size() == 1);
+ ICardReference rc = t.getReductionCards().iterator().next();
+
+ assert(rc.getCardIssuer().equals( "1234"));
+ assert(rc.getCardId().equals( "5678"));
+ assert(rc.getCardName().equals( "testcard"));
+ assert(rc.getCardType() == 123);
+ assert(rc.getLeadingCardId().equals("3456"));
+ assert(rc.getTrailingCardId().equals("100"));
+
+
+ assert(r.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(r.getPrice() == 12345);
+ assert(r.getVatDetails() != null);
+ IVatDetail v = r.getVatDetails().iterator().next();
+ assert(r.getVatDetails().size() == 1);
+ assert(v.getCountry() == 80);
+ assert(v.getPercentage() == 70);
+ assert(v.getAmount() == 10);
+ assert(v.getVatId().equals("IUDGTE"));
+
+ assert(r.getTypeOfSupplement() == 9);
+ assert(r.getNumberOfSupplements() == 2);
+ assert(r.getLuggageRestriction() != null);
+
+ assert(r.getLuggageRestriction().getMaxHandLuggagePieces() == 2);
+ assert(r.getLuggageRestriction().getMaxNonHandLuggagePieces() == 1);
+ assert(r.getLuggageRestriction().getRegisteredLuggage() != null);
+ assert(r.getLuggageRestriction().getRegisteredLuggage().size() == 2);
+
+
+ Iterator<IRegisteredLuggage> il = r.getLuggageRestriction().getRegisteredLuggage().iterator();
+ IRegisteredLuggage rl1 = null;
+ IRegisteredLuggage rl2 = null;
+ while (il.hasNext()) {
+ IRegisteredLuggage l = il.next();
+ if (l.getRegistrationId().equals("IODHUV")) {
+ rl1 = l;
+ } else {
+ rl2 = l;
+ }
+ }
+ assert(rl1.getRegistrationId().equals("IODHUV"));
+ assert(rl1.getMaxWeight() == 20);
+ assert(rl1.getMaxSize() == 100);
+ assert(rl2.getRegistrationId().equals("XXDHUV"));
+ assert(rl2.getMaxWeight() == 21);
+ assert(rl2.getMaxSize() == 101);
+ assert(r.getInfoText().equals("reservation"));
+ assert(r.getExtension() != null);
+
+ }
+
+
+ private void validate(ICarCarriageReservation r) {
+
+
+ assert(r.getToken() != null);
+ assert(UperEncoder.hexStringFromBytes(r.getToken().getToken()).equals("82DA"));
+ assert(r.getToken().getTokenProvider().equals("VDV"));
+ assert(r.getToken().getTokenSpecification().equals("TEST"));
+
+
+ assert(r.getTrain().equals("123"));
+ assert(r.getReference().equals("810123456789"));
+ assert(r.getProductOwner().equals("23456"));
+ assert(r.getProductId().equals("123456"));
+ assert(r.getServiceBrand().getServiceBrand() == 100);
+ assert(r.getServiceBrand().getServiceBrandAbbreviation().equals("AZ"));
+ assert(r.getServiceBrand().getServiceBrandDescription().equals("special train"));
+
+ assert(r.getBeginLoading() != null);
+ assert(r.getEndLoading() != null);
+
+ assert(r.getStationCodeTable().equals(IStationCodeTable.stationERA));
+ assert(r.getFromStation().equals("8100001"));
+ assert(r.getToStation().equals( "8100002"));
+ assert(r.getFromStationName().equals( "A-STATION"));
+ assert(r.getToStationName().equals( "B-STATION"));
+
+ assert(r.getCoach().equals("21"));
+ assert(r.getPlace().equals("41"));
+ assert(r.getCompartmentDetails() != null);
+
+ assert(r.getCompartmentDetails().getCoachType() == 1L);
+ assert(r.getCompartmentDetails().getCompartmentType() == 99L);
+ assert(r.getCompartmentDetails().getSpecialAllocation() == 50L);
+ assert(r.getCompartmentDetails().getCoachTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getCompartmentTypeDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getSpecialAllocationDescr().equals("xwz"));
+ assert(r.getCompartmentDetails().getPosition().equals(ICompartmentPositionType.upperLevel));
+
+ assert(r.getNumberPlate().equals( "AD-DE-123"));
+ assert(r.getTrailerPlate().equals( "DX-AB-123"));
+ assert(r.getCarCategory() == 3L);
+ assert(r.getBoatCategory() == 5L);
+ assert(r.isTextileRoof() == false);
+ assert(r.getRoofRackType().equals(IRoofRackType.bicycleRack));
+ assert(r.getRoofRackHeight() == 20L);
+ assert(r.getAttachedBoats() == 2L);
+ assert(r.getAttachedBicycles() == 1L);
+ assert(r.getAttachedSurfboards() == 2L);
+ assert(r.getLoadingListEntry() == 421L);
+ assert(r.getLoadingDeck().equals(ILoadingDeckType.upper));
+
+ assert(r.getCarriers()!= null);
+ assert(r.getCarriers().size() == 2);
+ Iterator<String> i9 = r.getCarriers().iterator();
+ assert(i9.next().equals("1080"));
+ assert(i9.next().equals("1181"));
+
+ assert(r.getTariff() != null);
+ assert(r.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(r.getPrice() == 12345L);
+
+ assert(r.getVatDetails() != null);
+
+ assert(r.getInfoText().equals("car carriage"));
+ assert(r.getExtension() != null);
+
+ }
+
+ public static int getIndexOfDifference(String s1, String s2) {
+
+ if (s1 == null || s2 == null) return -1;
+
+ char[] ca1 = null;
+ char[] ca2 = null;
+
+ if (s1.length() > s2.length()) {
+ ca1 = s1.toCharArray();
+ ca2 = s2.toCharArray();
+ } else {
+ ca1 = s2.toCharArray();
+ ca2 = s1.toCharArray();
+ }
+
+ int i = 0;
+ for (char c : ca2) {
+ if (c != ca1[i]) return i;
+ i++;
+ }
+ return 0;
+ }
+
+
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelAllElementsTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelAllElementsTestV3.java
index a5b4765..c0fb248 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelAllElementsTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelAllElementsTestV3.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.HemisphereLongitudeType;
import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType;
import org.uic.barcode.ticket.api.asn.omv3.LineType;
@@ -70,6 +71,8 @@ public class AsnLevelAllElementsTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java
index 955e2cf..39c4440 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCarCarriageTestV3.java
@@ -10,6 +10,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.CarCarriageReservationData;
import org.uic.barcode.ticket.api.asn.omv3.LoadingDeckType;
import org.uic.barcode.ticket.api.asn.omv3.PriceTypeType;
@@ -41,6 +42,8 @@ public class AsnLevelCarCarriageTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java
index e7dbd50..21fe946 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV1.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.test.testtickets.CountermarkTestComplexTicketV1;
@@ -34,6 +35,8 @@ public class AsnLevelCountermarkComplexTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java
index 918615c..60f5375 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelCountermarkComplexTestV3.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.CountermarkData;
import org.uic.barcode.ticket.api.asn.omv3.TravelClassType;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
@@ -38,6 +39,8 @@ public class AsnLevelCountermarkComplexTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java
index 8a2cbde..3bcd759 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelDelayConfirmationTestV3.java
@@ -10,6 +10,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.LinkMode;
import org.uic.barcode.ticket.api.asn.omv3.TicketType;
import org.uic.barcode.ticket.api.asn.omv3.DelayConfirmation;
@@ -40,6 +41,8 @@ public class AsnLevelDelayConfirmationTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java
index e45ae13..8077a13 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelParkingTestV3.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.ParkingGroundData;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.test.testtickets.ParkingTestTicketV3;
@@ -35,6 +36,8 @@ public class AsnLevelParkingTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java
index a1496c8..b2f1c9b 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelStationPassageTestV3.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.test.testtickets.StationPassageTestTicketV3;
@@ -34,6 +35,8 @@ public class AsnLevelStationPassageTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java
index eacdabb..6d25531 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/AsnLevelVoucherTestV3.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.VoucherData;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.test.testtickets.VoucherTestTicketV3;
@@ -35,6 +36,8 @@ public class AsnLevelVoucherTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java
new file mode 100644
index 0000000..ac7aed6
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java
@@ -0,0 +1,167 @@
+package org.uic.barcode.ticket.api.test;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.spec.ICarCarriageReservation;
+import org.uic.barcode.ticket.api.spec.IDocumentData;
+import org.uic.barcode.ticket.api.spec.ILoadingDeckType;
+import org.uic.barcode.ticket.api.spec.IPriceTypeType;
+import org.uic.barcode.ticket.api.spec.IRoofRackType;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.CarCarriageReservationTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class CarCarriageTestV1.
+ *
+ *
+ *
+ */
+public class CarCarriageTestV3 {
+
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ byte[] encodedInTimeZone1 = null;
+
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testDelayConfirmation() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+
+ defaulttimeZone = TimeZone.getDefault();
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ IUicRailTicket ticketDecoded = null;
+ try {
+ ticketDecoded = decoder.decodeFromAsn(CarCarriageReservationTestTicketV3.getEncodingBytes());
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ IDocumentData document = ticketDecoded.getDocumentData().iterator().next();
+ assert(document != null);
+ assert(document instanceof ICarCarriageReservation);
+
+ ICarCarriageReservation c = (ICarCarriageReservation) document;
+
+ assert(c.getAttachedBicycles() == 1L);
+ assert(c.getAttachedSurfboards() == 2L);
+
+ assert(c.getCarCategory() == 3L);
+ assert(c.getCoach().equals("21"));
+ assert(c.getPlace().equals("41"));
+ assert(c.getFromStation().equals("8100001"));
+ assert(c.getToStation().equals("800001"));
+ assert(c.getInfoText().equals("car carriage"));
+ assert(c.getLoadingDeck().equals(ILoadingDeckType.upper));
+ assert(c.getLoadingListEntry() == 421L);
+ assert(c.getTrain().equals("123"));
+ assert(c.getNumberPlate().equals("AD-DE-123"));
+ assert(c.getTrailerPlate().equals("DX-AB-123"));
+ assert(c.isTextileRoof() == false);
+ assert(c.getServiceBrand().getServiceBrandAbbreviation().equals("AZ"));
+ assert(c.getServiceBrand().getServiceBrandDescription().equals("special train"));
+ assert(c.getServiceBrand().getServiceBrand() == 100L);
+ assert(c.getRoofRackType().equals(IRoofRackType.bicycleRack));
+ assert(c.getTariff() != null);
+ assert(c.getRoofRackHeight() == 20L);
+ assert(c.getPriceType().equals(IPriceTypeType.travelPrice));
+ assert(c.getReference().equals("810123456789"));
+ assert(c.getVatDetails() != null);
+ assert(c.getCarriers().contains("1080"));
+ assert(c.getCarriers().contains("1181"));
+ assert(c.getPrice() == 12345L);
+
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ String pdb = dateFormat.format(c.getBeginLoading());
+ assert(pdb.equals("2018.01.11-00:00"));
+
+ String pde = dateFormat.format(c.getEndLoading());
+ assert(pde.equals("2018.01.11-08:20"));
+
+
+ byte[] encoded = null;
+ try {
+ encoded = encoder.encode(ticketDecoded);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ }
+
+
+ IUicRailTicket ticketDecoded2 = null;
+ try {
+ ticketDecoded2 = decoder.decodeFromAsn(encoded);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert (ticketDecoded2 != null);
+
+ String hex1 = UperEncoder.hexStringFromBytes(encoded);
+ String hex2 = CarCarriageReservationTestTicketV3.getEncodingHex();
+ assert(hex1.equals(hex2));
+
+
+
+
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java
index 1a05e6f..afc7e76 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/CounterMarkTimeZoneTestV3.java
@@ -1,6 +1,5 @@
package org.uic.barcode.ticket.api.test;
-import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -11,6 +10,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.ICounterMark;
@@ -87,6 +87,8 @@ public class CounterMarkTimeZoneTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = CountermarkTestComplexTicketV3.getUicTestTicket();
@@ -288,7 +290,7 @@ public class CounterMarkTimeZoneTestV3 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -303,7 +305,7 @@ public class CounterMarkTimeZoneTestV3 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV1.java
index 315774e..5f44950 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV1.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.ICustomerCard;
@@ -85,6 +86,8 @@ public class CustomerCardTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = CustomerCardTestTicketV1.getUicTestTicket();
@@ -288,7 +291,7 @@ public class CustomerCardTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -303,7 +306,7 @@ public class CustomerCardTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV2.java
index e8857ab..d9ae8dc 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV2.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.ICustomerCard;
@@ -85,6 +86,9 @@ public class CustomerCardTimeZoneTestV2 {
*/
@Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = CustomerCardTestTicketV2.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV3.java
index da0879b..f9d4f43 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/CustomerCardTimeZoneTestV3.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.ICustomerCard;
@@ -87,6 +88,8 @@ public class CustomerCardTimeZoneTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = CustomerCardTestTicketV3.getUicTestTicket();
@@ -290,7 +293,7 @@ public class CustomerCardTimeZoneTestV3 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -305,7 +308,7 @@ public class CustomerCardTimeZoneTestV3 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java b/src/test/java/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
index 5b2e578..b818738 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/DateTimeUtilsTest.java
@@ -2,13 +2,18 @@ package org.uic.barcode.ticket.api.test;
import java.util.Calendar;
import java.util.TimeZone;
+
+import org.junit.Before;
import org.junit.Test;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.utils.DateTimeUtils;
public class DateTimeUtilsTest{
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testDateDiff1() throws IllegalArgumentException, IllegalAccessException {
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/DelayConfirmationTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/DelayConfirmationTestV3.java
new file mode 100644
index 0000000..81f8f9e
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticket/api/test/DelayConfirmationTestV3.java
@@ -0,0 +1,180 @@
+package org.uic.barcode.ticket.api.test;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.spec.IDelayConfirmation;
+import org.uic.barcode.ticket.api.spec.IDocumentData;
+import org.uic.barcode.ticket.api.spec.ILinkMode;
+import org.uic.barcode.ticket.api.spec.ITicketLink;
+import org.uic.barcode.ticket.api.spec.ITicketType;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.DelayTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class VoucherTestV1.
+ *
+ *
+ *
+ */
+public class DelayConfirmationTestV3 {
+
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ byte[] encodedInTimeZone1 = null;
+
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testDelayConfirmation() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ IUicRailTicket ticketDecoded = null;
+ try {
+ ticketDecoded = decoder.decodeFromAsn(DelayTestTicketV3.getEncodingBytes());
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ IDocumentData document = ticketDecoded.getDocumentData().iterator().next();
+ assert(document != null);
+ assert(document instanceof IDelayConfirmation);
+
+ IDelayConfirmation del = (IDelayConfirmation) document;
+ assert(del.getDelay() == 31);
+
+ /*
+ *
+ referenceIA5 "ABDJ12345",
+ trainNum 100,
+ departureYear 2022,
+ departureDay 12,
+ departureTime 1000,
+ stationCodeTable stationUIC,
+ stationNum 8000001,
+ delay 31,
+ trainCancelled FALSE,
+ confirmationType travelerDelayConfirmation,
+ affectedTickets {
+ {
+ referenceNum 801234567890,
+ productOwnerNum 1080,
+ ticketType openTicket,
+ linkMode issuedTogether
+ }
+ },
+ infoText "delay confirmation"
+ */
+
+ assert(del.getLinkedTickets().size() == 1);
+ assert(del.getDelay() == 31L);
+ assert(del.isTrainCancelled() == false);
+ assert(del.getInfoText().equals("delay confirmation"));
+ assert(del.getReference().equals("ABDJ12345"));
+ assert(del.getTrain().equals("100"));
+
+
+ ITicketLink tl = del.getLinkedTickets().iterator().next();
+ assert(tl.getReference().equals("801234567890"));
+ assert(tl.getProductOwner().equals("1080"));
+ assert(tl.getTicketType().equals(ITicketType.openTicket));
+ assert(tl.getLinkMode().equals(ILinkMode.issuedTogether));
+
+ TimeZone current = TimeZone.getDefault();
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ String pd = dateFormat.format(del.getArrivalDate());
+ assert(pd.equals("2022.01.12-16:40"));
+ TimeZone.setDefault(current);
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ byte[] encoded = null;
+ try {
+ encoded = encoder.encode(ticketDecoded);
+ } catch (EncodingFormatException e) {
+ assert(false);
+ }
+
+
+ IUicRailTicket ticketDecoded2 = null;
+ try {
+ ticketDecoded2 = decoder.decodeFromAsn(encoded);
+ } catch (Exception e) {
+ assert(false);
+ }
+
+ assert (ticketDecoded2 != null);
+
+ String hex1 = UperEncoder.hexStringFromBytes(encoded);
+ String hex2 = DelayTestTicketV3.getEncodingHex();
+ assert(hex1.equals(hex2));
+
+
+
+
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java
index c9b0f31..d471eff 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV1.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IFipTicket;
@@ -89,6 +90,8 @@ public class FipTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = FipTimeZoneTestTicketV1.getUicTestTicket();
@@ -321,7 +324,7 @@ public class FipTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -336,7 +339,7 @@ public class FipTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java
index 89b6562..8b8c542 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV2.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IFipTicket;
@@ -89,6 +90,8 @@ public class FipTimeZoneTestV2 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = FipTimeZoneTestTicketV2.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV3.java
index a4c542e..ed54b72 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/FipTimeZoneTestV3.java
@@ -1,347 +1,350 @@
-package org.uic.barcode.ticket.api.test;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
-import org.uic.barcode.ticket.api.spec.IFipTicket;
-import org.uic.barcode.ticket.api.spec.IUicRailTicket;
-import org.uic.barcode.ticket.api.test.testtickets.FipTimeZoneTestTicketV3;
-import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
-import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
-import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
-import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
-
-
-/**
- * The Class FipTimeZoneTestV1.
- *
- *
- *
- */
-public class FipTimeZoneTestV3 {
-
- /** The low level encoded test ticket test case 1 . */
- private byte[] encoded1 = null;
-
- /** The low level encoded test ticket test case 2 . */
- private byte[] encoded2 = null;
-
- /** The low level encoded test ticket test case 3 . */
- private byte[] encoded3 = null;
-
- /** The decoder. */
- Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
-
- /** The encoder. */
- Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
-
- /** The API ticket low level encoded for case 1. */
- IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
-
- /** The API ticket low level encoded for case 2. */
- IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
-
- /** The API ticket low level encoded for case 3. */
- IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
-
-
- /** The ticket decoded 1. */
- IUicRailTicket iTicketDecodedCase1 = null;
-
- /** The i ticket decoded 2. */
- IUicRailTicket iTicketDecodedCase2 = null;
-
- /** The i ticket decoded 3. */
- IUicRailTicket iTicketDecodedCase3 = null;
-
- byte[] encodedInTimeZone1 = null;
- byte[] encodedInTimeZone2 = null;
- byte[] encodedInTimeZone3 = null;
-
- String issuingDate1 = null;
- String issuingDate2 = null;
- String issuingDate3 = null;
-
- String validFrom1 = null;
- String validFrom2 = null;
- String validFrom3 = null;
-
- String validUntil1 = null;
- String validUntil2 = null;
- String validUntil3 = null;
-
- String activationDate1 = null;
- String activationDate2 = null;
- String activationDate3 = null;
-
- TimeZone defaulttimeZone = null;
-
- /**
- * Prepare tickets.
- */
- @Before public void prepare() {
-
- defaulttimeZone = TimeZone.getDefault();
-
- UicRailTicketData ticket1 = FipTimeZoneTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket2 = FipTimeZoneTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket3 = FipTimeZoneTestTicketV3.getUicTestTicket();
-
- //encode in UTC time zone
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
-
- encoded1 = UperEncoder.encode(ticket1);
- encoded2 = UperEncoder.encode(ticket2);
- encoded3 = UperEncoder.encode(ticket3);
-
- }
-
- /**
- * clean up
- */
- @After public void resetTimeZone() {
- TimeZone.setDefault(defaulttimeZone);
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone CET
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("CET");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("GMT");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- }
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("CET");
- decode("GMT");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
- assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- }
-
- private void decodedDateToStrings() {
-
- issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
- issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
- issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
-
- validFrom1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
- validFrom2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
- validFrom3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
-
- validUntil1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntil2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntil3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
-
- activationDate1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
- activationDate2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
- activationDate3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
-
- }
-
-
- private void setActivatedDayTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- }
-
- private void setValidFromTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
- ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
- ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
- }
-
- private void setValidUntilTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
- ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
- ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
- }
-
-
- /**
- * Encode in Time Zone
- */
- private void encode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
- try {
- encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
- encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
- encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
- } catch (EncodingFormatException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Decode in Time Zone
- */
- private void decode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
-
- try {
- iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
- iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
- iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * Encode decode.
- */
- private void decodeTestTicketUTC() {
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- try {
- iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
- iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
- iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-}
+package org.uic.barcode.ticket.api.test;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IFipTicket;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.FipTimeZoneTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class FipTimeZoneTestV1.
+ *
+ *
+ *
+ */
+public class FipTimeZoneTestV3 {
+
+ /** The low level encoded test ticket test case 1 . */
+ private byte[] encoded1 = null;
+
+ /** The low level encoded test ticket test case 2 . */
+ private byte[] encoded2 = null;
+
+ /** The low level encoded test ticket test case 3 . */
+ private byte[] encoded3 = null;
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+ /** The API ticket low level encoded for case 2. */
+ IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
+
+ /** The API ticket low level encoded for case 3. */
+ IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ /** The i ticket decoded 2. */
+ IUicRailTicket iTicketDecodedCase2 = null;
+
+ /** The i ticket decoded 3. */
+ IUicRailTicket iTicketDecodedCase3 = null;
+
+ byte[] encodedInTimeZone1 = null;
+ byte[] encodedInTimeZone2 = null;
+ byte[] encodedInTimeZone3 = null;
+
+ String issuingDate1 = null;
+ String issuingDate2 = null;
+ String issuingDate3 = null;
+
+ String validFrom1 = null;
+ String validFrom2 = null;
+ String validFrom3 = null;
+
+ String validUntil1 = null;
+ String validUntil2 = null;
+ String validUntil3 = null;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = FipTimeZoneTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket2 = FipTimeZoneTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket3 = FipTimeZoneTestTicketV3.getUicTestTicket();
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ encoded1 = UperEncoder.encode(ticket1);
+ encoded2 = UperEncoder.encode(ticket2);
+ encoded3 = UperEncoder.encode(ticket3);
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone CET
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("CET");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("GMT");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("CET");
+ decode("GMT");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
+ assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IFipTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IFipTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IFipTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
+ }
+
+ private void setValidUntilTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IFipTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IFipTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
+ }
+
+
+ /**
+ * Encode in Time Zone
+ */
+ private void encode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+ try {
+ encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
+ encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
+ encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
+ } catch (EncodingFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Decode in Time Zone
+ */
+ private void decode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+
+ try {
+ iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
+ iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
+ iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Encode decode.
+ */
+ private void decodeTestTicketUTC() {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ try {
+ iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
+ iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
+ iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java
index 4b1d61e..1ee9bc1 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV1.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.test.testtickets.OpenTestComplexTicketV1;
@@ -35,6 +36,8 @@ public class OpenTicketComplexTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java
index da167c4..86bf2d4 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.test.testtickets.OpenTestComplexTicketV2;
@@ -35,6 +36,8 @@ public class OpenTicketComplexTestV2 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java
index 21266a9..e04fbb7 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV3.java
@@ -8,6 +8,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType;
import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData;
import org.uic.barcode.ticket.api.asn.omv3.PassengerType;
@@ -39,6 +40,8 @@ public class OpenTicketComplexTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketINcludedTicketDateTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketINcludedTicketDateTestV3.java
index 5631489..5420675 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketINcludedTicketDateTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketINcludedTicketDateTestV3.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.CodeTableType;
import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType;
import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData;
@@ -42,6 +43,8 @@ public class OpenTicketINcludedTicketDateTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java
index fe0bdda..5ae24b4 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketRestrictedLuggageComplexTestV3.java
@@ -8,6 +8,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.IncludedOpenTicketType;
import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData;
import org.uic.barcode.ticket.api.asn.omv3.PassengerType;
@@ -39,6 +40,8 @@ public class OpenTicketRestrictedLuggageComplexTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java
index c2d288e..af5eb71 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV1.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IOpenTicket;
@@ -89,6 +90,8 @@ public class OpenTicketTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = OpenTicketTimeZoneTestTicketV1.getUicTestTicket();
@@ -321,7 +324,7 @@ public class OpenTicketTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -336,7 +339,7 @@ public class OpenTicketTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV3.java
index 236d8b0..5752c46 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTimeZoneTestV3.java
@@ -1,347 +1,350 @@
-package org.uic.barcode.ticket.api.test;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
-import org.uic.barcode.ticket.api.spec.IOpenTicket;
-import org.uic.barcode.ticket.api.spec.IUicRailTicket;
-import org.uic.barcode.ticket.api.test.testtickets.OpenTicketTimeZoneTestTicketV3;
-import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
-import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
-import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
-import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
-
-
-/**
- * The Class FipTimeZoneTestV2.
- *
- *
- *
- */
-public class OpenTicketTimeZoneTestV3 {
-
- /** The low level encoded test ticket test case 1 . */
- private byte[] encoded1 = null;
-
- /** The low level encoded test ticket test case 2 . */
- private byte[] encoded2 = null;
-
- /** The low level encoded test ticket test case 3 . */
- private byte[] encoded3 = null;
-
- /** The decoder. */
- Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
-
- /** The encoder. */
- Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
-
- /** The API ticket low level encoded for case 1. */
- IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
-
- /** The API ticket low level encoded for case 2. */
- IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
-
- /** The API ticket low level encoded for case 3. */
- IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
-
-
- /** The ticket decoded 1. */
- IUicRailTicket iTicketDecodedCase1 = null;
-
- /** The i ticket decoded 2. */
- IUicRailTicket iTicketDecodedCase2 = null;
-
- /** The i ticket decoded 3. */
- IUicRailTicket iTicketDecodedCase3 = null;
-
- byte[] encodedInTimeZone1 = null;
- byte[] encodedInTimeZone2 = null;
- byte[] encodedInTimeZone3 = null;
-
- String issuingDate1 = null;
- String issuingDate2 = null;
- String issuingDate3 = null;
-
- String validFrom1 = null;
- String validFrom2 = null;
- String validFrom3 = null;
-
- String validUntil1 = null;
- String validUntil2 = null;
- String validUntil3 = null;
-
- String activationDate1 = null;
- String activationDate2 = null;
- String activationDate3 = null;
-
- TimeZone defaulttimeZone = null;
-
- /**
- * Prepare tickets.
- */
- @Before public void prepare() {
-
- defaulttimeZone = TimeZone.getDefault();
-
- UicRailTicketData ticket1 = OpenTicketTimeZoneTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket2 = OpenTicketTimeZoneTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket3 = OpenTicketTimeZoneTestTicketV3.getUicTestTicket();
-
- //encode in UTC time zone
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
-
- encoded1 = UperEncoder.encode(ticket1);
- encoded2 = UperEncoder.encode(ticket2);
- encoded3 = UperEncoder.encode(ticket3);
-
- }
-
- /**
- * clean up
- */
- @After public void resetTimeZone() {
- TimeZone.setDefault(defaulttimeZone);
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone CET
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("CET");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("GMT");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- }
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("CET");
- decode("GMT");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
- assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- }
-
- private void decodedDateToStrings() {
-
- issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
- issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
- issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
-
- validFrom1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
- validFrom2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
- validFrom3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
-
- validUntil1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntil2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntil3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
-
- activationDate1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
- activationDate2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
- activationDate3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
-
- }
-
-
- private void setActivatedDayTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- }
-
- private void setValidFromTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
- ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
- ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
- }
-
- private void setValidUntilTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
- ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
- ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
- }
-
-
- /**
- * Encode in Time Zone
- */
- private void encode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
- try {
- encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
- encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
- encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
- } catch (EncodingFormatException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Decode in Time Zone
- */
- private void decode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
-
- try {
- iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
- iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
- iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * Encode decode.
- */
- private void decodeTestTicketUTC() {
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- try {
- iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
- iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
- iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-}
+package org.uic.barcode.ticket.api.test;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IOpenTicket;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.OpenTicketTimeZoneTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class FipTimeZoneTestV2.
+ *
+ *
+ *
+ */
+public class OpenTicketTimeZoneTestV3 {
+
+ /** The low level encoded test ticket test case 1 . */
+ private byte[] encoded1 = null;
+
+ /** The low level encoded test ticket test case 2 . */
+ private byte[] encoded2 = null;
+
+ /** The low level encoded test ticket test case 3 . */
+ private byte[] encoded3 = null;
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+ /** The API ticket low level encoded for case 2. */
+ IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
+
+ /** The API ticket low level encoded for case 3. */
+ IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ /** The i ticket decoded 2. */
+ IUicRailTicket iTicketDecodedCase2 = null;
+
+ /** The i ticket decoded 3. */
+ IUicRailTicket iTicketDecodedCase3 = null;
+
+ byte[] encodedInTimeZone1 = null;
+ byte[] encodedInTimeZone2 = null;
+ byte[] encodedInTimeZone3 = null;
+
+ String issuingDate1 = null;
+ String issuingDate2 = null;
+ String issuingDate3 = null;
+
+ String validFrom1 = null;
+ String validFrom2 = null;
+ String validFrom3 = null;
+
+ String validUntil1 = null;
+ String validUntil2 = null;
+ String validUntil3 = null;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = OpenTicketTimeZoneTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket2 = OpenTicketTimeZoneTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket3 = OpenTicketTimeZoneTestTicketV3.getUicTestTicket();
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ encoded1 = UperEncoder.encode(ticket1);
+ encoded2 = UperEncoder.encode(ticket2);
+ encoded3 = UperEncoder.encode(ticket3);
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone CET
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("CET");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("GMT");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("CET");
+ decode("GMT");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
+ assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IOpenTicket) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IOpenTicket) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IOpenTicket) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
+ }
+
+ private void setValidUntilTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IOpenTicket) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
+ }
+
+
+ /**
+ * Encode in Time Zone
+ */
+ private void encode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+ try {
+ encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
+ encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
+ encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
+ } catch (EncodingFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Decode in Time Zone
+ */
+ private void decode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+
+ try {
+ iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
+ iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
+ iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Encode decode.
+ */
+ private void decodeTestTicketUTC() {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ try {
+ iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
+ iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
+ iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTrainLinkDateTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTrainLinkDateTestV3.java
index ae6a75a..75de2ae 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTrainLinkDateTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketTrainLinkDateTestV3.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.OpenTicketData;
import org.uic.barcode.ticket.api.asn.omv3.TrainLinkType;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
@@ -40,6 +41,8 @@ public class OpenTicketTrainLinkDateTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV1.java
index 0cda25e..2ac8da6 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV1.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IParkingGround;
@@ -85,6 +86,8 @@ public class ParkingTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = ParkingTestTicketV1.getUicTestTicket();
@@ -288,7 +291,7 @@ public class ParkingTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -303,7 +306,7 @@ public class ParkingTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV2.java
index 3833034..b4c2560 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV2.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IParkingGround;
@@ -85,6 +86,8 @@ public class ParkingTimeZoneTestV2 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = ParkingTestTicketV2.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV3.java
index 88c7a6e..cc06303 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/ParkingTimeZoneTestV3.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IParkingGround;
@@ -87,6 +88,8 @@ public class ParkingTimeZoneTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = ParkingTestTicketV3.getUicTestTicket();
@@ -290,7 +293,7 @@ public class ParkingTimeZoneTestV3 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -305,7 +308,7 @@ public class ParkingTimeZoneTestV3 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java
index 6b73221..9dc3bb5 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/PassComplexTestV3.java
@@ -7,6 +7,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.BoardingOrArrivalType;
import org.uic.barcode.ticket.api.asn.omv3.PassData;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
@@ -35,6 +36,8 @@ public class PassComplexTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java
index e7aeae8..d9c7d61 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV1.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IPass;
@@ -132,6 +133,8 @@ public class PassTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = PassTimeZoneTestTicketCase1V1.getUicTestTicket();
@@ -431,7 +434,7 @@ public class PassTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -446,7 +449,7 @@ public class PassTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java
index decc26b..6b71547 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV2.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IPass;
@@ -89,6 +90,8 @@ public class PassTimeZoneTestV2 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = PassTimeZoneTestTicketV2.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV3.java
index d8ea9f3..a838f3f 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/PassTimeZoneTestV3.java
@@ -1,347 +1,350 @@
-package org.uic.barcode.ticket.api.test;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
-import org.uic.barcode.ticket.api.spec.IPass;
-import org.uic.barcode.ticket.api.spec.IUicRailTicket;
-import org.uic.barcode.ticket.api.test.testtickets.PassTimeZoneTestTicketV3;
-import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
-import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
-import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
-import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
-
-
-/**
- * The Class FipTimeZoneTestV2.
- *
- *
- *
- */
-public class PassTimeZoneTestV3 {
-
- /** The low level encoded test ticket test case 1 . */
- private byte[] encoded1 = null;
-
- /** The low level encoded test ticket test case 2 . */
- private byte[] encoded2 = null;
-
- /** The low level encoded test ticket test case 3 . */
- private byte[] encoded3 = null;
-
- /** The decoder. */
- Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
-
- /** The encoder. */
- Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
-
- /** The API ticket low level encoded for case 1. */
- IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
-
- /** The API ticket low level encoded for case 2. */
- IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
-
- /** The API ticket low level encoded for case 3. */
- IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
-
-
- /** The ticket decoded 1. */
- IUicRailTicket iTicketDecodedCase1 = null;
-
- /** The i ticket decoded 2. */
- IUicRailTicket iTicketDecodedCase2 = null;
-
- /** The i ticket decoded 3. */
- IUicRailTicket iTicketDecodedCase3 = null;
-
- byte[] encodedInTimeZone1 = null;
- byte[] encodedInTimeZone2 = null;
- byte[] encodedInTimeZone3 = null;
-
- String issuingDate1 = null;
- String issuingDate2 = null;
- String issuingDate3 = null;
-
- String validFrom1 = null;
- String validFrom2 = null;
- String validFrom3 = null;
-
- String validUntil1 = null;
- String validUntil2 = null;
- String validUntil3 = null;
-
- String activationDate1 = null;
- String activationDate2 = null;
- String activationDate3 = null;
-
- TimeZone defaulttimeZone = null;
-
- /**
- * Prepare tickets.
- */
- @Before public void prepare() {
-
- defaulttimeZone = TimeZone.getDefault();
-
- UicRailTicketData ticket1 = PassTimeZoneTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket2 = PassTimeZoneTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket3 = PassTimeZoneTestTicketV3.getUicTestTicket();
-
- //encode in UTC time zone
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
-
- encoded1 = UperEncoder.encode(ticket1);
- encoded2 = UperEncoder.encode(ticket2);
- encoded3 = UperEncoder.encode(ticket3);
-
- }
-
- /**
- * clean up
- */
- @After public void resetTimeZone() {
- TimeZone.setDefault(defaulttimeZone);
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone CET
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("CET");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("GMT");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- }
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromTo("2021.03.14-00:00");
- setValidUntilTo("2021.03.24-23:59");
- setActivatedDayTo("2021.03.14-00:00");
-
- encode("CET");
- decode("GMT");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
- assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
-
- assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- assert(validUntil1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntil2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntil3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
-
- assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- }
-
- private void decodedDateToStrings() {
-
- issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
- issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
- issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
-
- validFrom1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
- validFrom2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
- validFrom3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
-
- validUntil1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntil2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntil3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
-
- activationDate1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
- activationDate2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
- activationDate3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
-
- }
-
-
- private void setActivatedDayTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
- ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
-
- }
-
- private void setValidFromTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
- ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
- ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
- }
-
- private void setValidUntilTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
- ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
- ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
- }
-
-
- /**
- * Encode in Time Zone
- */
- private void encode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
- try {
- encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
- encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
- encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
- } catch (EncodingFormatException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Decode in Time Zone
- */
- private void decode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
-
- try {
- iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
- iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
- iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * Encode decode.
- */
- private void decodeTestTicketUTC() {
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- try {
- iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
- iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
- iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-}
+package org.uic.barcode.ticket.api.test;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IPass;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.PassTimeZoneTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class FipTimeZoneTestV2.
+ *
+ *
+ *
+ */
+public class PassTimeZoneTestV3 {
+
+ /** The low level encoded test ticket test case 1 . */
+ private byte[] encoded1 = null;
+
+ /** The low level encoded test ticket test case 2 . */
+ private byte[] encoded2 = null;
+
+ /** The low level encoded test ticket test case 3 . */
+ private byte[] encoded3 = null;
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+ /** The API ticket low level encoded for case 2. */
+ IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
+
+ /** The API ticket low level encoded for case 3. */
+ IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ /** The i ticket decoded 2. */
+ IUicRailTicket iTicketDecodedCase2 = null;
+
+ /** The i ticket decoded 3. */
+ IUicRailTicket iTicketDecodedCase3 = null;
+
+ byte[] encodedInTimeZone1 = null;
+ byte[] encodedInTimeZone2 = null;
+ byte[] encodedInTimeZone3 = null;
+
+ String issuingDate1 = null;
+ String issuingDate2 = null;
+ String issuingDate3 = null;
+
+ String validFrom1 = null;
+ String validFrom2 = null;
+ String validFrom3 = null;
+
+ String validUntil1 = null;
+ String validUntil2 = null;
+ String validUntil3 = null;
+
+ String activationDate1 = null;
+ String activationDate2 = null;
+ String activationDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = PassTimeZoneTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket2 = PassTimeZoneTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket3 = PassTimeZoneTestTicketV3.getUicTestTicket();
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ encoded1 = UperEncoder.encode(ticket1);
+ encoded2 = UperEncoder.encode(ticket2);
+ encoded3 = UperEncoder.encode(ticket3);
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone CET
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("CET");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("GMT");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ }
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromTo("2021.03.14-00:00");
+ setValidUntilTo("2021.03.24-23:59");
+ setActivatedDayTo("2021.03.14-00:00");
+
+ encode("CET");
+ decode("GMT");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
+ assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
+
+ assert(validFrom1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFrom3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(validUntil1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntil2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntil3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+
+ assert(activationDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(activationDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFrom1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFrom3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntil1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntil3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+ activationDate1 = ((IPass) iTicketDecodedCase1.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate2 = ((IPass) iTicketDecodedCase2.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+ activationDate3 = ((IPass) iTicketDecodedCase3.getDocumentData().iterator().next()).getActivatedDays().iterator().next().toString();
+
+ }
+
+
+ private void setActivatedDayTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().clear();
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).getActivatedDays().add(date);
+
+ }
+
+ private void setValidFromTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
+ }
+
+ private void setValidUntilTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IPass) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IPass) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IPass) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
+ }
+
+
+ /**
+ * Encode in Time Zone
+ */
+ private void encode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+ try {
+ encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
+ encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
+ encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
+ } catch (EncodingFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Decode in Time Zone
+ */
+ private void decode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+
+ try {
+ iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
+ iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
+ iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Encode decode.
+ */
+ private void decodeTestTicketUTC() {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ try {
+ iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
+ iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
+ iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/PassTrainValidityTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/PassTrainValidityTestV3.java
index 2e78ef3..3691a69 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/PassTrainValidityTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/PassTrainValidityTestV3.java
@@ -10,6 +10,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv3.BoardingOrArrivalType;
import org.uic.barcode.ticket.api.asn.omv3.PassData;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
@@ -38,6 +39,8 @@ public class PassTrainValidityTestV3 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//encode in UTC time zone
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java
index 5bf78cb..3fb9460 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV1.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IReservation;
@@ -85,6 +86,8 @@ public class ReservationTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = ReservationTestTicketV1.getUicTestTicket();
@@ -288,7 +291,7 @@ public class ReservationTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -303,7 +306,7 @@ public class ReservationTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java
index 34d3bc2..72e7313 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV2.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IReservation;
@@ -85,6 +86,8 @@ public class ReservationTimeZoneTestV2 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = ReservationTestTicketV2.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV3.java
index 3eb43e1..e46402a 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/ReservationTimeZoneTestV3.java
@@ -1,314 +1,317 @@
-package org.uic.barcode.ticket.api.test;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
-import org.uic.barcode.ticket.api.spec.IReservation;
-import org.uic.barcode.ticket.api.spec.IUicRailTicket;
-import org.uic.barcode.ticket.api.test.testtickets.ReservationTestTicketV3;
-import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
-import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
-import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
-import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
-
-
-/**
- * The Class FipTimeZoneTestV3.
- *
- *
- *
- */
-public class ReservationTimeZoneTestV3 {
-
- /** The low level encoded test ticket test case 1 . */
- private byte[] encoded1 = null;
-
- /** The low level encoded test ticket test case 2 . */
- private byte[] encoded2 = null;
-
- /** The low level encoded test ticket test case 3 . */
- private byte[] encoded3 = null;
-
- /** The decoder. */
- Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
-
- /** The encoder. */
- Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
-
- /** The API ticket low level encoded for case 1. */
- IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
-
- /** The API ticket low level encoded for case 2. */
- IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
-
- /** The API ticket low level encoded for case 3. */
- IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
-
-
- /** The ticket decoded 1. */
- IUicRailTicket iTicketDecodedCase1 = null;
-
- /** The i ticket decoded 2. */
- IUicRailTicket iTicketDecodedCase2 = null;
-
- /** The i ticket decoded 3. */
- IUicRailTicket iTicketDecodedCase3 = null;
-
- byte[] encodedInTimeZone1 = null;
- byte[] encodedInTimeZone2 = null;
- byte[] encodedInTimeZone3 = null;
-
- String issuingDate1 = null;
- String issuingDate2 = null;
- String issuingDate3 = null;
-
- String departureDate1 = null;
- String departureDate2 = null;
- String departureDate3 = null;
-
- String arrivalDate1 = null;
- String arrivalDate2 = null;
- String arrivalDate3 = null;
-
- TimeZone defaulttimeZone = null;
-
- /**
- * Prepare tickets.
- */
- @Before public void prepare() {
-
- defaulttimeZone = TimeZone.getDefault();
-
- UicRailTicketData ticket1 = ReservationTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket2 = ReservationTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket3 = ReservationTestTicketV3.getUicTestTicket();
-
- //encode in UTC time zone
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
-
- encoded1 = UperEncoder.encode(ticket1);
- encoded2 = UperEncoder.encode(ticket2);
- encoded3 = UperEncoder.encode(ticket3);
-
- }
-
- /**
- * clean up
- */
- @After public void resetTimeZone() {
- TimeZone.setDefault(defaulttimeZone);
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone CET
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setdepartureDateTo("2021.03.14-00:00");
- setarrivalDateTo("2021.03.24-23:59");
-
- encode("CET");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(arrivalDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
-
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setdepartureDateTo("2021.03.14-00:00");
- setarrivalDateTo("2021.03.24-23:59");
-
- encode("GMT");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(arrivalDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
-
- }
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setdepartureDateTo("2021.03.14-00:00");
- setarrivalDateTo("2021.03.24-23:59");
-
- encode("CET");
- decode("GMT");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
- assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
-
- assert(departureDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(departureDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(departureDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- assert(arrivalDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(arrivalDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(arrivalDate3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
-
-
- }
-
- private void decodedDateToStrings() {
-
- issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
- issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
- issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
-
- departureDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getDepartureDate().toString();
- departureDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getDepartureDate().toString();
- departureDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getDepartureDate().toString();
-
- arrivalDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getArrivalDate().toString();
- arrivalDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getArrivalDate().toString();
- arrivalDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getArrivalDate().toString();
-
-
- }
-
-
- private void setdepartureDateTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setDepartureDate(date);
- ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setDepartureDate(date);
- ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setDepartureDate(date);
- }
-
- private void setarrivalDateTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setArrivalDate(date);
- ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setArrivalDate(date);
- ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setArrivalDate(date);
- }
-
-
- /**
- * Encode in Time Zone
- */
- private void encode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
- try {
- encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
- encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
- encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
- } catch (EncodingFormatException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Decode in Time Zone
- */
- private void decode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
-
- try {
- iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
- iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
- iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * Encode decode.
- */
- private void decodeTestTicketUTC() {
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- try {
- iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
- iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
- iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-}
+package org.uic.barcode.ticket.api.test;
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IReservation;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.ReservationTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class FipTimeZoneTestV3.
+ *
+ *
+ *
+ */
+public class ReservationTimeZoneTestV3 {
+
+ /** The low level encoded test ticket test case 1 . */
+ private byte[] encoded1 = null;
+
+ /** The low level encoded test ticket test case 2 . */
+ private byte[] encoded2 = null;
+
+ /** The low level encoded test ticket test case 3 . */
+ private byte[] encoded3 = null;
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+ /** The API ticket low level encoded for case 2. */
+ IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
+
+ /** The API ticket low level encoded for case 3. */
+ IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ /** The i ticket decoded 2. */
+ IUicRailTicket iTicketDecodedCase2 = null;
+
+ /** The i ticket decoded 3. */
+ IUicRailTicket iTicketDecodedCase3 = null;
+
+ byte[] encodedInTimeZone1 = null;
+ byte[] encodedInTimeZone2 = null;
+ byte[] encodedInTimeZone3 = null;
+
+ String issuingDate1 = null;
+ String issuingDate2 = null;
+ String issuingDate3 = null;
+
+ String departureDate1 = null;
+ String departureDate2 = null;
+ String departureDate3 = null;
+
+ String arrivalDate1 = null;
+ String arrivalDate2 = null;
+ String arrivalDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = ReservationTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket2 = ReservationTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket3 = ReservationTestTicketV3.getUicTestTicket();
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ encoded1 = UperEncoder.encode(ticket1);
+ encoded2 = UperEncoder.encode(ticket2);
+ encoded3 = UperEncoder.encode(ticket3);
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone CET
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("2021.03.24-23:59");
+
+ encode("CET");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("2021.03.24-23:59");
+
+ encode("GMT");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(departureDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(arrivalDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+
+ }
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setdepartureDateTo("2021.03.14-00:00");
+ setarrivalDateTo("2021.03.24-23:59");
+
+ encode("CET");
+ decode("GMT");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
+ assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
+
+ assert(departureDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(departureDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(departureDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(arrivalDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(arrivalDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(arrivalDate3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ departureDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getDepartureDate().toString();
+ departureDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getDepartureDate().toString();
+ departureDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getDepartureDate().toString();
+
+ arrivalDate1 = ((IReservation) iTicketDecodedCase1.getDocumentData().iterator().next()).getArrivalDate().toString();
+ arrivalDate2 = ((IReservation) iTicketDecodedCase2.getDocumentData().iterator().next()).getArrivalDate().toString();
+ arrivalDate3 = ((IReservation) iTicketDecodedCase3.getDocumentData().iterator().next()).getArrivalDate().toString();
+
+
+ }
+
+
+ private void setdepartureDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setDepartureDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setDepartureDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setDepartureDate(date);
+ }
+
+ private void setarrivalDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IReservation) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setArrivalDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setArrivalDate(date);
+ ((IReservation) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setArrivalDate(date);
+ }
+
+
+ /**
+ * Encode in Time Zone
+ */
+ private void encode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+ try {
+ encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
+ encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
+ encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
+ } catch (EncodingFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Decode in Time Zone
+ */
+ private void decode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+
+ try {
+ iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
+ iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
+ iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Encode decode.
+ */
+ private void decodeTestTicketUTC() {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ try {
+ iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
+ iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
+ iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java
index aedf569..ac899eb 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV1.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IStationPassage;
@@ -85,6 +86,8 @@ public class StationPassageTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = StationPassageTestTicketV1.getUicTestTicket();
@@ -288,7 +291,7 @@ public class StationPassageTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
}
@@ -303,7 +306,7 @@ public class StationPassageTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java
index e87e968..dffd5a8 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV2.java
@@ -11,6 +11,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IStationPassage;
@@ -85,6 +86,8 @@ public class StationPassageTimeZoneTestV2 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = StationPassageTestTicketV2.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV3.java
index c60225d..b1fb1bc 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/StationPassageTimeZoneTestV3.java
@@ -1,314 +1,316 @@
-package org.uic.barcode.ticket.api.test;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
-import org.uic.barcode.ticket.api.spec.IStationPassage;
-import org.uic.barcode.ticket.api.spec.IUicRailTicket;
-import org.uic.barcode.ticket.api.test.testtickets.StationPassageTestTicketV3;
-import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
-import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
-import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
-import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
-
-
-/**
- * The Class FipTimeZoneTestV3.
- *
- *
- *
- */
-public class StationPassageTimeZoneTestV3 {
-
- /** The low level encoded test ticket test case 1 . */
- private byte[] encoded1 = null;
-
- /** The low level encoded test ticket test case 2 . */
- private byte[] encoded2 = null;
-
- /** The low level encoded test ticket test case 3 . */
- private byte[] encoded3 = null;
-
- /** The decoder. */
- Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
-
- /** The encoder. */
- Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
-
- /** The API ticket low level encoded for case 1. */
- IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
-
- /** The API ticket low level encoded for case 2. */
- IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
-
- /** The API ticket low level encoded for case 3. */
- IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
-
-
- /** The ticket decoded 1. */
- IUicRailTicket iTicketDecodedCase1 = null;
-
- /** The i ticket decoded 2. */
- IUicRailTicket iTicketDecodedCase2 = null;
-
- /** The i ticket decoded 3. */
- IUicRailTicket iTicketDecodedCase3 = null;
-
- byte[] encodedInTimeZone1 = null;
- byte[] encodedInTimeZone2 = null;
- byte[] encodedInTimeZone3 = null;
-
- String issuingDate1 = null;
- String issuingDate2 = null;
- String issuingDate3 = null;
-
- String validFromDate1 = null;
- String validFromDate2 = null;
- String validFromDate3 = null;
-
- String validUntilDate1 = null;
- String validUntilDate2 = null;
- String validUntilDate3 = null;
-
- TimeZone defaulttimeZone = null;
-
- /**
- * Prepare tickets.
- */
- @Before public void prepare() {
-
- defaulttimeZone = TimeZone.getDefault();
-
- UicRailTicketData ticket1 = StationPassageTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket2 = StationPassageTestTicketV3.getUicTestTicket();
- UicRailTicketData ticket3 = StationPassageTestTicketV3.getUicTestTicket();
-
- //encode in UTC time zone
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
-
- encoded1 = UperEncoder.encode(ticket1);
- encoded2 = UperEncoder.encode(ticket2);
- encoded3 = UperEncoder.encode(ticket3);
-
- }
-
- /**
- * clean up
- */
- @After public void resetTimeZone() {
- TimeZone.setDefault(defaulttimeZone);
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone CET
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromDateTo("2021.03.14-00:00");
- setUntilDateTo("2021.03.24-23:59");
-
- encode("CET");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntilDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
-
- }
-
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromDateTo("2021.03.14-00:00");
- setUntilDateTo("2021.03.24-23:59");
-
- encode("GMT");
- decode("CET");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
- assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
-
- assert(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
- assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
-
- assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
- assert(validUntilDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
-
-
- }
-
- /**
- * Test encode test tickets in UTC and decode in CET.
- *
- * @throws IllegalArgumentException the illegal argument exception
- * @throws IllegalAccessException the illegal access exception
- * @throws ParseException
- */
- @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
-
- //get tickets
- decodeTestTicketUTC();
-
- //set the dates in the time zone GMT
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
- iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
- iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
-
- setValidFromDateTo("2021.03.14-00:00");
- setUntilDateTo("2021.03.24-23:59");
-
- encode("CET");
- decode("GMT");
- decodedDateToStrings();
-
- assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
- assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
- assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
-
- assert(validFromDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFromDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
- assert(validFromDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
-
- assert(validUntilDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntilDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
- assert(validUntilDate3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
-
-
- }
-
- private void decodedDateToStrings() {
-
- issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
- issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
- issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
-
- validFromDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
- validFromDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
- validFromDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
-
- validUntilDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntilDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
- validUntilDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
-
-
- }
-
-
- private void setValidFromDateTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
- ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
- ((IStationPassage) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
- }
-
- private void setUntilDateTo(String dateString) throws ParseException {
- DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
- Date date = dateFormat.parse(dateString);
- ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
- ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
- ((IStationPassage) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
- }
-
-
- /**
- * Encode in Time Zone
- */
- private void encode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
- try {
- encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
- encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
- encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
- } catch (EncodingFormatException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Decode in Time Zone
- */
- private void decode(String timeZone) {
- TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
-
- try {
- iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
- iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
- iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-
- /**
- * Encode decode.
- */
- private void decodeTestTicketUTC() {
- TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- try {
- iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
- iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
- iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- }
-
-}
+package org.uic.barcode.ticket.api.test;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.ticket.EncodingFormatException;
+import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
+import org.uic.barcode.ticket.api.spec.IStationPassage;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+import org.uic.barcode.ticket.api.test.testtickets.StationPassageTestTicketV3;
+import org.uic.barcode.ticket.api.utils.Api2AsnEncoder;
+import org.uic.barcode.ticket.api.utils.Api2OpenAsnEncoderV3;
+import org.uic.barcode.ticket.api.utils.Asn2ApiDecoder;
+import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoderV3;
+
+
+/**
+ * The Class FipTimeZoneTestV3.
+ *
+ *
+ *
+ */
+public class StationPassageTimeZoneTestV3 {
+
+ /** The low level encoded test ticket test case 1 . */
+ private byte[] encoded1 = null;
+
+ /** The low level encoded test ticket test case 2 . */
+ private byte[] encoded2 = null;
+
+ /** The low level encoded test ticket test case 3 . */
+ private byte[] encoded3 = null;
+
+ /** The decoder. */
+ Asn2ApiDecoder decoder = new OpenAsn2ApiDecoderV3();
+
+ /** The encoder. */
+ Api2AsnEncoder encoder = new Api2OpenAsnEncoderV3();
+
+ /** The API ticket low level encoded for case 1. */
+ IUicRailTicket iTicketDecodedFromAsn1Case1 = null;
+
+ /** The API ticket low level encoded for case 2. */
+ IUicRailTicket iTicketDecodedFromAsn1Case2 = null;
+
+ /** The API ticket low level encoded for case 3. */
+ IUicRailTicket iTicketDecodedFromAsn1Case3 = null;
+
+
+ /** The ticket decoded 1. */
+ IUicRailTicket iTicketDecodedCase1 = null;
+
+ /** The i ticket decoded 2. */
+ IUicRailTicket iTicketDecodedCase2 = null;
+
+ /** The i ticket decoded 3. */
+ IUicRailTicket iTicketDecodedCase3 = null;
+
+ byte[] encodedInTimeZone1 = null;
+ byte[] encodedInTimeZone2 = null;
+ byte[] encodedInTimeZone3 = null;
+
+ String issuingDate1 = null;
+ String issuingDate2 = null;
+ String issuingDate3 = null;
+
+ String validFromDate1 = null;
+ String validFromDate2 = null;
+ String validFromDate3 = null;
+
+ String validUntilDate1 = null;
+ String validUntilDate2 = null;
+ String validUntilDate3 = null;
+
+ TimeZone defaulttimeZone = null;
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+
+ UicRailTicketData ticket1 = StationPassageTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket2 = StationPassageTestTicketV3.getUicTestTicket();
+ UicRailTicketData ticket3 = StationPassageTestTicketV3.getUicTestTicket();
+
+ //encode in UTC time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+
+ encoded1 = UperEncoder.encode(ticket1);
+ encoded2 = UperEncoder.encode(ticket2);
+ encoded3 = UperEncoder.encode(ticket3);
+
+ }
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone CET
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("2021.03.24-23:59");
+
+ encode("CET");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+
+ }
+
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testGMTCETencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("2021.03.24-23:59");
+
+ encode("GMT");
+ decode("CET");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 13:30:00 CET 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 01:30:00 CET 2021" ));
+ assert(issuingDate3.equals("Thu Mar 04 00:30:00 CET 2021" ));
+
+ assert(validFromDate1.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 CET 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 CET 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 CET 2021" ));
+ assert(validUntilDate3.equals("Wed Mar 24 23:59:00 CET 2021" ));
+
+
+ }
+
+ /**
+ * Test encode test tickets in UTC and decode in CET.
+ *
+ * @throws IllegalArgumentException the illegal argument exception
+ * @throws IllegalAccessException the illegal access exception
+ * @throws ParseException
+ */
+ @Test public void testCETGMTencoding() throws IllegalArgumentException, IllegalAccessException, ParseException {
+
+ //get tickets
+ decodeTestTicketUTC();
+
+ //set the dates in the time zone GMT
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ iTicketDecodedFromAsn1Case1.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-12:30" ));
+ iTicketDecodedFromAsn1Case2.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.04-00:30" ));
+ iTicketDecodedFromAsn1Case3.getIssuerDetails().setIssuingDate(new SimpleDateFormat( "yyyy.MM.dd-HH:mm" ).parse( "2021.03.03-23:30" ));
+
+ setValidFromDateTo("2021.03.14-00:00");
+ setUntilDateTo("2021.03.24-23:59");
+
+ encode("CET");
+ decode("GMT");
+ decodedDateToStrings();
+
+ assert(issuingDate1.equals("Thu Mar 04 12:30:00 GMT 2021" ));
+ assert(issuingDate2.equals("Thu Mar 04 00:30:00 GMT 2021" ));
+ assert(issuingDate3.equals("Wed Mar 03 23:30:00 GMT 2021" ));
+
+ assert(validFromDate1.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFromDate2.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+ assert(validFromDate3.equals("Sun Mar 14 00:00:00 GMT 2021" ));
+
+ assert(validUntilDate1.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntilDate2.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+ assert(validUntilDate3.equals("Wed Mar 24 23:59:00 GMT 2021" ));
+
+
+ }
+
+ private void decodedDateToStrings() {
+
+ issuingDate1 = iTicketDecodedCase1.getIssuerDetails().getIssuingDate().toString();
+ issuingDate2 = iTicketDecodedCase2.getIssuerDetails().getIssuingDate().toString();
+ issuingDate3 = iTicketDecodedCase3.getIssuerDetails().getIssuingDate().toString();
+
+ validFromDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFromDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidFrom().toString();
+ validFromDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidFrom().toString();
+
+ validUntilDate1 = ((IStationPassage) iTicketDecodedCase1.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntilDate2 = ((IStationPassage) iTicketDecodedCase2.getDocumentData().iterator().next()).getValidUntil().toString();
+ validUntilDate3 = ((IStationPassage) iTicketDecodedCase3.getDocumentData().iterator().next()).getValidUntil().toString();
+
+
+ }
+
+
+ private void setValidFromDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidFrom(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidFrom(date);
+ }
+
+ private void setUntilDateTo(String dateString) throws ParseException {
+ DateFormat dateFormat = new SimpleDateFormat( "yyyy.MM.dd-HH:mm" );
+ Date date = dateFormat.parse(dateString);
+ ((IStationPassage) iTicketDecodedFromAsn1Case1.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case2.getDocumentData().iterator().next()).setValidUntil(date);
+ ((IStationPassage) iTicketDecodedFromAsn1Case3.getDocumentData().iterator().next()).setValidUntil(date);
+ }
+
+
+ /**
+ * Encode in Time Zone
+ */
+ private void encode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+ try {
+ encodedInTimeZone1 = encoder.encode(iTicketDecodedFromAsn1Case1);
+ encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
+ encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
+ } catch (EncodingFormatException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Decode in Time Zone
+ */
+ private void decode(String timeZone) {
+ TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
+
+ try {
+ iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
+ iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
+ iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ /**
+ * Encode decode.
+ */
+ private void decodeTestTicketUTC() {
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ try {
+ iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
+ iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
+ iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java
index cb20d79..4a7759a 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeOpenTicketTestV1.java
@@ -2,11 +2,12 @@ package org.uic.barcode.ticket.api.test;
import static org.junit.Assert.assertEquals;
-import java.io.IOException;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -17,6 +18,9 @@ import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
public class UperEncodeOpenTicketTestV1 {
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testDecodeTicket() throws IllegalArgumentException, IllegalAccessException {
@@ -31,17 +35,15 @@ public class UperEncodeOpenTicketTestV1 {
IUicRailTicket iTicket = null;
try {
iTicket = decoder.decodeFromAsn(encoded);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (Exception e) {
+ assert(false);
}
Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
try {
encoded = encoder.encode(iTicket);
} catch (EncodingFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ assert(false);
}
assert(decodedTicket != null);
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java
index 7436f5d..5d4a7e9 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodePassTestV1.java
@@ -2,11 +2,12 @@ package org.uic.barcode.ticket.api.test;
import static org.junit.Assert.assertEquals;
-import java.io.IOException;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
@@ -17,6 +18,9 @@ import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
public class UperEncodePassTestV1 {
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testDecodeTicket() throws IllegalArgumentException, IllegalAccessException {
UicRailTicketData ticket = PassTestTicketV1.getUicTestTicket();
@@ -30,17 +34,15 @@ public class UperEncodePassTestV1 {
IUicRailTicket iTicket = null;
try {
iTicket = decoder.decodeFromAsn(encoded);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ } catch (Exception e) {
+ assert(false);
}
Api2OpenAsnEncoder encoder = new Api2OpenAsnEncoder();
try {
encoded = encoder.encode(iTicket);
} catch (EncodingFormatException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ assert(false);
}
assert(decodedTicket != null);
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java
index 0a4b04c..4369d87 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketLinkTestV1.java
@@ -2,11 +2,12 @@ package org.uic.barcode.ticket.api.test;
import static org.junit.Assert.assertEquals;
-import java.io.IOException;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.ILinkMode;
import org.uic.barcode.ticket.api.spec.ITicketLink;
@@ -19,7 +20,9 @@ import org.uic.barcode.ticket.api.utils.OpenAsn2ApiDecoder;
public class UperEncodeTicketLinkTestV1 {
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncodeTicket() throws IllegalArgumentException, IllegalAccessException {
@@ -60,7 +63,7 @@ public class UperEncodeTicketLinkTestV1 {
IUicRailTicket uicTicket = null;
try {
uicTicket = decoder.decodeFromAsn(decodedTicket);
- } catch (IOException e) {
+ } catch (Exception e) {
assert (false);
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java
index cf8eec6..fd59308 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeTicketTestV1.java
@@ -4,8 +4,10 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.test.testtickets.SimpleUicTestTicket;
@@ -85,7 +87,9 @@ public class UperEncodeTicketTestV1 {
</pre>
*/
-
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncodeTicket() throws IllegalArgumentException, IllegalAccessException {
UicRailTicketData ticket = SimpleUicTestTicket.getUicTestTicket();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeUICTicketExtensionTest.java b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeUICTicketExtensionTest.java
index da59f67..6dda463 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeUICTicketExtensionTest.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/UperEncodeUICTicketExtensionTest.java
@@ -4,10 +4,12 @@ import static org.junit.Assert.assertEquals;
import java.util.logging.Level;
+import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData;
@@ -35,20 +37,7 @@ public class UperEncodeUICTicketExtensionTest {
}
}
-Encoding to the file 'data.uper' using PER UNALIGNED encoding rule...
-TestRecord SEQUENCE [fieldcount (not encoded) = 1]
- extensionList SEQUENCE OF [count = 2]
- ExtensionData SEQUENCE [fieldcount (not encoded) = 2]
- extensionId IA5String [length = 1.0]
- "1"
- extensionData OCTET STRING [length = 2.0]
- 0x82da
- ExtensionData SEQUENCE [fieldcount (not encoded) = 2]
- extensionId IA5String [length = 1.0]
- "2"
- extensionData OCTET STRING [length = 2.0]
- 0x83da
-Total encoded length = 10.7
+
Encoded successfully in 11 bytes:
8100B102 82DA0164 0507B4
</pre>
@@ -66,6 +55,9 @@ Encoded successfully in 11 bytes:
}
}
+ @Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+ }
@Test public void testEncodeTicket() throws IllegalArgumentException, IllegalAccessException {
TestRecord ticket = new TestRecord();
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV1.java
index 423908b..995845a 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV1.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV1.java
@@ -1,6 +1,5 @@
package org.uic.barcode.ticket.api.test;
-import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -11,6 +10,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IVoucher;
@@ -85,6 +85,8 @@ public class VoucherTimeZoneTestV1 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = VoucherTestTicketV1.getUicTestTicket();
@@ -274,7 +276,7 @@ public class VoucherTimeZoneTestV1 {
encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
} catch (EncodingFormatException e) {
- e.printStackTrace();
+ assert(false);
}
}
@@ -288,8 +290,8 @@ public class VoucherTimeZoneTestV1 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ assert(false);
}
}
@@ -303,7 +305,7 @@ public class VoucherTimeZoneTestV1 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
+ } catch (Exception e) {
e.printStackTrace();
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV2.java b/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV2.java
index c7c2512..44645e2 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV2.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV2.java
@@ -1,6 +1,5 @@
package org.uic.barcode.ticket.api.test;
-import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -11,6 +10,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv2.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IVoucher;
@@ -87,6 +87,8 @@ public class VoucherTimeZoneTestV2 {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
UicRailTicketData ticket1 = VoucherTestTicketV2.getUicTestTicket();
@@ -276,7 +278,7 @@ public class VoucherTimeZoneTestV2 {
encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
} catch (EncodingFormatException e) {
- e.printStackTrace();
+ assert(false);
}
}
@@ -290,8 +292,8 @@ public class VoucherTimeZoneTestV2 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ assert(false);
}
}
@@ -305,8 +307,8 @@ public class VoucherTimeZoneTestV2 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ assert(false);
}
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV3.java b/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV3.java
index 22b17c2..20fa455 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/VoucherTimeZoneTestV3.java
@@ -1,6 +1,5 @@
package org.uic.barcode.ticket.api.test;
-import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -11,6 +10,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.ticket.api.asn.omv3.UicRailTicketData;
import org.uic.barcode.ticket.api.spec.IVoucher;
@@ -86,6 +86,8 @@ public class VoucherTimeZoneTestV3 {
* Prepare tickets.
*/
@Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
defaulttimeZone = TimeZone.getDefault();
@@ -276,7 +278,7 @@ public class VoucherTimeZoneTestV3 {
encodedInTimeZone2 = encoder.encode(iTicketDecodedFromAsn1Case2);
encodedInTimeZone3 = encoder.encode(iTicketDecodedFromAsn1Case3);
} catch (EncodingFormatException e) {
- e.printStackTrace();
+ assert(false);
}
}
@@ -290,8 +292,8 @@ public class VoucherTimeZoneTestV3 {
iTicketDecodedCase1 = decoder.decodeFromAsn(encodedInTimeZone1);
iTicketDecodedCase2 = decoder.decodeFromAsn(encodedInTimeZone2);
iTicketDecodedCase3 = decoder.decodeFromAsn(encodedInTimeZone3);
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ assert(false);
}
}
@@ -305,8 +307,8 @@ public class VoucherTimeZoneTestV3 {
iTicketDecodedFromAsn1Case1 = decoder.decodeFromAsn(encoded1);
iTicketDecodedFromAsn1Case2 = decoder.decodeFromAsn(encoded2);
iTicketDecodedFromAsn1Case3 = decoder.decodeFromAsn(encoded3);
- } catch (IOException e) {
- e.printStackTrace();
+ } catch (Exception e) {
+ assert(false);
}
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/AllElementsTestTicketV1.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/AllElementsTestTicketV1.java
new file mode 100644
index 0000000..edaa0cc
--- /dev/null
+++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/AllElementsTestTicketV1.java
@@ -0,0 +1,1409 @@
+package org.uic.barcode.ticket.api.test.testtickets;
+
+import java.util.List;
+
+import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringUTF8;
+import org.uic.barcode.asn1.datatypesimpl.SequenceOfUnrestrictedLong;
+import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDeltaCoordinates;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfRegionalValidityType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfRegisteredLuggageType;
+import org.uic.barcode.ticket.api.asn.omv1.DeltaCoordinates;
+import org.uic.barcode.ticket.api.asn.omv1.BerthDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.BerthTypeType;
+import org.uic.barcode.ticket.api.asn.omv1.CarCarriageReservationData;
+import org.uic.barcode.ticket.api.asn.omv1.CardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.CodeTableType;
+import org.uic.barcode.ticket.api.asn.omv1.CompartmentDetailsType;
+import org.uic.barcode.ticket.api.asn.omv1.CompartmentGenderType;
+import org.uic.barcode.ticket.api.asn.omv1.CompartmentPositionType;
+import org.uic.barcode.ticket.api.asn.omv1.ConfirmationTypeType;
+import org.uic.barcode.ticket.api.asn.omv1.ControlData;
+import org.uic.barcode.ticket.api.asn.omv1.CountermarkData;
+import org.uic.barcode.ticket.api.asn.omv1.CustomerCardData;
+import org.uic.barcode.ticket.api.asn.omv1.CustomerStatusType;
+import org.uic.barcode.ticket.api.asn.omv1.DelayConfirmation;
+import org.uic.barcode.ticket.api.asn.omv1.DocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.FIPTicketData;
+import org.uic.barcode.ticket.api.asn.omv1.GenderType;
+import org.uic.barcode.ticket.api.asn.omv1.GeoCoordinateSystemType;
+import org.uic.barcode.ticket.api.asn.omv1.GeoCoordinateType;
+import org.uic.barcode.ticket.api.asn.omv1.GeoUnitType;
+import org.uic.barcode.ticket.api.asn.omv1.HemisphereLatitudeType;
+import org.uic.barcode.ticket.api.asn.omv1.HemisphereLongitudeType;
+import org.uic.barcode.ticket.api.asn.omv1.IncludedOpenTicketType;
+import org.uic.barcode.ticket.api.asn.omv1.IssuingData;
+import org.uic.barcode.ticket.api.asn.omv1.LineType;
+import org.uic.barcode.ticket.api.asn.omv1.LinkMode;
+import org.uic.barcode.ticket.api.asn.omv1.LoadingDeckType;
+import org.uic.barcode.ticket.api.asn.omv1.LuggageRestrictionType;
+import org.uic.barcode.ticket.api.asn.omv1.OpenTicketData;
+import org.uic.barcode.ticket.api.asn.omv1.ParkingGroundData;
+import org.uic.barcode.ticket.api.asn.omv1.PassData;
+import org.uic.barcode.ticket.api.asn.omv1.PassengerType;
+import org.uic.barcode.ticket.api.asn.omv1.PlacesType;
+import org.uic.barcode.ticket.api.asn.omv1.PolygoneType;
+import org.uic.barcode.ticket.api.asn.omv1.PriceTypeType;
+import org.uic.barcode.ticket.api.asn.omv1.RegionalValidityType;
+import org.uic.barcode.ticket.api.asn.omv1.RegisteredLuggageType;
+import org.uic.barcode.ticket.api.asn.omv1.ReservationData;
+import org.uic.barcode.ticket.api.asn.omv1.ReturnRouteDescriptionType;
+import org.uic.barcode.ticket.api.asn.omv1.RoofRackType;
+import org.uic.barcode.ticket.api.asn.omv1.RouteSectionType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfActivatedDays;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfBerthDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCardReferenceType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCountries;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfDocumentData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfExtensionData;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfIncludedOpenTicketType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfPlaceNum;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfServiceBrands;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTariffType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTimeRangeType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerId;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfTravelerType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfValidityPeriodType;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfVatDetail;
+import org.uic.barcode.ticket.api.asn.omv1.SequenceOfViaStationType;
+import org.uic.barcode.ticket.api.asn.omv1.SeriesDetailType;
+import org.uic.barcode.ticket.api.asn.omv1.ServiceType;
+import org.uic.barcode.ticket.api.asn.omv1.StationPassageData;
+import org.uic.barcode.ticket.api.asn.omv1.TariffType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketDetailData;
+import org.uic.barcode.ticket.api.asn.omv1.TicketLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.TicketType;
+import org.uic.barcode.ticket.api.asn.omv1.TimeRangeType;
+import org.uic.barcode.ticket.api.asn.omv1.TokenType;
+import org.uic.barcode.ticket.api.asn.omv1.TrainLinkType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelClassType;
+import org.uic.barcode.ticket.api.asn.omv1.TravelerData;
+import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
+import org.uic.barcode.ticket.api.asn.omv1.ValidityPeriodDetailType;
+import org.uic.barcode.ticket.api.asn.omv1.ValidityPeriodType;
+import org.uic.barcode.ticket.api.asn.omv1.VatDetailType;
+import org.uic.barcode.ticket.api.asn.omv1.ViaStationType;
+import org.uic.barcode.ticket.api.asn.omv1.VoucherData;
+import org.uic.barcode.ticket.api.asn.omv1.ZoneType;
+
+public class AllElementsTestTicketV1 {
+
+
+
+
+
+
+
+ public static UicRailTicketData getUicTestTicket() {
+ UicRailTicketData ticket = new UicRailTicketData();
+ populateTicket(ticket);
+ return ticket;
+ }
+
+
+ private static void populateTicket(UicRailTicketData ticket) {
+
+ ticket.setControlDetail(new ControlData());
+ populateControlDetail(ticket.getControlDetail());
+
+ ticket.setExtension(new SequenceOfExtensionData());
+ populateExtension(ticket.getExtension());
+
+ ticket.setIssuingDetail(new IssuingData());
+ populateIssuingData(ticket.getIssuingDetail());
+
+ ticket.setTravelerDetail(new TravelerData());
+ populateTravelerData(ticket.getTravelerDetail());
+
+ ticket.setTransportDocument(new SequenceOfDocumentData());
+
+ DocumentData d1 = new DocumentData();
+ populateReservation(d1);
+ ticket.getTransportDocument().add(d1);
+
+ DocumentData d2 = new DocumentData();
+ populateCarCarriage(d2);
+ ticket.getTransportDocument().add(d2);
+
+ DocumentData d3 = new DocumentData();
+ populateOpenTicket(d3);
+ ticket.getTransportDocument().add(d3);
+
+ DocumentData d4 = new DocumentData();
+ populatePass(d4);
+ ticket.getTransportDocument().add(d4);
+
+ DocumentData d5 = new DocumentData();
+ populateVoucher(d5);
+ ticket.getTransportDocument().add(d5);
+
+ DocumentData d6 = new DocumentData();
+ populateCustomerCard(d6);
+ ticket.getTransportDocument().add(d6);
+
+ DocumentData d7 = new DocumentData();
+ populateCounterMark(d7);
+ ticket.getTransportDocument().add(d7);
+
+ DocumentData d8 = new DocumentData();
+ populateParking(d8);
+ ticket.getTransportDocument().add(d8);
+
+ DocumentData d9 = new DocumentData();
+ populateFip(d9);
+ ticket.getTransportDocument().add(d9);
+
+ DocumentData d10 = new DocumentData();
+ populateStationPassage(d10);
+ ticket.getTransportDocument().add(d10);
+
+ DocumentData d11 = new DocumentData();
+ populateExtensionDocument(d11);
+ ticket.getTransportDocument().add(d11);
+
+ DocumentData d12 = new DocumentData();
+ populateDelay(d12);
+ ticket.getTransportDocument().add(d12);
+
+ }
+
+ private static void populateDelay(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ DelayConfirmation dc = new DelayConfirmation();
+ d.getTicket().setDelayConfirmation(dc);
+
+ dc.setTrainNum(Asn1BigInteger.toAsn1(100L));
+ dc.setTrainIA5("100");
+ dc.setPlannedArrivalYear(2022L);
+ dc.setPlannedArrivalDay(12L);
+ dc.setPlannedArrivalTime(1000L);
+ dc.setDepartureUTCOffset(30L);
+ dc.setReferenceIA5("ABDJ12345");
+ dc.setReferenceNum(12345L);
+
+ dc.setStationCodeTable(CodeTableType.stationUIC);
+ dc.setStationNum(8000001L);
+ dc.setStationIA5("DJE");
+ dc.setDelay(31L);
+ dc.setTrainCancelled(false);
+ dc.setConfirmationType(ConfirmationTypeType.travelerDelayConfirmation);
+
+ dc.setAffectedTickets(new SequenceOfTicketLinkType());
+ TicketLinkType tl = new TicketLinkType();
+ dc.getAffectedTickets().add(tl);
+
+ tl.setReferenceIA5("KDJET");
+ tl.setReferenceNum(801234567890L);
+ tl.setIssuerName("XYZ");
+ tl.setIssuerPNR("LDWDUR45");
+ tl.setProductOwnerNum(1080L);
+ tl.setProductOwnerIA5("IEFHU");
+ tl.setTicketType(TicketType.openTicket);
+ tl.setLinkMode(LinkMode.issuedTogether);
+
+ dc.setInfoText("delay confirmation");
+ dc.setExtension(new ExtensionData());
+ dc.getExtension().setExtensionId("1");
+ dc.getExtension().setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+
+ }
+
+
+ private static void populateExtensionDocument(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ d.getTicket().setExtension(new ExtensionData());
+ d.getTicket().getExtension().setExtensionId("1");
+ d.getTicket().getExtension().setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+
+ }
+
+
+ private static void populateStationPassage(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ StationPassageData s = new StationPassageData();
+ d.getTicket().setStationPassage(s);
+
+ s.setExtension(new ExtensionData());
+ s.getExtension().setExtensionId("1");
+ s.getExtension().setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+
+ s.setReferenceIA5("810123456789");
+ s.setReferenceNum(Asn1BigInteger.toAsn1(810123456789L));
+ s.setProductOwnerNum(23456L);
+ s.setProductOwnerIA5("23456");
+ s.setProductIdNum(15535L);
+ s.setProductIdIA5("23456");
+
+ s.setProductName("passage");
+ s.setStationCodeTable(CodeTableType.stationUIC);
+ s.setStationNum(new SequenceOfUnrestrictedLong());
+ s.getStationNum().add(8200001L);
+ s.setStationIA5(new SequenceOfStringIA5());
+ s.getStationIA5().add("AMS");
+ s.setStationNameUTF8(new SequenceOfStringUTF8());
+ s.getStationNameUTF8().add("Amsterdam");
+ s.setAreaCodeNum(new SequenceOfUnrestrictedLong());
+ s.getAreaCodeNum().add(8200001L);
+ s.setAreaCodeIA5(new SequenceOfStringIA5());
+ s.getAreaCodeIA5().add("AMS");
+ s.setAreaNameUTF8(new SequenceOfStringUTF8());
+ s.getAreaNameUTF8().add("Amsterdam");
+ s.setValidFromDay(5L);
+ s.setValidFromTime(0L);
+ s.setValidFromUTCOffset(1L);
+ s.setValidUntilDay(5L);
+ s.setValidUntilTime(1000L);
+ s.setValidUntilUTCOffset(1L);
+ s.setNumberOfDaysValid(5L);
+
+ }
+
+
+ private static void populateFip(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ FIPTicketData f = new FIPTicketData();
+ d.getTicket().setFipTicket(f);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ f.setExtension(e1);
+
+ f.setReferenceIA5("810123456789");
+ f.setReferenceNum(Asn1BigInteger.toAsn1(810123456789L));
+ f.setProductOwnerNum(23456L);
+ f.setProductOwnerIA5("23456");
+ f.setProductIdNum(15535L);
+ f.setProductIdIA5("23456");
+
+
+ f.setValidFromDay( 2L);
+ f.setValidUntilDay(5L);
+ f.setActivatedDay(new SequenceOfActivatedDays());
+ f.getActivatedDay().add(1L);
+ f.getActivatedDay().add(13L);
+ f.getActivatedDay().add(14L);
+ f.getActivatedDay().add(15L);
+
+ f.setCarrierNum(new SequenceOfCarrierNum());
+ f.getCarrierNum().add(1080L);
+ f.getCarrierNum().add(1181L);
+
+ f.setCarrierIA5(new SequenceOfStringIA5());
+ f.getCarrierIA5().add("1080");
+ f.getCarrierIA5().add("1181");
+
+ f.setNumberOfTravelDays(8L);
+ f.setIncludesSupplements(true);
+ f.setClassCode(TravelClassType.first);
+
+ }
+
+
+ private static void populateParking(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ ParkingGroundData p = new ParkingGroundData();
+ d.getTicket().setParkingGround(p);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ p.setExtension(e1);
+
+
+ p.setReferenceIA5("810123456789");
+ p.setReferenceNum(Asn1BigInteger.toAsn1(810123456789L));
+ p.setProductOwnerNum(23456L);
+ p.setProductOwnerIA5("23456");
+ p.setProductIdNum(15535L);
+ p.setProductIdIA5("23456");
+
+ p.setParkingGroundId("IA5");
+ p.setFromParkingDate(370L);
+ p.setToParkingDate(370L);
+
+ p.setAccessCode("4ga");
+ p.setLocation("Parking Frankfurt Main West");
+ p.setStationCodeTable(CodeTableType.stationUIC);
+ p.setStationNum(8000001L);
+ p.setStationIA5("8000001");
+ p.setSpecialInformation("outdoor parking");
+ p.setEntryTrack("left");
+ p.setNumberPlate("AA-DE-12345");
+ p.setPrice(500L);
+ p.setVatDetails(new SequenceOfVatDetail());
+ VatDetailType v = new VatDetailType();
+ p.getVatDetails().add(v);
+ v.setAmount(10L);
+ v.setCountry(80L);
+ v.setPercentage(70L);
+ v.setVatId("IUDGTE");
+
+ }
+
+
+ private static void populateCounterMark(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ CountermarkData t = new CountermarkData();
+ d.getTicket().setCounterMark(t);
+
+ t.setTicketReferenceIA5("810123456789");
+ t.setTicketReferenceNum(810123456789L);
+ t.setNumberOfCountermark(12L);
+ t.setTotalOfCountermarks(24L);
+ t.setGroupName("groupName");
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ t.setExtension(e1);
+
+ t.setReferenceIA5("810123456789");
+ t.setReferenceNum(810123456789L);
+ t.setProductOwnerNum( 23456L);
+ t.setProductOwnerIA5("23456");
+ t.setProductIdNum( 15535L);
+ t.setProductIdIA5("23456");
+
+ t.setReturnIncluded( false);
+
+ t.setStationCodeTable(CodeTableType.stationERA);
+ t.setFromStationNum( 8100001L);
+ t.setFromStationIA5("8100001");
+ t.setToStationNum( 8000002L);
+ t.setToStationIA5( "8100002");
+ t.setFromStationNameUTF8( "A-STATION");
+ t.setToStationNameUTF8( "B-STATION");
+
+ t.setValidRegionDesc("From A to B via C");
+
+ t.setValidRegion(new SequenceOfRegionalValidityType());
+ t.getValidRegion().add(new RegionalValidityType());
+ t.getValidRegion().get(0).setViaStations(new ViaStationType());
+ populateCounterMarkRoute(t.getValidRegion().get(0).getViaStations());
+
+ t.setReturnDescription(new ReturnRouteDescriptionType());
+ t.getReturnDescription().setFromStationNum( 8100001L);
+ t.getReturnDescription().setFromStationIA5("8100001");
+ t.getReturnDescription().setToStationNum( 8000002L);
+ t.getReturnDescription().setToStationIA5( "8100002");
+ t.getReturnDescription().setFromStationNameUTF8( "A-STATION");
+ t.getReturnDescription().setToStationNameUTF8( "B-STATION");
+ t.getReturnDescription().setValidReturnRegionDesc( "return");
+ t.getReturnDescription().setValidReturnRegion(new SequenceOfRegionalValidityType());
+ t.getReturnDescription().getValidReturnRegion().add(new RegionalValidityType());
+
+ t.getReturnDescription().getValidReturnRegion().get(0).setZones(new ZoneType());
+ t.getReturnDescription().getValidReturnRegion().get(0).getZones().setZoneId(new SequenceOfUnrestrictedLong());
+ t.getReturnDescription().getValidReturnRegion().get(0).getZones().getZoneId().add(100L);
+ t.getReturnDescription().getValidReturnRegion().get(0).getZones().getZoneId().add(200L);
+ t.getReturnDescription().getValidReturnRegion().get(0).getZones().setCarrierNum(1080L);
+ t.getReturnDescription().getValidReturnRegion().get(0).getZones().setCarrierIA5("1181");
+ t.getReturnDescription().getValidReturnRegion().get(0).getZones().setStationCodeTable(CodeTableType.stationERA);
+
+ t.setValidFromDay( 700L);
+ t.setValidFromTime( 0L);
+ t.setValidFromUTCOffset( 60L);
+ t.setValidUntilDay( 370L);
+ t.setValidUntilTime( 1439L);
+ t.setValidUntilUTCOffset( 10L);
+
+ t.setClassCode(TravelClassType.first);
+
+ t.setCarriersNum(new SequenceOfCarrierNum());
+ t.getCarriersNum().add(1080L);
+ t.getCarriersNum().add(1181L);
+
+ t.setCarriersIA5(new SequenceOfStringIA5());
+ t.getCarriersIA5().add("1080");
+ t.getCarriersIA5().add("1181");
+
+ t.setIncludedServiceBrands(new SequenceOfServiceBrands());
+ t.getIncludedServiceBrands().add(108L);
+ t.getIncludedServiceBrands().add(118L);
+
+ t.setExcludedServiceBrands(new SequenceOfServiceBrands());
+ t.getExcludedServiceBrands().add(108L);
+ t.getExcludedServiceBrands().add(118L);
+
+
+ t.setInfoText("counterMark");
+
+ }
+
+
+ private static void populateCustomerCard(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ CustomerCardData c = new CustomerCardData();
+ d.getTicket().setCustomerCard(c);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ c.setExtension(e1);
+
+ TravelerType t = new TravelerType();
+ c.setCustomer(t);
+ t.setCustomerIdIA5("1234");
+ t.setTicketHolder(false);
+ t.setPassengerType(PassengerType.senior);
+
+ c.setCardIdIA5("2345");
+ c.setCardIdNum(123456L);
+ c.setValidFromYear(2269L);
+ c.setValidFromDay(2L);
+ c.setValidUntilYear(1L);
+ c.setValidUntilDay(5L);
+ c.setClassCode(TravelClassType.second);
+ c.setCardType(15L);
+ c.setCardTypeDescr("RAILPLUS");
+ c.setCustomerStatus(1L);
+
+ c.setCustomerStatusDescr("gold");
+ c.setIncludedServices(new SequenceOfUnrestrictedLong());
+ c.getIncludedServices().add(1L);
+ c.getIncludedServices().add(2L);
+
+ }
+
+
+ private static void populateVoucher(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ VoucherData v = new VoucherData();
+ d.getTicket().setVoucher(v);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ v.setExtension(e1);
+
+ v.setReferenceIA5("810123456789");
+ v.setReferenceNum(Asn1BigInteger.toAsn1(810123456789L));
+ v.setProductOwnerNum(23456L);
+ v.setProductOwnerIA5("COFFEEMACHINE");
+ v.setProductIdNum(15535L);
+ v.setProductIdIA5("23456");
+
+ v.setValidFromYear(2022L);
+ v.setValidFromDay(1L);
+ v.setValidUntilYear(2022L);
+ v.setValidUntilDay(1L);
+ v.setValue(500L);
+ v.setType(123L);
+ v.setInfoText("coffee voucher");
+ }
+
+
+ private static void populatePass(DocumentData d) {
+
+
+ d.setTicket(new TicketDetailData());
+ PassData p = new PassData();
+ d.getTicket().setPass(p);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ p.setExtension(e1);
+
+ p.setReferenceIA5("810123456789");
+ p.setReferenceNum(Asn1BigInteger.toAsn1(810123456789L));
+ p.setProductOwnerNum(23456L);
+ p.setProductOwnerIA5("23456");
+ p.setProductIdNum(15535L);
+ p.setProductIdIA5("23456");
+
+ p.setPassType(2L);
+ p.setPassDescription("Eurail FlexPass");
+ p.setClassCode(TravelClassType.first);
+ p.setValidFromDay( 0L);
+ p.setValidFromTime( 1000L);
+ p.setValidFromUTCOffset( 1L);
+ p.setValidUntilDay( 1L);
+ p.setValidUntilTime( 1000L);
+ p.setValidUntilUTCOffset(1L);
+
+ ValidityPeriodDetailType v = new ValidityPeriodDetailType();
+ p.setValidityPeriodDetails(v);
+ v.setValidityPeriod(new SequenceOfValidityPeriodType());
+ v.setExcludedTimeRange(new SequenceOfTimeRangeType());
+
+ ValidityPeriodType vp = new ValidityPeriodType();
+ p.getValidityPeriodDetails().getValidityPeriod().add(vp);
+ vp.setValidFromDay(0L);
+ vp.setValidFromTime( 1000L);
+ vp.setValidFromUTCOffset( 1L);
+ vp.setValidUntilDay( 1L);
+ vp.setValidUntilTime( 1000L);
+ vp.setValidUntilUTCOffset(1L);
+
+ TimeRangeType tr = new TimeRangeType();
+ p.getValidityPeriodDetails().getExcludedTimeRange().add(tr);
+
+ tr.setFromTime(6L);
+ tr.setUntilTime(9L);
+
+ p.setNumberOfValidityDays(5L);
+
+
+ p.setNumberOfPossibleTrips( 3L);
+ p.setNumberOfDaysOfTravel( 10L);
+
+ p.setActivatedDay(new SequenceOfActivatedDays());
+ p.getActivatedDay().add(200L);
+ p.getActivatedDay().add(201L);
+
+
+ p.setCountries(new SequenceOfCountries());
+ p.getCountries().add(10L);
+ p.getCountries().add(20L);
+
+ p.setIncludedCarriersNum(new SequenceOfCarrierNum());
+ p.getIncludedCarriersNum().add(1080L);
+ p.getIncludedCarriersNum().add(1181L);
+
+ p.setIncludedCarriersIA5(new SequenceOfStringIA5());
+ p.getIncludedCarriersIA5().add("1080");
+ p.getIncludedCarriersIA5().add("1181");
+
+ p.setExcludedCarriersNum(new SequenceOfCarrierNum());
+ p.getExcludedCarriersNum().add(1080L);
+ p.getExcludedCarriersNum().add(1181L);
+
+ p.setExcludedCarriersIA5(new SequenceOfStringIA5());
+ p.getExcludedCarriersIA5().add("1080");
+ p.getExcludedCarriersIA5().add("1181");
+
+ p.setIncludedServiceBrands(new SequenceOfServiceBrands());
+ p.getIncludedServiceBrands().add(108L);
+ p.getIncludedServiceBrands().add(118L);
+
+ p.setExcludedServiceBrands(new SequenceOfServiceBrands());
+ p.getExcludedServiceBrands().add(108L);
+ p.getExcludedServiceBrands().add(118L);
+
+ p.setValidRegion(new SequenceOfRegionalValidityType());
+
+ RegionalValidityType rv = new RegionalValidityType();
+ p.getValidRegion().add(rv);
+ rv.setZones(new ZoneType());
+ rv.getZones().setZoneId(new SequenceOfUnrestrictedLong());
+ rv.getZones().getZoneId().add(100L);
+
+ p.setTariffs(new SequenceOfTariffType());
+ TariffType ta = new TariffType();
+ p.getTariffs().add(ta);
+ ta.setNumberOfPassengers(1L);
+ ta.setRestrictedToCountryOfResidence(false);
+ ta.setTariffIdNum(72L);
+ ta.setTariffDesc("Large Car Full Fare");
+
+ p.setVatDetails(new SequenceOfVatDetail());
+ VatDetailType v1 = new VatDetailType();
+ p.getVatDetails().add(v1);
+ v1.setAmount(10L);
+ v1.setCountry(80L);
+ v1.setPercentage(70L);
+ v1.setVatId("IUDGTE");
+
+ p.setPrice(10000L);
+ p.setInfoText("pass info");
+
+ }
+
+
+ private static void populateOpenTicket(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ OpenTicketData o = new OpenTicketData();
+ d.getTicket().setOpenTicket(o);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ o.setExtension(e1);
+
+ o.setReferenceIA5("810123456789");
+ o.setReferenceNum(810123456789L);
+ o.setProductOwnerNum( 23456L);
+ o.setProductOwnerIA5("23456");
+ o.setProductIdNum( 15535L);
+ o.setProductIdIA5("23456");
+
+
+ o.setExtIssuerId( 12L);
+ o.setIssuerAutorizationId( 13L);
+ o.setReturnIncluded( false);
+
+ o.setStationCodeTable(CodeTableType.stationERA);
+ o.setFromStationNum( 8100001L);
+ o.setFromStationIA5("8100001");
+ o.setToStationNum( 8000002L);
+ o.setToStationIA5( "8100002");
+ o.setFromStationNameUTF8( "A-STATION");
+ o.setToStationNameUTF8( "B-STATION");
+
+ o.setValidRegionDesc("From A to B via C");
+
+ o.setValidRegion(new SequenceOfRegionalValidityType());
+ o.getValidRegion().add(new RegionalValidityType());
+ o.getValidRegion().get(0).setViaStations(new ViaStationType());
+ o.getValidRegion().add(new RegionalValidityType());
+ o.getValidRegion().get(1).setZones(new ZoneType());
+ o.getValidRegion().add(new RegionalValidityType());
+ o.getValidRegion().get(2).setLines(new LineType());
+ o.getValidRegion().add(new RegionalValidityType());
+ o.getValidRegion().get(3).setTrainLink(new TrainLinkType());
+ o.getValidRegion().add(new RegionalValidityType());
+ o.getValidRegion().get(4).setPolygone(new PolygoneType());
+ populateRoute(o.getValidRegion().get(0).getViaStations());
+ populateZone(o.getValidRegion().get(1).getZones());
+ populateLine(o.getValidRegion().get(2).getLines());
+ populateTrainLink(o.getValidRegion().get(3).getTrainLink());
+ populatePolygon(o.getValidRegion().get(4).getPolygone());
+
+ o.setReturnDescription(new ReturnRouteDescriptionType());
+ o.getReturnDescription().setFromStationNum( 8100001L);
+ o.getReturnDescription().setFromStationIA5("8100001");
+ o.getReturnDescription().setToStationNum( 8000002L);
+ o.getReturnDescription().setToStationIA5( "8100002");
+ o.getReturnDescription().setFromStationNameUTF8( "A-STATION");
+ o.getReturnDescription().setToStationNameUTF8( "B-STATION");
+ o.getReturnDescription().setValidReturnRegionDesc( "return");
+ o.getReturnDescription().setValidReturnRegion(new SequenceOfRegionalValidityType());
+ o.getReturnDescription().getValidReturnRegion().add(new RegionalValidityType());
+
+ o.getReturnDescription().getValidReturnRegion().get(0).setZones(new ZoneType());
+ o.getReturnDescription().getValidReturnRegion().get(0).getZones().setZoneId(new SequenceOfUnrestrictedLong());
+ o.getReturnDescription().getValidReturnRegion().get(0).getZones().getZoneId().add(100L);
+ o.getReturnDescription().getValidReturnRegion().get(0).getZones().getZoneId().add(200L);
+ o.getReturnDescription().getValidReturnRegion().get(0).getZones().setCarrierIA5("1080");
+ o.getReturnDescription().getValidReturnRegion().get(0).getZones().setCarrierNum(1080L);
+ o.getReturnDescription().getValidReturnRegion().get(0).getZones().setStationCodeTable(CodeTableType.stationERA);
+
+ o.setValidFromDay( 700L);
+ o.setValidFromTime( 0L);
+ o.setValidFromUTCOffset( 60L);
+ o.setValidUntilDay( 370L);
+ o.setValidUntilTime( 1439L);
+ o.setValidUntilUTCOffset( 10L);
+
+ o.setActivatedDay(new SequenceOfActivatedDays());
+ o.getActivatedDay().add(1L);
+ o.getActivatedDay().add(2L);
+
+
+ o.setClassCode(TravelClassType.first);
+ o.setServiceLevel("A");
+
+ o.setCarriersNum(new SequenceOfCarrierNum());
+ o.getCarriersNum().add(1080L);
+ o.getCarriersNum().add(1181L);
+
+ o.setCarriersIA5(new SequenceOfStringIA5());
+ o.getCarriersIA5().add("1080");
+ o.getCarriersIA5().add("1181");
+
+ o.setIncludedServiceBrands(new SequenceOfServiceBrands());
+ o.getIncludedServiceBrands().add(108L);
+ o.getIncludedServiceBrands().add(118L);
+
+ o.setExcludedServiceBrands(new SequenceOfServiceBrands());
+ o.getExcludedServiceBrands().add(108L);
+ o.getExcludedServiceBrands().add(118L);
+
+ o.setTariffs(new SequenceOfTariffType());
+ TariffType ta = new TariffType();
+ o.getTariffs().add(ta);
+ ta.setNumberOfPassengers(1L);
+ ta.setRestrictedToCountryOfResidence(false);
+ ta.setTariffIdNum(72L);
+ ta.setTariffDesc("Large Car Full Fare");
+
+ o.setVatDetails(new SequenceOfVatDetail());
+ VatDetailType v1 = new VatDetailType();
+ o.getVatDetails().add(v1);
+ v1.setCountry(80L);
+ v1.setPercentage(70L);
+
+ o.setPrice( 12345L);
+
+
+ o.setInfoText("openTicketInfo");
+
+ o.setIncludedAddOns(new SequenceOfIncludedOpenTicketType());
+ o.getIncludedAddOns().add(new IncludedOpenTicketType());
+ populateIncludedTicket(o.getIncludedAddOns().get(0));
+
+ o.setLuggage(new LuggageRestrictionType());
+ o.getLuggage().setMaxHandLuggagePieces(2L);
+ o.getLuggage().setMaxNonHandLuggagePieces(1L);
+
+
+
+ }
+
+
+
+
+ private static void populateTrainLink(TrainLinkType t) {
+
+
+ t.setTrainNum( 12345L);
+ t.setTrainIA5("12345");
+ t.setTravelDate( 2L);
+ t.setDepartureTime( 1439L);
+
+
+ t.setFromStationNum( 8100001L);
+ t.setFromStationIA5("8100001");
+ t.setToStationNum( 8000002L);
+ t.setToStationIA5( "8100002");
+ t.setFromStationName( "A-STATION");
+ t.setToStationName( "B-STATION");
+
+ }
+
+ private static void populatePolygon(PolygoneType p) {
+
+ p.setFirstEdge(new GeoCoordinateType());
+ p.getFirstEdge().setLongitude( 12345L);
+ p.getFirstEdge().setLatitude( 56789L);
+ p.setEdges(new SequenceOfDeltaCoordinates());
+ p.getEdges().add(new DeltaCoordinates());
+ p.getEdges().add(new DeltaCoordinates());
+ p.getEdges().get(0).setLongitude( Asn1BigInteger.toAsn1(12345L));
+ p.getEdges().get(0).setLatitude(Asn1BigInteger.toAsn1(56789L));
+ p.getEdges().get(1).setLongitude(Asn1BigInteger.toAsn1(12345L));
+ p.getEdges().get(1).setLatitude(Asn1BigInteger.toAsn1(56789L));
+
+ }
+
+ private static void populateZone(ZoneType z) {
+
+ z.setCarrierNum( 1080L);
+ z.setCarrierIA5("1080");
+ z.setStationCodeTable(CodeTableType.stationERA);
+ z.setEntryStationNum( 1234L);
+ z.setEntryStationIA5( "1234");
+ z.setTerminatingStationNum( 2345L);
+ z.setTerminatingStationIA5( "2345");
+ z.setCity(Asn1BigInteger.toAsn1(123456L));
+ z.setZoneId(new SequenceOfUnrestrictedLong());
+ z.getZoneId().add(100L);
+ z.getZoneId().add(200L);
+ z.setNutsCode("DE4711");
+ z.setBinaryZoneId(UperEncoder.bytesFromHexString("82DA"));
+
+ }
+
+ private static void populateLine(LineType z) {
+
+ z.setCarrierNum( 1080L);
+ z.setCarrierIA5("1080");
+ z.setStationCodeTable(CodeTableType.stationERA);
+ z.setEntryStationNum( 1234L);
+ z.setEntryStationIA5( "1234");
+ z.setTerminatingStationNum( 2345L);
+ z.setTerminatingStationIA5( "2345");
+ z.setCity(123456L);
+ z.setLineId(new SequenceOfUnrestrictedLong());
+ z.getLineId().add(100L);
+ z.getLineId().add(200L);
+
+ }
+
+ private static void populateRoute(ViaStationType t) {
+
+
+ t.setRoute(new SequenceOfViaStationType());
+ t.getRoute().add(new ViaStationType());
+ t.getRoute().add(new ViaStationType());
+ t.getRoute().add(new ViaStationType());
+ t.getRoute().add(new ViaStationType());
+
+ t.getRoute().get(0).setStationNum( 123455L);
+ t.getRoute().get(0).setStationIA5("123455");
+ t.getRoute().get(0).setBorder( false);
+
+ t.getRoute().get(1).setStationNum( 123456L);
+ t.getRoute().get(1).setBorder( false);
+
+
+ t.getRoute().get(2).setAlternativeRoutes(new SequenceOfViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().add(new ViaStationType());
+ t.getRoute().get(2).setBorder( false);
+
+ t.getRoute().get(2).getAlternativeRoutes().get(0).setRoute(new SequenceOfViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(0).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(0).setStationNum( 23455L);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(0).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(1).setStationNum( 23456L);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(1).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).setRoute(new SequenceOfViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(1).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().get(0).setStationNum( 3455L);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().get(0).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().get(1).setStationNum( 3456L);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(1).setBorder(false);
+
+ t.getRoute().get(3).setStationNum( 123457L);
+ t.getRoute().get(3).setBorder(false);
+
+ t.setBorder( false);
+
+ t.setSeriesId( 999L);
+ t.setRouteId( 21L);
+
+ }
+
+ private static void populateCounterMarkRoute(ViaStationType t) {
+
+
+ t.setRoute(new SequenceOfViaStationType());
+ t.getRoute().add(new ViaStationType());
+ t.getRoute().add(new ViaStationType());
+ t.getRoute().add(new ViaStationType());
+ t.getRoute().add(new ViaStationType());
+
+ t.getRoute().get(0).setStationNum( 123455L);
+ t.getRoute().get(0).setStationIA5("123455");
+ t.getRoute().get(0).setBorder( false);
+
+ t.getRoute().get(1).setStationNum( 123456L);
+ t.getRoute().get(1).setBorder( false);
+
+
+ t.getRoute().get(2).setAlternativeRoutes(new SequenceOfViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().add(new ViaStationType());
+ t.getRoute().get(2).setBorder( false);
+
+ t.getRoute().get(2).getAlternativeRoutes().get(0).setRoute(new SequenceOfViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(0).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(0).setStationNum( 23455L);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(0).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(1).setStationNum( 23456L);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(1).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).setRoute(new SequenceOfViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(1).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().add(new ViaStationType());
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().get(0).setStationNum( 3455L);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().get(0).setBorder(false);
+ t.getRoute().get(2).getAlternativeRoutes().get(1).getRoute().get(1).setStationNum( 3456L);
+ t.getRoute().get(2).getAlternativeRoutes().get(0).getRoute().get(1).setBorder(false);
+
+ t.getRoute().get(3).setStationNum( 123457L);
+ t.getRoute().get(3).setBorder(false);
+
+ t.setCarriersIA5(new SequenceOfStringIA5());
+ t.getCarriersIA5().add("1080");
+ t.getCarriersIA5().add("1181");
+
+ t.setCarriersNum(new SequenceOfCarrierNum());
+ t.getCarriersNum().add(1080L);
+ t.getCarriersNum().add(1181L);
+
+
+ t.setBorder( false);
+
+ t.setSeriesId( 999L);
+ t.setRouteId( 21L);
+
+ }
+
+ private static void populateIncludedTicket(IncludedOpenTicketType t) {
+
+
+ t.setProductOwnerNum( 23456L);
+ t.setProductOwnerIA5("23456");
+ t.setProductIdNum( 15535L);
+ t.setProductIdIA5("23456");
+
+
+ t.setExternalIssuerId(12L);
+ t.setIssuerAutorizationId(13L);
+ t.setStationCodeTable(CodeTableType.stationERA);
+
+ t.setValidRegion(new SequenceOfRegionalValidityType());
+ RegionalValidityType rv = new RegionalValidityType();
+ t.getValidRegion().add(rv);
+ rv.setZones(new ZoneType());
+ rv.getZones().setZoneId(new SequenceOfUnrestrictedLong());
+ rv.getZones().getZoneId().add(100L);
+
+ t.setValidFromDay( 0L);
+ t.setValidFromTime(1000L);
+ t.setValidUntilDay(1L);
+ t.setValidUntilTime(1000L);
+ t.setClassCode(TravelClassType.second);
+ t.setServiceLevel("A");
+
+ t.setIncludedCarriersNum(new SequenceOfCarrierNum());
+ t.getIncludedCarriersNum().add(1080L);
+ t.getIncludedCarriersNum().add(1181L);
+
+ t.setIncludedCarriersIA5(new SequenceOfStringIA5());
+ t.getIncludedCarriersIA5().add("1080");
+ t.getIncludedCarriersIA5().add("1181");
+
+
+ t.setIncludedServiceBrands(new SequenceOfServiceBrands());
+ t.getIncludedServiceBrands().add(108L);
+ t.getIncludedServiceBrands().add(118L);
+
+ t.setExcludedServiceBrands(new SequenceOfServiceBrands());
+ t.getExcludedServiceBrands().add(108L);
+ t.getExcludedServiceBrands().add(118L);
+
+ t.setTariffs(new SequenceOfTariffType());
+ TariffType ta = new TariffType();
+ t.getTariffs().add(ta);
+ ta.setNumberOfPassengers(1L);
+ ta.setRestrictedToCountryOfResidence(false);
+ ta.setTariffIdNum(72L);
+ ta.setTariffDesc("Large Car Full Fare");
+
+ t.setInfoText("included ticket");
+
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ t.setExtension(e1);
+
+ }
+
+
+ private static void populateCarCarriage(DocumentData d2) {
+
+ d2.setTicket(new TicketDetailData());
+ d2.setToken(new TokenType());
+
+
+ assert(d2.getToken() != null);
+ d2.getToken().setToken(UperEncoder.bytesFromHexString("82DA"));
+ d2.getToken().setTokenProviderIA5("VDV");
+ d2.getToken().setTokenProviderNum(123L);
+ d2.getToken().setTokenSpecification("TEST");
+
+ CarCarriageReservationData r = new CarCarriageReservationData();
+ d2.getTicket().setCarCarriageReservation(r);
+
+ r.setTrainNum( 123L);
+ r.setTrainIA5("123");
+ r.setReferenceIA5("810123456789");
+ r.setReferenceNum( 810123456789L);
+ r.setProductOwnerNum( 23456L);
+ r.setProductOwnerIA5("23456");
+ r.setProductIdNum( 15535L);
+ r.setProductIdIA5("23456");
+ r.setServiceBrand( 100L);
+ r.setServiceBrandAbrUTF8("AZ");
+ r.setServiceBrandNameUTF8("special train");
+
+ r.setBeginLoadingDate( 10L);
+ r.setBeginLoadingTime( 0L);
+ r.setEndLoadingTime( 500L);
+ r.setLoadingUTCOffset( 30L);
+
+ r.setStationCodeTable(CodeTableType.stationERA);
+ r.setFromStationNum( 8100001L);
+ r.setFromStationIA5("8100001");
+ r.setToStationNum( 8000002L);
+ r.setToStationIA5( "8100002");
+ r.setFromStationNameUTF8( "A-STATION");
+ r.setToStationNameUTF8( "B-STATION");
+
+ r.setCoach("21");
+ r.setPlace("41");
+ r.setCompartmentDetails(new CompartmentDetailsType());
+
+ r.getCompartmentDetails().setCoachType( 1L);
+ r.getCompartmentDetails().setCompartmentType( 99L);
+ r.getCompartmentDetails().setSpecialAllocation( 50L);
+ r.getCompartmentDetails().setCoachTypeDescr("xwz");
+ r.getCompartmentDetails().setCompartmentTypeDescr("xwz");
+ r.getCompartmentDetails().setSpecialAllocationDescr("xwz");
+ r.getCompartmentDetails().setPosition(CompartmentPositionType.upperLevel);
+
+ r.setNumberPlate( "AD-DE-123");
+ r.setTrailerPlate( "DX-AB-123");
+ r.setCarCategory( 3L);
+ r.setBoatCategory( 5L);
+ r.setTextileRoof( false);
+ r.setRoofRackType(RoofRackType.bicycleRack);
+ r.setRoofRackHeight( 20L);
+ r.setAttachedBoats( 2L);
+ r.setAttachedBicycles( 1L);
+ r.setAttachedSurfboards( 2L);
+ r.setLoadingListEntry( 421L);
+ r.setLoadingDeck(LoadingDeckType.upper);
+
+ r.setCarrierNum(new SequenceOfCarrierNum());
+ r.getCarrierNum().add(1080L);
+ r.getCarrierNum().add(1181L);
+
+ r.setCarrierIA5(new SequenceOfStringIA5());
+ r.getCarrierIA5().add("1080");
+ r.getCarrierIA5().add("1181");
+
+
+ r.setPriceType(PriceTypeType.travelPrice);
+ r.setPrice(12345L);
+
+ r.setInfoText("car carriage");
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ r.setExtension(e1);
+
+ TariffType ta = new TariffType();
+ r.setTariff(ta);
+ ta.setNumberOfPassengers(1L);
+ ta.setRestrictedToCountryOfResidence(false);
+ ta.setTariffIdNum(72L);
+ ta.setTariffDesc("Large Car Full Fare");
+
+ r.setVatDetails(new SequenceOfVatDetail());
+ VatDetailType v1 = new VatDetailType();
+ r.getVatDetails().add(v1);
+ v1.setAmount(10L);
+ v1.setCountry(80L);
+ v1.setPercentage(70L);
+ v1.setVatId("IUDGTE");
+
+ }
+
+
+ private static void populateReservation(DocumentData d) {
+
+ d.setTicket(new TicketDetailData());
+ ReservationData r = new ReservationData();
+ d.getTicket().setReservation(r);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ r.setExtension(e1);
+
+ r.setTrainNum( 12345L);
+ r.setTrainIA5("12345");
+ r.setDepartureDate( 2L);
+ r.setReferenceIA5("810123456789");
+ r.setReferenceNum(80123456789L);
+ r.setProductOwnerNum( 23456L);
+ r.setProductOwnerIA5("23456");
+ r.setProductIdNum( 15535L);
+ r.setProductIdIA5("23456");
+ r.setServiceBrand( 12L);
+ r.setServiceBrandAbrUTF8("TGV");
+ r.setServiceBrandNameUTF8("Lyria");
+ r.setService(ServiceType.couchette);
+
+ r.setStationCodeTable(CodeTableType.stationUIC);
+ r.setFromStationNum( 8100001L);
+ r.setFromStationIA5("8100001");
+ r.setToStationNum( 8000002L);
+ r.setToStationIA5( "8100002");
+ r.setFromStationNameUTF8( "A-STATION");
+ r.setToStationNameUTF8( "B-STATION");
+ r.setDepartureTime( 1439L);
+ r.setDepartureUTCOffset( -60L);
+ r.setArrivalDate( 20L);
+ r.setArrivalTime( 0L);
+ r.setArrivalUTCOffset( 10L);
+ r.setCarrierNum(new SequenceOfCarrierNum());
+ r.getCarrierNum().add(1080L);
+ r.getCarrierNum().add(1181L);
+
+ r.setCarrierIA5(new SequenceOfStringIA5());
+ r.getCarrierIA5().add("1080");
+ r.getCarrierIA5().add("1181");
+ r.setClassCode(TravelClassType.first);
+ r.setServiceLevel("A");
+
+ r.setPlaces(new PlacesType());
+ r.getPlaces().setCoach("31A");
+ r.getPlaces().setPlaceString("31-47");
+ r.getPlaces().setPlaceDescription("Window");
+ r.getPlaces().setPlaceIA5(new SequenceOfStringIA5());
+ r.getPlaces().getPlaceIA5().add("31A");
+ r.getPlaces().getPlaceIA5().add("31B");
+ r.getPlaces().setPlaceNum(new SequenceOfPlaceNum());
+ r.getPlaces().getPlaceNum().add(31L);
+ r.getPlaces().getPlaceNum().add(32L);
+
+ r.setAdditionalPlaces(new PlacesType());
+ r.getAdditionalPlaces().setCoach("31A");
+ r.getAdditionalPlaces().setPlaceString("31-47");
+ r.getAdditionalPlaces().setPlaceDescription("Window");
+ r.getAdditionalPlaces().setPlaceIA5(new SequenceOfStringIA5());
+ r.getAdditionalPlaces().getPlaceIA5().add("31A");
+ r.getAdditionalPlaces().getPlaceIA5().add("31B");
+ r.getAdditionalPlaces().setPlaceNum(new SequenceOfPlaceNum());
+ r.getAdditionalPlaces().getPlaceNum().add(31L);
+ r.getAdditionalPlaces().getPlaceNum().add(32L);
+
+ r.setBicyclePlaces(new PlacesType());
+ r.getBicyclePlaces().setCoach("31A");
+ r.getBicyclePlaces().setPlaceString("31-47");
+ r.getBicyclePlaces().setPlaceDescription("Window");
+ r.getBicyclePlaces().setPlaceIA5(new SequenceOfStringIA5());
+ r.getBicyclePlaces().getPlaceIA5().add("31A");
+ r.getBicyclePlaces().getPlaceIA5().add("31B");
+ r.getBicyclePlaces().setPlaceNum(new SequenceOfPlaceNum());
+ r.getBicyclePlaces().getPlaceNum().add(31L);
+ r.getBicyclePlaces().getPlaceNum().add(32L);
+
+
+ r.setCompartmentDetails(new CompartmentDetailsType());
+ r.getCompartmentDetails().setCoachType( 1L);
+ r.getCompartmentDetails().setCompartmentType( 99L);
+ r.getCompartmentDetails().setSpecialAllocation( 50L);
+ r.getCompartmentDetails().setCoachTypeDescr("xwz");
+ r.getCompartmentDetails().setCompartmentTypeDescr( "xwz");
+ r.getCompartmentDetails().setSpecialAllocationDescr( "xwz");
+ r.getCompartmentDetails().setPosition(CompartmentPositionType.upperLevel);
+
+ r.setNumberOfOverbooked( 200L);
+ r.setBerth(new SequenceOfBerthDetailData());
+ BerthDetailData b = new BerthDetailData();
+ r.getBerth().add(b);
+ b.setBerthType(BerthTypeType.single);
+ b.setGender(CompartmentGenderType.female);
+ b.setNumberOfBerths( 999L);
+
+
+ r.setTariff(new SequenceOfTariffType());
+ TariffType ta = new TariffType();
+ r.getTariff().add(ta);
+ ta.setNumberOfPassengers(1L);
+
+ ta.setPassengerType(PassengerType.senior);
+ ta.setAgeBelow( 40L);
+ ta.setAgeAbove( 60L);
+ ta.setTraverlerid(new SequenceOfTravelerId());
+ ta.getTraverlerid().add(1L);
+
+ ta.setRestrictedToCountryOfResidence( false);
+ ta.setRestrictedToRouteSection(new RouteSectionType());
+ ta.getRestrictedToRouteSection().setStationCodeTable(CodeTableType.stationERA);
+ ta.getRestrictedToRouteSection().setFromStationNum( 123L);
+ ta.getRestrictedToRouteSection().setFromStationIA5( "123");
+ ta.getRestrictedToRouteSection().setToStationNum( 234L);
+ ta.getRestrictedToRouteSection().setToStationIA5( "234");
+ ta.getRestrictedToRouteSection().setFromStationNameUTF8( "A");
+ ta.getRestrictedToRouteSection().setToStationNameUTF8( "B");
+
+ ta.setSeriesDataDetails(new SeriesDetailType());
+ ta.getSeriesDataDetails().setSupplyingCarrier(2345L);
+ ta.getSeriesDataDetails().setOfferIdentification( 99L);
+ ta.getSeriesDataDetails().setSeries( 23456L);
+
+ ta.setTariffIdNum( 72L);
+ ta.setTariffIdIA5( "72");
+ ta.setTariffDesc( "Leasure Fare");
+ ta.setReductionCard(new SequenceOfCardReferenceType());
+ ta.getReductionCard().add(new CardReferenceType());
+
+ ta.getReductionCard().get(0).setCardIssuerNum(1234L);
+ ta.getReductionCard().get(0).setCardIssuerIA5( "1234");
+ ta.getReductionCard().get(0).setCardIdNum(5678L);
+ ta.getReductionCard().get(0).setCardIdIA5( "5678");
+ ta.getReductionCard().get(0).setCardName( "testcard");
+ ta.getReductionCard().get(0).setCardType(123L);
+ ta.getReductionCard().get(0).setLeadingCardIdNum(3456L);
+ ta.getReductionCard().get(0).setLeadingCardIdIA5("3456");
+ ta.getReductionCard().get(0).setTrailingCardIdNum(100L);
+ ta.getReductionCard().get(0).setTrailingCardIdIA5("100");
+
+
+ r.setPriceType(PriceTypeType.travelPrice);
+ r.setPrice( 12345L);
+
+ r.setVatDetails(new SequenceOfVatDetail());
+ VatDetailType v1 = new VatDetailType();
+ r.getVatDetails().add(v1);
+ v1.setAmount(10L);
+ v1.setCountry(80L);
+ v1.setPercentage(70L);
+ v1.setVatId("IUDGTE");
+
+ r.setTypeOfSupplement( 9L);
+ r.setNumberOfSupplements( 2L);
+
+ r.setLuggage(new LuggageRestrictionType());
+
+ r.getLuggage().setMaxHandLuggagePieces( 2L);
+ r.getLuggage().setMaxNonHandLuggagePieces( 1L);
+ r.getLuggage().setRegisteredLuggage(new SequenceOfRegisteredLuggageType());
+ r.getLuggage().getRegisteredLuggage().add(new RegisteredLuggageType());
+ r.getLuggage().getRegisteredLuggage().add(new RegisteredLuggageType());
+ r.getLuggage().getRegisteredLuggage().get(0).setRegistrationId("IODHUV");
+ r.getLuggage().getRegisteredLuggage().get(0).setMaxWeight( 20L);
+ r.getLuggage().getRegisteredLuggage().get(0).setMaxSize( 100L);
+ r.getLuggage().getRegisteredLuggage().get(1).setRegistrationId("XXDHUV");
+ r.getLuggage().getRegisteredLuggage().get(1).setMaxWeight( 21L);
+ r.getLuggage().getRegisteredLuggage().get(1).setMaxSize( 101L);
+
+ r.setInfoText("reservation");
+
+
+ }
+
+
+ private static void populateTravelerData(TravelerData td) {
+
+ td.setGroupName("myGroup");
+ td.setPreferedLanguage("EN");
+ td.setTraveler(new SequenceOfTravelerType());
+ TravelerType t = new TravelerType();
+ td.getTraveler().add(t);
+
+ t.setCountryOfIdCard(103L);
+ t.setCountryOfPassport(102L);
+ t.setCountryOfResidence(101L);
+ t.setCustomerIdIA5("DZE5gT");
+ t.setCustomerIdNum(12345L);
+ t.setYearOfBirth(1901L);
+ t.setDayOfBirth(31L);
+ t.setFirstName("John");
+ t.setGender(GenderType.male);
+ t.setIdCard("12345");
+ t.setLastName("Dow");
+ t.setPassengerType(PassengerType.senior);
+ t.setPassengerWithReducedMobility(false);
+ t.setPassportId("JDTS");
+ t.setSecondName("Little");
+ t.setTitle("PhD");
+ t.setTicketHolder(true);
+ t.setStatus(new SequenceOfCustomerStatusType());
+ CustomerStatusType cs = new CustomerStatusType();
+ t.getStatus().add(cs);
+ cs.setCustomerStatus(1L);
+ cs.setCustomerStatusDescr("senior");
+ }
+
+
+ private static void populateIssuingData(IssuingData id) {
+
+ id.setActivated(true);
+ id.setCurrency("SRF");
+ id.setCurrencyFract(3L);
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ id.setExtension(e1);
+
+ id.setIssuedOnLine(12L);
+ id.setIssuedOnTrainIA5("123");
+ id.setIssuedOnTrainNum(123L);
+ id.setIssuerName("name");
+ id.setIssuerIA5("1");
+ id.setIssuerNum(15000L);
+ id.setIssuerPNR("issuerTestPNR");
+ id.setIssuingDay(1L);
+ id.setIssuingTime(600L);
+ id.setIssuingYear(2018L);
+ id.setSecurePaperTicket(false);
+ id.setSecurityProviderIA5("1");
+ id.setSecurityProviderNum(1L);
+ id.setSpecimen(true);
+ id.setPointOfSale(new GeoCoordinateType());
+ id.getPointOfSale().setGeoUnit(GeoUnitType.microDegree);
+ id.getPointOfSale().setCoordinateSystem(GeoCoordinateSystemType.wgs84);
+ id.getPointOfSale().setAccuracy(GeoUnitType.microDegree);
+ id.getPointOfSale().setHemisphereLatitude(HemisphereLatitudeType.east);
+ id.getPointOfSale().setHemisphereLongitude(HemisphereLongitudeType.north);
+ id.getPointOfSale().setLatitude(56789L);
+ id.getPointOfSale().setLongitude(12345L);
+
+ }
+
+
+ private static void populateExtension(List<ExtensionData> extensions) {
+
+ ExtensionData e1 = new ExtensionData();
+ e1.setExtensionId("1");
+ e1.setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+ extensions.add(e1);
+
+ ExtensionData e2 = new ExtensionData();
+ e2.setExtensionId("2");
+ e2.setExtensionData(UperEncoder.bytesFromHexString("83DA"));
+ extensions.add(e2);
+
+ }
+
+
+ private static void populateControlDetail(ControlData controlDetail) {
+
+ controlDetail.setAgeCheckRequired(false);
+ controlDetail.setIdentificationByPassportId(false);
+ controlDetail.setIdentificationByIdCard(false);
+ controlDetail.setOnlineValidationRequired(false);
+ controlDetail.setIdentificationItem(12L);
+ controlDetail.setPassportValidationRequired(false);
+ controlDetail.setRandomDetailedValidationRequired(50L);
+ controlDetail.setExtension(new ExtensionData());
+ controlDetail.getExtension().setExtensionId("1");
+ controlDetail.getExtension().setExtensionData(UperEncoder.bytesFromHexString("82DA"));
+
+ controlDetail.setReductionCardCheckRequired(false);
+ controlDetail.setInfoText("control");
+ controlDetail.setIdentificationByCardReference(new SequenceOfCardReferenceType());
+
+ CardReferenceType cr = new CardReferenceType();
+ controlDetail.getIdentificationByCardReference().add(cr);
+ cr.setCardIdIA5("5678");
+ cr.setCardIdNum(5678L);
+ cr.setCardIssuerIA5("1234");
+ cr.setCardIssuerNum(1234L);
+ cr.setCardName("testcard");
+ cr.setCardType(123L);
+ cr.setLeadingCardIdIA5("3456");
+ cr.setLeadingCardIdNum(3456L);
+ cr.setTrailingCardIdIA5("100");
+ cr.setTrailingCardIdNum(100L);
+
+ controlDetail.setIncludedTickets(new SequenceOfTicketLinkType());
+ TicketLinkType tl = new TicketLinkType();
+ controlDetail.getIncludedTickets().add(tl);
+ tl.setIssuerName("XYZ");
+ tl.setIssuerPNR("LDWDUR45");
+ tl.setProductOwnerIA5("IEFHU");
+ tl.setProductOwnerNum(1080L);
+ tl.setLinkMode(LinkMode.issuedTogether);
+ tl.setReferenceIA5("KDJET");
+ tl.setReferenceNum(801234567890L);
+ tl.setTicketType(TicketType.openTicket);
+
+ }
+
+ }
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java
index 157c6db..0095239 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/CarCarriageReservationTestTicketV3.java
@@ -9,6 +9,7 @@ import org.uic.barcode.ticket.api.asn.omv3.IssuingData;
import org.uic.barcode.ticket.api.asn.omv3.LoadingDeckType;
import org.uic.barcode.ticket.api.asn.omv3.PriceTypeType;
import org.uic.barcode.ticket.api.asn.omv3.RoofRackType;
+import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.ticket.api.asn.omv3.CarCarriageReservationData;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCardReferenceType;
import org.uic.barcode.ticket.api.asn.omv3.SequenceOfCarrierNum;
@@ -320,6 +321,10 @@ import org.uic.barcode.ticket.api.asn.omv3.VatDetailType;
return cr;
}
+ public static byte[] getEncodingBytes() {
+ return UperEncoder.bytesFromHexString(getEncodingHex());
+ }
+
}
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java
index a74ad18..5285f03 100644
--- a/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java
+++ b/src/test/java/org/uic/barcode/ticket/api/test/testtickets/DelayTestTicketV3.java
@@ -1,6 +1,7 @@
package org.uic.barcode.ticket.api.test.testtickets;
import org.uic.barcode.asn1.datatypes.Asn1BigInteger;
+import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.ticket.api.asn.omv3.CardReferenceType;
import org.uic.barcode.ticket.api.asn.omv3.ControlData;
import org.uic.barcode.ticket.api.asn.omv3.CustomerStatusType;
@@ -121,6 +122,15 @@ value UicRailTicketData ::= {
}
+ public static byte[] getEncodingBytes() {
+
+ String hex = getEncodingHex();
+
+ return UperEncoder.bytesFromHexString(hex);
+
+
+ }
+
private static void populateTicket(UicRailTicketData ticket) {
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java
index 326eb99..2898b59 100644
--- a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java
+++ b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java
@@ -1,7 +1,6 @@
package org.uic.barcode.ticketTestDB;
-import java.util.Iterator;
import java.util.TimeZone;
import org.junit.After;
@@ -10,11 +9,10 @@ import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.asn1.uper.UperEncoder;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
-import org.uic.barcode.ticket.api.impl.SimpleTrainLink;
import org.uic.barcode.ticket.api.spec.IOpenTicket;
import org.uic.barcode.ticket.api.spec.IPassengerType;
-import org.uic.barcode.ticket.api.spec.IRegionalValidity;
import org.uic.barcode.ticket.api.spec.ITariff;
import org.uic.barcode.ticket.api.spec.ITrainLink;
import org.uic.barcode.ticket.api.spec.ITraveler;
@@ -28,6 +26,9 @@ public class DecodeSparpreisTicketDBTest {
* Prepare tickets.
*/
@Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//decode in local CET time zone
TimeZone.setDefault(TimeZone.getTimeZone("CET"));
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java
index 787abf5..2cb6d69 100644
--- a/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java
+++ b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java
@@ -17,6 +17,7 @@ import org.uic.barcode.Decoder;
import org.uic.barcode.Encoder;
import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
import org.uic.barcode.staticFrame.StaticFrame;
import org.uic.barcode.test.utils.TestUtils;
import org.uic.barcode.ticket.EncodingFormatException;
@@ -46,6 +47,9 @@ public class EncodeSparpreisTicketDBTest {
* @throws IOException
*/
@Before public void prepare() throws IOException, EncodingFormatException, DataFormatException {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
defaulttimeZone = TimeZone.getDefault();
//decode in local CET time zone
TimeZone.setDefault(TimeZone.getTimeZone("CET"));
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java
index 9249f4f..e8922d2 100644
--- a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java
+++ b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java
@@ -18,6 +18,7 @@ import org.junit.Test;
import org.uic.barcode.Decoder;
import org.uic.barcode.asn1.uper.UperEncoder;
import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.logger.LoggerFactory;
public class SignatureValidationDBTicketTest {
@@ -28,6 +29,8 @@ public class SignatureValidationDBTicketTest {
*/
@Before public void prepare() {
+ LoggerFactory.setActivateConsoleLog(true);
+
Security.addProvider(new BouncyCastleProvider());
defaulttimeZone = TimeZone.getDefault();