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.JVppIoamtraceImpl;
24 import io.fd.vpp.jvpp.ioamtrace.callback.TraceProfileAddCallback;
25 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAdd;
26 import io.fd.vpp.jvpp.ioamtrace.dto.TraceProfileAddReply;
28 public class ioamTraceApiTest {
31 static class ioamTraceTestCallback implements TraceProfileAddCallback {
34 public void onTraceProfileAddReply(final TraceProfileAddReply reply) {
35 System.out.printf("Received TraceProfileAddReply reply: context=%d%n",
40 public void onError(VppCallbackException ex) {
41 System.out.printf("Received onError exception: call=%s, context=%d, retval=%d%n", ex.getMethodName(),
42 ex.getCtxId(), ex.getErrorCode());
46 public static void main(String[] args) throws Exception {
50 private static void ioamTraceTestApi() throws Exception {
52 System.out.println("Testing Java API for ioam trace plugin");
53 final JVppRegistry registry = new JVppRegistryImpl("ioamTraceApiTest");
54 final JVpp jvpp = new JVppIoamtraceImpl();
56 registry.register(jvpp, new ioamTraceTestCallback());
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);
71 System.out.println("Disconnecting...");