use of joynr.SubscriptionRequest in project joynr by bmwcarit.
the class PushingPublicationTest method setupPureOnChangedQos.
void setupPureOnChangedQos() {
OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos();
qos.setMinIntervalMs(SubscriptionQos.IGNORE_VALUE).setValidityMs(19000).setPublicationTtlMs(1000);
subscriptionRequest = new SubscriptionRequest(subscriptionId, attributeName, qos);
}
use of joynr.SubscriptionRequest in project joynr by bmwcarit.
the class DispatcherImplTest method testReceiveMulticastSubscription.
@Test
public void testReceiveMulticastSubscription() throws Exception {
String from = "from";
String to = "to";
MulticastSubscriptionRequest subscriptionRequest = new MulticastSubscriptionRequest("multicastId", "subscriptionId", "multicastName", new OnChangeSubscriptionQos());
MutableMessage joynrMessage = messageFactory.createSubscriptionRequest(from, to, subscriptionRequest, new MessagingQos(1000L));
MutableMessageFactory messageFactoryMock = mock(MutableMessageFactory.class);
ObjectMapper objectMapperMock = mock(ObjectMapper.class);
when(objectMapperMock.readValue(anyString(), eq(SubscriptionRequest.class))).thenReturn(subscriptionRequest);
fixture = new DispatcherImpl(requestReplyManagerMock, subscriptionManagerMock, publicationManagerMock, messageRouterMock, messageSenderMock, messageFactoryMock, objectMapperMock);
fixture.messageArrived(joynrMessage.getImmutableMessage());
verify(publicationManagerMock).addSubscriptionRequest(eq(from), eq(to), eq(subscriptionRequest));
}
use of joynr.SubscriptionRequest in project joynr by bmwcarit.
the class PublicationTimersTest method publicationsSentUntilExpiryDate.
@SuppressWarnings("unchecked")
@Test(timeout = 4000)
public void publicationsSentUntilExpiryDate() throws InterruptedException, JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
LOG.debug("Starting PublicationTimersTest.timerIsStoppedWhenEnddateIsReached test");
int period = 500;
int subscriptionLength = 1100;
PeriodicSubscriptionQos qos = new PeriodicSubscriptionQos();
qos.setPeriodMs(period).setValidityMs(subscriptionLength).setPublicationTtlMs(1000);
String subscriptionId = "subscriptionId";
String proxyId = "proxyId";
String providerId = "providerId";
ProviderDirectory providerDirectory = Mockito.mock(ProviderDirectory.class);
SubscriptionRequest subscriptionRequest = new SubscriptionRequest(subscriptionId, attributeName, qos);
PublicationManager publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
when(providerDirectory.get(eq(providerId))).thenReturn(providerContainer);
when(providerDirectory.contains(eq(providerId))).thenReturn(true);
publicationManager.addSubscriptionRequest(proxyId, providerId, subscriptionRequest);
Thread.sleep(subscriptionLength + period / 2);
int publicationTimes = 1 + (subscriptionLength / period);
verify(dispatcher, times(publicationTimes)).sendSubscriptionPublication(eq(providerId), (Set<String>) argThat(contains(proxyId)), any(SubscriptionPublication.class), any(MessagingQos.class));
Thread.sleep(subscriptionLength);
verify(dispatcher).sendSubscriptionReply(eq(providerId), eq(proxyId), any(SubscriptionReply.class), any(MessagingQos.class));
verifyNoMoreInteractions(dispatcher);
}
use of joynr.SubscriptionRequest in project joynr by bmwcarit.
the class SubscriptionManagerTest method registerSubscription.
@SuppressWarnings("unchecked")
@Test
public void registerSubscription() throws JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
class IntegerReference extends TypeReference<Integer> {
}
Future<String> future = mock(Future.class);
AttributeSubscribeInvocation subscriptionRequest = new AttributeSubscribeInvocation(attributeName, IntegerReference.class, attributeSubscriptionCallback, qos, future);
subscriptionManager.registerAttributeSubscription(fromParticipantId, Sets.newHashSet(toDiscoveryEntry), subscriptionRequest);
subscriptionId = subscriptionRequest.getSubscriptionId();
verify(attributeSubscriptionDirectory).put(Mockito.anyString(), Mockito.eq(attributeSubscriptionCallback));
verify(subscriptionStates).put(Mockito.anyString(), Mockito.any(PubSubState.class));
verify(cleanupScheduler).schedule(Mockito.any(Runnable.class), Mockito.eq(qos.getExpiryDateMs()), Mockito.eq(TimeUnit.MILLISECONDS));
verify(subscriptionEndFutures, Mockito.times(1)).put(Mockito.eq(subscriptionId), Mockito.any(ScheduledFuture.class));
verify(dispatcher).sendSubscriptionRequest(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), any(SubscriptionRequest.class), any(MessagingQos.class));
}
use of joynr.SubscriptionRequest in project joynr by bmwcarit.
the class SubscriptionManagerTest method registerBroadcastSubscription.
@Test
public void registerBroadcastSubscription() throws JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
String broadcastName = "broadcastName";
BroadcastSubscriptionListener broadcastSubscriptionListener = mock(LocationUpdateBroadcastListener.class);
BroadcastSubscribeInvocation subscriptionRequest = new BroadcastSubscribeInvocation(broadcastName, broadcastSubscriptionListener, onChangeQos, future);
subscriptionManager.registerBroadcastSubscription(fromParticipantId, Sets.newHashSet(toDiscoveryEntry), subscriptionRequest);
subscriptionId = subscriptionRequest.getSubscriptionId();
verify(broadcastSubscriptionDirectory).put(Mockito.anyString(), Mockito.eq(broadcastSubscriptionListener));
verify(subscriptionStates).put(Mockito.anyString(), Mockito.any(PubSubState.class));
verify(cleanupScheduler).schedule(Mockito.any(Runnable.class), Mockito.eq(onChangeQos.getExpiryDateMs()), Mockito.eq(TimeUnit.MILLISECONDS));
verify(subscriptionEndFutures, Mockito.times(1)).put(Mockito.eq(subscriptionId), Mockito.any(ScheduledFuture.class));
verify(dispatcher).sendSubscriptionRequest(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), any(SubscriptionRequest.class), any(MessagingQos.class));
}
Aggregations