diff options
-rw-r--r-- | .classpath | 14 | ||||
-rw-r--r-- | .gitignore | 190 | ||||
-rw-r--r-- | .project | 29 | ||||
-rw-r--r-- | .settings/org.eclipse.jdt.core.prefs | 16 | ||||
-rw-r--r-- | .settings/org.eclipse.m2e.core.prefs | 4 | ||||
-rw-r--r-- | .settings/org.eclipse.wst.common.project.facet.core.xml | 4 | ||||
-rw-r--r-- | pom.xml | 130 | ||||
-rw-r--r-- | src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java | 151 | ||||
-rw-r--r-- | src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java | 8 | ||||
-rw-r--r-- | src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java | 243 |
10 files changed, 452 insertions, 337 deletions
diff --git a/.classpath b/.classpath deleted file mode 100644 index 5e12d97..0000000 --- a/.classpath +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
- <classpathentry kind="lib" path="D:/barcode/bc/bcprov-jdk15to18-165.jar"/>
- <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
- <attributes>
- <attribute name="maven.pomderived" value="true"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
@@ -1,4 +1,186 @@ -/bin/
-/target/
-/.settings/
-.project
+target/ + + +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +.idea + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Cache of project +.gradletasknamecache + +# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898 +# gradle/wrapper/gradle-wrapper.properties + +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build + + +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +.project + +.classpath diff --git a/.project b/.project deleted file mode 100644 index 5502f84..0000000 --- a/.project +++ /dev/null @@ -1,29 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>UIC-barcode</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.wst.common.project.facet.core.builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.m2e.core.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.m2e.core.maven2Nature</nature>
- <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 5208f74..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,16 +0,0 @@ -eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
-org.eclipse.jdt.core.compiler.release=disabled
-org.eclipse.jdt.core.compiler.source=1.8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index 14b697b..0000000 --- a/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles=
-eclipse.preferences.version=1
-resolveWorkspaceProjects=true
-version=1
diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml deleted file mode 100644 index 017b6f4..0000000 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<faceted-project>
- <installed facet="java" version="1.8"/>
-</faceted-project>
@@ -1,66 +1,66 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.uic.barcode</groupId>
- <artifactId>org.uic.barcode</artifactId>
- <version>1.2.5-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>UIC barcode</name>
- <description>encoding and decoding of bar code content according to UIC IRS 90918-9</description>
- <build>
- <sourceDirectory>src/main/java</sourceDirectory>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>${jdk.version}</source>
- <target>${jdk.version}</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-sources</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-source-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- <goals>
- <goal>jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
- </build>
-
-
- <licenses>
- <license>
- <name>The Apache Software License, Version 2.0</name>
- <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
- <distribution>repo</distribution>
- </license>
- </licenses>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.uic.barcode</groupId> + <artifactId>org.uic.barcode</artifactId> + <version>1.2.5-SNAPSHOT</version> + <packaging>jar</packaging> + <name>UIC barcode</name> + <description>encoding and decoding of bar code content according to UIC IRS 90918-9</description> + <build> + <sourceDirectory>src/main/java</sourceDirectory> + <resources> + <resource> + <directory>src/main/java</directory> + <excludes> + <exclude>**/*.java</exclude> + </excludes> + </resource> + </resources> + + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.3.2</version> + <configuration> + <source>${jdk.version}</source> + <target>${jdk.version}</target> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + + </build> + + + <licenses> + <license> + <name>The Apache Software License, Version 2.0</name> + <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> + <distribution>repo</distribution> + </license> + </licenses> </project>
\ No newline at end of file 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 edf3348..4b09604 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeObjectIdentifierTest.java @@ -1,76 +1,75 @@ -package org.uic.barcode.asn1.test;
-
-import static org.junit.Assert.assertEquals;
-import java.util.logging.Level;
-
-import org.junit.jupiter.api.Test;
-import org.uic.barcode.asn1.datatypes.Asn1Optional;
-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;
-
-class UperEncodeObjectIdentifierTest {
-
-
- /**
- * Example from the Standard on UPER.
- <pre>
- TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE {
- value1 OBJECT IDENTIFIER,
- value2 OBJECT IDENTIFIER,
- value3 OBJECT IDENTIFIER
- }
-
- value TestRecord ::= {
- value1 2.16.840.1.101.3.4.3.1,
- value2 2.16.840.1.101.3.4.3.2,
- value3 1.2.840.10045.3.1.7
- }
- </pre>
- */
-
- @Sequence
- public static class TestRecord {
-
- @FieldOrder(order = 0)
- @RestrictedString(CharacterRestriction.ObjectIdentifier)
- String value1 = "2.16.840.1.101.3.4.3.1"; //DSA SHA224
-
- @FieldOrder(order = 1)
- @RestrictedString(CharacterRestriction.ObjectIdentifier)
- String value2 = "2.16.840.1.101.3.4.3.2"; //DSA SHA248
-
- @FieldOrder(order = 2)
- @RestrictedString(CharacterRestriction.ObjectIdentifier)
- String value3 = "1.2.840.10045.3.1.7"; //ECC
-
- public TestRecord() {}
-
- }
-
- @Test
- public void testEncode() throws IllegalArgumentException, IllegalAccessException {
- TestRecord record = new TestRecord();
- byte[] encoded = UperEncoder.encode(record);
- String hex = UperEncoder.hexStringFromBytes(encoded);
- UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex));
- assertEquals("0960864801650304030109608648016503040302082A8648CE3D030107",hex);
- }
-
- @Test
- public void testDecode() throws IllegalArgumentException, IllegalAccessException {
- TestRecord record = new TestRecord();
- byte[] encoded = UperEncoder.encode(record);
- String hex = UperEncoder.hexStringFromBytes(encoded);
- UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex));
- assertEquals("0960864801650304030109608648016503040302082A8648CE3D030107",hex);
- TestRecord result = UperEncoder.decode(encoded, TestRecord.class);
- assertEquals(result.value1,record.value1);
- assertEquals(result.value2,record.value2);
- assertEquals(result.value3,record.value3);
- }
-
-
-}
+package org.uic.barcode.asn1.test; + +import static org.junit.Assert.assertEquals; +import java.util.logging.Level; + +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; + +public class UperEncodeObjectIdentifierTest { + + + /** + * Example from the Standard on UPER. + <pre> + TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { + value1 OBJECT IDENTIFIER, + value2 OBJECT IDENTIFIER, + value3 OBJECT IDENTIFIER + } + + value TestRecord ::= { + value1 2.16.840.1.101.3.4.3.1, + value2 2.16.840.1.101.3.4.3.2, + value3 1.2.840.10045.3.1.7 + } + </pre> + */ + + @Sequence + public static class TestRecord { + + @FieldOrder(order = 0) + @RestrictedString(CharacterRestriction.ObjectIdentifier) + String value1 = "2.16.840.1.101.3.4.3.1"; //DSA SHA224 + + @FieldOrder(order = 1) + @RestrictedString(CharacterRestriction.ObjectIdentifier) + String value2 = "2.16.840.1.101.3.4.3.2"; //DSA SHA248 + + @FieldOrder(order = 2) + @RestrictedString(CharacterRestriction.ObjectIdentifier) + String value3 = "1.2.840.10045.3.1.7"; //ECC + + public TestRecord() {} + + } + + @Test + public void testEncode() throws IllegalArgumentException, IllegalAccessException { + TestRecord record = new TestRecord(); + byte[] encoded = UperEncoder.encode(record); + String hex = UperEncoder.hexStringFromBytes(encoded); + UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); + assertEquals("0960864801650304030109608648016503040302082A8648CE3D030107",hex); + } + + @Test + public void testDecode() throws IllegalArgumentException, IllegalAccessException { + TestRecord record = new TestRecord(); + byte[] encoded = UperEncoder.encode(record); + String hex = UperEncoder.hexStringFromBytes(encoded); + UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); + assertEquals("0960864801650304030109608648016503040302082A8648CE3D030107",hex); + TestRecord result = UperEncoder.decode(encoded, TestRecord.class); + assertEquals(result.value1,record.value1); + assertEquals(result.value2,record.value2); + assertEquals(result.value3,record.value3); + } + + +} 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 5f4edc8..75ace32 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeStringTest.java @@ -50,7 +50,7 @@ public class UperEncodeStringTest { @Test public void testEncode() throws IllegalArgumentException, IllegalAccessException { - //Teststring: AêñüC + //Teststring: AêñüC String original = new String("A" + "\u00ea" + "\u00f1" + "\u00fc" + "C"); TestRecord record = new TestRecord(original, "Meier"); @@ -63,7 +63,7 @@ public class UperEncodeStringTest { @Test public void testEncodeUtf8() throws IllegalArgumentException, IllegalAccessException { - //"ä½ å¥½å?—" + //"你好å?—" String original = new String("\u00e4" + "\u00bd" + "\u00a0" + "\u00e5" + "\u00a5" + "\u00bd" + "\u00e5" + "\u0090" + "\u0097"); TestRecord record = new TestRecord(original, "Meier"); byte[] encoded = UperEncoder.encode(record); @@ -76,7 +76,7 @@ public class UperEncodeStringTest { @Test public void testDecode() throws IllegalArgumentException, IllegalAccessException { - //Teststring: AêñüC + //Teststring: AêñüC String original = new String("A" + "\u00ea" + "\u00f1" + "\u00fc" + "C"); TestRecord record = new TestRecord(original, "Meier"); @@ -91,7 +91,7 @@ public class UperEncodeStringTest { @Test public void testDecodeUtf8() throws IllegalArgumentException, IllegalAccessException { - //"ä½ å¥½å?—" + //"你好å?—" String original = new String("\u00e4" + "\u00bd" + "\u00a0" + "\u00e5" + "\u00a5" + "\u00bd" + "\u00e5" + "\u0090" + "\u0097"); TestRecord record = new TestRecord(original, "Meier"); byte[] encoded = UperEncoder.encode(record); diff --git a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java index 9999cec..1f1be30 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java @@ -1,122 +1,123 @@ -package org.uic.barcode.ticketTestDB;
-
-
-import java.util.TimeZone;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.uic.barcode.Decoder;
-import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
-import org.uic.barcode.ticket.api.spec.IOpenTicket;
-import org.uic.barcode.ticket.api.spec.IPassengerType;
-import org.uic.barcode.ticket.api.spec.ITariff;
-import org.uic.barcode.ticket.api.spec.ITrainLink;
-import org.uic.barcode.ticket.api.spec.ITraveler;
-import org.uic.barcode.ticket.api.spec.IUicRailTicket;
-
-public class DecodeSparpreisTicketDBTest {
-
- TimeZone defaulttimeZone = null;
-
- /**
- * Prepare tickets.
- */
- @Before public void prepare() {
- defaulttimeZone = TimeZone.getDefault();
- //decode in local CET time zone
- TimeZone.setDefault(TimeZone.getTimeZone("CET"));
- }
-
-
- /**
- * clean up
- */
- @After public void resetTimeZone() {
- TimeZone.setDefault(defaulttimeZone);
- }
-
- @Test
- public void testDecoder() throws Exception {
-
-
- byte[] content = UperEncoder.bytesFromHexString(getEncodingV2Hex());
-
- // try to decode
- Decoder decoder = new Decoder(content);
- TicketLayout layout = decoder.getLayout();
- IUicRailTicket ticket = decoder.getUicTicket();
-
-
- Assert.assertNotNull(ticket);
-
- Assert.assertNotNull(ticket.getDocumentData());
- Assert.assertNotNull(ticket.getIssuerDetails());
- Assert.assertNotNull(ticket.getTravelerDetails());
-
- assert(ticket.getIssuerDetails().getIssuer().equals("1080"));
- assert(ticket.getIssuerDetails().getIssuerPNR().equals("D260V48G"));
- String issuingDate = ticket.getIssuerDetails().getIssuingDate().toString();
- assert(issuingDate.equals("Fri Oct 30 11:50:00 CET 2020"));
- assert(ticket.getIssuerDetails().getSecurityProvider().equals("1080"));
- assert(ticket.getIssuerDetails().isSecurePaperTicket() == false);
- assert(ticket.getIssuerDetails().isActivated() == true);
- assert(ticket.getIssuerDetails().isSpecimen() == false);
-
- assert(ticket.getTravelerDetails().getTravelers().size() == 1);
- ITraveler traveler = ticket.getTravelerDetails().getTravelers().iterator().next();
- assert(traveler.getFirstName().equals("Karsten"));
- assert(traveler.getLastName().equals("Will"));
- assert(traveler.isTicketHolder() == true);
-
- assert(ticket.getDocumentData().size() == 1);
- IOpenTicket openTicket = (IOpenTicket) ticket.getDocumentData().iterator().next();
- Assert.assertNotNull(openTicket.getValidRegionList());
- assert(openTicket.getReference().equals("CN0CTUMY"));
- String fromDate = openTicket.getValidFrom().toString();
- assert(fromDate.equals("Thu Nov 05 00:00:00 CET 2020"));
- assert(openTicket.getValidFromUTCoffset() == -4L);
- String toDate = openTicket.getValidUntil().toString();
- assert(toDate.equals("Fri Nov 06 10:00:00 CET 2020"));
- assert(openTicket.getValidUntilUTCoffset() == -4L);
-
- Assert.assertNotNull(openTicket.getTariffs());
- assert(openTicket.getTariffs().size() == 1);
- ITariff tariff = openTicket.getTariffs().iterator().next();
- assert(tariff.getNumberOfPassengers() == 1);
- assert(tariff.getPassengerType().equals(IPassengerType.adult));
- assert(tariff.getTariffDescription().equals("Super Sparpreis"));
-
- ITrainLink tl = (ITrainLink) openTicket.getValidRegionList().iterator().next();
- Assert.assertNotNull(tl);
- assert(tl.getTrain().equals("ICE973"));
- String departureDate = tl.getDepartureDateTime().toString();
- assert(departureDate.equals("Fri Nov 06 11:58:00 CET 2020"));
- Assert.assertNull(layout);
- Assert.assertNotNull(decoder);
- }
-
- public static String getEncodingV2Hex() {
-
- return "2355543032313038303030303032782e" +
- "2fe184a1d85e89e9338b298ec61aeba2" +
- "48ce722056ca940a967c8a1d39126e2c" +
- "628c4fcea91ba35216a0a350f894de5e" +
- "bd7b8909920fde947feede0e20c43031" +
- "3939789c01bc0043ff555f464c455831" +
- "333031383862b20086e10dc125ea2815" +
- "110881051c844464d985668e23a00a80" +
- "000e96c2e4e6e8cadc08aed2d8d90104" +
- "44d7be0100221ce610ea559b64364c38" +
- "a82361d1cb5e1e5d32a3d0979bd099c8" +
- "426b0b7373432b4b6852932baba3634b" +
- "733b2b715ab34b09d101e18981c181f1" +
- "424221521291521292a17a3a920a1152" +
- "5a095282314952b20a49529952826278" +
- "083001a4c38ae5bb303ace7003800700" +
- "14b00240400f53757065722053706172" +
- "7072656973c41e4a03";
- }
+package org.uic.barcode.ticketTestDB; + + +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.Decoder; +import org.uic.barcode.asn1.uper.UperEncoder; +import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; +import org.uic.barcode.ticket.api.spec.IOpenTicket; +import org.uic.barcode.ticket.api.spec.IPassengerType; +import org.uic.barcode.ticket.api.spec.ITariff; +import org.uic.barcode.ticket.api.spec.ITrainLink; +import org.uic.barcode.ticket.api.spec.ITraveler; +import org.uic.barcode.ticket.api.spec.IUicRailTicket; + +public class DecodeSparpreisTicketDBTest { + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + defaulttimeZone = TimeZone.getDefault(); + //decode in local CET time zone + TimeZone.setDefault(TimeZone.getTimeZone("CET")); + } + + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + @Test + public void testDecoder() throws Exception { + + + byte[] content = UperEncoder.bytesFromHexString(getEncodingV2Hex()); + + // try to decode + Decoder decoder = new Decoder(content); + TicketLayout layout = decoder.getLayout(); + IUicRailTicket ticket = decoder.getUicTicket(); + + + Assert.assertNotNull(ticket); + + Assert.assertNotNull(ticket.getDocumentData()); + Assert.assertNotNull(ticket.getIssuerDetails()); + Assert.assertNotNull(ticket.getTravelerDetails()); + + assert(ticket.getIssuerDetails().getIssuer().equals("1080")); + assert(ticket.getIssuerDetails().getIssuerPNR().equals("D260V48G")); + String issuingDate = ticket.getIssuerDetails().getIssuingDate().toString(); + assert(issuingDate.equals("Fri Oct 30 11:50:00 CET 2020")); + assert(ticket.getIssuerDetails().getSecurityProvider().equals("1080")); + assert(ticket.getIssuerDetails().isSecurePaperTicket() == false); + assert(ticket.getIssuerDetails().isActivated() == true); + assert(ticket.getIssuerDetails().isSpecimen() == false); + + assert(ticket.getTravelerDetails().getTravelers().size() == 1); + ITraveler traveler = ticket.getTravelerDetails().getTravelers().iterator().next(); + assert(traveler.getFirstName().equals("Karsten")); + assert(traveler.getLastName().equals("Will")); + assert(traveler.isTicketHolder() == true); + + assert(ticket.getDocumentData().size() == 1); + IOpenTicket openTicket = (IOpenTicket) ticket.getDocumentData().iterator().next(); + Assert.assertNotNull(openTicket.getValidRegionList()); + assert(openTicket.getReference().equals("CN0CTUMY")); + String fromDate = openTicket.getValidFrom().toString(); + assert(fromDate.equals("Thu Nov 05 00:00:00 CET 2020")); + assert(openTicket.getValidFromUTCoffset() == -4L); + String toDate = openTicket.getValidUntil().toString(); + assert(toDate.equals("Fri Nov 06 10:00:00 CET 2020")); + assert(openTicket.getValidUntilUTCoffset() == -4L); + + Assert.assertNotNull(openTicket.getTariffs()); + assert(openTicket.getTariffs().size() == 1); + ITariff tariff = openTicket.getTariffs().iterator().next(); + assert(tariff.getNumberOfPassengers() == 1); + assert(tariff.getPassengerType().equals(IPassengerType.adult)); + assert(tariff.getTariffDescription().equals("Super Sparpreis")); + + ITrainLink tl = (ITrainLink) openTicket.getValidRegionList().iterator().next(); + Assert.assertNotNull(tl); + assert(tl.getTrain().equals("ICE973")); + String departureDate = tl.getDepartureDateTime().toString(); + assert(departureDate.equals("Fri Nov 06 11:58:00 CET 2020")); + Assert.assertNull(layout); + Assert.assertNotNull(decoder); + } + + public static String getEncodingV2Hex() { + + return "2355543032313038303030303032782e" + + "2fe184a1d85e89e9338b298ec61aeba2" + + "48ce722056ca940a967c8a1d39126e2c" + + "628c4fcea91ba35216a0a350f894de5e" + + "bd7b8909920fde947feede0e20c43031" + + "3939789c01bc0043ff555f464c455831" + + "333031383862b20086e10dc125ea2815" + + "110881051c844464d985668e23a00a80" + + "000e96c2e4e6e8cadc08aed2d8d90104" + + "44d7be0100221ce610ea559b64364c38" + + "a82361d1cb5e1e5d32a3d0979bd099c8" + + "426b0b7373432b4b6852932baba3634b" + + "733b2b715ab34b09d101e18981c181f1" + + "424221521291521292a17a3a920a1152" + + "5a095282314952b20a49529952826278" + + "083001a4c38ae5bb303ace7003800700" + + "14b00240400f53757065722053706172" + + "7072656973c41e4a03"; + } + }
\ No newline at end of file |