Search in sources :

Example 1 with JoynrRuntime

use of io.joynr.runtime.JoynrRuntime in project joynr by bmwcarit.

the class DefaultJoynrRuntimeFactoryTest method testNoOverrideForManuallyAddedParticipantIds.

@Test
public void testNoOverrideForManuallyAddedParticipantIds() throws Exception {
    Properties joynrProperties = new Properties();
    String key = (ParticipantIdKeyUtil.JOYNR_PARTICIPANT_PREFIX + LOCAL_DOMAIN + "." + MyService.INTERFACE_NAME).toLowerCase().replace("/", ".");
    joynrProperties.setProperty(key, "myvalue");
    createFixture(joynrProperties);
    JoynrRuntime joynrRuntime = fixture.create(Sets.newHashSet(MyServiceSync.class));
    assertNotNull(joynrRuntime);
    Properties properties = fixture.getInjector().getInstance(Key.get(Properties.class, Names.named(MessagingPropertyKeys.JOYNR_PROPERTIES)));
    assertNotNull(properties);
    assertTrue(properties.containsKey(key));
    String value = properties.getProperty(key);
    assertNotNull(value);
    assertEquals("myvalue", value);
}
Also used : JoynrRuntime(io.joynr.runtime.JoynrRuntime) Properties(java.util.Properties) MyServiceSync(joynr.jeeintegration.servicelocator.MyServiceSync) Test(org.junit.Test)

Example 2 with JoynrRuntime

use of io.joynr.runtime.JoynrRuntime in project joynr by bmwcarit.

the class JoynrAndroidRuntime method unregisterProvider.

@Override
public void unregisterProvider(String domain, Object provider) {
    // this will block until the runtime is created successfully
    // TODO since the caller expects the unregister call to be async, we need to check if
    // this will not block to long
    JoynrRuntime runtime = getJoynrRuntime();
    runtime.unregisterProvider(domain, provider);
}
Also used : JoynrRuntime(io.joynr.runtime.JoynrRuntime)

Example 3 with JoynrRuntime

use of io.joynr.runtime.JoynrRuntime in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method tearDown.

@After
public void tearDown() throws InterruptedException {
    if (providerRuntime != null) {
        providerRuntime.unregisterProvider(domain, provider);
        providerRuntime.unregisterProvider(domainAsync, provider);
        // wait grace period for the unregister (remove) message to get
        // sent to global discovery
        Thread.sleep(1000);
        providerRuntime.shutdown(true);
    }
    if (consumerRuntime != null) {
        consumerRuntime.shutdown(true);
    }
    // do not shutdown runtimes twice
    createdRuntimes.remove(providerRuntime);
    createdRuntimes.remove(consumerRuntime);
    for (JoynrRuntime createdRuntime : createdRuntimes) {
        createdRuntime.shutdown(true);
    }
}
Also used : JoynrRuntime(io.joynr.runtime.JoynrRuntime) After(org.junit.After)

Example 4 with JoynrRuntime

use of io.joynr.runtime.JoynrRuntime in project joynr by bmwcarit.

the class RoutingTableOverwriteEnd2EndTest method testProviderAddressCanBeOverwrittenAfterDiscovery.

@Test
public void testProviderAddressCanBeOverwrittenAfterDiscovery() throws Exception {
    // Tests that if a provider's address is changed in the discovery directory and a new proxy is
    // created for the provider, the routing table of the proxy's runtime will also be updated as long as
    // a new arbitration (cache max age = 0) is performed.
    final String providerDomain = "testDomain";
    final Properties fixedParticipantIdProperty = createFixedParticipantIdProperties(providerDomain, DefaulttestProvider.class, "fixedParticipantId");
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    discoveryQos.setCacheMaxAgeMs(0);
    JoynrRuntime runtimeProxy = createRuntime("proxy", null);
    JoynrRuntime runtimeProvider1 = createRuntime("provider_initial", fixedParticipantIdProperty);
    DefaulttestProvider provider1 = Mockito.spy(DefaulttestProvider.class);
    runtimeProvider1.registerProvider(providerDomain, provider1, createProviderQos()).get();
    testProxy proxy1 = runtimeProxy.getProxyBuilder(providerDomain, testProxy.class).setMessagingQos(new MessagingQos(2000)).setDiscoveryQos(discoveryQos).build();
    proxy1.addNumbers(1, 2, 3);
    verify(provider1).addNumbers(1, 2, 3);
    reset(provider1);
    JoynrRuntime runtimeProvider2 = createRuntime("provider_override", fixedParticipantIdProperty);
    DefaulttestProvider provider2 = Mockito.spy(DefaulttestProvider.class);
    runtimeProvider2.registerProvider(providerDomain, provider2, createProviderQos()).get();
    testProxy proxy2 = runtimeProxy.getProxyBuilder(providerDomain, testProxy.class).setMessagingQos(new MessagingQos(2000)).setDiscoveryQos(discoveryQos).build();
    proxy2.addNumbers(1, 2, 3);
    verify(provider1, never()).addNumbers(1, 2, 3);
    verify(provider2).addNumbers(1, 2, 3);
}
Also used : JoynrRuntime(io.joynr.runtime.JoynrRuntime) MessagingQos(io.joynr.messaging.MessagingQos) DefaulttestProvider(joynr.tests.DefaulttestProvider) joynr.tests.testProxy(joynr.tests.testProxy) Properties(java.util.Properties) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) Test(org.junit.Test)

Example 5 with JoynrRuntime

use of io.joynr.runtime.JoynrRuntime in project joynr by bmwcarit.

the class DefaultJoynrRuntimeFactoryTest method testClusterableParticipantIdsAdded.

@Test
public void testClusterableParticipantIdsAdded() throws Exception {
    createFixture();
    JoynrRuntime joynrRuntime = fixture.create(Sets.newHashSet(MyServiceSync.class));
    assertNotNull(joynrRuntime);
    Properties properties = fixture.getInjector().getInstance(Key.get(Properties.class, Names.named(MessagingPropertyKeys.JOYNR_PROPERTIES)));
    assertNotNull(properties);
    String key = (ParticipantIdKeyUtil.JOYNR_PARTICIPANT_PREFIX + LOCAL_DOMAIN + "." + MyService.INTERFACE_NAME).toLowerCase().replace("/", ".");
    assertTrue(properties.containsKey(key));
    String value = properties.getProperty(key);
    assertNotNull(value);
    assertEquals((LOCAL_DOMAIN + "." + CHANNEL_ID + "." + MyService.INTERFACE_NAME).replace("/", "."), value);
}
Also used : JoynrRuntime(io.joynr.runtime.JoynrRuntime) MyServiceSync(joynr.jeeintegration.servicelocator.MyServiceSync) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

JoynrRuntime (io.joynr.runtime.JoynrRuntime)9 Test (org.junit.Test)4 Properties (java.util.Properties)3 MyServiceSync (joynr.jeeintegration.servicelocator.MyServiceSync)2 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1 JeeJoynrServiceLocator (io.joynr.jeeintegration.JeeJoynrServiceLocator)1 JoynrIntegrationBean (io.joynr.jeeintegration.JoynrIntegrationBean)1 MessagingQos (io.joynr.messaging.MessagingQos)1 JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)1 LibjoynrWebSocketRuntimeModule (io.joynr.runtime.LibjoynrWebSocketRuntimeModule)1 File (java.io.File)1 DefaulttestProvider (joynr.tests.DefaulttestProvider)1 joynr.tests.testProxy (joynr.tests.testProxy)1 After (org.junit.After)1