Search in sources :

Example 1 with ResponseType

use of iso.std.iso_iec._24727.tech.schema.ResponseType in project open-ecard by ecsec.

the class MessageDispatcher method deliver.

@Override
public Object deliver(Object req) throws DispatcherException, InvocationTargetException {
    EventDispatcher disp = environment.getEventDispatcher();
    // send API CALL STARTED event
    ConnectionHandleType handle = HandlerUtils.extractHandle(req);
    if (disp != null && req instanceof RequestType) {
        ApiCallEventObject startEvt = new ApiCallEventObject(handle, (RequestType) req);
        LOG.debug("Sending API_CALL_STARTED event.");
        disp.notify(EventType.API_CALL_STARTED, startEvt);
    }
    try {
        Class<?> reqClass = req.getClass();
        Service s = getService(reqClass);
        Object serviceImpl = getServiceImpl(s);
        LOG.debug("Delivering message of type: {}", req.getClass().getName());
        Object result = s.invoke(serviceImpl, req);
        // send API CALL FINISHED event
        if (disp != null && req instanceof RequestType && result instanceof ResponseType) {
            ApiCallEventObject finEvt = new ApiCallEventObject(handle, (RequestType) req);
            finEvt.setResponse((ResponseType) result);
            LOG.debug("Sending API_CALL_FINISHED event.");
            disp.notify(EventType.API_CALL_FINISHED, finEvt);
        }
        return result;
    } catch (IllegalAccessException | IllegalArgumentException ex) {
        throw new DispatcherException(ex);
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) EventDispatcher(org.openecard.common.interfaces.EventDispatcher) ApiCallEventObject(org.openecard.common.event.ApiCallEventObject) DispatcherException(org.openecard.common.interfaces.DispatcherException) ApiCallEventObject(org.openecard.common.event.ApiCallEventObject) RequestType(iso.std.iso_iec._24727.tech.schema.RequestType) ResponseType(iso.std.iso_iec._24727.tech.schema.ResponseType)

Example 2 with ResponseType

use of iso.std.iso_iec._24727.tech.schema.ResponseType in project open-ecard by ecsec.

the class TinyManagementTest method testRest.

@Test
public void testRest() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    for (Method m : instance.getClass().getDeclaredMethods()) {
        // cobertura adds methods whose names start with '__cobertura'
        if (m.getName().equals("initializeFramework") || m.getName().startsWith("__cobertura")) {
            continue;
        }
        System.out.println(m.getName());
        if (m.getParameterTypes().length == 1) {
            Object o = m.getParameterTypes()[0].newInstance();
            ResponseType result = (ResponseType) m.invoke(instance, o);
            assertEquals(ECardConstants.Major.ERROR, result.getResult().getResultMajor());
        }
    }
}
Also used : BeforeMethod(org.testng.annotations.BeforeMethod) Method(java.lang.reflect.Method) ResponseType(iso.std.iso_iec._24727.tech.schema.ResponseType) Test(org.testng.annotations.Test)

Aggregations

ResponseType (iso.std.iso_iec._24727.tech.schema.ResponseType)2 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 RequestType (iso.std.iso_iec._24727.tech.schema.RequestType)1 Method (java.lang.reflect.Method)1 ApiCallEventObject (org.openecard.common.event.ApiCallEventObject)1 DispatcherException (org.openecard.common.interfaces.DispatcherException)1 EventDispatcher (org.openecard.common.interfaces.EventDispatcher)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1