Search in sources :

Example 1 with MqttAddress

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();
}
Also used : MutableMessage(joynr.MutableMessage) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 2 with MqttAddress

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;
}
Also used : MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) ProviderQos(joynr.types.ProviderQos) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 3 with MqttAddress

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));
}
Also used : Field(java.lang.reflect.Field) Version(joynr.types.Version) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Before(org.junit.Before)

Example 4 with MqttAddress

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;
}
Also used : Promise(io.joynr.provider.Promise) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) DeferredVoid(io.joynr.provider.DeferredVoid) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) GlobalDiscoveryEntryPersisted(io.joynr.capabilities.GlobalDiscoveryEntryPersisted) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 5 with MqttAddress

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());
}
Also used : TransportReadyListener(io.joynr.messaging.routing.TransportReadyListener) ReplyToAddressProvider(io.joynr.runtime.ReplyToAddressProvider) MutableMessage(joynr.MutableMessage) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ImmutableMessage(joynr.ImmutableMessage) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Aggregations

MqttAddress (joynr.system.RoutingTypes.MqttAddress)19 Address (joynr.system.RoutingTypes.Address)11 ProviderQos (joynr.types.ProviderQos)10 Test (org.junit.Test)9 Version (joynr.types.Version)8 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)7 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)6 DiscoveryEntry (joynr.types.DiscoveryEntry)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 HashSet (java.util.HashSet)3 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)2 GlobalDiscoveryEntryPersisted (io.joynr.capabilities.GlobalDiscoveryEntryPersisted)2 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)2 MessagingQos (io.joynr.messaging.MessagingQos)2 InProcessAddress (io.joynr.messaging.inprocess.InProcessAddress)2 Callback (io.joynr.proxy.Callback)2 Future (io.joynr.proxy.Future)2 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)2 ArrayList (java.util.ArrayList)2