use of joynr.system.RoutingTypes.MqttAddress in project joynr by bmwcarit.
the class MqttMessagingSkeletonTestUtil method createTestMessage.
static ImmutableMessage createTestMessage(String messageType) throws Exception {
MutableMessage message = new MutableMessage();
ObjectMapper objectMapper = new ObjectMapper();
MqttAddress address = new MqttAddress("testBrokerUri", "testTopic");
message.setSender("someSender");
message.setRecipient("someRecipient");
message.setTtlAbsolute(true);
message.setTtlMs(100000);
message.setPayload(new byte[] { 0, 1, 2 });
message.setType(messageType);
message.setReplyTo(objectMapper.writeValueAsString(address));
return message.getImmutableMessage();
}
use of joynr.system.RoutingTypes.MqttAddress in project joynr by bmwcarit.
the class DiscoveryEntryStorePersistedTest method createDiscoveryEntry.
private GlobalDiscoveryEntryPersisted createDiscoveryEntry(String domain, String interfaceName, String participantId) throws Exception {
ProviderQos qos = new ProviderQos();
long lastSeenDateMs = 123L;
long expiryDateMs = Long.MAX_VALUE;
String publicKeyId = "publicKeyId";
Address address = new MqttAddress("brokerUri", "topic");
String addressSerialized = new ObjectMapper().writeValueAsString(address);
GlobalDiscoveryEntryPersisted discoveryEntry = new GlobalDiscoveryEntryPersisted(new Version(47, 11), domain, interfaceName, participantId, qos, lastSeenDateMs, expiryDateMs, publicKeyId, addressSerialized, "clusterControllerId");
return discoveryEntry;
}
use of joynr.system.RoutingTypes.MqttAddress in project joynr by bmwcarit.
the class GlobalCapabilitiesDirectoryEjbTest method setup.
@Before
public void setup() throws NoSuchFieldException, IllegalAccessException {
Field field = CapabilityUtils.class.getDeclaredField("objectMapper");
field.setAccessible(true);
field.set(CapabilityUtils.class, new ObjectMapper());
testParticpantId = "participantId";
testGlobalDiscoveryEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1), "domain", "interfaceName", testParticpantId, new ProviderQos(), System.currentTimeMillis(), System.currentTimeMillis() + 1000L, "public key ID", new MqttAddress("tcp://mqttbroker:1883", TOPIC_NAME));
}
use of joynr.system.RoutingTypes.MqttAddress in project joynr by bmwcarit.
the class CapabilitiesDirectoryImpl method add.
@Override
public Promise<DeferredVoid> add(GlobalDiscoveryEntry globalDiscoveryEntry) {
DeferredVoid deferred = new DeferredVoid();
Promise<DeferredVoid> promise = new Promise<DeferredVoid>(deferred);
Address address = CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry);
String clusterControllerId;
if (address instanceof MqttAddress) {
clusterControllerId = ((MqttAddress) address).getTopic();
} else if (address instanceof ChannelAddress) {
clusterControllerId = ((ChannelAddress) address).getChannelId();
} else {
deferred.reject(new ProviderRuntimeException(""));
return promise;
}
GlobalDiscoveryEntryPersisted discoveryEntry = new GlobalDiscoveryEntryPersisted(globalDiscoveryEntry, clusterControllerId);
logger.debug("registered discovery entry: {}", discoveryEntry);
discoveryEntryStore.add(discoveryEntry);
deferred.resolve();
return promise;
}
use of joynr.system.RoutingTypes.MqttAddress in project joynr by bmwcarit.
the class CcMessageSenderTest method testReplyToIsSet.
@Test
public void testReplyToIsSet() throws Exception {
MutableMessage message = createTestRequestMessage();
final MqttAddress replyToAddress = new MqttAddress("testBrokerUri", "testTopic");
ObjectMapper objectMapper = new ObjectMapper();
String serializedReplyToAddress = objectMapper.writeValueAsString(replyToAddress);
ReplyToAddressProvider replyToAddressProviderMock = Mockito.mock(ReplyToAddressProvider.class);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
assertEquals(1, invocation.getArguments().length);
assertThat(invocation.getArguments()[0], instanceOf(TransportReadyListener.class));
TransportReadyListener listener = (TransportReadyListener) invocation.getArguments()[0];
listener.transportReady(replyToAddress);
return null;
}
}).when(replyToAddressProviderMock).registerGlobalAddressesReadyListener(any(TransportReadyListener.class));
CcMessageSender subject = new CcMessageSender(messageRouterMock, replyToAddressProviderMock);
subject.sendMessage(message);
ArgumentCaptor<ImmutableMessage> argCaptor = ArgumentCaptor.forClass(ImmutableMessage.class);
verify(messageRouterMock).route(argCaptor.capture());
assertEquals(serializedReplyToAddress, argCaptor.getValue().getReplyTo());
}
Aggregations