From 7ec06722923d96d2e51300bafb44b920ca341d58 Mon Sep 17 00:00:00 2001 From: CGantert345 <57003061+CGantert345@users.noreply.github.com> Date: Fri, 10 Mar 2023 16:49:58 +0100 Subject: ssb unit tests --- src/main/java/org/uic/barcode/Decoder.java | 9 +- src/main/java/org/uic/barcode/Encoder.java | 2 + .../org/uic/barcode/asn1/uper/ByteBitBuffer.java | 1 + src/main/java/org/uic/barcode/package.html | 30 +++--- .../uic/barcode/ssbFrame/SsbCommonTicketPart.java | 7 +- .../java/org/uic/barcode/ssbFrame/SsbFrame.java | 102 ++++++++++++++++----- .../java/org/uic/barcode/ssbFrame/SsbGroup.java | 19 ++-- .../java/org/uic/barcode/ssbFrame/SsbHeader.java | 8 +- .../uic/barcode/ssbFrame/SsbNonReservation.java | 14 ++- .../java/org/uic/barcode/ssbFrame/SsbNonUic.java | 41 +++++++-- .../java/org/uic/barcode/ssbFrame/SsbPass.java | 11 ++- .../org/uic/barcode/ssbFrame/SsbReservation.java | 24 +++-- .../org/uic/barcode/ssbFrame/SsbTicketPart.java | 10 +- .../java/org/uic/barcode/staticFrame/package.html | 29 +++--- .../org/uic/barcode/ticket/api/asn/package.html | 8 +- .../org/uic/barcode/ticket/api/impl/package.html | 7 +- .../org/uic/barcode/ticket/api/spec/package.html | 10 +- .../org/uic/barcode/ticket/api/utils/package.html | 7 +- src/main/java/org/uic/barcode/ticket/package.html | 12 ++- src/main/java/org/uic/barcode/utils/package.html | 21 +++-- 20 files changed, 249 insertions(+), 123 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/uic/barcode/Decoder.java b/src/main/java/org/uic/barcode/Decoder.java index 1b3fb0c..85faa4a 100644 --- a/src/main/java/org/uic/barcode/Decoder.java +++ b/src/main/java/org/uic/barcode/Decoder.java @@ -213,6 +213,13 @@ public class Decoder { } else { throw e; } + } catch (AssertionError e) { + dynamicFrame = null; + if (isSsbFrame(data)) { + decodeSsbFrame(data); + } else { + throw new EncodingFormatException(e.getMessage()); + } } } else if (isStaticHeader(data)){ @@ -292,7 +299,7 @@ public class Decoder { * @return true, if is static header */ private boolean isSsbFrame(byte[] data) { - if (data.length == 144) { + if (data.length == 114) { return true; } return false; diff --git a/src/main/java/org/uic/barcode/Encoder.java b/src/main/java/org/uic/barcode/Encoder.java index cf2d4d2..f2b9b0c 100644 --- a/src/main/java/org/uic/barcode/Encoder.java +++ b/src/main/java/org/uic/barcode/Encoder.java @@ -462,6 +462,8 @@ public class Encoder { return DynamicFrameCoder.encode(dynamicFrame); } else if (staticFrame != null) { return staticFrame.encode(); + } else if (ssbFrame != null) { + return ssbFrame.encode(); } return null; } diff --git a/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java b/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java index e409005..ce5ca60 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java +++ b/src/main/java/org/uic/barcode/asn1/uper/ByteBitBuffer.java @@ -125,6 +125,7 @@ public class ByteBitBuffer implements BitBuffer { public ByteBitBuffer(byte[] backingArray) { this.bytes = backingArray; this.isFinite = true; + this.limit = backingArray.length * 8; } private ByteBitBuffer(int initialCapacity) { diff --git a/src/main/java/org/uic/barcode/package.html b/src/main/java/org/uic/barcode/package.html index 4a6ee0d..075af29 100644 --- a/src/main/java/org/uic/barcode/package.html +++ b/src/main/java/org/uic/barcode/package.html @@ -3,19 +3,21 @@
-Provides the decoder and encoder for a UIC barcode
- - - Included features:
-
Provides the decoder and encoder for a UIC barcode
+ + +
+ Included features:
+
+