Search in sources :

Example 1 with TestInterfaceProxy

use of joynr.interlanguagetest.TestInterfaceProxy in project joynr by bmwcarit.

the class IltConsumerTest method setupConsumerRuntime.

protected static void setupConsumerRuntime(boolean msgQosCompressed) throws DiscoveryException, JoynrIllegalStateException, InterruptedException {
    LOG.info("setupConsumerRuntime: Entering");
    final String configFileName = "ilt-consumer-test.settings";
    InputStream resourceStream;
    try {
        resourceStream = new FileInputStream("src/main/resources/" + configFileName);
    } catch (IOException e) {
        LOG.error("setupConsumerRuntime: Error", e);
        resourceStream = null;
    }
    Properties joynrConfig = new Properties();
    try {
        if (resourceStream != null) {
            LOG.info("setupConsumerRuntime: resources from " + configFileName);
            joynrConfig.load(resourceStream);
        }
    } catch (IOException ex) {
        LOG.info("setupConsumerRuntime: not load the configuration file: " + configFileName + ": " + ex);
    }
    joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, STATIC_PERSISTENCE_FILE);
    joynrConfig.setProperty(AbstractJoynrApplication.PROPERTY_JOYNR_DOMAIN_LOCAL, "inter_language_test_consumer_local_domain");
    consumerRuntime = getRuntime(joynrConfig);
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryTimeoutMs(10000);
    discoveryQos.setCacheMaxAgeMs(Long.MAX_VALUE);
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    ProxyBuilder<TestInterfaceProxy> proxyBuilder = consumerRuntime.getProxyBuilder(providerDomain, TestInterfaceProxy.class);
    MessagingQos messagingQos = new MessagingQos(10000);
    messagingQos.setCompress(msgQosCompressed);
    LOG.info("setupConsumerRuntime: msgQosCompression = " + msgQosCompressed);
    testInterfaceProxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<TestInterfaceProxy>() {

        @Override
        public void onProxyCreationFinished(TestInterfaceProxy result) {
            LOG.info("proxy created");
            proxyCreated.release();
        }

        @Override
        public void onProxyCreationError(JoynrRuntimeException error) {
            LOG.info("error creating proxy");
        }
    });
    if (testInterfaceProxy == null) {
        LOG.info("setupConsumerRuntime: proxy = null");
    } else {
        LOG.info("setupConsumerRuntime: proxy is set != null");
    }
    // wait until proxy creation is finished or discovery timeout +
    // 1 second grace period have passed
    proxyCreated.tryAcquire(11000, TimeUnit.MILLISECONDS);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) TestInterfaceProxy(joynr.interlanguagetest.TestInterfaceProxy) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) ProxyCreatedCallback(io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) FileInputStream(java.io.FileInputStream) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Aggregations

DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 MessagingQos (io.joynr.messaging.MessagingQos)1 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 TestInterfaceProxy (joynr.interlanguagetest.TestInterfaceProxy)1