use of joynr.exceptions.ProviderRuntimeException 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.ProviderRuntimeException 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.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 IltProvider method methodWithAnonymousErrorEnum.
/*
* methodWithAnonymousErrorEnum
*/
@Override
public Promise<MethodWithAnonymousErrorEnumDeferred> methodWithAnonymousErrorEnum(String wantedExceptionArg) {
logger.warn("*************************************************");
logger.warn("* IltProvider.methodWithAnonymousErrorEnum called");
logger.warn("*************************************************");
MethodWithAnonymousErrorEnumDeferred deferred = new MethodWithAnonymousErrorEnumDeferred();
if (wantedExceptionArg.equals("ProviderRuntimeException")) {
deferred.reject(new ProviderRuntimeException("Exception from methodWithAnonymousErrorEnum"));
} else if (wantedExceptionArg.equals("ApplicationException")) {
deferred.reject(MethodWithAnonymousErrorEnumErrorEnum.ERROR_3_1_NTC);
} else {
deferred.resolve();
}
return new Promise<MethodWithAnonymousErrorEnumDeferred>(deferred);
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class IltProvider method methodWithStringsAndSpecifiedStringOutLength.
/*
* methodWithStringsAndSpecifiedStringOutLength
*/
@Override
public Promise<MethodWithStringsAndSpecifiedStringOutLengthDeferred> methodWithStringsAndSpecifiedStringOutLength(String stringArg, Integer int32StringLengthArg) {
logger.warn("*****************************************************************");
logger.warn("* IltProvider.methodWithStringsAndSpecifiedStringOutLength called");
logger.warn("*****************************************************************");
MethodWithStringsAndSpecifiedStringOutLengthDeferred deferred = new MethodWithStringsAndSpecifiedStringOutLengthDeferred();
StringBuilder s = new StringBuilder();
if (int32StringLengthArg > 1024 * 1024) {
deferred.reject(new ProviderRuntimeException("methodWithStringsAndSpecifiedStringOutLength: Maximum length exceeded"));
return new Promise<MethodWithStringsAndSpecifiedStringOutLengthDeferred>(deferred);
}
for (int i = 0; i < int32StringLengthArg; i++) {
s.append("A");
}
deferred.resolve(s.toString());
return new Promise<MethodWithStringsAndSpecifiedStringOutLengthDeferred>(deferred);
}
Aggregations