VPP-413 DTOs generated by JVpp improvements:

- hashCode & equals
- toString

Change-Id: I5f8bc8868c216862a307dcc8f6b423f0ce29e7b5
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
This commit is contained in:
Maros Marsalek
2016-09-16 16:17:58 +02:00
committed by Damjan Marion
parent e83b7d5d01
commit a53b0e2909
12 changed files with 273 additions and 143 deletions

View File

@ -37,30 +37,29 @@ public class CallbackApiTest {
@Override
public void onGetNodeIndexReply(final GetNodeIndexReply msg) {
System.out.printf("Received GetNodeIndexReply: context=%d, nodeIndex=%d\n",
msg.context, msg.nodeIndex);
System.out.printf("Received GetNodeIndexReply: %s\n", msg);
}
@Override
public void onShowVersionReply(final ShowVersionReply msg) {
System.out.printf("Received ShowVersionReply: context=%d, program=%s, version=%s, "
+ "buildDate=%s, buildDirectory=%s\n",
msg.context, new String(msg.program), new String(msg.version),
new String(msg.buildDate), new String(msg.buildDirectory));
+ "buildDate=%s, buildDirectory=%s\n",
msg.context, new String(msg.program), new String(msg.version),
new String(msg.buildDate), new String(msg.buildDirectory));
}
@Override
public void onSwInterfaceDetails(final SwInterfaceDetails msg) {
System.out.printf("Received SwInterfaceDetails: interfaceName=%s, l2AddressLength=%d, adminUpDown=%d, "
+ "linkUpDown=%d, linkSpeed=%d, linkMtu=%d\n",
new String(msg.interfaceName), msg.l2AddressLength, msg.adminUpDown,
msg.linkUpDown, msg.linkSpeed, (int) msg.linkMtu);
+ "linkUpDown=%d, linkSpeed=%d, linkMtu=%d\n",
new String(msg.interfaceName), msg.l2AddressLength, msg.adminUpDown,
msg.linkUpDown, msg.linkSpeed, (int) msg.linkMtu);
}
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n", ex.getMethodName(),
ex.getCtxId(), ex.getErrorCode());
ex.getCtxId(), ex.getErrorCode());
}
}

View File

@ -37,23 +37,23 @@ public class CallbackJVppFacadeNotificationTest {
System.out.println("Successfully connected to VPP");
final AutoCloseable notificationListenerReg =
jvppCallbackFacade.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback(
NotificationUtils::printNotification
);
jvppCallbackFacade.getNotificationRegistry().registerSwInterfaceSetFlagsNotificationCallback(
NotificationUtils::printNotification
);
jvppCallbackFacade.wantInterfaceEvents(NotificationUtils.getEnableInterfaceNotificationsReq(),
new WantInterfaceEventsCallback() {
@Override
public void onWantInterfaceEventsReply(final WantInterfaceEventsReply reply) {
System.out.println("Interface events started");
}
new WantInterfaceEventsCallback() {
@Override
public void onWantInterfaceEventsReply(final WantInterfaceEventsReply reply) {
System.out.println("Interface events started");
}
@Override
public void onError(final VppCallbackException ex) {
System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n",
ex.getMethodName(), ex.getCtxId(), ex.getErrorCode());
}
});
@Override
public void onError(final VppCallbackException ex) {
System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n",
ex.getMethodName(), ex.getCtxId(), ex.getErrorCode());
}
});
System.out.println("Changing interface configuration");
NotificationUtils.getChangeInterfaceState().send(jvpp);
@ -61,18 +61,18 @@ public class CallbackJVppFacadeNotificationTest {
Thread.sleep(1000);
jvppCallbackFacade.wantInterfaceEvents(NotificationUtils.getDisableInterfaceNotificationsReq(),
new WantInterfaceEventsCallback() {
@Override
public void onWantInterfaceEventsReply(final WantInterfaceEventsReply reply) {
System.out.println("Interface events stopped");
}
new WantInterfaceEventsCallback() {
@Override
public void onWantInterfaceEventsReply(final WantInterfaceEventsReply reply) {
System.out.println("Interface events stopped");
}
@Override
public void onError(final VppCallbackException ex) {
System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n",
ex.getMethodName(), ex.getCtxId(), ex.getErrorCode());
}
});
@Override
public void onError(final VppCallbackException ex) {
System.out.printf("Received onError exception: call=%s, context=%d, retval=%d\n",
ex.getMethodName(), ex.getCtxId(), ex.getErrorCode());
}
});
notificationListenerReg.close();

View File

@ -38,14 +38,14 @@ public class CallbackJVppFacadeTest {
@Override
public void onShowVersionReply(final ShowVersionReply msg) {
System.out.printf("ShowVersionCallback1 received ShowVersionReply: context=%d, program=%s,"
+ "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, new String(msg.program),
new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory));
+ "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, new String(msg.program),
new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory));
}
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception in showVersionCallback1: call=%s, reply=%d, context=%d\n",
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
}
};
@ -53,14 +53,14 @@ public class CallbackJVppFacadeTest {
@Override
public void onShowVersionReply(final ShowVersionReply msg) {
System.out.printf("ShowVersionCallback2 received ShowVersionReply: context=%d, program=%s,"
+ "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, new String(msg.program),
new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory));
+ "version=%s, buildDate=%s, buildDirectory=%s\n", msg.context, new String(msg.program),
new String(msg.version), new String(msg.buildDate), new String(msg.buildDirectory));
}
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception in showVersionCallback2: call=%s, reply=%d, context=%d\n",
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
}
};
@ -68,14 +68,13 @@ public class CallbackJVppFacadeTest {
private static GetNodeIndexCallback getNodeIndexCallback = new GetNodeIndexCallback() {
@Override
public void onGetNodeIndexReply(final GetNodeIndexReply msg) {
System.out.printf("Received GetNodeIndexReply: context=%d, nodeIndex=%d\n",
msg.context, msg.nodeIndex);
System.out.printf("Received GetNodeIndexReply: %s\n", msg);
}
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception in getNodeIndexCallback: call=%s, reply=%d, context=%d\n",
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
}
};

View File

@ -36,11 +36,11 @@ import org.openvpp.jvpp.core.dto.WantInterfaceEventsReply;
public class CallbackNotificationApiTest {
private static class TestCallback implements SwInterfaceSetFlagsNotificationCallback,
WantInterfaceEventsCallback, SwInterfaceSetFlagsCallback {
WantInterfaceEventsCallback, SwInterfaceSetFlagsCallback {
@Override
public void onSwInterfaceSetFlagsNotification(
final SwInterfaceSetFlagsNotification msg) {
final SwInterfaceSetFlagsNotification msg) {
printNotification(msg);
}
@ -57,7 +57,7 @@ public class CallbackNotificationApiTest {
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception in getNodeIndexCallback: call=%s, reply=%d, context=%d\n",
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
ex.getMethodName(), ex.getErrorCode(), ex.getCtxId());
}
}

View File

@ -35,14 +35,13 @@ public class ControlPingTest {
registry.register(jvpp, new ControlPingCallback() {
@Override
public void onControlPingReply(final ControlPingReply reply) {
System.out.printf("Received ControlPingReply: context=%d, clientIndex=%d vpePid=%d\n",
reply.context, reply.clientIndex, reply.vpePid);
System.out.printf("Received ControlPingReply: %s\n", reply);
}
@Override
public void onError(VppCallbackException ex) {
System.out.printf("Received onError exception: call=%s, reply=%d, context=%d ", ex.getMethodName(),
ex.getErrorCode(), ex.getCtxId());
ex.getErrorCode(), ex.getCtxId());
}
});

View File

@ -54,8 +54,8 @@ public class CreateSubInterfaceTest {
private static void requireSingleIface(final SwInterfaceDetailsReplyDump response, final String ifaceName) {
if (response.swInterfaceDetails.size() != 1) {
throw new IllegalStateException(
String.format("Expected one interface matching filter %s but was %d", ifaceName,
response.swInterfaceDetails.size()));
String.format("Expected one interface matching filter %s but was %d", ifaceName,
response.swInterfaceDetails.size()));
}
}
@ -77,7 +77,7 @@ public class CreateSubInterfaceTest {
}
private static void print(CreateSubifReply reply) {
System.out.printf("CreateSubifReply: context=%d, swIfIndex=%d\n", reply.context, reply.swIfIndex);
System.out.printf("CreateSubifReply: %s\n", reply);
}
private static void testCreateSubInterface() throws Exception {
@ -92,7 +92,7 @@ public class CreateSubInterfaceTest {
final String ifaceName = "GigabitEthernet0/8/0";
final SwInterfaceDetailsReplyDump swInterfaceDetails =
jvppFacade.swInterfaceDump(createSwInterfaceDumpRequest(ifaceName)).toCompletableFuture().get();
jvppFacade.swInterfaceDump(createSwInterfaceDumpRequest(ifaceName)).toCompletableFuture().get();
requireNonNull(swInterfaceDetails, "swInterfaceDump returned null");
requireNonNull(swInterfaceDetails.swInterfaceDetails, "swInterfaceDetails is null");
@ -102,12 +102,12 @@ public class CreateSubInterfaceTest {
final int subId = 1;
final CreateSubifReply createSubifReply =
jvppFacade.createSubif(createSubifRequest(swIfIndex, subId)).toCompletableFuture().get();
jvppFacade.createSubif(createSubifRequest(swIfIndex, subId)).toCompletableFuture().get();
print(createSubifReply);
final String subIfaceName = "GigabitEthernet0/8/0." + subId;
final SwInterfaceDetailsReplyDump subIface =
jvppFacade.swInterfaceDump(createSwInterfaceDumpRequest(subIfaceName)).toCompletableFuture().get();
jvppFacade.swInterfaceDump(createSwInterfaceDumpRequest(subIfaceName)).toCompletableFuture().get();
requireNonNull(swInterfaceDetails, "swInterfaceDump returned null");
requireNonNull(subIface.swInterfaceDetails, "swInterfaceDump returned null");
requireSingleIface(swInterfaceDetails, ifaceName);

View File

@ -38,8 +38,8 @@ public class FutureApiNotificationTest {
System.out.println("Successfully connected to VPP");
final AutoCloseable notificationListenerReg =
jvppFacade.getNotificationRegistry()
.registerSwInterfaceSetFlagsNotificationCallback(NotificationUtils::printNotification);
jvppFacade.getNotificationRegistry()
.registerSwInterfaceSetFlagsNotificationCallback(NotificationUtils::printNotification);
jvppFacade.wantInterfaceEvents(getEnableInterfaceNotificationsReq()).toCompletableFuture().get();
System.out.println("Interface events started");

View File

@ -16,7 +16,6 @@
package org.openvpp.jvpp.core.test;
import java.util.Arrays;
import javax.xml.bind.DatatypeConverter;
import org.openvpp.jvpp.JVpp;
import org.openvpp.jvpp.JVppRegistry;
@ -26,7 +25,6 @@ import org.openvpp.jvpp.core.dto.ClassifyAddDelSession;
import org.openvpp.jvpp.core.dto.ClassifyAddDelSessionReply;
import org.openvpp.jvpp.core.dto.ClassifyAddDelTable;
import org.openvpp.jvpp.core.dto.ClassifyAddDelTableReply;
import org.openvpp.jvpp.core.dto.ClassifySessionDetails;
import org.openvpp.jvpp.core.dto.ClassifySessionDetailsReplyDump;
import org.openvpp.jvpp.core.dto.ClassifySessionDump;
import org.openvpp.jvpp.core.dto.ClassifyTableByInterface;
@ -65,8 +63,8 @@ public class L2AclTest {
request.skipNVectors = 0;
request.matchNVectors = 1;
request.mask =
new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00};
new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
(byte) 0xff, (byte) 0xff, 0x00, 0x00, 0x00, 0x00};
return request;
}
@ -85,8 +83,8 @@ public class L2AclTest {
request.advance = 0; // default
// match 01:02:03:04:05:06 mac address
request.match =
new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
(byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00};
new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
(byte) 0x05, (byte) 0x06, 0x00, 0x00, 0x00, 0x00};
return request;
}
@ -113,61 +111,38 @@ public class L2AclTest {
}
private static void print(ClassifyAddDelTableReply reply) {
System.out.printf("ClassifyAddDelTableReply: context=%d, "
+ "newTableIndex=%d, skipNVectors=%d, matchNVectors=%d\n",
reply.context, reply.newTableIndex, reply.skipNVectors, reply.matchNVectors);
System.out.printf("ClassifyAddDelTableReply: %s\n", reply);
}
private static void print(ClassifyTableIdsReply reply) {
System.out.printf("ClassifyTableIdsReply: context=%d, count=%d, ids.length=%d\n",
reply.context, reply.count, reply.ids.length);
Arrays.stream(reply.ids).forEach(System.out::println);
System.out.printf("ClassifyTableIdsReply: %s\n", reply);
}
private static void print(final ClassifyTableInfoReply reply) {
final StringBuilder builder = new StringBuilder("ClassifyTableInfoReply:\n");
builder.append("context: ").append(reply.context).append('\n');
builder.append("tableId: ").append(reply.tableId).append('\n');
builder.append("nbuckets: ").append(reply.nbuckets).append('\n');
builder.append("matchNVectors: ").append(reply.matchNVectors).append('\n');
builder.append("skipNVectors: ").append(reply.skipNVectors).append('\n');
builder.append("activeSessions: ").append(reply.activeSessions).append('\n');
builder.append("nextTableIndex: ").append(reply.nextTableIndex).append('\n');
builder.append("missNextIndex: ").append(reply.missNextIndex).append('\n');
builder.append("maskLength: ").append(reply.maskLength).append('\n');
builder.append("mask: ").append(DatatypeConverter.printHexBinary(reply.mask)).append('\n');
System.out.println(builder.toString());
System.out.println(reply);
if (reply != null) {
System.out.println("Mask hex: " + DatatypeConverter.printHexBinary(reply.mask));
}
}
private static void print(ClassifyAddDelSessionReply reply) {
System.out.printf("ClassifyAddDelSessionReply: context=%d\n",
reply.context);
System.out.printf("ClassifyAddDelSessionReply: context=%s\n", reply);
}
private static void print(final ClassifySessionDetailsReplyDump reply) {
if (reply.classifySessionDetails == null) {
System.out.println("ClassifySessionDetailsReplyDump: classifySessionDetails == NULL");
}
for (final ClassifySessionDetails details : reply.classifySessionDetails) {
final StringBuilder builder = new StringBuilder("ClassifySessionDetails:\n");
builder.append("context: ").append(details.context).append('\n');
builder.append("tableId: ").append(details.tableId).append('\n');
builder.append("hitNextIndex: ").append(details.hitNextIndex).append('\n');
builder.append("advance: ").append(details.advance).append('\n');
builder.append("opaqueIndex: ").append(details.opaqueIndex).append('\n');
builder.append("matchLength: ").append(details.matchLength).append('\n');
builder.append("match: ").append(DatatypeConverter.printHexBinary(details.match)).append('\n');
System.out.println(builder.toString());
}
System.out.println(reply);
reply.classifySessionDetails.forEach(detail -> {
System.out.println(detail);
System.out.println("Match hex: " + DatatypeConverter.printHexBinary(detail.match));
});
}
private static void print(final InputAclSetInterfaceReply reply) {
System.out.printf("InputAclSetInterfaceReply: context=%d\n", reply.context);
System.out.printf("InputAclSetInterfaceReply: context=%s\n", reply);
}
private static void print(final ClassifyTableByInterfaceReply reply) {
System.out.printf("ClassifyAddDelTableReply: context=%d, swIfIndex=%d, l2TableId=%d, ip4TableId=%d,"
+ "ip6TableId=%d\n", reply.context, reply.swIfIndex, reply.l2TableId, reply.ip4TableId, reply.ip6TableId);
System.out.printf("ClassifyAddDelTableReply: %s\n", reply);
}
private static void testL2Acl() throws Exception {
@ -180,34 +155,34 @@ public class L2AclTest {
Thread.sleep(1000);
final ClassifyAddDelTableReply classifyAddDelTableReply =
jvppFacade.classifyAddDelTable(createClassifyTable()).toCompletableFuture().get();
jvppFacade.classifyAddDelTable(createClassifyTable()).toCompletableFuture().get();
print(classifyAddDelTableReply);
final ClassifyTableIdsReply classifyTableIdsReply =
jvppFacade.classifyTableIds(new ClassifyTableIds()).toCompletableFuture().get();
jvppFacade.classifyTableIds(new ClassifyTableIds()).toCompletableFuture().get();
print(classifyTableIdsReply);
final ClassifyTableInfoReply classifyTableInfoReply =
jvppFacade.classifyTableInfo(createClassifyTableInfoRequest(classifyAddDelTableReply.newTableIndex))
.toCompletableFuture().get();
jvppFacade.classifyTableInfo(createClassifyTableInfoRequest(classifyAddDelTableReply.newTableIndex))
.toCompletableFuture().get();
print(classifyTableInfoReply);
final ClassifyAddDelSessionReply classifyAddDelSessionReply =
jvppFacade.classifyAddDelSession(createClassifySession(classifyAddDelTableReply.newTableIndex))
.toCompletableFuture().get();
jvppFacade.classifyAddDelSession(createClassifySession(classifyAddDelTableReply.newTableIndex))
.toCompletableFuture().get();
print(classifyAddDelSessionReply);
final ClassifySessionDetailsReplyDump classifySessionDetailsReplyDump =
jvppFacade.classifySessionDump(createClassifySessionDumpRequest(classifyAddDelTableReply.newTableIndex))
.toCompletableFuture().get();
jvppFacade.classifySessionDump(createClassifySessionDumpRequest(classifyAddDelTableReply.newTableIndex))
.toCompletableFuture().get();
print(classifySessionDetailsReplyDump);
final InputAclSetInterfaceReply inputAclSetInterfaceReply =
jvppFacade.inputAclSetInterface(aclSetInterface()).toCompletableFuture().get();
jvppFacade.inputAclSetInterface(aclSetInterface()).toCompletableFuture().get();
print(inputAclSetInterfaceReply);
final ClassifyTableByInterfaceReply classifyTableByInterfaceReply =
jvppFacade.classifyTableByInterface(createClassifyTableByInterfaceRequest()).toCompletableFuture().get();
jvppFacade.classifyTableByInterface(createClassifyTableByInterfaceRequest()).toCompletableFuture().get();
print(classifyTableByInterfaceReply);
System.out.println("Disconnecting...");

View File

@ -26,8 +26,7 @@ final class NotificationUtils {
private NotificationUtils() {}
static PrintStream printNotification(final SwInterfaceSetFlagsNotification msg) {
return System.out.printf("Received interface notification: ifc: %d, admin: %d, link: %d, deleted: %d\n",
msg.swIfIndex, msg.adminUpDown, msg.linkUpDown, msg.deleted);
return System.out.printf("Received interface notification: ifc: %s\n", msg);
}
static SwInterfaceSetFlags getChangeInterfaceState() {