diff options
author | 2016-07-26 15:28:22 +0200 | |
---|---|---|
committer | 2016-08-16 21:26:19 +0000 | |
commit | 66ea26b1bc7bbc8d54a3498dbd3d0919c4712fa8 (patch) | |
tree | 16c46e75723099ad859128af6069055e68897300 /vpp-api/java/jvpp/org | |
parent | f4691cd7befd4cf31a63adffc204d71b1f1548e1 (diff) |
VPP-205: jvpp plugin support.
Splits jvpp into two jars
jvpp-registry.jar - base jvpp functionality
jvpp-core.jar - Java wrapper for vpe.api
Plugins can be generated the same way jvpp-core.jar is.
Example (nsh):
https://gerrit.fd.io/r/#/c/2118/
Change-Id: I2254f90b2c3e423563bb91bf70877979f1e90a7d
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'vpp-api/java/jvpp/org')
28 files changed, 0 insertions, 1780 deletions
diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/VppBaseCallException.java b/vpp-api/java/jvpp/org/openvpp/jvpp/VppBaseCallException.java deleted file mode 100644 index 792af2c69ec..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/VppBaseCallException.java +++ /dev/null @@ -1,60 +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; - -/** - * Base exception representing failed operation of JVpp request call - */ -public abstract class VppBaseCallException extends Exception { - private final String methodName; - private final int errorCode; - - /** - * Constructs an VppCallbackException with the specified api method name and error code. - * - * @param methodName name of a method, which invocation or execution failed - * @param errorCode negative error code value associated with this failure - * @throws NullPointerException if apiMethodName is null - */ - public VppBaseCallException(final String methodName, final int errorCode) { - super(String.format("vppApi.%s failed with error code: %d", methodName, errorCode)); - this.methodName = java.util.Objects.requireNonNull(methodName, "apiMethodName is null!"); - this.errorCode = errorCode; - if(errorCode >= 0) { - throw new IllegalArgumentException("Error code must be < 0. Was " + errorCode + - " for " + methodName ); - } - } - - /** - * Returns name of a method, which invocation failed. - * - * @return method name - */ - public String getMethodName() { - return methodName; - } - - /** - * Returns the error code associated with this failure. - * - * @return a negative integer error code - */ - public int getErrorCode() { - return errorCode; - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/VppCallbackException.java b/vpp-api/java/jvpp/org/openvpp/jvpp/VppCallbackException.java deleted file mode 100644 index 3d2a1cb2013..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/VppCallbackException.java +++ /dev/null @@ -1,47 +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; - -/** - * Callback Exception representing failed operation of JVpp request call - */ -public class VppCallbackException extends VppBaseCallException { - private final int ctxId; - - /** - * Constructs an VppCallbackException with the specified api method name and error code. - * - * @param methodName name of a method, which invocation failed. - * @param ctxId api request context identifier - * @param errorCode negative error code value associated with this failure - * @throws NullPointerException if apiMethodName is null - */ - public VppCallbackException(final String methodName, final int ctxId, final int errorCode ){ - super(methodName, errorCode); - this.ctxId = ctxId; - } - - /** - * Returns api request context identifier. - * - * @return value of context identifier - */ - public int getCtxId() { - return ctxId; - } - -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/VppConnection.java b/vpp-api/java/jvpp/org/openvpp/jvpp/VppConnection.java deleted file mode 100644 index 19733985452..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/VppConnection.java +++ /dev/null @@ -1,48 +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; - -import java.io.IOException; - -/** - * Representation of a management connection to VPP. - * Connection is initiated when instance is created, closed with close(). - */ -public interface VppConnection extends AutoCloseable { - - /** - * Open VppConnection for communication with VPP - * - * @param callback instance handling responses - * - * @throws IOException if connection is not established - */ - void connect(final org.openvpp.jvpp.callback.JVppCallback callback) throws IOException; - - /** - * Check if this instance connection is active. - * - * @throws IllegalStateException if this instance was disconnected. - */ - void checkActive(); - - /** - * Closes Vpp connection. - */ - @Override - void close(); -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/VppInvocationException.java b/vpp-api/java/jvpp/org/openvpp/jvpp/VppInvocationException.java deleted file mode 100644 index 298bcd0ae55..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/VppInvocationException.java +++ /dev/null @@ -1,33 +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; - -/** - * Exception thrown when Vpp jAPI method invocation failed. - */ -public class VppInvocationException extends VppBaseCallException { - /** - * Constructs an VppApiInvocationFailedException with the specified api method name and error code. - * - * @param methodName name of a method, which invocation failed. - * @param errorCode negative error code value associated with this failure - * @throws NullPointerException if apiMethodName is null - */ - public VppInvocationException(final String methodName, final int errorCode) { - super(methodName, errorCode); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/VppJNIConnection.java b/vpp-api/java/jvpp/org/openvpp/jvpp/VppJNIConnection.java deleted file mode 100644 index 7401bcadc47..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/VppJNIConnection.java +++ /dev/null @@ -1,143 +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; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.nio.file.attribute.PosixFilePermission; -import java.nio.file.attribute.PosixFilePermissions; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.logging.Logger; -import org.openvpp.jvpp.callback.JVppCallback; - -/** - * JNI based representation of a management connection to VPP - */ -public final class VppJNIConnection implements VppConnection { - private final static Logger LOG = Logger.getLogger(VppJNIConnection.class.getName()); - private static final String LIBNAME = "libjvpp.so.0.0.0"; - - static { - try { - loadLibrary(); - } catch (Exception e) { - LOG.severe("Can't find vpp jni library: " + LIBNAME); - throw new ExceptionInInitializerError(e); - } - } - - private static void loadStream(final InputStream is) throws IOException { - final Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---"); - final Path p = Files.createTempFile(LIBNAME, null, PosixFilePermissions.asFileAttribute(perms)); - try { - Files.copy(is, p, StandardCopyOption.REPLACE_EXISTING); - - try { - Runtime.getRuntime().load(p.toString()); - } catch (UnsatisfiedLinkError e) { - throw new IOException("Failed to load library " + p, e); - } - } finally { - try { - Files.deleteIfExists(p); - } catch (IOException e) { - } - } - } - - private static void loadLibrary() throws IOException { - try (final InputStream is = VppJNIConnection.class.getResourceAsStream('/' + LIBNAME)) { - if (is == null) { - throw new IOException("Failed to open library resource " + LIBNAME); - } - loadStream(is); - } - } - - private final String clientName; - private volatile boolean disconnected = false; - - /** - * Create VPPJNIConnection instance for client connecting to VPP. - * - * @param clientName client name instance to be used for communication. Single connection per clientName is allowed. - */ - public VppJNIConnection(final String clientName) { - this.clientName = Objects.requireNonNull(clientName,"Null clientName"); - } - - /** - * Guarded by VppJNIConnection.class - */ - private static final Map<String, VppJNIConnection> connections = new HashMap<>(); - - /** - * Initiate VPP connection for current instance - * - * Multiple instances are allowed since this class is not a singleton - * (VPP allows multiple management connections). - * - * However only a single connection per clientName is allowed. - * - * @param callback global callback to receive response calls from vpp - * - * @throws IOException in case the connection could not be established - */ - public void connect(final JVppCallback callback) throws IOException { - synchronized (VppJNIConnection.class) { - if(connections.containsKey(clientName)) { - throw new IOException("Client " + clientName + " already connected"); - } - - final int ret = clientConnect(clientName, callback); - if (ret != 0) { - throw new IOException("Connection returned error " + ret); - } - connections.put(clientName, this); - } - } - - @Override - public final void checkActive() { - if (disconnected) { - throw new IllegalStateException("Disconnected client " + clientName); - } - } - - @Override - public synchronized final void close() { - if (!disconnected) { - disconnected = true; - try { - clientDisconnect(); - } finally { - synchronized (VppJNIConnection.class) { - connections.remove(clientName); - } - } - } - } - - private static native int clientConnect(String clientName, JVppCallback callback); - private static native void clientDisconnect(); -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppCallback.java b/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppCallback.java deleted file mode 100644 index f681e379bfd..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppCallback.java +++ /dev/null @@ -1,29 +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.callback; -import org.openvpp.jvpp.VppCallbackException; - -/** - * Base JVppCallback interface - */ -public interface JVppCallback { - /** - * onError callback handler used to report failing operation - * @param ex VppCallbackException object containing details about failing operation - */ - void onError(VppCallbackException ex); -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppNotificationCallback.java b/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppNotificationCallback.java deleted file mode 100644 index 72a75c83942..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/callback/JVppNotificationCallback.java +++ /dev/null @@ -1,24 +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.callback; - -/** -* Notification callback -*/ -public interface JVppNotificationCallback { - -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppDump.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppDump.java deleted file mode 100644 index 295bbba8525..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppDump.java +++ /dev/null @@ -1,24 +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.dto; - -/** -* Base interface for all dump requests -*/ -public interface JVppDump extends JVppRequest { - -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppNotification.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppNotification.java deleted file mode 100644 index 7d0fecb7d78..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppNotification.java +++ /dev/null @@ -1,23 +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.dto; - -/** -* Base interface for all notification DTOs -*/ -public interface JVppNotification { -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReply.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReply.java deleted file mode 100644 index 2f4964c4de0..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReply.java +++ /dev/null @@ -1,24 +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.dto; - -/** -* Base interface for all reply DTOs -*/ -public interface JVppReply<REQ extends JVppRequest> { - -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java deleted file mode 100644 index 4aecedc19d4..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppReplyDump.java +++ /dev/null @@ -1,25 +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.dto; - -/** -* Base interface for all dump replies -*/ -public interface JVppReplyDump<REQ extends JVppRequest, RESP extends JVppReply<REQ>> - extends JVppReply<REQ> { - -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppRequest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppRequest.java deleted file mode 100644 index 273e444f601..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/dto/JVppRequest.java +++ /dev/null @@ -1,34 +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.dto; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.VppInvocationException; - -/** -* Base interface for all request DTOs -*/ -public interface JVppRequest { - - /** - * Invoke current operation asynchronously on VPP - * - * @return context id of this request. Can be used to track incomming response - */ - int send(JVpp jvpp) throws VppInvocationException; - -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppInvoker.java b/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppInvoker.java deleted file mode 100644 index 1683bd75139..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppInvoker.java +++ /dev/null @@ -1,39 +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.future; - - -import org.openvpp.jvpp.dto.JVppReply; -import org.openvpp.jvpp.dto.JVppRequest; - -import java.util.concurrent.CompletionStage; -import org.openvpp.jvpp.notification.NotificationRegistryProvider; - -/** -* Future facade on top of JVpp -*/ -public interface FutureJVppInvoker extends NotificationRegistryProvider, AutoCloseable { - - /** - * Invoke asynchronous operation on VPP - * - * @return CompletionStage with future result of an async VPP call - * @throws org.openvpp.jvpp.VppInvocationException when send request failed with details - */ - <REQ extends JVppRequest, REPLY extends JVppReply<REQ>> CompletionStage<REPLY> send(REQ req); - -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppInvokerFacade.java b/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppInvokerFacade.java deleted file mode 100644 index a60e1b285dd..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/future/FutureJVppInvokerFacade.java +++ /dev/null @@ -1,112 +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.future; - - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.VppInvocationException; -import org.openvpp.jvpp.dto.*; - -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; -import org.openvpp.jvpp.notification.NotificationRegistryProviderContext; - -/** -* Future facade on top of JVpp -*/ -public class FutureJVppInvokerFacade extends NotificationRegistryProviderContext implements FutureJVppInvoker { - - private final JVpp jvpp; - - /** - * Guarded by self - */ - private final Map<Integer, CompletableFuture<? extends JVppReply<?>>> requests; - - public FutureJVppInvokerFacade(final JVpp jvpp, - final Map<Integer, CompletableFuture<? extends JVppReply<?>>> requestMap) { - this.jvpp = Objects.requireNonNull(jvpp, "Null jvpp"); - // Request map represents the shared state between this facade and it's callback - // where facade puts futures in and callback completes + removes them - // TODO what if the call never completes ? - this.requests = Objects.requireNonNull(requestMap, "Null requestMap"); - } - - protected final Map<Integer, CompletableFuture<? extends JVppReply<?>>> getRequests() { - return this.requests; - } - - // TODO use Optional in Future, java8 - - @Override - @SuppressWarnings("unchecked") - public <REQ extends JVppRequest, REPLY extends JVppReply<REQ>> CompletionStage<REPLY> send(REQ req) { - synchronized(requests) { - try { - final CompletableFuture<REPLY> replyCompletableFuture; - final int contextId = jvpp.send(req); - - if(req instanceof JVppDump) { - replyCompletableFuture = (CompletableFuture<REPLY>) new CompletableDumpFuture<>(contextId); - } else { - replyCompletableFuture = new CompletableFuture<>(); - } - - requests.put(contextId, replyCompletableFuture); - if(req instanceof JVppDump) { - requests.put(jvpp.send(new ControlPing()), replyCompletableFuture); - } - return replyCompletableFuture; - } catch (VppInvocationException ex) { - final CompletableFuture<REPLY> replyCompletableFuture = new CompletableFuture<>(); - replyCompletableFuture.completeExceptionally(ex); - return replyCompletableFuture; - } - } - } - - static final class CompletableDumpFuture<T extends JVppReplyDump<?, ?>> extends CompletableFuture<T> { - // The reason why this is not final is the instantiation of ReplyDump DTOs - // Their instantiation must be generated, so currently the DTOs are created in callback and set when first dump reponses - // is handled in the callback. - private T replyDump; - private final long contextId; - - CompletableDumpFuture(final long contextId) { - this.contextId = contextId; - } - - long getContextId() { - return contextId; - } - - T getReplyDump() { - return replyDump; - } - - void setReplyDump(final T replyDump) { - this.replyDump = replyDump; - } - } - - @Override - public void close() throws Exception { - // NOOP - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/notification/NotificationRegistryProvider.java b/vpp-api/java/jvpp/org/openvpp/jvpp/notification/NotificationRegistryProvider.java deleted file mode 100644 index 50b72be5805..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/notification/NotificationRegistryProvider.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.openvpp.jvpp.notification; - -/** - * Provides notification registry - */ -public interface NotificationRegistryProvider { - - /** - * Get current notification registry instance - */ - NotificationRegistry getNotificationRegistry(); -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/notification/NotificationRegistryProviderContext.java b/vpp-api/java/jvpp/org/openvpp/jvpp/notification/NotificationRegistryProviderContext.java deleted file mode 100644 index 8e703812eee..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/notification/NotificationRegistryProviderContext.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.openvpp.jvpp.notification; - -/** - * Base class for notification aware JVpp facades - */ -public abstract class NotificationRegistryProviderContext implements NotificationRegistryProvider { - - private final NotificationRegistryImpl notificationRegistry = new NotificationRegistryImpl(); - - public final NotificationRegistry getNotificationRegistry() { - return notificationRegistry; - } - - /** - * Get instance of notification callback. Can be used to propagate notifications from JVpp facade - */ - protected final GlobalNotificationCallback getNotificationCallback() { - return notificationRegistry; - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackApiTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackApiTest.java deleted file mode 100644 index 8c976db2397..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackApiTest.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.test; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.callback.GetNodeIndexCallback; -import org.openvpp.jvpp.callback.ShowVersionCallback; -import org.openvpp.jvpp.callback.SwInterfaceCallback; -import org.openvpp.jvpp.dto.*; - -public class CallbackApiTest { - - private static class TestCallback implements GetNodeIndexCallback, ShowVersionCallback, SwInterfaceCallback { - - @Override - public void onGetNodeIndexReply(final GetNodeIndexReply msg) { - System.out.printf("Received GetNodeIndexReply: context=%d, nodeIndex=%d\n", - msg.context, msg.nodeIndex); - } - @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()); - } - } - - private static void testCallbackApi() throws Exception { - System.out.println("Testing Java callback API"); - JVpp jvpp = new JVppImpl(new VppJNIConnection("CallbackApiTest")); - jvpp.connect(new TestCallback()); - System.out.println("Successfully connected to VPP"); - - System.out.println("Sending ShowVersion request..."); - jvpp.send(new ShowVersion()); - - System.out.println("Sending GetNodeIndex request..."); - GetNodeIndex getNodeIndexRequest = new GetNodeIndex(); - getNodeIndexRequest.nodeName = "node0".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(5000); - - System.out.println("Disconnecting..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackApi(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeNotificationTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeNotificationTest.java deleted file mode 100644 index 430ce8812c2..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeNotificationTest.java +++ /dev/null @@ -1,87 +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.test; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.callback.WantInterfaceEventsCallback; -import org.openvpp.jvpp.callfacade.CallbackJVppFacade; -import org.openvpp.jvpp.dto.WantInterfaceEventsReply; - -public class CallbackJVppFacadeNotificationTest { - - private static void testCallbackFacade() throws Exception { - System.out.println("Testing CallbackJVppFacade for notifications"); - - JVpp jvpp = new JVppImpl(new VppJNIConnection("CallbackApiTest")); - - CallbackJVppFacade jvppCallbackFacade = new CallbackJVppFacade(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..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackFacade(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackJVppFacadeTest.java deleted file mode 100644 index bb06c761108..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/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.test; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.callback.GetNodeIndexCallback; -import org.openvpp.jvpp.callback.ShowVersionCallback; -import org.openvpp.jvpp.callfacade.CallbackJVppFacade; -import org.openvpp.jvpp.dto.GetNodeIndex; -import org.openvpp.jvpp.dto.GetNodeIndexReply; -import org.openvpp.jvpp.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; - private static ShowVersionCallback showVersionCallback2; - private static GetNodeIndexCallback getNodeIndexCallback; - - static { - getNodeIndexCallback = new GetNodeIndexCallback() { - @Override - public void onGetNodeIndexReply(final GetNodeIndexReply msg) { - System.out.printf("Received GetNodeIndexReply: context=%d, nodeIndex=%d\n", - msg.context, msg.nodeIndex); - } - - @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()); - } - }; - showVersionCallback2 = 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 showVersionCallback2: call=%s, reply=%d, context=%d\n", ex.getMethodName(), ex.getErrorCode(), ex.getCtxId()); - } - - }; - 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 void testCallbackFacade() throws Exception { - System.out.println("Testing CallbackJVppFacade"); - - JVpp jvpp = new JVppImpl(new VppJNIConnection("CallbackApiTest")); - - CallbackJVppFacade jvppCallbackFacade = new CallbackJVppFacade(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..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackFacade(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackNotificationApiTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackNotificationApiTest.java deleted file mode 100644 index 5bf2b212f73..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CallbackNotificationApiTest.java +++ /dev/null @@ -1,93 +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.test; - -import static org.openvpp.jvpp.test.NotificationUtils.getChangeInterfaceState; -import static org.openvpp.jvpp.test.NotificationUtils.getDisableInterfaceNotificationsReq; -import static org.openvpp.jvpp.test.NotificationUtils.getEnableInterfaceNotificationsReq; -import static org.openvpp.jvpp.test.NotificationUtils.printNotification; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.callback.SwInterfaceSetFlagsCallback; -import org.openvpp.jvpp.callback.SwInterfaceSetFlagsNotificationCallback; -import org.openvpp.jvpp.callback.WantInterfaceEventsCallback; -import org.openvpp.jvpp.dto.SwInterfaceSetFlagsNotification; -import org.openvpp.jvpp.dto.SwInterfaceSetFlagsReply; -import org.openvpp.jvpp.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"); - JVpp jvpp = new JVppImpl( new VppJNIConnection("CallbackApiTest")); - jvpp.connect( 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); - - // Notification is received - Thread.sleep(500); - - getDisableInterfaceNotificationsReq().send(jvpp); - System.out.println("Interface events stopped"); - - Thread.sleep(2000); - - System.out.println("Disconnecting..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackApi(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/ControlPingTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/ControlPingTest.java deleted file mode 100644 index 514bb3ef887..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/ControlPingTest.java +++ /dev/null @@ -1,61 +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.test; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.VppJNIConnection; -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"); - - JVpp jvpp = new JVppImpl( new VppJNIConnection("ControlPingTest")); - jvpp.connect( new ControlPingCallback() { - @Override - public void onControlPingReply(final ControlPingReply reply) { - System.out.printf("Received ControlPingReply: context=%d, clientIndex=%d vpePid=%d\n", - reply.context, reply.clientIndex, reply.vpePid); - } - - @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); - - jvpp.send(new ControlPing()); - - Thread.sleep(2000); - - System.out.println("Disconnecting..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testControlPing(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/CreateSubInterfaceTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/CreateSubInterfaceTest.java deleted file mode 100644 index b3dc1f49491..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/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.test; - -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.dto.CreateSubif; -import org.openvpp.jvpp.dto.CreateSubifReply; -import org.openvpp.jvpp.dto.SwInterfaceDetailsReplyDump; -import org.openvpp.jvpp.dto.SwInterfaceDump; -import org.openvpp.jvpp.future.FutureJVppFacade; - -import static java.util.Objects.requireNonNull; - -/** - * <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: context=%d, swIfIndex=%d\n", - reply.context, - reply.swIfIndex); - } - - private static void testCreateSubInterface() throws Exception { - System.out.println("Testing sub-interface creation using Java callback API"); - final JVppImpl jvpp = new JVppImpl(new VppJNIConnection("SubIfaceTest")); - final FutureJVppFacade jvppFacade = new FutureJVppFacade(jvpp); - - System.out.println("Successfully connected to VPP"); - Thread.sleep(1000); - - final String ifaceName = "GigabitEthernet0/9/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/9/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..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCreateSubInterface(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiNotificationTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiNotificationTest.java deleted file mode 100644 index c48f86d4f00..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiNotificationTest.java +++ /dev/null @@ -1,60 +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.test; - -import static org.openvpp.jvpp.test.NotificationUtils.getChangeInterfaceState; -import static org.openvpp.jvpp.test.NotificationUtils.getDisableInterfaceNotificationsReq; -import static org.openvpp.jvpp.test.NotificationUtils.getEnableInterfaceNotificationsReq; - -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.future.FutureJVppFacade; - -public class FutureApiNotificationTest { - - private static void testFutureApi() throws Exception { - System.out.println("Testing Java future API for notifications"); - - final org.openvpp.jvpp.JVppImpl impl = - new org.openvpp.jvpp.JVppImpl(new VppJNIConnection("FutureApiTest")); - final FutureJVppFacade jvppFacade = new FutureJVppFacade(impl); - 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..."); - // TODO we should consider adding jvpp.close(); to the facade - impl.close(); - } - - public static void main(String[] args) throws Exception { - testFutureApi(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiTest.java deleted file mode 100644 index 0000bcd907c..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/FutureApiTest.java +++ /dev/null @@ -1,116 +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.test; - -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.dto.*; -import org.openvpp.jvpp.future.FutureJVppFacade; - -import java.util.Objects; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -public class FutureApiTest { - - private static void testShowVersion(final FutureJVppFacade jvpp) { - System.out.println("Sending ShowVersion request..."); - try { - Objects.requireNonNull(jvpp,"jvpp is null"); - final Future<ShowVersionReply> replyFuture = jvpp.showVersion(new ShowVersion()).toCompletableFuture(); - Objects.requireNonNull(replyFuture,"replyFuture is null"); - final ShowVersionReply reply = replyFuture.get(); - Objects.requireNonNull(reply,"reply is null"); - System.out.printf("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)); - } catch (Exception e) { - System.err.printf("ShowVersion request failed:"+e.getCause()); - e.printStackTrace(); - } - } - - /** - * This test will fail with some error code if node 'node0' is not defined. - * TODO: consider adding error messages specific for given api calls - */ - private static void testGetNodeIndex(final FutureJVppFacade jvpp) { - System.out.println("Sending GetNodeIndex request..."); - try { - Objects.requireNonNull(jvpp,"jvpp is null"); - final GetNodeIndex request = new GetNodeIndex(); - request.nodeName = "node0".getBytes(); - final Future<GetNodeIndexReply> replyFuture = jvpp.getNodeIndex(request).toCompletableFuture(); - Objects.requireNonNull(replyFuture,"replyFuture is null"); - final GetNodeIndexReply reply = replyFuture.get(); - Objects.requireNonNull(reply,"reply is null"); - System.out.printf("Received GetNodeIndexReply: context=%d, nodeIndex=%d\n", - reply.context, reply.nodeIndex); - } catch (ExecutionException e) { - System.err.printf("GetNodeIndex request failed:"+e.getCause()); - } catch (Exception e) { - System.err.printf("GetNodeIndex request failed:"+e.getCause()); - e.printStackTrace(); - } - } - - private static void testSwInterfaceDump(final FutureJVppFacade jvpp) { - System.out.println("Sending SwInterfaceDump request..."); - try { - Objects.requireNonNull(jvpp,"SwInterfaceDetailsReplyDump is null!"); - final SwInterfaceDump request = new SwInterfaceDump(); - request.nameFilterValid = 0; - request.nameFilter = "".getBytes(); - final Future<SwInterfaceDetailsReplyDump> replyFuture = jvpp.swInterfaceDump(request).toCompletableFuture(); - Objects.requireNonNull(replyFuture,"replyFuture is null"); - final SwInterfaceDetailsReplyDump reply = replyFuture.get(); - Objects.requireNonNull(reply.swInterfaceDetails, "SwInterfaceDetailsReplyDump.swInterfaceDetails is null!"); - for (SwInterfaceDetails details : reply.swInterfaceDetails) { - Objects.requireNonNull(details, "reply.swInterfaceDetails contains null element!"); - System.out.printf("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); - } - } catch(NullPointerException e) { - throw new IllegalStateException(e.getMessage()); - } catch (Exception e) { - System.err.printf("SwInterfaceDump request failed:"+e.getCause()); - e.printStackTrace(); - } - } - - private static void testFutureApi() throws Exception { - System.out.println("Testing Java future API"); - - final org.openvpp.jvpp.JVppImpl impl = - new org.openvpp.jvpp.JVppImpl(new VppJNIConnection("FutureApiTest")); - final FutureJVppFacade jvppFacade = new FutureJVppFacade(impl); - System.out.println("Successfully connected to VPP"); - testShowVersion(jvppFacade); - testGetNodeIndex(jvppFacade); - testSwInterfaceDump(jvppFacade); - - System.out.println("Disconnecting..."); - // TODO we should consider adding jvpp.close(); to the facade - impl.close(); - } - - public static void main(String[] args) throws Exception { - testFutureApi(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/L2AclTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/L2AclTest.java deleted file mode 100644 index 802df631162..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/L2AclTest.java +++ /dev/null @@ -1,218 +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.test; - -import java.util.Arrays; -import javax.xml.bind.DatatypeConverter; -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.dto.ClassifyAddDelSession; -import org.openvpp.jvpp.dto.ClassifyAddDelSessionReply; -import org.openvpp.jvpp.dto.ClassifyAddDelTable; -import org.openvpp.jvpp.dto.ClassifyAddDelTableReply; -import org.openvpp.jvpp.dto.ClassifySessionDetails; -import org.openvpp.jvpp.dto.ClassifySessionDetailsReplyDump; -import org.openvpp.jvpp.dto.ClassifySessionDump; -import org.openvpp.jvpp.dto.ClassifyTableByInterface; -import org.openvpp.jvpp.dto.ClassifyTableByInterfaceReply; -import org.openvpp.jvpp.dto.ClassifyTableIds; -import org.openvpp.jvpp.dto.ClassifyTableIdsReply; -import org.openvpp.jvpp.dto.ClassifyTableInfo; -import org.openvpp.jvpp.dto.ClassifyTableInfoReply; -import org.openvpp.jvpp.dto.InputAclSetInterface; -import org.openvpp.jvpp.dto.InputAclSetInterfaceReply; -import org.openvpp.jvpp.future.FutureJVppFacade; - -/** - * <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: context=%d, " + - "newTableIndex=%d, skipNVectors=%d, matchNVectors=%d\n", - reply.context, reply.newTableIndex, reply.skipNVectors, reply.matchNVectors); - } - - private static void print(ClassifyTableIdsReply reply) { - System.out.printf("ClassifyTableIdsReply: context=%d, count=%d, ids.length=%d\n", - reply.context, reply.count, reply.ids.length); - Arrays.stream(reply.ids).forEach(System.out::println); - } - - private static void print(final ClassifyTableInfoReply reply) { - final StringBuilder builder = new StringBuilder("ClassifyTableInfoReply:\n"); - builder.append("context: ").append(reply.context).append('\n'); - builder.append("tableId: ").append(reply.tableId).append('\n'); - builder.append("nbuckets: ").append(reply.nbuckets).append('\n'); - builder.append("matchNVectors: ").append(reply.matchNVectors).append('\n'); - builder.append("skipNVectors: ").append(reply.skipNVectors).append('\n'); - builder.append("activeSessions: ").append(reply.activeSessions).append('\n'); - builder.append("nextTableIndex: ").append(reply.nextTableIndex).append('\n'); - builder.append("missNextIndex: ").append(reply.missNextIndex).append('\n'); - builder.append("maskLength: ").append(reply.maskLength).append('\n'); - builder.append("mask: ").append(DatatypeConverter.printHexBinary(reply.mask)).append('\n'); - System.out.println(builder.toString()); - } - - private static void print(ClassifyAddDelSessionReply reply) { - System.out.printf("ClassifyAddDelSessionReply: context=%d\n", - reply.context); - } - - private static void print(final ClassifySessionDetailsReplyDump reply) { - if (reply.classifySessionDetails == null) { - System.out.println("ClassifySessionDetailsReplyDump: classifySessionDetails == NULL"); - } - for (final ClassifySessionDetails details : reply.classifySessionDetails) { - final StringBuilder builder = new StringBuilder("ClassifySessionDetails:\n"); - builder.append("context: ").append(details.context).append('\n'); - builder.append("tableId: ").append(details.tableId).append('\n'); - builder.append("hitNextIndex: ").append(details.hitNextIndex).append('\n'); - builder.append("advance: ").append(details.advance).append('\n'); - builder.append("opaqueIndex: ").append(details.opaqueIndex).append('\n'); - builder.append("matchLength: ").append(details.matchLength).append('\n'); - builder.append("match: ").append(DatatypeConverter.printHexBinary(details.match)).append('\n'); - System.out.println(builder.toString()); - } - } - - private static void print(final InputAclSetInterfaceReply reply) { - System.out.printf("InputAclSetInterfaceReply: context=%d\n", reply.context); - } - - private static void print(final ClassifyTableByInterfaceReply reply) { - System.out.printf("ClassifyAddDelTableReply: context=%d, swIfIndex=%d, l2TableId=%d, ip4TableId=%d," + - "ip6TableId=%d\n", reply.context, reply.swIfIndex, reply.l2TableId, reply.ip4TableId, reply.ip6TableId); - } - - private static void testL2Acl() throws Exception { - System.out.println("Testing L2 ACLs using Java callback API"); - final JVppImpl jvpp = new JVppImpl(new VppJNIConnection("L2AclTest")); - final FutureJVppFacade jvppFacade = new FutureJVppFacade(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..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testL2Acl(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/NotificationUtils.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/NotificationUtils.java deleted file mode 100644 index 9c24d572cbc..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/NotificationUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.openvpp.jvpp.test; - -import java.io.PrintStream; -import org.openvpp.jvpp.dto.SwInterfaceSetFlags; -import org.openvpp.jvpp.dto.SwInterfaceSetFlagsNotification; -import org.openvpp.jvpp.dto.WantInterfaceEvents; - -final class NotificationUtils { - - private NotificationUtils() {} - - static PrintStream printNotification(final SwInterfaceSetFlagsNotification msg) { - return System.out.printf("Received interface notification: ifc: %d, admin: %d, link: %d, deleted: %d\n", - msg.swIfIndex, msg.adminUpDown, msg.linkUpDown, msg.deleted); - } - - 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/org/openvpp/jvpp/test/OnErrorCallbackTest.java b/vpp-api/java/jvpp/org/openvpp/jvpp/test/OnErrorCallbackTest.java deleted file mode 100644 index 46d8558338f..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/OnErrorCallbackTest.java +++ /dev/null @@ -1,74 +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.test; - -import org.openvpp.jvpp.JVpp; -import org.openvpp.jvpp.JVppImpl; -import org.openvpp.jvpp.VppCallbackException; -import org.openvpp.jvpp.VppJNIConnection; -import org.openvpp.jvpp.callback.GetNodeIndexCallback; -import org.openvpp.jvpp.callback.ShowVersionCallback; -import org.openvpp.jvpp.dto.*; - -public class OnErrorCallbackTest { - - private static class TestCallback implements GetNodeIndexCallback, ShowVersionCallback{ - - @Override - public void onGetNodeIndexReply(final GetNodeIndexReply msg) { - System.out.printf("Received GetNodeIndexReply: context=%d, nodeIndex=%d\n", - msg.context, msg.nodeIndex); - } - @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 onError(VppCallbackException ex) { - System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n", ex.getMethodName(), ex.getCtxId(), ex.getErrorCode()); - } - } - - private static void testCallbackApi() throws Exception { - System.out.println("Testing Java callback API"); - JVpp jvpp = new JVppImpl(new VppJNIConnection("CallbackApiTest")); - jvpp.connect(new TestCallback()); - System.out.println("Successfully connected to VPP"); - - System.out.println("Sending ShowVersion request..."); - jvpp.send(new ShowVersion()); - - System.out.println("Sending GetNodeIndex request..."); - GetNodeIndex getNodeIndexRequest = new GetNodeIndex(); - getNodeIndexRequest.nodeName = "dummyNode".getBytes(); - jvpp.send(getNodeIndexRequest); - - Thread.sleep(5000); - - System.out.println("Disconnecting..."); - jvpp.close(); - Thread.sleep(1000); - } - - public static void main(String[] args) throws Exception { - testCallbackApi(); - } -} diff --git a/vpp-api/java/jvpp/org/openvpp/jvpp/test/Readme.txt b/vpp-api/java/jvpp/org/openvpp/jvpp/test/Readme.txt deleted file mode 100644 index e0aa4f4d085..00000000000 --- a/vpp-api/java/jvpp/org/openvpp/jvpp/test/Readme.txt +++ /dev/null @@ -1,17 +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-native/vpp-api/java/jvpp-16.09.jar org.openvpp.jvpp.test.[test name] - -Available tests: -ControlPingTest - Simple test executing a single control ping using low level JVpp APIs -CallbackApiTest - Similar to ControlPingTest, invokes more complex calls (e.g. interface dump) using low level JVpp APIs -CallbackNotificationApiTest - Tests interface notifications using low level JVpp APIs -FutureApiTest - Execution of more complex calls using Future based JVpp facade -FutureApiNotificationTest - Tests interface notifications using Future based JVpp facade -CallbackJVppFacadeTest - Execution of more complex calls using Callback based JVpp facade -CallbackJVppFacadeNotificationTest - Tests interface notifications using Callback based JVpp facade -L2AclTest - Tests L2 ACL creation -CreateSubInterfaceTest - Tests sub-interface creation -OnErrorCallbackTest - simple test failing with onError |