Search in sources :

Example 1 with JoynrProvider

use of io.joynr.provider.JoynrProvider in project joynr by bmwcarit.

the class ProviderWrapperTest method testMessageScopeActivated.

@Test
public void testMessageScopeActivated() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceProviderInterface.class.getMethod("assertMessageContextActive");
    assertFalse(JoynrJeeMessageContext.getInstance().isActive());
    subject.invoke(proxy, method, new Object[0]);
    assertFalse(JoynrJeeMessageContext.getInstance().isActive());
}
Also used : Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Test(org.junit.Test)

Example 2 with JoynrProvider

use of io.joynr.provider.JoynrProvider in project joynr by bmwcarit.

the class ProviderWrapperTest method testSetSubscriptionPublisherDoesNotActivateScope.

@Test
public void testSetSubscriptionPublisherDoesNotActivateScope() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceSubscriptionPublisherInjection.class.getMethod("setSubscriptionPublisher", new Class[] { SubscriptionPublisher.class });
    subject.invoke(proxy, method, new Object[] { mock(MySubscriptionPublisher.class) });
    assertFalse(JoynrJeeMessageContext.getInstance().isActive());
}
Also used : Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Test(org.junit.Test)

Example 3 with JoynrProvider

use of io.joynr.provider.JoynrProvider in project joynr by bmwcarit.

the class ProviderWrapperTest method testInvokeMultiOutMethod.

@Test
public void testInvokeMultiOutMethod() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceProviderInterface.class.getMethod("testMultiOutMethod");
    Object result = subject.invoke(proxy, method, new Object[0]);
    assertTrue(result instanceof Promise);
    Promise<?> promise = (Promise<?>) result;
    assertTrue(promise.isFulfilled());
    promise.then(new PromiseListener() {

        @Override
        public void onFulfillment(Object... values) {
            assertArrayEquals(new Object[] { "one", "two" }, values);
        }

        @Override
        public void onRejection(JoynrException error) {
            fail("Shouldn't be here.");
        }
    });
}
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) Test(org.junit.Test)

Example 4 with JoynrProvider

use of io.joynr.provider.JoynrProvider in project joynr by bmwcarit.

the class ProviderWrapperTest method testSetSubscriptionPublisherRegistersWithProducer.

@Test
public void testSetSubscriptionPublisherRegistersWithProducer() throws Throwable {
    ProviderWrapper subject = createSubject();
    JoynrProvider proxy = createProxy(subject);
    Method method = TestServiceSubscriptionPublisherInjection.class.getMethod("setSubscriptionPublisher", new Class[] { SubscriptionPublisher.class });
    subject.invoke(proxy, method, new Object[] { mock(MySubscriptionPublisher.class) });
    verify(subscriptionPublisherProducer).add(any(), eq(TestServiceImpl.class));
}
Also used : Method(java.lang.reflect.Method) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderWrapper(io.joynr.jeeintegration.ProviderWrapper) Test(org.junit.Test)

Example 5 with JoynrProvider

use of io.joynr.provider.JoynrProvider 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)

Aggregations

JoynrProvider (io.joynr.provider.JoynrProvider)12 Test (org.junit.Test)12 ProviderWrapper (io.joynr.jeeintegration.ProviderWrapper)11 Method (java.lang.reflect.Method)11 Promise (io.joynr.provider.Promise)6 JoynrException (io.joynr.exceptions.JoynrException)3 PromiseListener (io.joynr.provider.PromiseListener)3 ApplicationException (joynr.exceptions.ApplicationException)1 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)1 DefaulttestProvider (joynr.tests.DefaulttestProvider)1 ProviderQos (joynr.types.ProviderQos)1