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));
}
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);
}
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);
}
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());
}
}
}
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);
}
Aggregations