Search in sources :

Example 1 with ProviderRuntimeException

use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.

the class LocalCapabilitiesDirectoryImpl method remove.

@Override
public io.joynr.provider.Promise<io.joynr.provider.DeferredVoid> remove(String participantId) {
    DeferredVoid deferred = new DeferredVoid();
    DiscoveryEntry entryToRemove = localDiscoveryEntryStore.lookup(participantId, Long.MAX_VALUE);
    if (entryToRemove != null) {
        remove(entryToRemove);
        deferred.resolve();
    } else {
        deferred.reject(new ProviderRuntimeException("Failed to remove participantId: " + participantId));
    }
    return new Promise<>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) DeferredVoid(io.joynr.provider.DeferredVoid) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 2 with ProviderRuntimeException

use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.

the class IltConsumerSyncMethodTest method callMethodWithExistingErrorEnum.

@Test
public void callMethodWithExistingErrorEnum() {
    LOG.info(name.getMethodName() + "");
    // 1st test
    try {
        String wantedExceptionArg = "ProviderRuntimeException";
        testInterfaceProxy.methodWithExistingErrorEnum(wantedExceptionArg);
        fail(name.getMethodName() + " - FAILED - 1st - unexpected return without exception");
        return;
    } catch (ProviderRuntimeException e) {
        if (e.getMessage() == null || !e.getMessage().endsWith("Exception from methodWithExistingErrorEnum")) {
            fail(name.getMethodName() + " - FAILED - 1st - got invalid exception content");
            return;
        }
    } catch (Exception e) {
        fail(name.getMethodName() + " - FAILED - 1st - caught unexpected exception type: " + e.getMessage());
        return;
    }
    // 2nd test
    try {
        String wantedExceptionArg = "ApplicationException_1";
        testInterfaceProxy.methodWithExistingErrorEnum(wantedExceptionArg);
        fail(name.getMethodName() + " - FAILED - 2nd - unexpected return without exception");
        return;
    } catch (ApplicationException e) {
        if (e.getError() != ExtendedErrorEnumTc.ERROR_2_3_TC2) {
            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.methodWithExistingErrorEnum(wantedExceptionArg);
        fail(name.getMethodName() + " - FAILED - 3rd - unexpected return without exception");
        return;
    } catch (ApplicationException e) {
        if (e.getError() != ExtendedErrorEnumTc.ERROR_1_2_TC_2) {
            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 3 with ProviderRuntimeException

use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.

the class IltConsumerSyncMethodTest method callMethodWithoutErrorEnum.

/*
     * SYNCHRONOUS METHOD CALLS WITH EXCEPTION HANDLING
     */
@Test
public void callMethodWithoutErrorEnum() {
    LOG.info(name.getMethodName() + "");
    try {
        String wantedExceptionArg = "ProviderRuntimeException";
        testInterfaceProxy.methodWithoutErrorEnum(wantedExceptionArg);
        fail(name.getMethodName() + " - FAILED - unexpected return");
        return;
    } catch (ProviderRuntimeException e) {
        if (e.getMessage() == null || !e.getMessage().endsWith("Exception from methodWithoutErrorEnum")) {
            fail(name.getMethodName() + " - FAILED - invalid exception message");
            return;
        }
    } catch (Exception e) {
        fail(name.getMethodName() + " - FAILED - caught unexpected exception: " + e.getMessage());
        return;
    }
    LOG.info(name.getMethodName() + " - OK");
}
Also used : MapStringString(joynr.interlanguagetest.namedTypeCollection2.MapStringString) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) ApplicationException(joynr.exceptions.ApplicationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) Test(org.junit.Test)

Example 4 with ProviderRuntimeException

use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.

the class IltProvider method overloadedMethodWithSelector.

/*
     * overloadedMethodWithSelector (2)
     */
@Override
public Promise<OverloadedMethodWithSelector1Deferred> overloadedMethodWithSelector(Boolean booleanArg) {
    logger.warn("*************************************************");
    logger.warn("* IltProvider.overloadedMethodWithSelector called");
    logger.warn("*************************************************");
    OverloadedMethodWithSelector1Deferred deferred = new OverloadedMethodWithSelector1Deferred();
    // check input parameter
    if (booleanArg != false) {
        logger.warn("overloadedMethodWithSelector: invalid argument booleanArg");
        deferred.reject(new ProviderRuntimeException("overloadedMethodWithSelector: invalid parameter booleanArg"));
        return new Promise<OverloadedMethodWithSelector1Deferred>(deferred);
    }
    // setup output parameter
    String stringOut = "Return value from overloadedMethodWithSelector 2";
    deferred.resolve(stringOut);
    return new Promise<OverloadedMethodWithSelector1Deferred>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) MapStringString(joynr.interlanguagetest.namedTypeCollection2.MapStringString) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 5 with ProviderRuntimeException

use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.

the class IltProvider method methodWithoutErrorEnum.

/*
     * methodWithoutErrorEnum
     */
@Override
public Promise<DeferredVoid> methodWithoutErrorEnum(String wantedExceptionArg) {
    logger.warn("*******************************************");
    logger.warn("* IltProvider.methodWithoutErrorEnum called");
    logger.warn("*******************************************");
    DeferredVoid deferred = new DeferredVoid();
    if (wantedExceptionArg.equals("ProviderRuntimeException")) {
        deferred.reject(new ProviderRuntimeException("Exception from methodWithoutErrorEnum"));
    } else {
        deferred.resolve();
    }
    return new Promise<DeferredVoid>(deferred);
}
Also used : Promise(io.joynr.provider.Promise) DeferredVoid(io.joynr.provider.DeferredVoid) 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