Search in sources :

Example 41 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class AccessControllerEnd2EndTest method registerProvider.

private void registerProvider(JoynrRuntime runtime) {
    ProviderQos providerQos = new ProviderQos();
    providerQos.setScope(ProviderScope.LOCAL);
    providerQos.setPriority(System.currentTimeMillis());
    TestProviderImpl testProvider = new TestProviderImpl();
    runtime.registerProvider(TEST_DOMAIN, testProvider, providerQos);
}
Also used : ProviderQos(joynr.types.ProviderQos)

Example 42 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class SerializationTest method serializeAndDeserializeGlobalDiscoveryEntryTest.

@Test
public void serializeAndDeserializeGlobalDiscoveryEntryTest() throws Exception {
    ProviderQos qos = new ProviderQos();
    String channelAddress = "channelId";
    final GlobalDiscoveryEntry[] capInfos = { new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", qos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddress) };
    String writeValueAsString = null;
    writeValueAsString = objectMapper.writeValueAsString(capInfos);
    System.err.println(writeValueAsString);
    assertTrue(writeValueAsString.startsWith("[{\"_typeName\":\"joynr.types.GlobalDiscoveryEntry\""));
    GlobalDiscoveryEntry[] readValue = objectMapper.readValue(writeValueAsString, GlobalDiscoveryEntry[].class);
    assertArrayEquals(capInfos, readValue);
    GlobalDiscoveryEntry globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", qos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddress);
    writeValueAsString = objectMapper.writeValueAsString(globalDiscoveryEntry);
    System.err.println(writeValueAsString);
    GlobalDiscoveryEntry readCapInfo = objectMapper.readValue(writeValueAsString, GlobalDiscoveryEntry.class);
    assertEquals(globalDiscoveryEntry, readCapInfo);
}
Also used : Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 43 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class SerializationTest method serializeReplyWithCapabilityInfoArray.

@Test
public void serializeReplyWithCapabilityInfoArray() throws JsonGenerationException, JsonMappingException, IOException {
    Object response = new GlobalDiscoveryEntry[] { new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", new ProviderQos(), System.currentTimeMillis(), expiryDateMs, publicKeyId, "channelId") };
    Reply reply = new Reply(UUID.randomUUID().toString(), response);
    String writeValueAsString = objectMapper.writeValueAsString(reply);
    Reply receivedReply = objectMapper.readValue(writeValueAsString, Reply.class);
    GlobalDiscoveryEntry[] convertValue = objectMapper.convertValue(receivedReply.getResponse()[0], GlobalDiscoveryEntry[].class);
    Assert.assertArrayEquals((GlobalDiscoveryEntry[]) reply.getResponse()[0], convertValue);
    ComplexTestType2[] complexTestType2Array = { new ComplexTestType2(3, 4), new ComplexTestType2(5, 6) };
    ArrayList<ComplexTestType2> customListParam2List = new ArrayList<ComplexTestType2>();
    customListParam2List.add(new ComplexTestType2(3, 4));
    customListParam2List.add(new ComplexTestType2(5, 6));
    ComplexTestType2[] convertValue2 = objectMapper.convertValue(customListParam2List, ComplexTestType2[].class);
    Assert.assertArrayEquals(complexTestType2Array, convertValue2);
}
Also used : Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ArrayList(java.util.ArrayList) Reply(joynr.Reply) ComplexTestType2(joynr.tests.testTypes.ComplexTestType2) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 44 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class AbstractLocalCommunicationTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    logger.info("setup beginning...");
    String channelId = UUID.randomUUID().toString() + "-end2endA";
    Properties customProperties = new Properties();
    customProperties.put(MessagingPropertyKeys.CHANNELID, channelId);
    runtimeA = getRuntime(customProperties);
    provider = new SubscriptionTestsProviderImpl();
    domain = "TestDomain" + System.currentTimeMillis();
    ProviderQos providerQos = new ProviderQos();
    runtimeA.registerProvider(domain, provider, providerQos);
    ProxyBuilder<testProxy> proxyBuilder;
    MessagingQos messagingQos = new MessagingQos(20000);
    DiscoveryQos discoveryQos = new DiscoveryQos(50000, ArbitrationStrategy.HighestPriority, Long.MAX_VALUE);
    proxyBuilder = runtimeA.getProxyBuilder(domain, testProxy.class);
    proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) SubscriptionTestsProviderImpl(io.joynr.dispatching.subscription.SubscriptionTestsProviderImpl) joynr.tests.testProxy(joynr.tests.testProxy) Properties(java.util.Properties) ProviderQos(joynr.types.ProviderQos) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) Before(org.junit.Before)

Example 45 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class ArbitrationTest method testVersionFilterUsed.

@SuppressWarnings("unchecked")
@Test
public void testVersionFilterUsed() throws InterruptedException {
    ProviderQos providerQos = new ProviderQos();
    String publicKeyId = "publicKeyId";
    expectedEndpointAddress = new ChannelAddress("http://testUrl", "testChannelId");
    String[] participantIds = new String[] { "first-participant", "second-participant" };
    for (int index = 0; index < participantIds.length; index++) {
        DiscoveryEntryWithMetaInfo discoveryEntry = new DiscoveryEntryWithMetaInfo(new Version(index, index), domain, TestInterface.INTERFACE_NAME, participantIds[index], providerQos, System.currentTimeMillis(), NO_EXPIRY, publicKeyId, true);
        capabilitiesList.add(discoveryEntry);
    }
    ArbitrationStrategyFunction arbitrationStrategyFunction = mock(ArbitrationStrategyFunction.class);
    when(arbitrationStrategyFunction.select(any(Map.class), any(Collection.class))).thenReturn(new HashSet<DiscoveryEntryWithMetaInfo>(capabilitiesList));
    discoveryQos = new DiscoveryQos(ARBITRATION_TIMEOUT, arbitrationStrategyFunction, Long.MAX_VALUE);
    Arbitrator arbitrator = ArbitratorFactory.create(Sets.newHashSet(domain), interfaceName, interfaceVersion, discoveryQos, localDiscoveryAggregator);
    arbitrator.setArbitrationListener(arbitrationCallback);
    arbitrator.scheduleArbitration();
    assertTrue(localDiscoveryAggregatorSemaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
    verify(discoveryEntryVersionFilter).filter(interfaceVersion, new HashSet<DiscoveryEntryWithMetaInfo>(capabilitiesList), new HashMap<String, Set<Version>>());
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) Version(joynr.types.Version) Collection(java.util.Collection) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) Map(java.util.Map) HashMap(java.util.HashMap) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Aggregations

ProviderQos (joynr.types.ProviderQos)69 Version (joynr.types.Version)43 Test (org.junit.Test)37 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)27 DiscoveryEntry (joynr.types.DiscoveryEntry)25 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)24 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)21 Matchers.anyString (org.mockito.Matchers.anyString)16 ArrayList (java.util.ArrayList)15 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)13 Before (org.junit.Before)13 Callback (io.joynr.proxy.Callback)12 HashSet (java.util.HashSet)11 MqttAddress (joynr.system.RoutingTypes.MqttAddress)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 Address (joynr.system.RoutingTypes.Address)9 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)8 MessagingQos (io.joynr.messaging.MessagingQos)8 Properties (java.util.Properties)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7