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);
}
Aggregations