Sho SHIMIZU
Committed by Gerrit Code Review

Add unit tests for constraint object serializations

Duration is additionally registered because LatencyConstraint has it

Change-Id: Ibbf31761b789fa71fb6cb1a1155f5ea0680853ce
......@@ -16,6 +16,7 @@
package org.onlab.onos.store.serializers;
import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
......@@ -123,7 +124,8 @@ public final class KryoNamespaces {
HashMap.class,
HashSet.class,
LinkedList.class,
byte[].class
byte[].class,
Duration.class
)
.build();
......
......@@ -52,6 +52,13 @@ import org.onlab.onos.net.resource.Lambda;
import org.onlab.onos.net.resource.LambdaResourceAllocation;
import org.onlab.onos.net.resource.LinkResourceRequest;
import org.onlab.onos.net.resource.ResourceAllocation;
import org.onlab.onos.net.intent.constraint.AnnotationConstraint;
import org.onlab.onos.net.intent.constraint.BandwidthConstraint;
import org.onlab.onos.net.intent.constraint.LambdaConstraint;
import org.onlab.onos.net.intent.constraint.LatencyConstraint;
import org.onlab.onos.net.intent.constraint.LinkTypeConstraint;
import org.onlab.onos.net.intent.constraint.ObstacleConstraint;
import org.onlab.onos.net.intent.constraint.WaypointConstraint;
import org.onlab.packet.ChassisId;
import org.onlab.packet.IpAddress;
import org.onlab.packet.Ip4Address;
......@@ -66,6 +73,7 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.time.Duration;
import static java.util.Arrays.asList;
import static org.junit.Assert.*;
......@@ -287,6 +295,40 @@ public class KryoSerializerTest {
testSerializable(new DefaultLinkResourceAllocations(request, allocations));
}
@Test
public void testLambdaConstraint() {
testSerializable(new LambdaConstraint(Lambda.valueOf(1)));
}
@Test
public void testBandwidthConstraint() {
testSerializable(new BandwidthConstraint(Bandwidth.valueOf(1000.0)));
}
@Test
public void testLinkTypeConstraint() {
testSerializable(new LinkTypeConstraint(true, Link.Type.DIRECT));
}
@Test
public void testLatencyConstraint() {
testSerializable(new LatencyConstraint(Duration.ofSeconds(10)));
}
@Test
public void testWaypointConstraint() {
testSerializable(new WaypointConstraint(deviceId("of:1"), deviceId("of:2")));
}
@Test
public void testObstacleConstraint() {
testSerializable(new ObstacleConstraint(deviceId("of:1"), deviceId("of:2")));
}
@Test
public void testAnnotationConstraint() {
testSerializable(new AnnotationConstraint("distance", 100.0));
}
@Test
public void testAnnotations() {
......