diff options
author | 2016-09-28 10:12:04 +0200 | |
---|---|---|
committer | 2016-09-29 08:54:43 +0000 | |
commit | e85581cd07cf70d19870d8f858420f252ced3405 (patch) | |
tree | 58c4e2fcaa02c7f324e684687e328b76f2e8bbe1 /vpp-api/java/jvpp-core/org/openvpp | |
parent | 85ecc810ca98550a250c74f32244760e459e3f87 (diff) |
VPP-378: rename jvpp package to the same as groupId of deployed jars
Related changes:
- NSH: https://gerrit.fd.io/r/#/c/3181/
- Honeycomb: https://gerrit.fd.io/r/#/c/3182
Change-Id: Ifdd6b8b575916fdf99794618dbe604c2e17e8e82
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-api/java/jvpp-core/org/openvpp')
11 files changed, 0 insertions, 1037 deletions
diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackApiTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackApiTest.java deleted file mode 100644 index 61c92b123d9..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackApiTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.callback.GetNodeIndexCallback; -import org.openvpp.jvpp.core.callback.ShowVersionCallback; -import org.openvpp.jvpp.core.callback.SwInterfaceCallback; -import org.openvpp.jvpp.core.dto.GetNodeIndex; -import org.openvpp.jvpp.core.dto.GetNodeIndexReply; -import org.openvpp.jvpp.core.dto.ShowVersion; -import org.openvpp.jvpp.core.dto.ShowVersionReply; -import org.openvpp.jvpp.core.dto.SwInterfaceDetails; -import org.openvpp.jvpp.core.dto.SwInterfaceDump; - -public class CallbackApiTest { - - static class TestCallback implements GetNodeIndexCallback, ShowVersionCallback, SwInterfaceCallback { - - @Override - public void onGetNodeIndexReply(final GetNodeIndexReply msg) { - System.out.printf("Received GetNodeIndexReply: %s\n", msg); - } - - @Override - public void onShowVersionReply(final ShowVersionReply msg) { - System.out.printf("Received ShowVersionReply: context=%d, program=%s, version=%s, " - + "buildDate=%s, buildDirectory=%s\n", - msg.context, new String(msg.program), new String(msg.version), - new String(msg.buildDate), new String(msg.buildDirectory)); - } - - @Override - public void onSwInterfaceDetails(final SwInterfaceDetails msg) { - System.out.printf("Received SwInterfaceDetails: interfaceName=%s, l2AddressLength=%d, adminUpDown=%d, " - + "linkUpDown=%d, linkSpeed=%d, linkMtu=%d\n", - new String(msg.interfaceName), msg.l2AddressLength, msg.adminUpDown, - msg.linkUpDown, msg.linkSpeed, (int) msg.linkMtu); - } - - @Override - public void onError(VppCallbackException ex) { - System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n", ex.getMethodName(), - ex.getCtxId(), ex.getErrorCode()); - } - } - - public static void main(String[] args) throws Exception { - testCallbackApi(); - } - - private static void testCallbackApi() throws Exception { - System.out.println("Testing Java callback API with JVppRegistry"); - JVppRegistry registry = new JVppRegistryImpl("CallbackApiTest"); - JVpp jvpp = new JVppCoreImpl(); - - registry.register(jvpp, new TestCallback()); - - System.out.println("Sending ShowVersion request..."); - final int result = jvpp.send(new ShowVersion()); - System.out.printf("ShowVersion send result = %d\n", result); - - System.out.println("Sending GetNodeIndex request..."); - GetNodeIndex getNodeIndexRequest = new GetNodeIndex(); - getNodeIndexRequest.nodeName = "non-existing-node".getBytes(); - jvpp.send(getNodeIndexRequest); - - System.out.println("Sending SwInterfaceDump request..."); - SwInterfaceDump swInterfaceDumpRequest = new SwInterfaceDump(); - swInterfaceDumpRequest.nameFilterValid = 0; - swInterfaceDumpRequest.nameFilter = "".getBytes(); - jvpp.send(swInterfaceDumpRequest); - - Thread.sleep(1000); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackJVppFacadeNotificationTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackJVppFacadeNotificationTest.java deleted file mode 100644 index a4b528a9ad1..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackJVppFacadeNotificationTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.core.JVppCore; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.callback.WantInterfaceEventsCallback; -import org.openvpp.jvpp.core.callfacade.CallbackJVppCoreFacade; -import org.openvpp.jvpp.core.dto.WantInterfaceEventsReply; - -public class CallbackJVppFacadeNotificationTest { - - private static void testCallbackFacade() throws Exception { - System.out.println("Testing CallbackJVppFacade for notifications"); - - final JVppRegistry registry = new JVppRegistryImpl("CallbackFacadeTest"); - final JVppCore jvpp = new JVppCoreImpl(); - - CallbackJVppCoreFacade jvppCallbackFacade = new CallbackJVppCoreFacade(registry, jvpp); - System.out.println("Successfully connected to VPP"); - - final AutoCloseable notificationListenerReg = - jvppCallbackFacade.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback( - NotificationUtils::printNotification - ); - - jvppCallbackFacade.wantInterfaceEvents(NotificationUtils.getEnableInterfaceNotificationsReq(), - new WantInterfaceEventsCallback() { - @Override - public void onWantInterfaceEventsReply(final WantInterfaceEventsReply reply) { - System.out.println("Interface events started"); - } - - @Override - public void onError(final VppCallbackException ex) { - System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n", - ex.getMethodName(), ex.getCtxId(), ex.getErrorCode()); - } - }); - - System.out.println("Changing interface configuration"); - NotificationUtils.getChangeInterfaceState().send(jvpp); - - Thread.sleep(1000); - - jvppCallbackFacade.wantInterfaceEvents(NotificationUtils.getDisableInterfaceNotificationsReq(), - new WantInterfaceEventsCallback() { - @Override - public void onWantInterfaceEventsReply(final WantInterfaceEventsReply reply) { - System.out.println("Interface events stopped"); - } - - @Override - public void onError(final VppCallbackException ex) { - System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n", - ex.getMethodName(), ex.getCtxId(), ex.getErrorCode()); - } - }); - - notificationListenerReg.close(); - - Thread.sleep(2000); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackFacade(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackJVppFacadeTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackJVppFacadeTest.java deleted file mode 100644 index 63a399ddb3e..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackJVppFacadeTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.core.JVppCore; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.callback.GetNodeIndexCallback; -import org.openvpp.jvpp.core.callback.ShowVersionCallback; -import org.openvpp.jvpp.core.callfacade.CallbackJVppCoreFacade; -import org.openvpp.jvpp.core.dto.GetNodeIndex; -import org.openvpp.jvpp.core.dto.GetNodeIndexReply; -import org.openvpp.jvpp.core.dto.ShowVersionReply; - -/** - * CallbackJVppFacade together with CallbackJVppFacadeCallback allow for setting different callback for each request. - * This is more convenient than the approach shown in CallbackApiTest. - */ -public class CallbackJVppFacadeTest { - - private static ShowVersionCallback showVersionCallback1 = new ShowVersionCallback() { - @Override - public void onShowVersionReply(final ShowVersionReply msg) { - System.out.printf("ShowVersionCallback1 received ShowVersionReply: context=%d, program=%s," - + "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, new String(msg.program), - new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory)); - } - - @Override - public void onError(VppCallbackException ex) { - System.out.printf("Received onError exception in showVersionCallback1: call=%s, reply=%d, context=%d\n", - ex.getMethodName(), ex.getErrorCode(), ex.getCtxId()); - } - }; - - private static ShowVersionCallback showVersionCallback2 = new ShowVersionCallback() { - @Override - public void onShowVersionReply(final ShowVersionReply msg) { - System.out.printf("ShowVersionCallback2 received ShowVersionReply: context=%d, program=%s," - + "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, new String(msg.program), - new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory)); - } - - @Override - public void onError(VppCallbackException ex) { - System.out.printf("Received onError exception in showVersionCallback2: call=%s, reply=%d, context=%d\n", - ex.getMethodName(), ex.getErrorCode(), ex.getCtxId()); - } - - }; - - private static GetNodeIndexCallback getNodeIndexCallback = new GetNodeIndexCallback() { - @Override - public void onGetNodeIndexReply(final GetNodeIndexReply msg) { - System.out.printf("Received GetNodeIndexReply: %s\n", msg); - } - - @Override - public void onError(VppCallbackException ex) { - System.out.printf("Received onError exception in getNodeIndexCallback: call=%s, reply=%d, context=%d\n", - ex.getMethodName(), ex.getErrorCode(), ex.getCtxId()); - } - }; - - private static void testCallbackFacade() throws Exception { - System.out.println("Testing CallbackJVppFacade"); - - final JVppRegistry registry = new JVppRegistryImpl("CallbackFacadeTest"); - final JVppCore jvpp = new JVppCoreImpl(); - - CallbackJVppCoreFacade jvppCallbackFacade = new CallbackJVppCoreFacade(registry, jvpp); - System.out.println("Successfully connected to VPP"); - - jvppCallbackFacade.showVersion(showVersionCallback1); - jvppCallbackFacade.showVersion(showVersionCallback2); - - GetNodeIndex getNodeIndexRequest = new GetNodeIndex(); - getNodeIndexRequest.nodeName = "dummyNode".getBytes(); - jvppCallbackFacade.getNodeIndex(getNodeIndexRequest, getNodeIndexCallback); - - Thread.sleep(2000); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackFacade(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackNotificationApiTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackNotificationApiTest.java deleted file mode 100644 index bb99fef61a1..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CallbackNotificationApiTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import static org.openvpp.jvpp.core.test.NotificationUtils.getChangeInterfaceState; -import static org.openvpp.jvpp.core.test.NotificationUtils.getDisableInterfaceNotificationsReq; -import static org.openvpp.jvpp.core.test.NotificationUtils.getEnableInterfaceNotificationsReq; -import static org.openvpp.jvpp.core.test.NotificationUtils.printNotification; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.callback.SwInterfaceSetFlagsCallback; -import org.openvpp.jvpp.core.callback.SwInterfaceSetFlagsNotificationCallback; -import org.openvpp.jvpp.core.callback.WantInterfaceEventsCallback; -import org.openvpp.jvpp.core.dto.SwInterfaceSetFlagsNotification; -import org.openvpp.jvpp.core.dto.SwInterfaceSetFlagsReply; -import org.openvpp.jvpp.core.dto.WantInterfaceEventsReply; - -public class CallbackNotificationApiTest { - - private static class TestCallback implements SwInterfaceSetFlagsNotificationCallback, - WantInterfaceEventsCallback, SwInterfaceSetFlagsCallback { - - @Override - public void onSwInterfaceSetFlagsNotification( - final SwInterfaceSetFlagsNotification msg) { - printNotification(msg); - } - - @Override - public void onWantInterfaceEventsReply(final WantInterfaceEventsReply wantInterfaceEventsReply) { - System.out.println("Interface notification stream updated"); - } - - @Override - public void onSwInterfaceSetFlagsReply(final SwInterfaceSetFlagsReply swInterfaceSetFlagsReply) { - System.out.println("Interface flags set successfully"); - } - - @Override - public void onError(VppCallbackException ex) { - System.out.printf("Received onError exception in getNodeIndexCallback: call=%s, reply=%d, context=%d\n", - ex.getMethodName(), ex.getErrorCode(), ex.getCtxId()); - - } - } - - private static void testCallbackApi() throws Exception { - System.out.println("Testing Java callback API for notifications"); - JVppRegistry registry = new JVppRegistryImpl("CallbackNotificationTest"); - JVpp jvpp = new JVppCoreImpl(); - - registry.register(jvpp, new TestCallback()); - System.out.println("Successfully connected to VPP"); - - getEnableInterfaceNotificationsReq().send(jvpp); - System.out.println("Interface notifications started"); - // TODO test ifc dump which also triggers interface flags send - - System.out.println("Changing interface configuration"); - getChangeInterfaceState().send(jvpp); - - // Notifications are received - Thread.sleep(500); - - getDisableInterfaceNotificationsReq().send(jvpp); - System.out.println("Interface events stopped"); - - Thread.sleep(2000); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackApi(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/ControlPingTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/ControlPingTest.java deleted file mode 100644 index b4119993eaf..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/ControlPingTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.callback.ControlPingCallback; -import org.openvpp.jvpp.dto.ControlPing; -import org.openvpp.jvpp.dto.ControlPingReply; - -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(); - - 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(), - 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()); - - Thread.sleep(2000); - - System.out.println("Sending control ping using JVpp plugin"); - jvpp.send(new ControlPing()); - - Thread.sleep(2000); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testControlPing(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CreateSubInterfaceTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CreateSubInterfaceTest.java deleted file mode 100644 index a22aec66e61..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/CreateSubInterfaceTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import static java.util.Objects.requireNonNull; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.dto.CreateSubif; -import org.openvpp.jvpp.core.dto.CreateSubifReply; -import org.openvpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; -import org.openvpp.jvpp.core.dto.SwInterfaceDump; -import org.openvpp.jvpp.core.future.FutureJVppCoreFacade; - -/** - * <p>Tests sub-interface creation.<br> Equivalent to:<br> - * - * <pre>{@code - * vppctl create sub GigabitEthernet0/9/0 1 dot1q 100 inner-dot1q any - * } - * </pre> - * - * To verify invoke:<br> - * <pre>{@code - * vpp_api_test json - * vat# sw_interface_dump - * } - */ -public class CreateSubInterfaceTest { - - private static SwInterfaceDump createSwInterfaceDumpRequest(final String ifaceName) { - SwInterfaceDump request = new SwInterfaceDump(); - request.nameFilter = ifaceName.getBytes(); - request.nameFilterValid = 1; - return request; - } - - private static void requireSingleIface(final SwInterfaceDetailsReplyDump response, final String ifaceName) { - if (response.swInterfaceDetails.size() != 1) { - throw new IllegalStateException( - String.format("Expected one interface matching filter %s but was %d", ifaceName, - response.swInterfaceDetails.size())); - } - } - - private static CreateSubif createSubifRequest(final int swIfIndex, final int subId) { - CreateSubif request = new CreateSubif(); - request.swIfIndex = swIfIndex; // super interface id - request.subId = subId; - request.noTags = 0; - request.oneTag = 0; - request.twoTags = 1; - request.dot1Ad = 0; - request.exactMatch = 1; - request.defaultSub = 0; - request.outerVlanIdAny = 0; - request.innerVlanIdAny = 1; - request.outerVlanId = 100; - request.innerVlanId = 0; - return request; - } - - private static void print(CreateSubifReply reply) { - System.out.printf("CreateSubifReply: %s\n", reply); - } - - private static void testCreateSubInterface() throws Exception { - System.out.println("Testing sub-interface creation using Java callback API"); - final JVppRegistry registry = new JVppRegistryImpl("CreateSubInterface"); - final JVpp jvpp = new JVppCoreImpl(); - final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, jvpp); - - System.out.println("Successfully connected to VPP"); - Thread.sleep(1000); - - final String ifaceName = "GigabitEthernet0/8/0"; - - final SwInterfaceDetailsReplyDump swInterfaceDetails = - jvppFacade.swInterfaceDump(createSwInterfaceDumpRequest(ifaceName)).toCompletableFuture().get(); - - requireNonNull(swInterfaceDetails, "swInterfaceDump returned null"); - requireNonNull(swInterfaceDetails.swInterfaceDetails, "swInterfaceDetails is null"); - requireSingleIface(swInterfaceDetails, ifaceName); - - final int swIfIndex = swInterfaceDetails.swInterfaceDetails.get(0).swIfIndex; - final int subId = 1; - - final CreateSubifReply createSubifReply = - jvppFacade.createSubif(createSubifRequest(swIfIndex, subId)).toCompletableFuture().get(); - print(createSubifReply); - - final String subIfaceName = "GigabitEthernet0/8/0." + subId; - final SwInterfaceDetailsReplyDump subIface = - jvppFacade.swInterfaceDump(createSwInterfaceDumpRequest(subIfaceName)).toCompletableFuture().get(); - requireNonNull(swInterfaceDetails, "swInterfaceDump returned null"); - requireNonNull(subIface.swInterfaceDetails, "swInterfaceDump returned null"); - requireSingleIface(swInterfaceDetails, ifaceName); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCreateSubInterface(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/FutureApiNotificationTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/FutureApiNotificationTest.java deleted file mode 100644 index 20f8ae4dd87..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/FutureApiNotificationTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import static org.openvpp.jvpp.core.test.NotificationUtils.getChangeInterfaceState; -import static org.openvpp.jvpp.core.test.NotificationUtils.getDisableInterfaceNotificationsReq; -import static org.openvpp.jvpp.core.test.NotificationUtils.getEnableInterfaceNotificationsReq; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.future.FutureJVppCoreFacade; - -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(); - } - - public static void main(String[] args) throws Exception { - testFutureApi(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/FutureApiTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/FutureApiTest.java deleted file mode 100644 index dc172471163..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/FutureApiTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.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 org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.dto.BridgeDomainDetailsReplyDump; -import org.openvpp.jvpp.core.dto.BridgeDomainDump; -import org.openvpp.jvpp.core.dto.GetNodeIndex; -import org.openvpp.jvpp.core.dto.GetNodeIndexReply; -import org.openvpp.jvpp.core.dto.ShowVersion; -import org.openvpp.jvpp.core.dto.ShowVersionReply; -import org.openvpp.jvpp.core.dto.SwInterfaceDetails; -import org.openvpp.jvpp.core.dto.SwInterfaceDetailsReplyDump; -import org.openvpp.jvpp.core.dto.SwInterfaceDump; -import org.openvpp.jvpp.core.future.FutureJVppCoreFacade; - -public class FutureApiTest { - - private static final Logger LOG = Logger.getLogger(FutureApiTest.class.getName()); - - private static void testShowVersion(final FutureJVppCoreFacade jvpp) throws Exception { - LOG.info("Sending ShowVersion request..."); - 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))); - } - - private static void testEmptyBridgeDomainDump(final FutureJVppCoreFacade jvpp) throws Exception { - LOG.info("Sending ShowVersion request..."); - final BridgeDomainDump request = new BridgeDomainDump(); - request.bdId = -1; // dump call - - final CompletableFuture<BridgeDomainDetailsReplyDump> - 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)); - } - } - - private static void testGetNodeIndex(final FutureJVppCoreFacade jvpp) { - LOG.info("Sending GetNodeIndex request..."); - final GetNodeIndex request = new GetNodeIndex(); - request.nodeName = "non-existing-node".getBytes(); - final Future<GetNodeIndexReply> replyFuture = jvpp.getNodeIndex(request).toCompletableFuture(); - try { - final GetNodeIndexReply reply = replyFuture.get(); - LOG.info( - String.format( - "Received GetNodeIndexReply: context=%d, nodeIndex=%d\n", reply.context, reply.nodeIndex)); - } catch (Exception e) { - LOG.log(Level.SEVERE, "GetNodeIndex request failed", e); - } - } - - private static void testSwInterfaceDump(final FutureJVppCoreFacade jvpp) throws Exception { - LOG.info("Sending SwInterfaceDump request..."); - final SwInterfaceDump request = new SwInterfaceDump(); - request.nameFilterValid = 0; - request.nameFilter = "".getBytes(); - - final Future<SwInterfaceDetailsReplyDump> replyFuture = jvpp.swInterfaceDump(request).toCompletableFuture(); - final SwInterfaceDetailsReplyDump reply = replyFuture.get(); - 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)); - } - } - - private static void testFutureApi() throws Exception { - LOG.info("Testing Java future API"); - - 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); - - LOG.info("Disconnecting..."); - registry.close(); - } - - public static void main(String[] args) throws Exception { - testFutureApi(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/L2AclTest.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/L2AclTest.java deleted file mode 100644 index 33716c32ef9..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/L2AclTest.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import javax.xml.bind.DatatypeConverter; -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppRegistry; -import org.openvpp.jvpp.JVppRegistryImpl; -import org.openvpp.jvpp.core.JVppCoreImpl; -import org.openvpp.jvpp.core.dto.ClassifyAddDelSession; -import org.openvpp.jvpp.core.dto.ClassifyAddDelSessionReply; -import org.openvpp.jvpp.core.dto.ClassifyAddDelTable; -import org.openvpp.jvpp.core.dto.ClassifyAddDelTableReply; -import org.openvpp.jvpp.core.dto.ClassifySessionDetailsReplyDump; -import org.openvpp.jvpp.core.dto.ClassifySessionDump; -import org.openvpp.jvpp.core.dto.ClassifyTableByInterface; -import org.openvpp.jvpp.core.dto.ClassifyTableByInterfaceReply; -import org.openvpp.jvpp.core.dto.ClassifyTableIds; -import org.openvpp.jvpp.core.dto.ClassifyTableIdsReply; -import org.openvpp.jvpp.core.dto.ClassifyTableInfo; -import org.openvpp.jvpp.core.dto.ClassifyTableInfoReply; -import org.openvpp.jvpp.core.dto.InputAclSetInterface; -import org.openvpp.jvpp.core.dto.InputAclSetInterfaceReply; -import org.openvpp.jvpp.core.future.FutureJVppCoreFacade; - -/** - * <p>Tests L2 ACL creation and read.<br> Equivalent to the following vppctl commands:<br> - * - * <pre>{@code - * vppctl classify table mask l2 src - * vppctl classify session acl-hit-next deny opaque-index 0 table-index 0 match l2 src 01:02:03:04:05:06 - * vppctl set int input acl intfc local0 l2-table 0 - * vppctl sh class table verbose - * } - * </pre> - */ -public class L2AclTest { - - private static final int LOCAL0_IFACE_ID = 0; - - private static ClassifyAddDelTable createClassifyTable() { - ClassifyAddDelTable request = new ClassifyAddDelTable(); - request.isAdd = 1; - request.tableIndex = ~0; // default - request.nbuckets = 2; - request.memorySize = 2 << 20; - request.nextTableIndex = ~0; // default - request.missNextIndex = ~0; // default - request.skipNVectors = 0; - request.matchNVectors = 1; - request.mask = - new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, - (byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00}; - return request; - } - - private static ClassifyTableInfo createClassifyTableInfoRequest(final int tableId) { - ClassifyTableInfo request = new ClassifyTableInfo(); - request.tableId = tableId; - return request; - } - - private static ClassifyAddDelSession createClassifySession(final int tableIndex) { - ClassifyAddDelSession request = new ClassifyAddDelSession(); - request.isAdd = 1; - request.tableIndex = tableIndex; - request.hitNextIndex = 0; // deny - request.opaqueIndex = 0; - request.advance = 0; // default - // match 01:02:03:04:05:06 mac address - request.match = - new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, - (byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00}; - return request; - } - - private static ClassifySessionDump createClassifySessionDumpRequest(final int newTableIndex) { - ClassifySessionDump request = new ClassifySessionDump(); - request.tableId = newTableIndex; - return request; - } - - private static InputAclSetInterface aclSetInterface() { - InputAclSetInterface request = new InputAclSetInterface(); - request.isAdd = 1; - request.swIfIndex = LOCAL0_IFACE_ID; - request.ip4TableIndex = ~0; // skip - request.ip6TableIndex = ~0; // skip - request.l2TableIndex = 0; - return request; - } - - private static ClassifyTableByInterface createClassifyTableByInterfaceRequest() { - ClassifyTableByInterface request = new ClassifyTableByInterface(); - request.swIfIndex = LOCAL0_IFACE_ID; - return request; - } - - private static void print(ClassifyAddDelTableReply reply) { - System.out.printf("ClassifyAddDelTableReply: %s\n", reply); - } - - private static void print(ClassifyTableIdsReply reply) { - System.out.printf("ClassifyTableIdsReply: %s\n", reply); - } - - private static void print(final ClassifyTableInfoReply reply) { - System.out.println(reply); - if (reply != null) { - System.out.println("Mask hex: " + DatatypeConverter.printHexBinary(reply.mask)); - } - } - - private static void print(ClassifyAddDelSessionReply reply) { - System.out.printf("ClassifyAddDelSessionReply: context=%s\n", reply); - } - - private static void print(final ClassifySessionDetailsReplyDump reply) { - System.out.println(reply); - reply.classifySessionDetails.forEach(detail -> { - System.out.println(detail); - System.out.println("Match hex: " + DatatypeConverter.printHexBinary(detail.match)); - }); - } - - private static void print(final InputAclSetInterfaceReply reply) { - System.out.printf("InputAclSetInterfaceReply: context=%s\n", reply); - } - - private static void print(final ClassifyTableByInterfaceReply reply) { - System.out.printf("ClassifyAddDelTableReply: %s\n", reply); - } - - private static void testL2Acl() throws Exception { - System.out.println("Testing L2 ACLs using Java callback API"); - final JVppRegistry registry = new JVppRegistryImpl("L2AclTest"); - final JVpp jvpp = new JVppCoreImpl(); - final FutureJVppCoreFacade jvppFacade = new FutureJVppCoreFacade(registry, jvpp); - - System.out.println("Successfully connected to VPP"); - Thread.sleep(1000); - - final ClassifyAddDelTableReply classifyAddDelTableReply = - jvppFacade.classifyAddDelTable(createClassifyTable()).toCompletableFuture().get(); - print(classifyAddDelTableReply); - - final ClassifyTableIdsReply classifyTableIdsReply = - jvppFacade.classifyTableIds(new ClassifyTableIds()).toCompletableFuture().get(); - print(classifyTableIdsReply); - - final ClassifyTableInfoReply classifyTableInfoReply = - jvppFacade.classifyTableInfo(createClassifyTableInfoRequest(classifyAddDelTableReply.newTableIndex)) - .toCompletableFuture().get(); - print(classifyTableInfoReply); - - final ClassifyAddDelSessionReply classifyAddDelSessionReply = - jvppFacade.classifyAddDelSession(createClassifySession(classifyAddDelTableReply.newTableIndex)) - .toCompletableFuture().get(); - print(classifyAddDelSessionReply); - - final ClassifySessionDetailsReplyDump classifySessionDetailsReplyDump = - jvppFacade.classifySessionDump(createClassifySessionDumpRequest(classifyAddDelTableReply.newTableIndex)) - .toCompletableFuture().get(); - print(classifySessionDetailsReplyDump); - - final InputAclSetInterfaceReply inputAclSetInterfaceReply = - jvppFacade.inputAclSetInterface(aclSetInterface()).toCompletableFuture().get(); - print(inputAclSetInterfaceReply); - - final ClassifyTableByInterfaceReply classifyTableByInterfaceReply = - jvppFacade.classifyTableByInterface(createClassifyTableByInterfaceRequest()).toCompletableFuture().get(); - print(classifyTableByInterfaceReply); - - System.out.println("Disconnecting..."); - registry.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testL2Acl(); - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/NotificationUtils.java b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/NotificationUtils.java deleted file mode 100644 index 02875bbf763..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/NotificationUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.openvpp.jvpp.core.test; - -import java.io.PrintStream; -import org.openvpp.jvpp.core.dto.SwInterfaceSetFlags; -import org.openvpp.jvpp.core.dto.SwInterfaceSetFlagsNotification; -import org.openvpp.jvpp.core.dto.WantInterfaceEvents; - -final class NotificationUtils { - - private NotificationUtils() {} - - static PrintStream printNotification(final SwInterfaceSetFlagsNotification msg) { - return System.out.printf("Received interface notification: ifc: %s\n", msg); - } - - static SwInterfaceSetFlags getChangeInterfaceState() { - final SwInterfaceSetFlags swInterfaceSetFlags = new SwInterfaceSetFlags(); - swInterfaceSetFlags.swIfIndex = 0; - swInterfaceSetFlags.adminUpDown = 1; - swInterfaceSetFlags.deleted = 0; - return swInterfaceSetFlags; - } - - static WantInterfaceEvents getEnableInterfaceNotificationsReq() { - WantInterfaceEvents wantInterfaceEvents = new WantInterfaceEvents(); - wantInterfaceEvents.pid = 1; - wantInterfaceEvents.enableDisable = 1; - return wantInterfaceEvents; - } - - static WantInterfaceEvents getDisableInterfaceNotificationsReq() { - WantInterfaceEvents wantInterfaceEvents = new WantInterfaceEvents(); - wantInterfaceEvents.pid = 1; - wantInterfaceEvents.enableDisable = 0; - return wantInterfaceEvents; - } -} diff --git a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/Readme.txt b/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/Readme.txt deleted file mode 100644 index c24af24fb49..00000000000 --- a/vpp-api/java/jvpp-core/org/openvpp/jvpp/core/test/Readme.txt +++ /dev/null @@ -1,16 +0,0 @@ -This package contains basic tests for jvpp. To run the tests: - -- Make sure VPP is running -- From VPP's build-root/ folder execute: - - sudo java -cp build-vpp_debug-native/vpp-api/java/jvpp-registry-16.12.jar:build-vpp_debug-native/vpp-api/java/jvpp-core-16.12.jar org.openvpp.jvpp.core.test.[test name] - -Available tests: -CallbackApiTest - Similar to ControlPingTest, invokes more complex calls (e.g. interface dump) using low level JVpp APIs -CallbackJVppFacadeNotificationTest - Tests interface notifications using Callback based JVpp facade -CallbackJVppFacadeTest - Execution of more complex calls using Callback based JVpp facade -CallbackNotificationApiTest - Tests interface notifications using low level JVpp APIs -ControlPingTest - Simple test executing a single control ping using low level JVpp APIs -CreateSubInterfaceTest - Tests sub-interface creation -FutureApiNotificationTest - Tests interface notifications using Future based JVpp facade -FutureApiTest - Execution of more complex calls using Future based JVpp facade -L2AclTest - Tests L2 ACL creation |