Search in sources :

Example 6 with ProviderWrapper

use of io.joynr.jeeintegration.ProviderWrapper in project joynr by bmwcarit.

the class ProviderWrapperTest method testInvokeMethodWithParams.

@Test
public void testInvokeMethodWithParams() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceProviderInterface.class.getMethod("testServiceMethod", new Class[] { Integer.TYPE, String.class });
    Object result = subject.invoke(proxy, method, new Object[] { 1, "one" });
    assertTrue(result instanceof Promise);
    assertPromiseEquals(result, new TestServiceImpl().testServiceMethod(1, "one"));
}
Also used : Promise(io.joynr.provider.Promise) Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Test(org.junit.Test)

Example 7 with ProviderWrapper

use of io.joynr.jeeintegration.ProviderWrapper in project joynr by bmwcarit.

the class ProviderWrapperTest method testInvokeMethodNoArgs.

@Test
public void testInvokeMethodNoArgs() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceProviderInterface.class.getMethod("testServiceMethodNoArgs");
    Object result = subject.invoke(proxy, method, new Object[0]);
    assertTrue(result instanceof Promise);
    assertPromiseEquals(result, "test");
}
Also used : Promise(io.joynr.provider.Promise) Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Test(org.junit.Test)

Example 8 with ProviderWrapper

use of io.joynr.jeeintegration.ProviderWrapper in project joynr by bmwcarit.

the class ProviderWrapperTest method testInvokeMethodThrowingProviderRuntimeException.

@Test
public void testInvokeMethodThrowingProviderRuntimeException() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceProviderInterface.class.getMethod("testThrowsProviderRuntimeException");
    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 ProviderRuntimeException);
        }
    });
}
Also used : Promise(io.joynr.provider.Promise) PromiseListener(io.joynr.provider.PromiseListener) JoynrException(io.joynr.exceptions.JoynrException) Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) Test(org.junit.Test)

Example 9 with ProviderWrapper

use of io.joynr.jeeintegration.ProviderWrapper in project joynr by bmwcarit.

the class ProviderWrapperTest method testPrincipalCopied.

@Test
public void testPrincipalCopied() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceProviderInterface.class.getMethod("testServiceMethodNoArgs");
    subject.invoke(proxy, method, new Object[0]);
    verify(joynrCallingPincipal).setUsername(USERNAME);
}
Also used : Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Test(org.junit.Test)

Example 10 with ProviderWrapper

use of io.joynr.jeeintegration.ProviderWrapper 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);
        }
    });
}
Also used : Promise(io.joynr.provider.Promise) ApplicationException(joynr.exceptions.ApplicationException) PromiseListener(io.joynr.provider.PromiseListener) JoynrException(io.joynr.exceptions.JoynrException) Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Test(org.junit.Test)

Aggregations

ProviderWrapper (io.joynr.jeeintegration.ProviderWrapper)12 JoynrProvider (io.joynr.provider.JoynrProvider)11 Method (java.lang.reflect.Method)11 Test (org.junit.Test)11 Promise (io.joynr.provider.Promise)6 JoynrException (io.joynr.exceptions.JoynrException)3 PromiseListener (io.joynr.provider.PromiseListener)3 Injector (com.google.inject.Injector)1 JoynrJeeMessageMetaInfo (io.joynr.jeeintegration.JoynrJeeMessageMetaInfo)1 JoynrCallingPrincipal (io.joynr.jeeintegration.api.security.JoynrCallingPrincipal)1 SubscriptionPublisherProducer (io.joynr.jeeintegration.multicast.SubscriptionPublisherProducer)1 JoynrMessageCreator (io.joynr.messaging.JoynrMessageCreator)1 JoynrMessageMetaInfo (io.joynr.messaging.JoynrMessageMetaInfo)1 Annotated (javax.enterprise.inject.spi.Annotated)1 Bean (javax.enterprise.inject.spi.Bean)1 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 ApplicationException (joynr.exceptions.ApplicationException)1 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)1