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.ioampot.test;
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;
28 public class IoamPotApiTest {
30 static class IoamPotTestCallback implements PotProfileAddCallback {
33 public void onPotProfileAddReply(final PotProfileAddReply reply) {
34 System.out.printf("Received PotProfileAddReply reply: context=%d%n",
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());
45 public static void main(String[] args) throws Exception {
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());
55 System.out.println("Sending ioam pot profile add request...");
56 PotProfileAdd request = new PotProfileAdd();
58 request.validator = 4;
59 request.secretKey = 1;
60 request.secretShare = 2;
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);
72 System.out.println("Disconnecting...");