Search in sources :

Example 1 with DefaulttestProvider

use of joynr.tests.DefaulttestProvider 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 2 with DefaulttestProvider

use of joynr.tests.DefaulttestProvider in project joynr by bmwcarit.

the class SubscriptionPublisherFactoryTest method testCreateWithCorrectProvider.

@Test
public void testCreateWithCorrectProvider() throws Exception {
    DefaulttestProvider providerSpy = Mockito.spy(new DefaulttestProvider());
    subscriptionPublisherFactory.create(providerSpy);
    verify(providerSpy, times(1)).setSubscriptionPublisher(any(testSubscriptionPublisherImpl.class));
}
Also used : DefaulttestProvider(joynr.tests.DefaulttestProvider) joynr.tests.testSubscriptionPublisherImpl(joynr.tests.testSubscriptionPublisherImpl) Test(org.junit.Test)

Example 3 with DefaulttestProvider

use of joynr.tests.DefaulttestProvider in project joynr by bmwcarit.

the class ShutdownTest method setup.

@Before
public void setup() {
    Properties factoryPropertiesProvider = new Properties();
    factoryPropertiesProvider.put(AbstractJoynrApplication.PROPERTY_JOYNR_DOMAIN_LOCAL, "localdomain");
    factoryPropertiesProvider.put(MessagingPropertyKeys.CHANNELID, "ShutdownTestChannelId");
    MockitoAnnotations.initMocks(this);
    Module runtimeModule = Modules.override(new CCInProcessRuntimeModule()).with(new TestGlobalAddressModule());
    dummyApplication = (DummyJoynrApplication) new JoynrInjectorFactory(factoryPropertiesProvider, runtimeModule).createApplication(DummyJoynrApplication.class);
    provider = new DefaulttestProvider();
    providerQos = new ProviderQos();
    providerQos.setScope(ProviderScope.LOCAL);
    providerQos.setPriority(System.currentTimeMillis());
}
Also used : TestGlobalAddressModule(io.joynr.messaging.routing.TestGlobalAddressModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) DefaulttestProvider(joynr.tests.DefaulttestProvider) Properties(java.util.Properties) Module(com.google.inject.Module) TestGlobalAddressModule(io.joynr.messaging.routing.TestGlobalAddressModule) CCInProcessRuntimeModule(io.joynr.runtime.CCInProcessRuntimeModule) ProviderQos(joynr.types.ProviderQos) JoynrInjectorFactory(io.joynr.runtime.JoynrInjectorFactory) Before(org.junit.Before)

Example 4 with DefaulttestProvider

use of joynr.tests.DefaulttestProvider in project joynr by bmwcarit.

the class ShutdownTest method unregisterMultibleProvidersBeforeShutdown.

@Test
public void unregisterMultibleProvidersBeforeShutdown() throws JoynrWaitExpiredException, JoynrRuntimeException, InterruptedException, ApplicationException {
    int providercount = 10;
    JoynrProvider[] providers = new JoynrProvider[providercount];
    for (int i = 0; i < providers.length; i++) {
        providerQos = new ProviderQos();
        providerQos.setScope(ProviderScope.LOCAL);
        providerQos.setPriority(System.currentTimeMillis());
        providers[i] = new DefaulttestProvider();
        Future<Void> registerFinished = dummyApplication.getRuntime().registerProvider("ShutdownTestdomain" + i, providers[i], providerQos);
        registerFinished.get();
    }
    for (int i = 0; i < providers.length; i++) {
        dummyApplication.getRuntime().unregisterProvider("ShutdownTestdomain" + i, providers[i]);
    }
    dummyApplication.shutdown();
}
Also used : DefaulttestProvider(joynr.tests.DefaulttestProvider) JoynrProvider(io.joynr.provider.JoynrProvider) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 5 with DefaulttestProvider

use of joynr.tests.DefaulttestProvider in project joynr by bmwcarit.

the class AbstractSSLEnd2EndTest method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    String methodName = name.getMethodName();
    logger.info("{} setup beginning...", methodName);
    domain = "SSLEnd2EndTest." + methodName + System.currentTimeMillis();
    provisionPermissiveAccessControlEntry(domain, ProviderAnnotations.getInterfaceName(DefaulttestProvider.class));
    // use channelNames = test name
    String channelIdProvider = "JavaTest-" + methodName + UUID.randomUUID().getLeastSignificantBits() + "-end2endTestProvider";
    String channelIdConsumer = "JavaTest-" + methodName + UUID.randomUUID().getLeastSignificantBits() + "-end2endConsumer";
    Properties joynrConfigProvider = PropertyLoader.loadProperties("testMessaging.properties");
    joynrConfigProvider.put(AbstractJoynrApplication.PROPERTY_JOYNR_DOMAIN_LOCAL, "localdomain." + UUID.randomUUID().toString());
    joynrConfigProvider.put(MessagingPropertyKeys.CHANNELID, channelIdProvider);
    joynrConfigProvider.put(MessagingPropertyKeys.RECEIVERID, UUID.randomUUID().toString());
    providerRuntime = getRuntime(joynrConfigProvider, new StaticDomainAccessControlProvisioningModule());
    Properties joynrConfigConsumer = PropertyLoader.loadProperties("testMessaging.properties");
    joynrConfigConsumer.put(AbstractJoynrApplication.PROPERTY_JOYNR_DOMAIN_LOCAL, "localdomain." + UUID.randomUUID().toString());
    joynrConfigConsumer.put(MessagingPropertyKeys.CHANNELID, channelIdConsumer);
    joynrConfigConsumer.put(MessagingPropertyKeys.RECEIVERID, UUID.randomUUID().toString());
    consumerRuntime = getRuntime(joynrConfigConsumer);
    provider = new DefaulttestProvider();
    ProviderQos providerQos = new ProviderQos();
    providerRuntime.registerProvider(domain, provider, providerQos);
    messagingQos = new MessagingQos(5000);
    discoveryQos = new DiscoveryQos(5000, ArbitrationStrategy.HighestPriority, Long.MAX_VALUE);
    // Make sure the channel is created before the first messages sent.
    Thread.sleep(200);
    logger.info("setup finished");
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) DefaulttestProvider(joynr.tests.DefaulttestProvider) Properties(java.util.Properties) StaticDomainAccessControlProvisioningModule(io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule) ProviderQos(joynr.types.ProviderQos) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) Before(org.junit.Before)

Aggregations

DefaulttestProvider (joynr.tests.DefaulttestProvider)7 Properties (java.util.Properties)4 ProviderQos (joynr.types.ProviderQos)3 Before (org.junit.Before)3 Test (org.junit.Test)3 StaticDomainAccessControlProvisioningModule (io.joynr.accesscontrol.StaticDomainAccessControlProvisioningModule)2 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 MessagingQos (io.joynr.messaging.MessagingQos)2 Module (com.google.inject.Module)1 RequestCallerFactory (io.joynr.dispatching.RequestCallerFactory)1 TestGlobalAddressModule (io.joynr.messaging.routing.TestGlobalAddressModule)1 JoynrProvider (io.joynr.provider.JoynrProvider)1 CCInProcessRuntimeModule (io.joynr.runtime.CCInProcessRuntimeModule)1 JoynrInjectorFactory (io.joynr.runtime.JoynrInjectorFactory)1 JoynrRuntime (io.joynr.runtime.JoynrRuntime)1 OneWayRequest (joynr.OneWayRequest)1 joynr.tests.testProxy (joynr.tests.testProxy)1 joynr.tests.testSubscriptionPublisherImpl (joynr.tests.testSubscriptionPublisherImpl)1