Search in sources :

Example 26 with Version

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

the class CapabilitiesUtilsTest method testCreateNewGlobalDiscoveryEntry.

@Test
public void testCreateNewGlobalDiscoveryEntry() {
    Version version = new Version(0, 0);
    String domain = "domain";
    String interfaceName = "interfaceName";
    String participantId = "participantId";
    String publicKeyId = "publicKeyId";
    Address mqttAddress = new MqttAddress("tcp://broker:1883", "topic");
    ProviderQos providerQos = new ProviderQos();
    GlobalDiscoveryEntry result = CapabilityUtils.newGlobalDiscoveryEntry(version, domain, interfaceName, participantId, providerQos, 0L, 0L, publicKeyId, mqttAddress);
    assertNotNull(result);
    assertEquals(version, result.getProviderVersion());
    assertEquals(domain, result.getDomain());
    assertEquals(interfaceName, result.getInterfaceName());
    assertEquals(participantId, result.getParticipantId());
    assertEquals(providerQos, result.getQos());
    assertEquals((Long) 0L, result.getLastSeenDateMs());
    assertEquals((Long) 0L, result.getExpiryDateMs());
    assertEquals(publicKeyId, result.getPublicKeyId());
    assertEquals("{\"_typeName\":\"joynr.system.RoutingTypes.MqttAddress\",\"brokerUri\":\"tcp://broker:1883\",\"topic\":\"topic\"}", result.getAddress());
}
Also used : MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Example 27 with Version

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

the class CapabilitiesUtilsTest method createCollectionOfDiscoveryEntriesWithMetaInfo.

private Collection<DiscoveryEntryWithMetaInfo> createCollectionOfDiscoveryEntriesWithMetaInfo() {
    Collection<DiscoveryEntryWithMetaInfo> discoveryEntries = new ArrayList<>(2);
    discoveryEntries.add(new DiscoveryEntryWithMetaInfo(new Version(42, 23), "testDomain1", "testInterfaceName", "testParticipantId1", new ProviderQos(), 4711l, 4712l, "testPublicKeyId1", true));
    discoveryEntries.add(new DiscoveryEntryWithMetaInfo(new Version(42, 23), "testDomain2", "testInterfaceName", "testParticipantId2", new ProviderQos(), 4721l, 4722l, "testPublicKeyId2", false));
    return discoveryEntries;
}
Also used : Version(joynr.types.Version) ArrayList(java.util.ArrayList) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderQos(joynr.types.ProviderQos)

Example 28 with Version

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

the class StaticCapabilitiesProvisioningTest method createDiscoveryEntries.

private Set<DiscoveryEntry> createDiscoveryEntries(String domain, String... interfaceNames) {
    Set<DiscoveryEntry> discoveryEntries = new HashSet<DiscoveryEntry>();
    String participantId = "particpantId";
    ProviderQos qos = new ProviderQos();
    Long lastSeenDateMs = 0L;
    Long expiryDateMs = 0L;
    String publicKeyId = "publicKeyId";
    Address address = new MqttAddress("brokerUri", "topic");
    for (String interfaceName : interfaceNames) {
        GlobalDiscoveryEntry entry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1), domain, interfaceName, participantId, qos, lastSeenDateMs, expiryDateMs, publicKeyId, address);
        discoveryEntries.add(entry);
    }
    return discoveryEntries;
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) HashSet(java.util.HashSet) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 29 with Version

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

the class ServersUtil method createJsonFor.

private static String createJsonFor(String directoriesUrl) throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    setObjectMapperOnCapabilitiesUtils(objectMapper);
    String channelId = "discoverydirectory_channelid";
    String participantId = "capabilitiesdirectory_participantid";
    GlobalDiscoveryEntry discoveryEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1), "io.joynr", GlobalCapabilitiesDirectory.INTERFACE_NAME, participantId, new ProviderQos(), System.currentTimeMillis(), Long.MAX_VALUE, "", new ChannelAddress(directoriesUrl, channelId));
    String accessParticipantId = "domainaccesscontroller_participantid";
    GlobalDiscoveryEntry accessControlEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1), "io.joynr", GlobalDomainAccessController.INTERFACE_NAME, accessParticipantId, new ProviderQos(), System.currentTimeMillis(), Long.MAX_VALUE, "", new InProcessAddress());
    List<DiscoveryEntry> entries = new ArrayList<>();
    entries.add(discoveryEntry);
    entries.add(accessControlEntry);
    return objectMapper.writeValueAsString(entries);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ArrayList(java.util.ArrayList) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ProviderQos(joynr.types.ProviderQos)

Example 30 with Version

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

the class RequestInterpreter method invokeMethod.

public Object invokeMethod(RequestCaller requestCaller, OneWayRequest request) {
    // A method is identified by its defining request caller, its name and the types of its arguments
    MethodSignature methodSignature = new MethodSignature(requestCaller, request.getMethodName(), request.getParamDatatypes());
    ensureMethodMetaInformationPresent(requestCaller, request, methodSignature);
    Method method = methodSignatureToMethodMap.get(methodSignature);
    Object[] params = null;
    try {
        if (method.getParameterTypes().length > 0) {
            // method with parameters
            params = request.getParams();
        }
        joynrMessageScope.activate();
        setContext(requestCaller, request);
        logger.trace("invoke provider method {}({})", method.getName(), params == null ? "" : params);
        return requestCaller.invoke(method, params);
    } catch (IllegalAccessException e) {
        logger.error("RequestInterpreter: Received an RPC invocation for a non public method {}", request);
        JoynrVersion joynrVersion = AnnotationUtil.getAnnotation(requestCaller.getProxy().getClass(), JoynrVersion.class);
        throw new MethodInvocationException(e, new Version(joynrVersion.major(), joynrVersion.minor()));
    } catch (InvocationTargetException e) {
        logger.debug("invokeMethod error", e);
        Throwable cause = e.getCause();
        logger.error("RequestInterpreter: Could not perform an RPC invocation: {}", cause == null ? e.toString() : cause.getMessage());
        throw new ProviderRuntimeException(cause == null ? e.toString() : cause.toString());
    } finally {
        requestCaller.removeContext();
        joynrMessageScope.deactivate();
    }
}
Also used : MethodSignature(io.joynr.proxy.MethodSignature) JoynrVersion(io.joynr.JoynrVersion) JoynrVersion(io.joynr.JoynrVersion) Version(joynr.types.Version) Method(java.lang.reflect.Method) MethodInvocationException(joynr.exceptions.MethodInvocationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Aggregations

Version (joynr.types.Version)65 Test (org.junit.Test)47 ProviderQos (joynr.types.ProviderQos)43 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)29 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)24 DiscoveryEntry (joynr.types.DiscoveryEntry)22 ArrayList (java.util.ArrayList)13 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)13 Matchers.anyString (org.mockito.Matchers.anyString)12 Callback (io.joynr.proxy.Callback)11 HashSet (java.util.HashSet)11 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 JoynrVersion (io.joynr.JoynrVersion)9 Address (joynr.system.RoutingTypes.Address)9 HashMap (java.util.HashMap)8 MqttAddress (joynr.system.RoutingTypes.MqttAddress)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 Set (java.util.Set)7 DeferredVoid (io.joynr.provider.DeferredVoid)6