diff options
Diffstat (limited to 'src/org/uic/barcode/test/utils')
5 files changed, 0 insertions, 439 deletions
diff --git a/src/org/uic/barcode/test/utils/Level2TestDataFactory.java b/src/org/uic/barcode/test/utils/Level2TestDataFactory.java deleted file mode 100644 index b1eb0f5..0000000 --- a/src/org/uic/barcode/test/utils/Level2TestDataFactory.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.uic.barcode.test.utils;
-
-import org.uic.barcode.asn1.datatypesimpl.OctetString;
-import org.uic.barcode.dynamicFrame.DataType;
-
-public class Level2TestDataFactory {
-
- public static DataType getLevel2SimpleTestData() {
-
- String testContent = "2020.10.01T12:12.20";
-
- DataType level2Data = new DataType();
- level2Data.setFormat("TEST");
- level2Data.setData(new OctetString(testContent.getBytes()));
-
- return level2Data;
- }
-
-}
diff --git a/src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java b/src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java deleted file mode 100644 index 0060fcd..0000000 --- a/src/org/uic/barcode/test/utils/SimpleDynamicFrameTestBarcode.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.uic.barcode.test.utils;
-
-import java.security.KeyPair;
-
-import org.uic.barcode.dynamicFrame.Constants;
-import org.uic.barcode.dynamicFrame.DataType;
-import org.uic.barcode.dynamicFrame.DynamicFrame;
-import org.uic.barcode.dynamicFrame.Level1DataType;
-import org.uic.barcode.dynamicFrame.Level2DataType;
-import org.uic.barcode.dynamicFrame.SequenceOfDataType;
-import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.ticket.api.asn.omv1.UicRailTicketData;
-import org.uic.barcode.ticket.api.test.testtickets.SimpleUicTestTicket;
-
-
-public class SimpleDynamicFrameTestBarcode {
-
- public static DynamicFrame getSimpleDynamicHeaderBarcode(String algorithm, KeyPair keyPair) {
-
-
-
- DynamicFrame barcode = null;
-
-
-
- try {
- barcode = new DynamicFrame();
- barcode.setFormat(Constants.DYNAMIC_BARCODE_FORMAT_DEFAULT);
- Level2DataType level2Data = new Level2DataType();
- barcode.setLevel2SignedData(level2Data);
-
- Level1DataType level1Data = new Level1DataType();
- level2Data.setLevel1Data(level1Data);
-
- level1Data.setSecurityProvider("1080");
- level1Data.setKeyId(1L);
-
- level1Data.setLevel1SigningAlg(Constants.ECDSA_SHA256);
-
- DataType data = new DataType();
- UicRailTicketData ticket = SimpleUicTestTicket.getUicTestTicket();
- byte[] ticketData = ticket.encode();
- data.setByteData(ticketData);
- data.setFormat(Constants.DATA_TYPE_FCB_VERSION_1);
- SequenceOfDataType dataSequence = new SequenceOfDataType();
- level1Data.setData(dataSequence);
- level1Data.getData().add(data);
-
- try {
- level2Data.signLevel1(keyPair.getPrivate());
- } catch (Exception e) {
- assert(false);
- }
-
-
- } catch (EncodingFormatException e) {
- e.printStackTrace();
- return null;
- }
-
- return barcode;
- }
-
-
- public static void compareFrame(DynamicFrame frame1, DynamicFrame frame2) {
-
- assert(frame1.getLevel2SignedData().getLevel1Data().getKeyId() == frame2.getLevel2SignedData().getLevel1Data().getKeyId());
-
- assert(frame1.getLevel2SignedData().getLevel1Data().getLevel1SigningAlg().equals(frame2.getLevel2SignedData().getLevel1Data().level1SigningAlg));
-
- assert(frame1.getLevel2SignedData().getLevel1Data().getSecurityProvider().equals(frame2.getLevel2SignedData().getLevel1Data().getSecurityProvider()));
-
- DataType data1 = frame1.getLevel2SignedData().getLevel1Data().getData().get(0);
- DataType data2 = frame2.getLevel2SignedData().getLevel1Data().getData().get(0);
-
- assert(data1.getFormat().equals(data2.getFormat()));
-
- }
-
-}
diff --git a/src/org/uic/barcode/test/utils/SimpleTestTicketLayout.java b/src/org/uic/barcode/test/utils/SimpleTestTicketLayout.java deleted file mode 100644 index 7b9ae1b..0000000 --- a/src/org/uic/barcode/test/utils/SimpleTestTicketLayout.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.uic.barcode.test.utils;
-
-import org.uic.barcode.staticFrame.ticketLayoutBarcode.LayoutElement;
-import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
-
-public class SimpleTestTicketLayout {
-
-
- public static TicketLayout getSimpleTestTicketLayout() {
-
- TicketLayout layout = new TicketLayout();
-
- layout.setLayoutStandard("RCT2");
-
- LayoutElement element = new LayoutElement();
- element.setColumn(1);
- element.setLine(1);
- element.setHeight(1);
- element.setWidth(20);
- element.setText("Müller");
- layout.addLayoutElement(element);
-
- return layout;
-
- }
-
- public static void compare(TicketLayout layout1, TicketLayout layout2) {
-
- assert(layout1.getLayoutStandard().equals(layout2.getLayoutStandard()));
-
- for (LayoutElement e1: layout1.getElements() ) {
-
- for (LayoutElement e2 :layout2.getElements()) {
-
- boolean found = false;
- if (e1.getLine() == e2.getLine() && e1.getColumn() == e2.getColumn()) {
- found = true;
- assert(e1.getText().equals(e2.getText()));
- }
- assert(found == true);
-
- }
-
- }
-
- }
-
-}
diff --git a/src/org/uic/barcode/test/utils/SimpleUICTestTicket.java b/src/org/uic/barcode/test/utils/SimpleUICTestTicket.java deleted file mode 100644 index be34535..0000000 --- a/src/org/uic/barcode/test/utils/SimpleUICTestTicket.java +++ /dev/null @@ -1,254 +0,0 @@ -package org.uic.barcode.test.utils;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.uic.barcode.ticket.api.impl.SimpleCardReference;
-import org.uic.barcode.ticket.api.impl.SimpleControlDetail;
-import org.uic.barcode.ticket.api.impl.SimpleCustomerStatusDescription;
-import org.uic.barcode.ticket.api.impl.SimpleExtension;
-import org.uic.barcode.ticket.api.impl.SimpleIssuingDetail;
-import org.uic.barcode.ticket.api.impl.SimpleOpenTicket;
-import org.uic.barcode.ticket.api.impl.SimpleStationPassage;
-import org.uic.barcode.ticket.api.impl.SimpleTicketLink;
-import org.uic.barcode.ticket.api.impl.SimpleToken;
-import org.uic.barcode.ticket.api.impl.SimpleTraveler;
-import org.uic.barcode.ticket.api.impl.SimpleTravelerDetail;
-import org.uic.barcode.ticket.api.impl.SimpleUicRailTicket;
-import org.uic.barcode.ticket.api.spec.ICardReference;
-import org.uic.barcode.ticket.api.spec.IControlDetail;
-import org.uic.barcode.ticket.api.spec.ICustomerStatusDescription;
-import org.uic.barcode.ticket.api.spec.IExtension;
-import org.uic.barcode.ticket.api.spec.IIssuingDetail;
-import org.uic.barcode.ticket.api.spec.ILinkMode;
-import org.uic.barcode.ticket.api.spec.IOpenTicket;
-import org.uic.barcode.ticket.api.spec.IStationPassage;
-import org.uic.barcode.ticket.api.spec.ITicketLink;
-import org.uic.barcode.ticket.api.spec.IToken;
-import org.uic.barcode.ticket.api.spec.ITraveler;
-import org.uic.barcode.ticket.api.spec.IUicRailTicket;
-
-public class SimpleUICTestTicket {
-
-
- public static IUicRailTicket getUicTestTicket() {
- IUicRailTicket ticket = new SimpleUicRailTicket();
- populateTicket(ticket);
- return ticket;
- }
-
-
- private static void populateTicket(IUicRailTicket ticket) {
-
- ticket.setControlDetails(new SimpleControlDetail());
- populate(ticket.getControlDetails());
-
-
- ticket.setIssuerDetails(new SimpleIssuingDetail());
- populateIssuingData(ticket.getIssuerDetails());
-
- SimpleTravelerDetail td = new SimpleTravelerDetail();
- populateTravelerData(td);
- ticket.setTravelerDetails(td);
-
-
- //OpenTicket
- IOpenTicket do1 = new SimpleOpenTicket();
- populate(do1);
- ticket.addOpenTicket(do1);
-
- //StationPassage
- IStationPassage do2 = new SimpleStationPassage();
- populateStationPassage(do2);
- ticket.addStationPassage(do2);
-
- //token
- IToken to = new SimpleToken();
- to.setTokenProvider("VDV");
- byte[] ba = { (byte) 0x82, (byte) 0xDA };
- to.setToken(ba);
-
-
- ticket.addExtension(populateExtension());
-
- }
-
- /*
- ticket stationPassage : {
- productName "passage"
- ,station {8312345}
- ,stationNameUTF8 { "Amsterdam" }
- ,validFromDay 0
- ,validUntilDay 4
- }
- */
- private static void populateStationPassage(IStationPassage sp) {
- sp.setProductName("passage");
-
- try {
- Date date = new SimpleDateFormat("dd/MM/yyyy").parse("01/01/2018");
- sp.setValidFrom(date);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- try {
- Date date = new SimpleDateFormat("dd/MM/yyyy").parse("04/01/2018");
- sp.setValidUntil(date);
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
- sp.addStation("8312345");
- sp.addStationName("Amsterdam");
-
- }
-
- /*
- {
- token {tokenProviderIA5 "VDV", token '82DA'H }
- ,ticket openTicket : {
- returnIncluded FALSE
- infoText "openTicketInfo"
- }
- }
- */
-
- private static void populate(IOpenTicket otd) {
- otd.setInfoText("openTicketInfo");
- otd.setReturnIncluded(false);
- }
-
-
- /*
- ,travelerDetail{
- traveler {
- {
- firstName "John"
- ,secondName "Dow"
- ,idCard "12345"
- ,ticketHolder TRUE
- ,status {{customerStatusDescr "senior" }}
- }
- }
- ,groupName "myGroup"
- }
- */
-
- private static void populateTravelerData(SimpleTravelerDetail td) {
- td.setGroupName("myGroup");
- ITraveler tr = new SimpleTraveler();
- tr.setIdCard("12345");
- tr.setFirstName("John");
- tr.setSecondName("Dow");
- tr.setTicketHolder(true);
- ICustomerStatusDescription cst = new SimpleCustomerStatusDescription();
- tr.addStatusDescription(cst);
- cst.setDescription("senior");
- td.addTraveler(tr);
- }
-
- /*
- ,issuingDetail {
- issuerNum 1080
- issuingYear 2018
- issuingDay 1
- specimen TRUE,
- securePaperTicket FALSE,
- activated TRUE,
- issuerPNR "issuerTestPNR",
- issuedOnLine 12
- }
- */
- private static void populateIssuingData(IIssuingDetail iIssuingDetail) {
-
- try {
- Date date = new SimpleDateFormat("dd/MM/yyyy").parse("01/01/2018");
- iIssuingDetail.setIssuer("1080");
- iIssuingDetail.setIssuingDate(date);
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
-
- iIssuingDetail.setIssuerPNR("issuerTestPNR");
- iIssuingDetail.setSpecimen(true);
- iIssuingDetail.setSecurePaperTicket(false);
- iIssuingDetail.setActivated(true);
- iIssuingDetail.setIssuedOnLine(12);
- }
-
- /*
- ,extension {
- { extensionId "1", extensionData '82DA'H }
- ,{ extensionId "2", extensionData '83DA'H }
- }
- */
- private static IExtension populateExtension() {
- IExtension ed1 = new SimpleExtension();
- ed1.setId("1");
- byte[] ba1 = { (byte) 0x82, (byte) 0xDA };
- ed1.setBinarydata(ba1);
- return ed1;
- }
-
- /*
- ,controlDetail {
- identificationByCardReference {
- { trailingCardIdNum 100 }
- }
- ,identificationByIdCard FALSE
- ,identificationByPassportId FALSE
- ,passportValidationRequired FALSE
- ,onlineValidationRequired FALSE
- ,ageCheckRequired FALSE
- ,reductionCardCheckRequired FALSE
- ,infoText "cd"
- ,includedTickets {
- { productOwnerIA5 "test" }
- }
- }
- */
- private static void populate(IControlDetail iControlDetail) {
- iControlDetail.setInfoText("cd");
- iControlDetail.setAgeCheckRequired(false);
- iControlDetail.setIdentificationByIdCard(false);
- iControlDetail.setIdentificationByPassportId(false);
- iControlDetail.setOnlineValidationRequired(false);
- iControlDetail.setPassportValidationRequired(false);
- iControlDetail.setReductionCardCheckRequired(false);
- iControlDetail.getIdentificationByCardReference().add(populateCardRefrence());
- iControlDetail.addLinkedTicket(populateLinkedTicket());
- }
-
-
- /*
- *
- */
- private static ITicketLink populateLinkedTicket() {
- ITicketLink it = new SimpleTicketLink();
- it.setProductOwner("test");
- it.setLinkMode(ILinkMode.issuedTogether);
- return it;
- }
-
- /*
- {
- trailingCardIdNum 100
- }
- */
- private static ICardReference populateCardRefrence() {
- ICardReference cr = new SimpleCardReference();
- cr.setTrailingCardId("100");
- return cr;
- }
-
-
- public static void compare(IUicRailTicket ticket1, IUicRailTicket ticket2) {
-
- assert(ticket1.getIssuerDetails().getIssuer().equals(ticket2.getIssuerDetails().getIssuer()));
-
- }
-
-
-}
diff --git a/src/org/uic/barcode/test/utils/TestUtils.java b/src/org/uic/barcode/test/utils/TestUtils.java deleted file mode 100644 index 7311ae4..0000000 --- a/src/org/uic/barcode/test/utils/TestUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.uic.barcode.test.utils;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-public class TestUtils {
-
- final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
-
- public static String hexStringFromBytes(byte[] bytes) {
- char[] hexChars = new char[bytes.length * 2];
- for (int j = 0; j < bytes.length; j++) {
- int v = bytes[j] & 0xFF;
- hexChars[j * 2] = hexArray[v >>> 4];
- hexChars[j * 2 + 1] = hexArray[v & 0x0F];
- }
- return new String(hexChars);
- }
-
-
- public static Date parseDate (String source){
-
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
-
- try {
- return formatter.parse(source);
- } catch (ParseException e) {
- try {
- return formatter.parse("2001-01-01");
- } catch (ParseException e1) {
- return null;
- }
- }
-
- }
-
-}
|