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.ioamtrace.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.ioamtrace.future.FutureJVppIoamtraceFacade;
24 import io.fd.vpp.jvpp.ioamtrace.JVppIoamtraceImpl;
25 import io.fd.vpp.jvpp.ioamtrace.callback.TraceProfileAddCallback;
26 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAdd;
27 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAddReply;
28 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileShowConfig;
29 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileShowConfigReply;
31 public class IoamTraceApiTest {
33 static class IoamTraceTestCallback implements TraceProfileAddCallback {
36 public void onTraceProfileAddReply(final TraceProfileAddReply reply) {
37 System.out.printf("Received TraceProfileAddReply reply: context=%d%n",
42 public void onError(VppCallbackException ex) {
43 System.out.printf("Received onError exception: call=%s, context=%d, retval=%d%n", ex.getMethodName(),
44 ex.getCtxId(), ex.getErrorCode());
48 public static void main(String[] args) throws Exception {
52 private static void ioamTraceTestApi() throws Exception {
53 System.out.println("Testing Java API for ioam trace plugin");
54 try (final JVppRegistry registry = new JVppRegistryImpl("ioamTraceApiTest");
55 final JVpp jvpp = new JVppIoamtraceImpl()) {
56 FutureJVppIoamtraceFacade ioamtraceJvpp = new FutureJVppIoamtraceFacade(registry,jvpp);
58 System.out.println("Sending ioam trace profile add request...");
59 TraceProfileAdd request = new TraceProfileAdd();
60 request.traceType = 0x1f;
64 request.appData = 1234;
65 final int result = jvpp.send(request);
66 System.out.printf("TraceProfileAdd send result = %d%n", result);
70 TraceProfileShowConfig showRequest = new TraceProfileShowConfig();
71 TraceProfileShowConfigReply reply = ioamtraceJvpp.traceProfileShowConfig(showRequest).toCompletableFuture().get();
72 System.out.printf("TraceProfileShowConfig result = "+ reply.toString());
74 System.out.println("Disconnecting...");