aboutsummaryrefslogtreecommitdiffstats
path: root/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiNotificationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiNotificationTest.java')
-rw-r--r--vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiNotificationTest.java45
1 files changed, 18 insertions, 27 deletions
diff --git a/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiNotificationTest.java b/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiNotificationTest.java
index 2ba1b09b..9efeae19 100644
--- a/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiNotificationTest.java
+++ b/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/FutureApiNotificationTest.java
@@ -20,7 +20,6 @@ import static io.fd.vpp.jvpp.core.test.NotificationUtils.getChangeInterfaceState
import static io.fd.vpp.jvpp.core.test.NotificationUtils.getDisableInterfaceNotificationsReq;
import static io.fd.vpp.jvpp.core.test.NotificationUtils.getEnableInterfaceNotificationsReq;
-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;
@@ -30,32 +29,24 @@ public class FutureApiNotificationTest {
private static void testFutureApi() throws Exception {
System.out.println("Testing Java future API for notifications");
-
- final JVppRegistry registry = new JVppRegistryImpl("FutureApiNotificationTest");
- final JVpp jvpp = new JVppCoreImpl();
- final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, jvpp);
-
- System.out.println("Successfully connected to VPP");
-
- final AutoCloseable notificationListenerReg =
- jvppFacade.getNotificationRegistry()
- .registerSwInterfaceSetFlagsNotificationCallback(NotificationUtils::printNotification);
-
- jvppFacade.wantInterfaceEvents(getEnableInterfaceNotificationsReq()).toCompletableFuture().get();
- System.out.println("Interface events started");
-
- System.out.println("Changing interface configuration");
- jvppFacade.swInterfaceSetFlags(getChangeInterfaceState()).toCompletableFuture().get();
-
- Thread.sleep(1000);
-
- jvppFacade.wantInterfaceEvents(getDisableInterfaceNotificationsReq()).toCompletableFuture().get();
- System.out.println("Interface events stopped");
-
- notificationListenerReg.close();
-
- System.out.println("Disconnecting...");
- registry.close();
+ try (final JVppRegistry registry = new JVppRegistryImpl("FutureApiNotificationTest");
+ final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, new JVppCoreImpl());
+ final AutoCloseable notificationListenerReg =
+ jvppFacade.getNotificationRegistry()
+ .registerSwInterfaceSetFlagsNotificationCallback(NotificationUtils::printNotification)) {
+ System.out.println("Successfully connected to VPP");
+ jvppFacade.wantInterfaceEvents(getEnableInterfaceNotificationsReq()).toCompletableFuture().get();
+ System.out.println("Interface events started");
+
+ System.out.println("Changing interface configuration");
+ jvppFacade.swInterfaceSetFlags(getChangeInterfaceState()).toCompletableFuture().get();
+
+ Thread.sleep(1000);
+
+ jvppFacade.wantInterfaceEvents(getDisableInterfaceNotificationsReq()).toCompletableFuture().get();
+ System.out.println("Interface events stopped");
+ System.out.println("Disconnecting...");
+ }
}
public static void main(String[] args) throws Exception {