048d244590e2b1a83649be859a35f032116bd25d
[vpp.git] / src / vpp-api / java / jvpp-ioamexport / io / fd / vpp / jvpp / ioamexport / test / FutureApiTest.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package io.fd.vpp.jvpp.ioamexport.test;
18
19
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;
27
28 import java.util.concurrent.Future;
29 import java.util.logging.Logger;
30
31 public class FutureApiTest {
32
33     private static final Logger LOG = Logger.getLogger(FutureApiTest.class.getName());
34
35     public static void main(String[] args) throws Exception {
36         testCallbackApi(args);
37     }
38
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");
44
45             testIoamExportIp6EnableDisable(jvpp);
46
47             LOG.info("Disconnecting...");
48         }
49     }
50
51     private static void testIoamExportIp6EnableDisable(FutureJVppIoamexportFacade jvpp) throws Exception {
52         LOG.info("Sending IoamExportIp6EnableDisable request...");
53         final IoamExportIp6EnableDisable request = new IoamExportIp6EnableDisable();
54
55         final Future<IoamExportIp6EnableDisableReply> replyFuture = jvpp.ioamExportIp6EnableDisable(request).toCompletableFuture();
56         final IoamExportIp6EnableDisableReply reply = replyFuture.get();
57
58         Assertions.assertNotNull(reply);
59     }
60 }