Repair Doxygen build infrastructure
[vpp.git] / src / vpp-api / java / jvpp-ioampot / io / fd / vpp / jvpp / ioampot / test / IoamPotApiTest.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.ioampot.test;
18
19 import io.fd.vpp.jvpp.JVpp;
20 import io.fd.vpp.jvpp.JVppRegistry;
21 import io.fd.vpp.jvpp.JVppRegistryImpl;
22 import io.fd.vpp.jvpp.VppCallbackException;
23 import io.fd.vpp.jvpp.ioampot.JVppIoampotImpl;
24 import io.fd.vpp.jvpp.ioampot.callback.PotProfileAddCallback;
25 import io.fd.vpp.jvpp.ioampot.dto.PotProfileAdd;
26 import io.fd.vpp.jvpp.ioampot.dto.PotProfileAddReply;
27
28 public class IoamPotApiTest {
29
30     static class IoamPotTestCallback implements PotProfileAddCallback {
31
32         @Override
33         public void onPotProfileAddReply(final PotProfileAddReply reply) {
34             System.out.printf("Received PotProfileAddReply reply: context=%d%n",
35                 reply.context);
36         }
37
38         @Override
39         public void onError(VppCallbackException ex) {
40             System.out.printf("Received onError exception: call=%s, context=%d, retval=%d%n", ex.getMethodName(),
41                 ex.getCtxId(), ex.getErrorCode());
42         }
43     }
44
45     public static void main(String[] args) throws Exception {
46         ioamPotTestApi();
47     }
48
49     private static void ioamPotTestApi() throws Exception {
50         System.out.println("Testing Java API for ioam pot plugin");
51         try (final JVppRegistry registry = new JVppRegistryImpl("ioamPotApiTest");
52              final JVpp jvpp = new JVppIoampotImpl()) {
53             registry.register(jvpp, new IoamPotTestCallback());
54
55             System.out.println("Sending ioam pot profile add request...");
56             PotProfileAdd request = new PotProfileAdd();
57             request.id = 0;
58             request.validator = 4;
59             request.secretKey = 1;
60             request.secretShare = 2;
61             request.prime = 1234;
62             request.maxBits = 53;
63             request.lpc = 1234;
64             request.polynomialPublic = 1234;
65             request.listNameLen = (byte)"test pot profile".getBytes().length;
66             request.listName = "test pot profile".getBytes();
67             final int result = jvpp.send(request);
68             System.out.printf("PotProfileAdd send result = %d%n", result);
69
70             Thread.sleep(1000);
71
72             System.out.println("Disconnecting...");
73         }
74     }
75 }