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);
}
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);
}
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);
}
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();
}
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>>());
}
Aggregations