cb85f005ff50925c8d49fa7d94c319b613f0d714
[vpp.git] / plugins / ioam-plugin / ioam / jvpp / io / fd / vpp / jvpp / ioamexport / test / IoamExportApiTest.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 import java.net.InetAddress;
20
21 import io.fd.vpp.jvpp.JVpp;
22 import io.fd.vpp.jvpp.JVppRegistry;
23 import io.fd.vpp.jvpp.JVppRegistryImpl;
24 import io.fd.vpp.jvpp.VppCallbackException;
25 import io.fd.vpp.jvpp.ioamexport.JVppIoamexportImpl;
26 import io.fd.vpp.jvpp.ioamexport.future.FutureJVppIoamexportFacade;
27 import io.fd.vpp.jvpp.ioamexport.dto.IoamExportIp6EnableDisable;
28 import io.fd.vpp.jvpp.ioamexport.dto.IoamExportIp6EnableDisableReply;
29
30 public class IoamExportApiTest {
31
32     public static void main(String[] args) throws Exception {
33         ioamExportTestApi();
34     }
35
36     private static void ioamExportTestApi() throws Exception {
37         System.out.println("Testing Java API for ioam export plugin");
38         try (final JVppRegistry registry = new JVppRegistryImpl("ioamExportApiTest");
39              final JVpp jvpp = new JVppIoamexportImpl()) {
40             FutureJVppIoamexportFacade ioamexportJvpp = new FutureJVppIoamexportFacade(registry,jvpp);
41             System.out.println("Sending ioam export request...");
42             IoamExportIp6EnableDisable request = new IoamExportIp6EnableDisable();
43             request.isDisable = 0;
44             InetAddress collectorAddress = InetAddress.getByName("2001:0DB8:AC10:FE01:0000:0000:0000:0000");
45             InetAddress srcAddress = InetAddress.getByName("2001:0DB8:AC10:FE01:0000:0000:0000:0001");
46             request.collectorAddress = collectorAddress.getAddress();
47             request.srcAddress = srcAddress.getAddress();
48             IoamExportIp6EnableDisableReply reply = ioamexportJvpp.ioamExportIp6EnableDisable(request).toCompletableFuture().get();
49             System.out.printf("IoamExportIp6EnableDisableReply = "+reply.toString()+"%n");
50
51             Thread.sleep(1000);
52
53             System.out.println("Disconnecting...");
54         }
55     }
56 }