2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.vpp.jvpp.ioamexport.test;
20 import io.fd.vpp.jvpp.Assertions;
21 import io.fd.vpp.jvpp.JVppRegistry;
22 import io.fd.vpp.jvpp.JVppRegistryImpl;
23 import io.fd.vpp.jvpp.ioamexport.JVppIoamexportImpl;
24 import io.fd.vpp.jvpp.ioamexport.dto.IoamExportIp6EnableDisable;
25 import io.fd.vpp.jvpp.ioamexport.dto.IoamExportIp6EnableDisableReply;
26 import io.fd.vpp.jvpp.ioamexport.future.FutureJVppIoamexportFacade;
28 import java.util.concurrent.Future;
29 import java.util.logging.Logger;
31 public class FutureApiTest {
33 private static final Logger LOG = Logger.getLogger(FutureApiTest.class.getName());
35 public static void main(String[] args) throws Exception {
36 testCallbackApi(args);
39 private static void testCallbackApi(String[] args) throws Exception {
40 LOG.info("Testing Java callback API for ioamexport plugin");
41 try (final JVppRegistry registry = new JVppRegistryImpl("FutureApiTest", args[0]);
42 final FutureJVppIoamexportFacade jvpp = new FutureJVppIoamexportFacade(registry, new JVppIoamexportImpl())) {
43 LOG.info("Successfully connected to VPP");
45 testIoamExportIp6EnableDisable(jvpp);
47 LOG.info("Disconnecting...");
51 private static void testIoamExportIp6EnableDisable(FutureJVppIoamexportFacade jvpp) throws Exception {
52 LOG.info("Sending IoamExportIp6EnableDisable request...");
53 final IoamExportIp6EnableDisable request = new IoamExportIp6EnableDisable();
55 final Future<IoamExportIp6EnableDisableReply> replyFuture = jvpp.ioamExportIp6EnableDisable(request).toCompletableFuture();
56 final IoamExportIp6EnableDisableReply reply = replyFuture.get();
58 Assertions.assertNotNull(reply);