Move java api to extras/
[vpp.git] / extras / japi / java / jvpp-ioamtrace / io / fd / vpp / jvpp / ioamtrace / 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.ioamtrace.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.ioamtrace.JVppIoamtraceImpl;
24 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileShowConfig;
25 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileShowConfigReply;
26 import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
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(io.fd.vpp.jvpp.ioamtrace.test.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 ioamtrace plugin");
41         try (final JVppRegistry registry = new JVppRegistryImpl("FutureApiTest", args[0]);
42              final FutureJVppIoamtraceFacade jvpp = new FutureJVppIoamtraceFacade(registry, new JVppIoamtraceImpl())) {
43             LOG.info("Successfully connected to VPP");
44
45             testTraceProfileShowConfig(jvpp);
46
47             LOG.info("Disconnecting...");
48         }
49     }
50
51     private static void testTraceProfileShowConfig(FutureJVppIoamtraceFacade jvpp) throws Exception {
52         LOG.info("Sending TraceProfileShowConfig request...");
53         final TraceProfileShowConfig request = new TraceProfileShowConfig();
54
55         final Future<TraceProfileShowConfigReply> replyFuture = jvpp.traceProfileShowConfig(request).toCompletableFuture();
56         final TraceProfileShowConfigReply reply = replyFuture.get();
57
58         Assertions.assertNotNull(reply);
59     }
60 }