diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2021-04-12 19:25:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-12 19:25:09 +0200 |
commit | c3d1c3ec323c1321b1e81bfbfed38f022c66a207 (patch) | |
tree | f163bda9d7fad6fe354c2e8b9fa53980c86d2eab /src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java | |
parent | Merge pull request #20 from UnionInternationalCheminsdeFer/fix_train_link (diff) | |
parent | included open ticket test (diff) | |
download | UIC-barcode-c3d1c3ec323c1321b1e81bfbfed38f022c66a207.tar UIC-barcode-c3d1c3ec323c1321b1e81bfbfed38f022c66a207.tar.gz UIC-barcode-c3d1c3ec323c1321b1e81bfbfed38f022c66a207.tar.bz2 UIC-barcode-c3d1c3ec323c1321b1e81bfbfed38f022c66a207.tar.lz UIC-barcode-c3d1c3ec323c1321b1e81bfbfed38f022c66a207.tar.xz UIC-barcode-c3d1c3ec323c1321b1e81bfbfed38f022c66a207.tar.zst UIC-barcode-c3d1c3ec323c1321b1e81bfbfed38f022c66a207.zip |
Diffstat (limited to '')
-rw-r--r-- | src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java | 96 |
1 files changed, 96 insertions, 0 deletions
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 new file mode 100644 index 0000000..da167c4 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/OpenTicketComplexTestV2.java @@ -0,0 +1,96 @@ +package org.uic.barcode.ticket.api.test; + +import java.text.ParseException; +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.api.asn.omv2.UicRailTicketData; +import org.uic.barcode.ticket.api.test.testtickets.OpenTestComplexTicketV2; + + + +/** + * The Class FipTimeZoneTestV2. + * + * + * + */ +public class OpenTicketComplexTestV2 { + + + + /** The ticket decoded 1. */ + UicRailTicketData ticket = null; + + byte[] encodedInTimeZone1 = null; + + + TimeZone defaulttimeZone = null; + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + defaulttimeZone = TimeZone.getDefault(); + + //encode in UTC time zone + TimeZone.setDefault(TimeZone.getTimeZone("UTC")); + + + } + + /** + * 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 decoding() { + + //get tickets + String hex = OpenTestComplexTicketV2.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + assert(ticket != null); + + } + + @Test public void encoding() throws IllegalArgumentException, IllegalAccessException, ParseException { + + //get tickets + String hex = OpenTestComplexTicketV2.getEncodingHex(); + byte[] content = UperEncoder.bytesFromHexString(hex); + ticket = UperEncoder.decode(content, UicRailTicketData.class); + + + //ticket = OpenTestComplexTicketV2.getUicTestTicket(); + byte[] encoded = UperEncoder.encode(ticket); + + + + assert(encoded != null); + assert(encoded.length > 20); + + String encodedHex = UperEncoder.hexStringFromBytes(encoded); + String expectedHex = OpenTestComplexTicketV2.getEncodingHex(); + + assert(expectedHex.equals(encodedHex)); + + } + + +} |