Implement serialization/deserialization feature for each Intent classes
Change-Id: I63db34914d8df76d5a000831da1e03e03383e62f
diff --git a/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java b/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java
index 93aa8ab..73eee6b 100644
--- a/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java
+++ b/src/test/java/net/onrc/onos/intent/runtime/UseCaseTest.java
@@ -4,6 +4,7 @@
import net.onrc.onos.intent.ConstrainedShortestPathIntent;
import net.onrc.onos.intent.Intent;
+import net.onrc.onos.intent.MockNetworkGraph;
import net.onrc.onos.intent.PathIntent;
import net.onrc.onos.intent.PathIntents;
import net.onrc.onos.intent.ShortestPathIntent;
@@ -17,79 +18,13 @@
* @author Toshio Koide (t-koide@onlab.us)
*/
public class UseCaseTest {
- public class MutableNetworkGraph extends AbstractNetworkGraph {
- public Switch addSwitch(Long switchId) {
- SwitchImpl sw = new SwitchImpl(this, switchId);
- switches.put(sw.getDpid(), sw);
- return sw;
-
- }
-
- public Link addLink(Long srcDpid, Long srcPortNo, Long dstDpid, Long dstPortNo) {
- return new LinkImpl(
- this,
- getSwitch(srcDpid).getPort(srcPortNo),
- getSwitch(dstDpid).getPort(dstPortNo));
- }
-
- public Link[] addBidirectionalLinks(Long srcDpid, Long srcPortNo, Long dstDpid, Long dstPortNo) {
- Link[] links = new Link[2];
- links[0] = addLink(srcDpid, srcPortNo, dstDpid, dstPortNo);
- links[1] = addLink(dstDpid, dstPortNo, srcDpid, srcPortNo);
-
- return links;
- }
- }
-
NetworkGraph g;
@Before
public void setUp() {
- MutableNetworkGraph g = new MutableNetworkGraph();
-
- // add 10 switches (24 ports switch)
- for (Long dpid=1L; dpid<10L; dpid++) {
- SwitchImpl sw = (SwitchImpl) g.addSwitch(dpid);
- for (Long j=1L; j<=24L; j++) {
- sw.addPort(j);
- }
- }
-
- // add loop path
- g.addBidirectionalLinks(1L, 1L, 2L, 2L);
- g.addBidirectionalLinks(2L, 1L, 3L, 2L);
- g.addBidirectionalLinks(3L, 1L, 4L, 2L);
- g.addBidirectionalLinks(4L, 1L, 5L, 2L);
- g.addBidirectionalLinks(5L, 1L, 6L, 2L);
- g.addBidirectionalLinks(6L, 1L, 7L, 2L);
- g.addBidirectionalLinks(7L, 1L, 8L, 2L);
- g.addBidirectionalLinks(8L, 1L, 9L, 2L);
- g.addBidirectionalLinks(9L, 1L, 1L, 2L);
-
- // add other links
- g.addBidirectionalLinks(1L, 3L, 5L, 3L);
- g.addBidirectionalLinks(2L, 4L, 5L, 4L);
- g.addBidirectionalLinks(2L, 5L, 7L, 5L);
- g.addBidirectionalLinks(3L, 6L, 7L, 6L);
- g.addBidirectionalLinks(3L, 7L, 8L, 7L);
- g.addBidirectionalLinks(3L, 8L, 9L, 8L);
- g.addBidirectionalLinks(4L, 9l, 9L, 9L);
-
- // set capacity of all links to 1000Mbps
- for (Link link: g.getLinks()) {
- ((LinkImpl)link).setCapacity(1000.0);
- }
-
- /*
- // add Devices
- for (Long l=1L; l<=9L; l++) {
- DeviceImpl d = new DeviceImpl(g, MACAddress.valueOf(l));
- d.addAttachmentPoint(g.getSwitch(l).getPort(20L));
- g.addDevice(d);
- }
- */
-
- this.g = g;
+ MockNetworkGraph graph = new MockNetworkGraph();
+ graph.createSampleTopology();
+ g = graph;
}
@After