use of org.openecard.ws.IFD in project open-ecard by ecsec.
the class TestTransactions method testExecute.
/**
* Manual test to ensure the card recognition with transactions is working as expected. This test starts two
* Threads. The first one blocks the card for 15 seconds. The second one attempts to recognize the card. This will
* obviously fail within the 15 seconds and a MessageDialog will be displayed. After the 15 seconds the recognition
* will succeed.
*
* @throws Exception
*/
// a reader with an inserted card is needed
@Test(enabled = false)
public void testExecute() throws Exception {
// set up ifd and establish context
Environment env = new ClientEnv();
final IFD ifd = new org.openecard.ifd.scio.IFD();
env.setIFD(ifd);
EstablishContext eCtx = new EstablishContext();
EstablishContextResponse eCtxR = ifd.establishContext(eCtx);
final byte[] ctx = eCtxR.getContextHandle();
// Set up GUI and card recognition
SwingUserConsent gui = new SwingUserConsent(new SwingDialogWrapper());
final CardRecognitionImpl recog = new CardRecognitionImpl(env);
recog.setGUI(gui);
// get the first reader
ListIFDs listIFDs = new ListIFDs();
listIFDs.setContextHandle(ctx);
ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
final String ifdName = listIFDsResponse.getIFDName().get(0);
Thread t1 = new Thread(new BlockingRunnable(ctx, ifdName, ifd));
t1.start();
Thread t2 = new Thread(new RecognizeRunnable(ctx, ifdName, recog));
t2.start();
t2.join();
}
use of org.openecard.ws.IFD in project open-ecard by ecsec.
the class TestDispatcher method testDispatcher2.
/**
* Test instance of TestEnv2.
*
* @throws Exception If the test is a failure.
*/
@Test
public void testDispatcher2() throws Exception {
// test with inherited annotation without explicit class specification
IFD ifd = new TestIFD();
Environment env = new TestEnv2();
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.ws.IFD 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.ws.IFD 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());
}
}
}
Aggregations