diff options
Diffstat (limited to 'vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/ControlPingTest.java')
-rw-r--r-- | vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/ControlPingTest.java | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/ControlPingTest.java b/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/ControlPingTest.java index ecf61a53..e97f4e3a 100644 --- a/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/ControlPingTest.java +++ b/vpp-api/java/jvpp-core/io/fd/vpp/jvpp/core/test/ControlPingTest.java @@ -20,8 +20,8 @@ import io.fd.vpp.jvpp.JVpp; import io.fd.vpp.jvpp.JVppRegistry; import io.fd.vpp.jvpp.JVppRegistryImpl; import io.fd.vpp.jvpp.VppCallbackException; -import io.fd.vpp.jvpp.core.JVppCoreImpl; import io.fd.vpp.jvpp.callback.ControlPingCallback; +import io.fd.vpp.jvpp.core.JVppCoreImpl; import io.fd.vpp.jvpp.dto.ControlPing; import io.fd.vpp.jvpp.dto.ControlPingReply; @@ -29,37 +29,36 @@ public class ControlPingTest { private static void testControlPing() throws Exception { System.out.println("Testing ControlPing using Java callback API"); - JVppRegistry registry = new JVppRegistryImpl("ControlPingTest"); - JVpp jvpp = new JVppCoreImpl(); + try (JVppRegistry registry = new JVppRegistryImpl("ControlPingTest"); + JVpp jvpp = new JVppCoreImpl()) { - registry.register(jvpp, new ControlPingCallback() { - @Override - public void onControlPingReply(final ControlPingReply reply) { - System.out.printf("Received ControlPingReply: %s%n", reply); - } + registry.register(jvpp, new ControlPingCallback() { + @Override + public void onControlPingReply(final ControlPingReply reply) { + System.out.printf("Received ControlPingReply: %s%n", reply); + } - @Override - public void onError(VppCallbackException ex) { - System.out.printf("Received onError exception: call=%s, reply=%d, context=%d ", ex.getMethodName(), + @Override + public void onError(VppCallbackException ex) { + System.out.printf("Received onError exception: call=%s, reply=%d, context=%d ", ex.getMethodName(), ex.getErrorCode(), ex.getCtxId()); - } - - }); - System.out.println("Successfully connected to VPP"); - Thread.sleep(1000); + } - System.out.println("Sending control ping using JVppRegistry"); - registry.controlPing(jvpp.getClass()); + }); + System.out.println("Successfully connected to VPP"); + Thread.sleep(1000); - Thread.sleep(2000); + System.out.println("Sending control ping using JVppRegistry"); + registry.controlPing(jvpp.getClass()); - System.out.println("Sending control ping using JVpp plugin"); - jvpp.send(new ControlPing()); + Thread.sleep(2000); - Thread.sleep(2000); + System.out.println("Sending control ping using JVpp plugin"); + jvpp.send(new ControlPing()); - System.out.println("Disconnecting..."); - registry.close(); + Thread.sleep(2000); + System.out.println("Disconnecting..."); + } Thread.sleep(1000); } |