use of joynr.exceptions.ApplicationException in project joynr by bmwcarit.
the class IltConsumerSyncMethodTest method callMethodWithExtendedErrorEnum.
@Test
public void callMethodWithExtendedErrorEnum() {
LOG.info(name.getMethodName() + "");
// 1st test
try {
String wantedExceptionArg = "ProviderRuntimeException";
testInterfaceProxy.methodWithExtendedErrorEnum(wantedExceptionArg);
fail(name.getMethodName() + " - FAILED - 1st - unexpected return without exception");
return;
} catch (ProviderRuntimeException e) {
if (e.getMessage() == null || !e.getMessage().endsWith("Exception from methodWithExtendedErrorEnum")) {
fail(name.getMethodName() + " - FAILED - 1st - invalid exception message");
return;
}
} catch (Exception e) {
fail(name.getMethodName() + " - FAILED - caught unexpected exception: " + e.getMessage());
return;
}
// 2nd test
try {
String wantedExceptionArg = "ApplicationException_1";
testInterfaceProxy.methodWithExtendedErrorEnum(wantedExceptionArg);
fail(name.getMethodName() + " - FAILED - 2nd - unexpected return without exception");
return;
} catch (ApplicationException e) {
if (e.getError() != MethodWithExtendedErrorEnumErrorEnum.ERROR_3_3_NTC) {
fail(name.getMethodName() + " - FAILED - 2nd - unexpected exception error enum value");
return;
}
} catch (Exception e) {
fail(name.getMethodName() + " - FAILED - caught unexpected exception: " + e.getMessage());
return;
}
// 3rd test
try {
String wantedExceptionArg = "ApplicationException_2";
testInterfaceProxy.methodWithExtendedErrorEnum(wantedExceptionArg);
fail(name.getMethodName() + " - FAILED - 3rd - unexpected return without exception");
return;
} catch (ApplicationException e) {
if (e.getError() != MethodWithExtendedErrorEnumErrorEnum.ERROR_2_1_TC2) {
fail(name.getMethodName() + " - FAILED - 3rd - unexpected 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.ApplicationException 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.ApplicationException in project joynr by bmwcarit.
the class IltProviderBean method methodWithAnonymousErrorEnum.
/*
* methodWithAnonymousErrorEnum
*/
@Override
public void methodWithAnonymousErrorEnum(String wantedExceptionArg) throws ApplicationException {
logger.warn("*************************************************");
logger.warn("* IltProvider.methodWithAnonymousErrorEnum called");
logger.warn("*************************************************");
if (wantedExceptionArg.equals("ProviderRuntimeException")) {
throw new ProviderRuntimeException("Exception from methodWithAnonymousErrorEnum");
} else if (wantedExceptionArg.equals("ApplicationException")) {
throw new ApplicationException(MethodWithAnonymousErrorEnumErrorEnum.ERROR_3_1_NTC);
}
}
use of joynr.exceptions.ApplicationException in project joynr by bmwcarit.
the class IltProviderBean method methodWithExtendedErrorEnum.
/*
* methodWithExtendedErrorEnum
*/
@Override
public void methodWithExtendedErrorEnum(String wantedExceptionArg) throws ApplicationException {
logger.warn("************************************************");
logger.warn("* IltProvider.methodWithExtendedErrorEnum called");
logger.warn("************************************************");
if (wantedExceptionArg.equals("ProviderRuntimeException")) {
throw new ProviderRuntimeException("Exception from methodWithExtendedErrorEnum");
} else if (wantedExceptionArg.equals("ApplicationException_1")) {
throw new ApplicationException(MethodWithExtendedErrorEnumErrorEnum.ERROR_3_3_NTC);
} else if (wantedExceptionArg.equals("ApplicationException_2")) {
throw new ApplicationException(MethodWithExtendedErrorEnumErrorEnum.ERROR_2_1_TC2);
}
}
use of joynr.exceptions.ApplicationException in project joynr by bmwcarit.
the class ProviderWrapperTest method testInvokeMethodThrowingApplicationException.
@Test
public void testInvokeMethodThrowingApplicationException() throws Throwable {
ProviderWrapper subject = createSubject();
JoynrProvider proxy = createProxy(subject);
Method method = TestServiceProviderInterface.class.getMethod("testThrowsApplicationException");
Object result = subject.invoke(proxy, method, new Object[0]);
assertNotNull(result);
assertTrue(result instanceof Promise);
assertTrue(((Promise<?>) result).isRejected());
((Promise<?>) result).then(new PromiseListener() {
@Override
public void onFulfillment(Object... values) {
fail("Should never get here");
}
@Override
public void onRejection(JoynrException error) {
assertTrue(error instanceof ApplicationException);
}
});
}
Aggregations