Committed by
Gerrit Code Review
Add unit tests for constraint object serializations
Duration is additionally registered because LatencyConstraint has it Change-Id: Ibbf31761b789fa71fb6cb1a1155f5ea0680853ce
Showing
2 changed files
with
45 additions
and
1 deletions
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onlab.onos.store.serializers; | 16 | package org.onlab.onos.store.serializers; |
17 | 17 | ||
18 | import java.net.URI; | 18 | import java.net.URI; |
19 | +import java.time.Duration; | ||
19 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
20 | import java.util.Arrays; | 21 | import java.util.Arrays; |
21 | import java.util.HashMap; | 22 | import java.util.HashMap; |
... | @@ -123,7 +124,8 @@ public final class KryoNamespaces { | ... | @@ -123,7 +124,8 @@ public final class KryoNamespaces { |
123 | HashMap.class, | 124 | HashMap.class, |
124 | HashSet.class, | 125 | HashSet.class, |
125 | LinkedList.class, | 126 | LinkedList.class, |
126 | - byte[].class | 127 | + byte[].class, |
128 | + Duration.class | ||
127 | ) | 129 | ) |
128 | .build(); | 130 | .build(); |
129 | 131 | ... | ... |
... | @@ -52,6 +52,13 @@ import org.onlab.onos.net.resource.Lambda; | ... | @@ -52,6 +52,13 @@ import org.onlab.onos.net.resource.Lambda; |
52 | import org.onlab.onos.net.resource.LambdaResourceAllocation; | 52 | import org.onlab.onos.net.resource.LambdaResourceAllocation; |
53 | import org.onlab.onos.net.resource.LinkResourceRequest; | 53 | import org.onlab.onos.net.resource.LinkResourceRequest; |
54 | import org.onlab.onos.net.resource.ResourceAllocation; | 54 | import org.onlab.onos.net.resource.ResourceAllocation; |
55 | +import org.onlab.onos.net.intent.constraint.AnnotationConstraint; | ||
56 | +import org.onlab.onos.net.intent.constraint.BandwidthConstraint; | ||
57 | +import org.onlab.onos.net.intent.constraint.LambdaConstraint; | ||
58 | +import org.onlab.onos.net.intent.constraint.LatencyConstraint; | ||
59 | +import org.onlab.onos.net.intent.constraint.LinkTypeConstraint; | ||
60 | +import org.onlab.onos.net.intent.constraint.ObstacleConstraint; | ||
61 | +import org.onlab.onos.net.intent.constraint.WaypointConstraint; | ||
55 | import org.onlab.packet.ChassisId; | 62 | import org.onlab.packet.ChassisId; |
56 | import org.onlab.packet.IpAddress; | 63 | import org.onlab.packet.IpAddress; |
57 | import org.onlab.packet.Ip4Address; | 64 | import org.onlab.packet.Ip4Address; |
... | @@ -66,6 +73,7 @@ import java.nio.ByteBuffer; | ... | @@ -66,6 +73,7 @@ import java.nio.ByteBuffer; |
66 | import java.util.HashMap; | 73 | import java.util.HashMap; |
67 | import java.util.Map; | 74 | import java.util.Map; |
68 | import java.util.Set; | 75 | import java.util.Set; |
76 | +import java.time.Duration; | ||
69 | 77 | ||
70 | import static java.util.Arrays.asList; | 78 | import static java.util.Arrays.asList; |
71 | import static org.junit.Assert.*; | 79 | import static org.junit.Assert.*; |
... | @@ -287,6 +295,40 @@ public class KryoSerializerTest { | ... | @@ -287,6 +295,40 @@ public class KryoSerializerTest { |
287 | testSerializable(new DefaultLinkResourceAllocations(request, allocations)); | 295 | testSerializable(new DefaultLinkResourceAllocations(request, allocations)); |
288 | } | 296 | } |
289 | 297 | ||
298 | + @Test | ||
299 | + public void testLambdaConstraint() { | ||
300 | + testSerializable(new LambdaConstraint(Lambda.valueOf(1))); | ||
301 | + } | ||
302 | + | ||
303 | + @Test | ||
304 | + public void testBandwidthConstraint() { | ||
305 | + testSerializable(new BandwidthConstraint(Bandwidth.valueOf(1000.0))); | ||
306 | + } | ||
307 | + | ||
308 | + @Test | ||
309 | + public void testLinkTypeConstraint() { | ||
310 | + testSerializable(new LinkTypeConstraint(true, Link.Type.DIRECT)); | ||
311 | + } | ||
312 | + | ||
313 | + @Test | ||
314 | + public void testLatencyConstraint() { | ||
315 | + testSerializable(new LatencyConstraint(Duration.ofSeconds(10))); | ||
316 | + } | ||
317 | + | ||
318 | + @Test | ||
319 | + public void testWaypointConstraint() { | ||
320 | + testSerializable(new WaypointConstraint(deviceId("of:1"), deviceId("of:2"))); | ||
321 | + } | ||
322 | + | ||
323 | + @Test | ||
324 | + public void testObstacleConstraint() { | ||
325 | + testSerializable(new ObstacleConstraint(deviceId("of:1"), deviceId("of:2"))); | ||
326 | + } | ||
327 | + | ||
328 | + @Test | ||
329 | + public void testAnnotationConstraint() { | ||
330 | + testSerializable(new AnnotationConstraint("distance", 100.0)); | ||
331 | + } | ||
290 | 332 | ||
291 | @Test | 333 | @Test |
292 | public void testAnnotations() { | 334 | public void testAnnotations() { | ... | ... |
-
Please register or login to post a comment