use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class IltConsumerSyncMethodTest method callMethodWithAnonymousErrorEnum.
@Test
public void callMethodWithAnonymousErrorEnum() {
LOG.info(name.getMethodName() + "");
try {
String wantedExceptionArg = "ProviderRuntimeException";
testInterfaceProxy.methodWithAnonymousErrorEnum(wantedExceptionArg);
fail(name.getMethodName() + " - FAILED - got no result");
return;
} catch (ProviderRuntimeException e) {
if (e.getMessage() == null || !e.getMessage().endsWith("Exception from methodWithAnonymousErrorEnum")) {
fail(name.getMethodName() + " - FAILED - got invalid ProviderRuntimeException");
return;
}
} catch (Exception e) {
fail(name.getMethodName() + " - FAILED - caught unexpected exception: " + e.getMessage());
return;
}
// 2nd test
try {
String wantedExceptionArg = "ApplicationException";
testInterfaceProxy.methodWithAnonymousErrorEnum(wantedExceptionArg);
fail(name.getMethodName() + " - FAILED - unexpected return of method");
return;
} catch (ApplicationException e) {
if (e.getError() != MethodWithAnonymousErrorEnumErrorEnum.ERROR_3_1_NTC) {
fail(name.getMethodName() + " - FAILED - got invalid exception error enum value");
return;
}
} catch (Exception e) {
fail(name.getMethodName() + " - FAILED - caught unexpected exception: " + e.getMessage());
return;
}
LOG.info(name.getMethodName() + " - OK");
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class RequestInterpreter method invokeMethod.
public Object invokeMethod(RequestCaller requestCaller, OneWayRequest request) {
// A method is identified by its defining request caller, its name and the types of its arguments
MethodSignature methodSignature = new MethodSignature(requestCaller, request.getMethodName(), request.getParamDatatypes());
ensureMethodMetaInformationPresent(requestCaller, request, methodSignature);
Method method = methodSignatureToMethodMap.get(methodSignature);
Object[] params = null;
try {
if (method.getParameterTypes().length > 0) {
// method with parameters
params = request.getParams();
}
joynrMessageScope.activate();
setContext(requestCaller, request);
logger.trace("invoke provider method {}({})", method.getName(), params == null ? "" : params);
return requestCaller.invoke(method, params);
} catch (IllegalAccessException e) {
logger.error("RequestInterpreter: Received an RPC invocation for a non public method {}", request);
JoynrVersion joynrVersion = AnnotationUtil.getAnnotation(requestCaller.getProxy().getClass(), JoynrVersion.class);
throw new MethodInvocationException(e, new Version(joynrVersion.major(), joynrVersion.minor()));
} catch (InvocationTargetException e) {
logger.debug("invokeMethod error", e);
Throwable cause = e.getCause();
logger.error("RequestInterpreter: Could not perform an RPC invocation: {}", cause == null ? e.toString() : cause.getMessage());
throw new ProviderRuntimeException(cause == null ? e.toString() : cause.toString());
} finally {
requestCaller.removeContext();
joynrMessageScope.deactivate();
}
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class RequestInterpreter method execute.
public void execute(final ProviderCallback<Reply> callback, RequestCaller requestCaller, final Request request) {
Promise<? extends AbstractDeferred> promise;
logger.debug("execute request on provider: {}", request);
try {
promise = (Promise<?>) invokeMethod(requestCaller, request);
} catch (MethodInvocationException | ProviderRuntimeException e) {
logger.warn("execute request on provider failed with exception: {}, request: {}", e, request);
callback.onFailure(e);
return;
} catch (Exception e) {
JoynrVersion joynrVersion = AnnotationUtil.getAnnotation(requestCaller.getProxy().getClass(), JoynrVersion.class);
MethodInvocationException methodInvocationException = new MethodInvocationException(e, new Version(joynrVersion.major(), joynrVersion.minor()));
logger.warn("execute request on provider failed with exception: {}, request: {}", methodInvocationException, request);
callback.onFailure(methodInvocationException);
return;
}
promise.then(new PromiseListener() {
@Override
public void onRejection(JoynrException error) {
logger.debug("execute request on provider onRejection: {}, request: {}", error, request);
callback.onFailure(error);
}
@Override
public void onFulfillment(Object... values) {
logger.debug("execute request on provider onFulfillment: {}, request: {}", values, request);
callback.onSuccess(createReply(request, values));
}
});
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class IltProvider method methodWithSingleArrayParameters.
/*
* methodWithSingleArrayParameters
*
* Return an array with the stringified double entries
*/
@Override
public Promise<MethodWithSingleArrayParametersDeferred> methodWithSingleArrayParameters(Double[] doubleArrayArg) {
logger.warn("****************************************************");
logger.warn("* IltProvider.methodWithSingleArrayParameters called");
logger.warn("****************************************************");
MethodWithSingleArrayParametersDeferred deferred = new MethodWithSingleArrayParametersDeferred();
// check input parameter
if (!IltUtil.checkDoubleArray(doubleArrayArg)) {
logger.warn("methodWithMultiplePrimitiveParameters: invalid argument doubleArrayArg");
deferred.reject(new ProviderRuntimeException("methodWithSingleArrayParameters: received wrong argument"));
return new Promise<MethodWithSingleArrayParametersDeferred>(deferred);
}
// prepare output parameter
String[] stringArrayOut = IltUtil.createStringArray();
deferred.resolve(stringArrayOut);
return new Promise<MethodWithSingleArrayParametersDeferred>(deferred);
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class IltProvider method methodWithMultipleArrayParameters.
/*
* methodWithMultipleArrayParameters
*
* return the byte array as int64array
* return the string list as list of string arrays with 1 element each, where this element
* refers to the one from input
*/
@Override
public Promise<MethodWithMultipleArrayParametersDeferred> methodWithMultipleArrayParameters(String[] stringArrayArg, Byte[] int8ArrayArg, ExtendedInterfaceEnumerationInTypeCollection[] enumArrayArg, StructWithStringArray[] structWithStringArrayArrayArg) {
logger.warn("******************************************************");
logger.warn("* IltProvider.methodWithMultipleArrayParameters called");
logger.warn("******************************************************");
MethodWithMultipleArrayParametersDeferred deferred = new MethodWithMultipleArrayParametersDeferred();
if (!IltUtil.checkStringArray(stringArrayArg)) {
deferred.reject(new ProviderRuntimeException("methodWithMultipleArrayParameters: invalid stringArrayArg"));
return new Promise<MethodWithMultipleArrayParametersDeferred>(deferred);
}
if (!IltUtil.checkByteArray(int8ArrayArg)) {
deferred.reject(new ProviderRuntimeException("methodWithMultipleArrayParameters: invalid int8ArrayArg"));
return new Promise<MethodWithMultipleArrayParametersDeferred>(deferred);
}
if (!IltUtil.checkExtendedInterfaceEnumerationInTypeCollectionArray(enumArrayArg)) {
deferred.reject(new ProviderRuntimeException("methodWithMultipleArrayParameters: invalid enumArrayArg"));
return new Promise<MethodWithMultipleArrayParametersDeferred>(deferred);
}
if (!IltUtil.checkStructWithStringArrayArray(structWithStringArrayArrayArg)) {
deferred.reject(new ProviderRuntimeException("methodWithMultipleArrayParameters: invalid structWithStringArrayArrayArg"));
return new Promise<MethodWithMultipleArrayParametersDeferred>(deferred);
}
Long[] uInt64ArrayOut = IltUtil.createUInt64Array();
StructWithStringArray[] structWithStringArrayArrayOut = new StructWithStringArray[2];
structWithStringArrayArrayOut[0] = IltUtil.createStructWithStringArray();
structWithStringArrayArrayOut[1] = IltUtil.createStructWithStringArray();
deferred.resolve(uInt64ArrayOut, structWithStringArrayArrayOut);
return new Promise<MethodWithMultipleArrayParametersDeferred>(deferred);
}
Aggregations