edgeUpdate API enhancement and related changes.
[controller.git] / opendaylight / routing / dijkstra_implementation / src / test / java / org / opendaylight / controller / routing / dijkstra_implementation / MaxThruputTest.java
index 77c55f3c10185ba9869b19903806b962655d1a60..17952c80372001d0291402fad2fdcb046d4a88df 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -16,10 +15,13 @@ import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Path;
+import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
+
 import java.util.LinkedList;
 import java.util.List;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -27,9 +29,12 @@ import org.junit.Assert;
 import org.opendaylight.controller.routing.dijkstra_implementation.internal.DijkstraImplementation;
 
 import org.opendaylight.controller.sal.core.UpdateType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class MaxThruputTest {
-
+    protected static final Logger logger = LoggerFactory
+            .getLogger(MaxThruputTest.class);
     Map<Edge, Number> LinkCostMap = new HashMap<Edge, Number>();
 
     @Test
@@ -71,14 +76,14 @@ public class MaxThruputTest {
         try {
             edge1 = new Edge(nc11, nc21);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge1, 10);
         Edge edge2 = null;
         try {
             edge2 = new Edge(nc21, nc11);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge2, 10);
 
@@ -86,14 +91,14 @@ public class MaxThruputTest {
         try {
             edge3 = new Edge(nc22, nc31);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge3, 30);
         Edge edge4 = null;
         try {
             edge4 = new Edge(nc31, nc22);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge4, 30);
 
@@ -101,14 +106,14 @@ public class MaxThruputTest {
         try {
             edge5 = new Edge(nc32, nc41);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge5, 10);
         Edge edge6 = null;
         try {
             edge6 = new Edge(nc41, nc32);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge6, 10);
 
@@ -116,14 +121,14 @@ public class MaxThruputTest {
         try {
             edge7 = new Edge(nc12, nc51);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge7, 20);
         Edge edge8 = null;
         try {
             edge8 = new Edge(nc51, nc12);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge8, 20);
 
@@ -131,14 +136,14 @@ public class MaxThruputTest {
         try {
             edge9 = new Edge(nc52, nc61);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge9, 20);
         Edge edge10 = null;
         try {
             edge10 = new Edge(nc61, nc52);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge10, 20);
 
@@ -146,29 +151,47 @@ public class MaxThruputTest {
         try {
             edge11 = new Edge(nc62, nc42);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge11, 20);
         Edge edge12 = null;
         try {
             edge12 = new Edge(nc42, nc62);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         LinkCostMap.put(edge12, 20);
 
-        imp.edgeUpdate(edge1, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge2, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge3, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge4, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge5, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge6, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge7, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge8, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge9, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge10, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge11, UpdateType.ADDED, null);
-        imp.edgeUpdate(edge12, UpdateType.ADDED, null);
+        List<TopoEdgeUpdate> topoedgeupdateList = new ArrayList<TopoEdgeUpdate>();
+        TopoEdgeUpdate teu1 = new TopoEdgeUpdate(edge1, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu1);
+        TopoEdgeUpdate teu2 = new TopoEdgeUpdate(edge2, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu2);
+        TopoEdgeUpdate teu3 = new TopoEdgeUpdate(edge3, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu3);
+        TopoEdgeUpdate teu4 = new TopoEdgeUpdate(edge4, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu4);
+        TopoEdgeUpdate teu5 = new TopoEdgeUpdate(edge5, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu5);
+        TopoEdgeUpdate teu6 = new TopoEdgeUpdate(edge6, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu6);
+        TopoEdgeUpdate teu7 = new TopoEdgeUpdate(edge7, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu7);
+        TopoEdgeUpdate teu8 = new TopoEdgeUpdate(edge8, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu8);
+        TopoEdgeUpdate teu9 = new TopoEdgeUpdate(edge9, null, UpdateType.ADDED);
+        topoedgeupdateList.add(teu9);
+        TopoEdgeUpdate teu10 = new TopoEdgeUpdate(edge10, null,
+                UpdateType.ADDED);
+        topoedgeupdateList.add(teu10);
+        TopoEdgeUpdate teu11 = new TopoEdgeUpdate(edge11, null,
+                UpdateType.ADDED);
+        topoedgeupdateList.add(teu11);
+        TopoEdgeUpdate teu12 = new TopoEdgeUpdate(edge12, null,
+                UpdateType.ADDED);
+        topoedgeupdateList.add(teu12);
+
+        imp.edgeUpdate(topoedgeupdateList);
 
         imp.initMaxThroughput(LinkCostMap);
 
@@ -185,7 +208,7 @@ public class MaxThruputTest {
         try {
             expectedRes = new Path(expectedPath);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         if (!res.equals(expectedRes)) {
             System.out.println("Actual Res is " + res);
@@ -203,7 +226,7 @@ public class MaxThruputTest {
         try {
             expectedRes = new Path(expectedPath);
         } catch (ConstructionException e) {
-            e.printStackTrace();
+            logger.error("", e);
         }
         if (!res.equals(expectedRes)) {
             System.out.println("Actual Res is " + res);