diff options
Diffstat (limited to '')
14 files changed, 201 insertions, 127 deletions
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java b/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java index 30043c0..cb5c37a 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java @@ -1,8 +1,5 @@ package org.uic.barcode.dynamicFrame.v2;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Signature;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
@@ -14,7 +11,6 @@ import org.uic.barcode.dynamicContent.api.DynamicContentCoder; import org.uic.barcode.dynamicContent.api.IUicDynamicContent;
import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.utils.AlgorithmNameResolver;
/**
@@ -122,53 +118,5 @@ public class DynamicFrame extends Object{ return UperEncoder.decode(bytes, DynamicFrame.class);
}
-
-
- /**
- * Adds the dynamic content and encodes it. (API level)
- *
- * @param content the dynamic content
- * @throws EncodingFormatException the encoding format exception
- */
- public void addDynamicContent(IUicDynamicContent content) throws EncodingFormatException {
-
-
- this.getLevel2SignedData().setLevel2Data(new DataType());
-
- this.getLevel2SignedData().getLevel2Data().setFormat(DynamicContentCoder.dynamicContentDataFDC1);
-
- this.getLevel2SignedData().getLevel2Data().setByteData(DynamicContentCoder.encode(content, DynamicContentCoder.dynamicContentDataFDC1));
-
- }
-
- /**
- * Adds the level 2 dynamic data. (ASN level)
- *
- * @param dynamicData the dynamic data
- */
- public void addLevel2DynamicData(UicDynamicContentDataFDC1 dynamicData) {
- DataType dt = new DataType();
- dt.setByteData(dynamicData.getDataType().getByteData());
- dt.setFormat(dynamicData.getDataType().getFormat());
- level2SignedData.setLevel2Data(dt);
- }
-
- /**
- * Gets the dynamic content.
- *
- * @return the dynamic content
- */
- public IUicDynamicContent getDynamicContent() {
-
- if (this.getLevel2SignedData() == null ||
- this.getLevel2SignedData().getLevel2Data() == null){
- return null;
- }
-
- return DynamicContentCoder.decode(this.getLevel2SignedData().getLevel2Data().getByteData());
-
- }
-
-
}
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v2/Level2DataType.java b/src/main/java/org/uic/barcode/dynamicFrame/v2/Level2DataType.java index cd0800e..262fa2f 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/v2/Level2DataType.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/v2/Level2DataType.java @@ -1,15 +1,10 @@ package org.uic.barcode.dynamicFrame.v2;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Signature;
-
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.datatypesimpl.OctetString;
import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.utils.AlgorithmNameResolver;
/**
* The Class DataType.
@@ -76,46 +71,7 @@ public class Level2DataType { return UperEncoder.encode(this);
}
- /**
- * Sign the contained data block.
- *
- * Note: an appropriate security provider (e.g. BC) must be registered before
- *
- * @param key the key
- * @return
- * @return the byte[]
- * @throws Exception
- */
- public void signLevel1(PrivateKey key) throws Exception {
- //find the algorithm name for the signature OID
- String algo = AlgorithmNameResolver.getSignatureAlgorithmName(getLevel1Data().level1SigningAlg);
- Signature sig = Signature.getInstance(algo);
- sig.initSign(key);
- byte[] data = level1Data.encode();
- sig.update(data);
- this.level1Signature = new OctetString(sig.sign());
- }
- /**
- * Sign the contained data block.
- *
- * Note: an appropriate security provider (e.g. BC) must be registered before
- *
- * @param key the key
- * @param security provider - security provider that must be sued to create the signature
- * @return
- * @return the byte[]
- * @throws Exception
- */
- public void signLevel1(PrivateKey key, Provider prov) throws Exception {
- //find the algorithm name for the signature OID
- String algo = AlgorithmNameResolver.getSignatureAlgorithmName(getLevel1Data().level1SigningAlg);
- Signature sig = Signature.getInstance(algo, prov);
- sig.initSign(key);
- byte[] data = level1Data.encode();
- sig.update(data);
- this.level1Signature = new OctetString(sig.sign());
- }
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfPlaceNum.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfPlaceNum.java index 3780dc3..1a6dbfc 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfPlaceNum.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfPlaceNum.java @@ -20,7 +20,6 @@ public class SequenceOfPlaceNum extends Asn1SequenceOf<Long> { }
}
- @Deprecated
public static SequenceOfPlaceNum getSequence(List<Long> numList) {
if (numList == null || numList.isEmpty()) return null;
return new SequenceOfPlaceNum(numList);
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfServiceBrands.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfServiceBrands.java index 388392b..3048235 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfServiceBrands.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfServiceBrands.java @@ -19,7 +19,6 @@ public class SequenceOfServiceBrands extends Asn1SequenceOf<Long> { }
}
- @Deprecated
public static SequenceOfServiceBrands getSequence(List<Long> numList) {
if (numList == null || numList.isEmpty()) return null;
return new SequenceOfServiceBrands(numList);
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTransportTypes.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTransportTypes.java index 934b5c9..edec045 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTransportTypes.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTransportTypes.java @@ -19,7 +19,6 @@ public class SequenceOfTransportTypes extends Asn1SequenceOf<Long> { }
}
- @Deprecated
public static SequenceOfTransportTypes getSequence(List<Long> numList) {
if (numList == null || numList.isEmpty()) return null;
return new SequenceOfTransportTypes(numList);
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTravelerId.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTravelerId.java index b04fcfa..6808104 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTravelerId.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv3/SequenceOfTravelerId.java @@ -18,7 +18,6 @@ public class SequenceOfTravelerId extends Asn1SequenceOf<Long> { }
}
- @Deprecated
public static SequenceOfTravelerId getSequence(List<Long> numList) {
if (numList == null || numList.isEmpty()) return null;
return new SequenceOfTravelerId(numList);
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java index f4b9569..633f2d7 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoder.java @@ -359,6 +359,7 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setCompartmentDetails(encodeCompartmentDetails(document.getCompartmentDetails()));
@@ -389,21 +390,20 @@ public class Api2OpenAsnEncoder implements Api2AsnEncoder { asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),1,5));
- asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),1,2));
- asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,5));
+ asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),0,4));
+ asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),0,2));
+ asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),0,5));
if (document.getLoadingDeck() != ILoadingDeckType.upper && document.getLoadingDeck() != null){
asnData.setLoadingDeck(LoadingDeckType.valueOf(document.getLoadingDeck().name()));
}
- asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,200));
-
- asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),1,6));
- asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),1,9));
+ asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getLoadingListEntry(),0,999));
+ asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),0,6));
+ asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),0,9));
asnData.setCoach(UicEncoderUtils.getIA5(document.getCoach()));
- asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),1,99));
+ asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),0,99));
if (document.getRoofRackType()!= IRoofRackType.norack && document.getRoofRackType() != null ) {
asnData.setRoofRackType(RoofRackType.valueOf(document.getRoofRackType().name()));
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java index 6bffddc..00c0ce3 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV2.java @@ -386,21 +386,21 @@ public class Api2OpenAsnEncoderV2 implements Api2AsnEncoder { asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),1,5));
- asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),1,2));
- asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,5));
-
+ asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),0,4));
+ asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),0,2));
+ asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),0,5));
+
if (document.getLoadingDeck() != ILoadingDeckType.upper && document.getLoadingDeck() != null){
asnData.setLoadingDeck(LoadingDeckType.valueOf(document.getLoadingDeck().name()));
}
- asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,200));
+ asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),0,999));
- asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),1,6));
- asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),1,9));
+ asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),0,6));
+ asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),0,9));
asnData.setCoach(UicEncoderUtils.getIA5(document.getCoach()));
- asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),1,99));
+ asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),0,99));
if (document.getRoofRackType()!= IRoofRackType.norack && document.getRoofRackType() != null) {
asnData.setRoofRackType(RoofRackType.valueOf(document.getRoofRackType().name()));
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java index 0ead754..c586da0 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/Api2OpenAsnEncoderV3.java @@ -360,6 +360,7 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setCarrierNum(SequenceOfCarrierNum.getSequence(UicEncoderUtils.getNumList(document.getCarriers())));
asnData.setCarrierIA5(UicEncoderUtils.getIA5NonNumList(document.getCarriers()));
+ asnData.setInfoText(document.getInfoText());
asnData.setExtension(encodeExtension(document.getExtension()));
asnData.setCompartmentDetails(encodeCompartmentDetails(document.getCompartmentDetails()));
@@ -390,21 +391,21 @@ public class Api2OpenAsnEncoderV3 implements Api2AsnEncoder { asnData.setToStationNameUTF8(document.getToStationName());
- asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),1,5));
- asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),1,2));
- asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,5));
+ asnData.setAttachedBicycles(UicEncoderUtils.getRestrictedInt(document.getAttachedBicycles(),0,4));
+ asnData.setAttachedBoats(UicEncoderUtils.getRestrictedInt(document.getAttachedBoats(),0,2));
+ asnData.setAttachedSurfboards(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),0,5));
if (document.getLoadingDeck() != ILoadingDeckType.upper && document.getLoadingDeck() != null){
asnData.setLoadingDeck(LoadingDeckType.valueOf(document.getLoadingDeck().name()));
}
- asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getAttachedSurfboards(),1,200));
-
- asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),1,6));
- asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),1,9));
+ asnData.setLoadingListEntry(UicEncoderUtils.getRestrictedInt(document.getLoadingListEntry(),0,999));
+ asnData.setBoatCategory(UicEncoderUtils.getRestrictedInt(document.getBoatCategory(),0,6));
+ asnData.setCarCategory(UicEncoderUtils.getRestrictedInt(document.getCarCategory(),0,9));
+ asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),0,99));
+
asnData.setCoach(UicEncoderUtils.getIA5(document.getCoach()));
- asnData.setRoofRackHeight(UicEncoderUtils.getRestrictedInt(document.getRoofRackHeight(),1,99));
if (document.getRoofRackType()!= IRoofRackType.norack && document.getRoofRackType() != null) {
asnData.setRoofRackType(RoofRackType.valueOf(document.getRoofRackType().name()));
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java index f4e041f..f62e1f9 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoder.java @@ -648,7 +648,7 @@ public class OpenAsn2ApiDecoder implements Asn2ApiDecoder { }
}
- return null;
+ return document;
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java index 57d2366..1f8e25b 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV2.java @@ -650,7 +650,7 @@ public class OpenAsn2ApiDecoderV2 implements Asn2ApiDecoder { }
}
- return null;
+ return document;
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java index 9521858..b656d3c 100644 --- a/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java +++ b/src/main/java/org/uic/barcode/ticket/api/utils/OpenAsn2ApiDecoderV3.java @@ -653,7 +653,7 @@ public class OpenAsn2ApiDecoderV3 implements Asn2ApiDecoder { }
}
- return null;
+ return document;
}
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..b711c84 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticket/api/test/CarCarriageTestV3.java @@ -0,0 +1,168 @@ +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.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 (IOException 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 (IOException 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/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());
+ }
+
}
|