Search in sources :

Example 1 with SystemIntegrationTestProxy

use of joynr.test.SystemIntegrationTestProxy in project joynr by bmwcarit.

the class ConsumerApplication method run.

@SuppressWarnings("checkstyle:methodlength")
@Override
public void run() {
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryTimeoutMs(10000);
    discoveryQos.setCacheMaxAgeMs(Long.MAX_VALUE);
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    ProxyBuilder<SystemIntegrationTestProxy> proxyBuilder = runtime.getProxyBuilder(providerDomain, SystemIntegrationTestProxy.class);
    boolean success = false;
    try {
        systemIntegrationTestProxy = proxyBuilder.setMessagingQos(new MessagingQos(10000)).setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<SystemIntegrationTestProxy>() {

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

            @Override
            public void onProxyCreationError(JoynrRuntimeException error) {
                LOG.error("error creating proxy");
            }
        });
        try {
            if (proxyCreated.tryAcquire(11000, TimeUnit.MILLISECONDS) == false) {
                throw new DiscoveryException("proxy not created in time");
            }
        } catch (InterruptedException e) {
            throw new DiscoveryException("proxy not created in time");
        }
        try {
            int addendA = 3333333;
            int addendB = 4444444;
            Integer sum = systemIntegrationTestProxy.add(addendA, addendB);
            if (sum != null && sum == (addendA + addendB)) {
                LOG.info("SIT RESULT success: Java consumer -> " + providerDomain + " (" + addendA + " + " + addendB + " =  " + sum + ")");
                success = true;
            }
        } catch (Exception e) {
        // fallthrough
        }
    } catch (DiscoveryException | JoynrCommunicationException e) {
    // fallthrough
    }
    if (!success) {
        LOG.info("SIT RESULT error: Java consumer -> " + providerDomain);
    }
    System.exit((success) ? 0 : 1);
}
Also used : SystemIntegrationTestProxy(joynr.test.SystemIntegrationTestProxy) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrCommunicationException(io.joynr.exceptions.JoynrCommunicationException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) DiscoveryException(io.joynr.exceptions.DiscoveryException) IOException(java.io.IOException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrCommunicationException(io.joynr.exceptions.JoynrCommunicationException) MessagingQos(io.joynr.messaging.MessagingQos) ProxyCreatedCallback(io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback) DiscoveryException(io.joynr.exceptions.DiscoveryException) SuppressWarnings(edu.umd.cs.findbugs.annotations.SuppressWarnings)

Aggregations

SuppressWarnings (edu.umd.cs.findbugs.annotations.SuppressWarnings)1 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1 DiscoveryException (io.joynr.exceptions.DiscoveryException)1 JoynrCommunicationException (io.joynr.exceptions.JoynrCommunicationException)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 MessagingQos (io.joynr.messaging.MessagingQos)1 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)1 IOException (java.io.IOException)1 SystemIntegrationTestProxy (joynr.test.SystemIntegrationTestProxy)1