Search in sources :

Example 41 with ProviderRuntimeException

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");
}
Also used : ApplicationException(joynr.exceptions.ApplicationException) MapStringString(joynr.interlanguagetest.namedTypeCollection2.MapStringString) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) ApplicationException(joynr.exceptions.ApplicationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) Test(org.junit.Test)

Example 42 with ProviderRuntimeException

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");
}
Also used : ApplicationException(joynr.exceptions.ApplicationException) MapStringString(joynr.interlanguagetest.namedTypeCollection2.MapStringString) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) ApplicationException(joynr.exceptions.ApplicationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) Test(org.junit.Test)

Example 43 with ProviderRuntimeException

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");
}
Also used : ApplicationException(joynr.exceptions.ApplicationException) MapStringString(joynr.interlanguagetest.namedTypeCollection2.MapStringString) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) ApplicationException(joynr.exceptions.ApplicationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) Test(org.junit.Test)

Example 44 with ProviderRuntimeException

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);
}
Also used : Promise(io.joynr.provider.Promise) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 45 with ProviderRuntimeException

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);
}
Also used : Promise(io.joynr.provider.Promise) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Aggregations

ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)67 Promise (io.joynr.provider.Promise)27 ApplicationException (joynr.exceptions.ApplicationException)23 Test (org.junit.Test)21 MapStringString (joynr.interlanguagetest.namedTypeCollection2.MapStringString)19 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)13 DiscoveryException (io.joynr.exceptions.DiscoveryException)10 DeferredVoid (io.joynr.provider.DeferredVoid)10 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)8 JoynrTimeoutException (io.joynr.exceptions.JoynrTimeoutException)8 JoynrWaitExpiredException (io.joynr.exceptions.JoynrWaitExpiredException)8 joynr.tests.testProxy (joynr.tests.testProxy)8 ExtendedExtendedBaseStruct (joynr.interlanguagetest.namedTypeCollection2.ExtendedExtendedBaseStruct)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 JoynrException (io.joynr.exceptions.JoynrException)4 ExtendedBaseStruct (joynr.interlanguagetest.namedTypeCollection2.ExtendedBaseStruct)4 JoynrVersion (io.joynr.JoynrVersion)3 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)3 Deferred (io.joynr.provider.Deferred)3 PromiseListener (io.joynr.provider.PromiseListener)3