Add and update test codes for Intent related codes
Change-Id: Idbd1e9978c1f9df0e2d19b15d108ff1f0b8d0c8b
diff --git a/src/test/java/net/onrc/onos/intent/ConstrainedShortestPathIntentTest.java b/src/test/java/net/onrc/onos/intent/ConstrainedShortestPathIntentTest.java
index aba4c11..99fa0b3 100644
--- a/src/test/java/net/onrc/onos/intent/ConstrainedShortestPathIntentTest.java
+++ b/src/test/java/net/onrc/onos/intent/ConstrainedShortestPathIntentTest.java
@@ -1,6 +1,7 @@
package net.onrc.onos.intent;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import net.onrc.onos.ofcontroller.util.serializers.KryoFactory;
import org.junit.After;
import org.junit.Before;
@@ -23,21 +24,36 @@
}
@Test
- public void test() {
- Kryo kryo = new Kryo();
- Output output = new Output(1024);
-
+ public void testCreate() {
ConstrainedShortestPathIntent intent1 =
new ConstrainedShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L, 1000.0);
+ assertEquals("1", intent1.getId());
+ assertEquals(2L, intent1.getSrcSwitchDpid());
+ assertEquals(3L, intent1.getSrcPortNumber());
+ assertEquals(4L, intent1.getSrcMac());
+ assertEquals(5L, intent1.getDstSwitchDpid());
+ assertEquals(6L, intent1.getDstPortNumber());
+ assertEquals(7L, intent1.getDstMac());
+ assertEquals(1000.0, intent1.getBandwidth(), 0.0);
+ }
+
+ @Test
+ public void testKryo() {
+ KryoFactory factory = new KryoFactory();
+ Kryo kryo = factory.newKryo();
+ Output output = new Output(1000);
+
+ ConstrainedShortestPathIntent intent1 =
+ new ConstrainedShortestPathIntent("1", 2L, 3L, 4L, 5L, 6L, 7L, 1000.0);
kryo.writeObject(output, intent1);
+
output.close();
+ byte bytes[] = output.toBytes();
- Input input = new Input(output.toBytes());
- ConstrainedShortestPathIntent intent2 =
- kryo.readObject(input, ConstrainedShortestPathIntent.class);
+ Input input = new Input(bytes);
+ ConstrainedShortestPathIntent intent2 = kryo.readObject(input, ConstrainedShortestPathIntent.class);
input.close();
-
assertEquals("1", intent2.getId());
assertEquals(2L, intent2.getSrcSwitchDpid());
assertEquals(3L, intent2.getSrcPortNumber());