Search in sources :

Example 6 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class DataSetInfoWrapperTest method test.

/**
 * Simple test for DataSetInfoWrapper-class. After getting the DataSetInfoWrapper for the EF.DIR data set in the
 * root applicaton of the npa we check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    DataSetInfoWrapper dataSetInfoWrapper = cardApplicationWrapper.getDataSetInfo("EF.DIR");
    assertSame(dataSetInfoWrapper, cardApplicationWrapper.getDataSetInfo("EF.DIR"));
    assertNotNull(dataSetInfoWrapper.getDataSetInfo());
    assertNotNull(dataSetInfoWrapper.getSecurityCondition(NamedDataServiceActionName.DSI_READ));
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Example 7 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class TestDispatcher method testDispatcher1.

/**
 * Test instance of TestEnv1.
 *
 * @throws Exception If the test is a failure.
 */
@Test
public void testDispatcher1() throws Exception {
    // test with direct annotation with explicit class specification
    IFD ifd = new TestIFD();
    Environment env = new TestEnv1();
    MessageDispatcher disp = new MessageDispatcher(env);
    env.setIFD(ifd);
    Object req = new EstablishContext();
    Object res = disp.deliver(req);
    assertTrue(res instanceof EstablishContextResponse);
}
Also used : IFD(org.openecard.ws.IFD) Environment(org.openecard.common.interfaces.Environment) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) Test(org.testng.annotations.Test)

Example 8 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class TestEventManager method test.

@Test(enabled = false)
public void test() throws InterruptedException, InitializationException {
    Environment env = new ClientEnv();
    MiddlewareSAL mwSAL = new MiddlewareSAL(env, null, mwConfig, cb);
    env.setSAL(mwSAL);
    EventDispatcher ed = new EventDispatcherImpl();
    env.setEventDispatcher(ed);
    mwSAL.initialize(new Initialize());
    ed.start();
    Thread.sleep(10000);
}
Also used : ClientEnv(org.openecard.common.ClientEnv) EventDispatcherImpl(org.openecard.common.event.EventDispatcherImpl) EventDispatcher(org.openecard.common.interfaces.EventDispatcher) Environment(org.openecard.common.interfaces.Environment) Initialize(iso.std.iso_iec._24727.tech.schema.Initialize) Test(org.testng.annotations.Test)

Example 9 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class ExecuteRecognition method testExecute.

@Test(enabled = false)
public void testExecute() throws Exception {
    Environment env = new ClientEnv();
    IFD ifd = new org.openecard.ifd.scio.IFD();
    env.setIFD(ifd);
    byte[] ctx;
    // establish context
    EstablishContext eCtx = new EstablishContext();
    EstablishContextResponse eCtxR = ifd.establishContext(eCtx);
    ctx = eCtxR.getContextHandle();
    // get status to see if we can execute the recognition
    GetStatus status = new GetStatus();
    status.setContextHandle(ctx);
    GetStatusResponse statusR = ifd.getStatus(status);
    if (statusR.getIFDStatus().size() > 0 && statusR.getIFDStatus().get(0).getSlotStatus().get(0).isCardAvailable()) {
        CardRecognitionImpl recog = new CardRecognitionImpl(env);
        IFDStatusType stat = statusR.getIFDStatus().get(0);
        RecognitionInfo info = recog.recognizeCard(ctx, stat.getIFDName(), BigInteger.ZERO);
        if (info == null) {
            System.out.println("Card not recognized.");
        } else {
            System.out.println(info.getCardType());
        }
    }
}
Also used : GetStatusResponse(iso.std.iso_iec._24727.tech.schema.GetStatusResponse) IFD(org.openecard.ws.IFD) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) ClientEnv(org.openecard.common.ClientEnv) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) Environment(org.openecard.common.interfaces.Environment) IFDStatusType(iso.std.iso_iec._24727.tech.schema.IFDStatusType) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) GetStatus(iso.std.iso_iec._24727.tech.schema.GetStatus) Test(org.testng.annotations.Test)

Example 10 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class CardInfoWrapperTest method test.

/**
 * Simple test for CardInfoWrapper-class. After getting the CardInfoWrapper for the npa we
 * check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    assertEquals(cardInfoWrapper.getCardType(), "http://bsi.bund.de/cif/npa.xml");
    assertEquals(cardInfoWrapper.getImplicitlySelectedApplication(), rootApplication);
    assertEquals(cardInfoWrapper.getCardApplications().size(), 3);
    assertEquals(cardInfoWrapper.getDataSetNameList(rootApplication).getDataSetName().size(), 5);
    assertEquals(cardInfoWrapper.getCardApplicationNameList().size(), 3);
// CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Aggregations

Environment (org.openecard.common.interfaces.Environment)10 Test (org.testng.annotations.Test)10 ClientEnv (org.openecard.common.ClientEnv)8 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)5 EstablishContextResponse (iso.std.iso_iec._24727.tech.schema.EstablishContextResponse)5 CardInfoType (iso.std.iso_iec._24727.tech.schema.CardInfoType)4 Expectations (mockit.Expectations)4 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)4 IFD (org.openecard.ws.IFD)4 RecognitionInfo (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo)1 GetStatus (iso.std.iso_iec._24727.tech.schema.GetStatus)1 GetStatusResponse (iso.std.iso_iec._24727.tech.schema.GetStatusResponse)1 IFDStatusType (iso.std.iso_iec._24727.tech.schema.IFDStatusType)1 Initialize (iso.std.iso_iec._24727.tech.schema.Initialize)1 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)1 ListIFDsResponse (iso.std.iso_iec._24727.tech.schema.ListIFDsResponse)1 EventDispatcherImpl (org.openecard.common.event.EventDispatcherImpl)1 EventDispatcher (org.openecard.common.interfaces.EventDispatcher)1 SwingDialogWrapper (org.openecard.gui.swing.SwingDialogWrapper)1 SwingUserConsent (org.openecard.gui.swing.SwingUserConsent)1