aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-10-24 08:06:52 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2016-10-24 10:05:53 +0000
commit9c2964ce01fa05c715499206cf3d0f610c5c334d (patch)
tree19ac7c2bf7ebdad4b2c5b8f6aad84cc3af2a1143 /vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java
parente319de0b0407cd1e0ebc6ad523b9c608499d8c0c (diff)
Fix jvpp coverity issues #2
- synchronize AbstractFutureJvppInvoker.getRequests - handle registry & jvpp close in API usage examples Change-Id: I918bf864b8212fde04f0d9194037f1c6a810fc3f Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java')
-rw-r--r--vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java59
1 files changed, 28 insertions, 31 deletions
diff --git a/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java b/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java
index 80c1108d..f478bab4 100644
--- a/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java
+++ b/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiTest.java
@@ -16,12 +16,6 @@
package io.fd.vpp.jvpp.core.test;
-import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import io.fd.vpp.jvpp.JVpp;
import io.fd.vpp.jvpp.JVppRegistry;
import io.fd.vpp.jvpp.JVppRegistryImpl;
import io.fd.vpp.jvpp.core.JVppCoreImpl;
@@ -35,6 +29,11 @@ import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade;
+import java.util.Objects;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.logging.Logger;
public class FutureApiTest {
@@ -45,10 +44,10 @@ public class FutureApiTest {
final Future<ShowVersionReply> replyFuture = jvpp.showVersion(new ShowVersion()).toCompletableFuture();
final ShowVersionReply reply = replyFuture.get();
LOG.info(
- String.format(
- "Received ShowVersionReply: context=%d, program=%s, version=%s, buildDate=%s, buildDirectory=%s%n",
- reply.context, new String(reply.program), new String(reply.version), new String(reply.buildDate),
- new String(reply.buildDirectory)));
+ String.format(
+ "Received ShowVersionReply: context=%d, program=%s, version=%s, buildDate=%s, buildDirectory=%s%n",
+ reply.context, new String(reply.program), new String(reply.version), new String(reply.buildDate),
+ new String(reply.buildDirectory)));
}
private static void testEmptyBridgeDomainDump(final FutureJVppCoreFacade jvpp) throws Exception {
@@ -57,16 +56,16 @@ public class FutureApiTest {
request.bdId = -1; // dump call
final CompletableFuture<BridgeDomainDetailsReplyDump>
- replyFuture = jvpp.bridgeDomainDump(request).toCompletableFuture();
+ replyFuture = jvpp.bridgeDomainDump(request).toCompletableFuture();
final BridgeDomainDetailsReplyDump reply = replyFuture.get();
if (reply == null || reply.bridgeDomainDetails == null) {
LOG.severe("Received null response for empty dump: " + reply);
} else {
LOG.info(
- String.format(
- "Received empty bridge-domain dump reply with list of bridge-domains: %s, %s",
- reply.bridgeDomainDetails, reply.bridgeDomainSwIfDetails));
+ String.format(
+ "Received empty bridge-domain dump reply with list of bridge-domains: %s, %s",
+ reply.bridgeDomainDetails, reply.bridgeDomainSwIfDetails));
}
}
@@ -78,8 +77,8 @@ public class FutureApiTest {
try {
final GetNodeIndexReply reply = replyFuture.get();
LOG.info(
- String.format(
- "Received GetNodeIndexReply: context=%d, nodeIndex=%d%n", reply.context, reply.nodeIndex));
+ String.format(
+ "Received GetNodeIndexReply: context=%d, nodeIndex=%d%n", reply.context, reply.nodeIndex));
} catch (Exception e) {
LOG.log(Level.SEVERE, "GetNodeIndex request failed", e);
}
@@ -96,28 +95,26 @@ public class FutureApiTest {
for (SwInterfaceDetails details : reply.swInterfaceDetails) {
Objects.requireNonNull(details, "reply.swInterfaceDetails contains null element!");
LOG.info(
- String.format("Received SwInterfaceDetails: interfaceName=%s, l2AddressLength=%d, adminUpDown=%d, "
- + "linkUpDown=%d, linkSpeed=%d, linkMtu=%d%n",
- new String(details.interfaceName), details.l2AddressLength, details.adminUpDown,
- details.linkUpDown, details.linkSpeed, (int) details.linkMtu));
+ String.format("Received SwInterfaceDetails: interfaceName=%s, l2AddressLength=%d, adminUpDown=%d, "
+ + "linkUpDown=%d, linkSpeed=%d, linkMtu=%d%n",
+ new String(details.interfaceName), details.l2AddressLength, details.adminUpDown,
+ details.linkUpDown, details.linkSpeed, (int) details.linkMtu));
}
}
private static void testFutureApi() throws Exception {
LOG.info("Testing Java future API");
+ try (final JVppRegistry registry = new JVppRegistryImpl("FutureApiTest");
+ final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, new JVppCoreImpl())) {
+ LOG.info("Successfully connected to VPP");
- final JVppRegistry registry = new JVppRegistryImpl("FutureApiTest");
- final JVpp jvpp = new JVppCoreImpl();
- final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, jvpp);
- LOG.info("Successfully connected to VPP");
-
- testEmptyBridgeDomainDump(jvppFacade);
- testShowVersion(jvppFacade);
- testGetNodeIndex(jvppFacade);
- testSwInterfaceDump(jvppFacade);
+ testEmptyBridgeDomainDump(jvppFacade);
+ testShowVersion(jvppFacade);
+ testGetNodeIndex(jvppFacade);
+ testSwInterfaceDump(jvppFacade);
- LOG.info("Disconnecting...");
- registry.close();
+ LOG.info("Disconnecting...");
+ }
}
public static void main(String[] args) throws Exception {