Refactor ForwardingRulesmanager
[controller.git] / opendaylight / forwardingrulesmanager / api / src / test / java / org / opendaylight / controller / forwardingrulesmanager / frmTest.java
index 34337ba42b625443b3a7587171325ee331dbe2be..f139f45377a0344733b853cb6c86c59daca1226f 100644 (file)
@@ -14,6 +14,8 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -28,6 +30,7 @@ import org.opendaylight.controller.sal.action.PopVlan;
 import org.opendaylight.controller.sal.action.SetDlDst;
 import org.opendaylight.controller.sal.action.SetNwDst;
 import org.opendaylight.controller.sal.action.SetVlanId;
+import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.flowprogrammer.Flow;
@@ -37,19 +40,18 @@ import org.opendaylight.controller.sal.utils.EtherTypes;
 import org.opendaylight.controller.sal.utils.IPProtocols;
 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
 import org.opendaylight.controller.sal.utils.NodeCreator;
+import org.opendaylight.controller.sal.utils.Status;
 
 public class frmTest {
 
     @Test
     public void testFlowEntryInstall() throws UnknownHostException {
         Node node = NodeCreator.createOFNode(1L);
-        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node),
-                node);
-        FlowEntry pol2 = new FlowEntry("polTest2", null, getSampleFlowV6(node),
-                node);
-        FlowEntryInstall fei = new FlowEntryInstall(pol, null);
-        FlowEntryInstall fei2 = new FlowEntryInstall(pol, null);
-        FlowEntryInstall fei3 = new FlowEntryInstall(pol2, null);
+        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
+        FlowEntry pol2 = new FlowEntry("polTest2", null, getSampleFlowV6(node), node);
+        FlowEntryInstall fei = new FlowEntryInstall(pol.clone(), null);
+        FlowEntryInstall fei2 = new FlowEntryInstall(pol.clone(), null);
+        FlowEntryInstall fei3 = new FlowEntryInstall(pol2.clone(), null);
         Assert.assertTrue(fei.getOriginal().equals(pol));
         Assert.assertTrue(fei.getInstall().equals(pol));
         Assert.assertTrue(fei.getFlowName().equals(pol.getFlowName()));
@@ -59,21 +61,18 @@ public class frmTest {
         fei.toBeDeleted();
         Assert.assertTrue(fei.isDeletePending());
         Assert.assertNull(fei.getContainerFlow());
-        Assert.assertTrue(fei.equalsByNodeAndName(pol.getNode(),
-                pol.getFlowName()));
+        Assert.assertTrue(fei.equalsByNodeAndName(pol.getNode(), pol.getFlowName()));
 
         Assert.assertTrue(fei.equals(fei2));
-        fei2.getOriginal().setFlowName("polTest2");
         Assert.assertFalse(fei.equals(null));
-        Assert.assertFalse(fei.equals(fei3));
+        Assert.assertTrue(fei.equals(fei3));
 
     }
 
     @Test
     public void testFlowEntryCreation() throws UnknownHostException {
         Node node = NodeCreator.createOFNode(1L);
-        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node),
-                node);
+        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
         Assert.assertTrue(pol.getFlow().equals(getSampleFlowV6(node)));
     }
 
@@ -81,8 +80,7 @@ public class frmTest {
     public void testFlowEntrySetGet() throws UnknownHostException {
         Node node = NodeCreator.createOFNode(1L);
         Node node2 = NodeCreator.createOFNode(2L);
-        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node),
-                node);
+        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
         pol.setGroupName("polTest2");
         pol.setFlowName("flowName");
         Assert.assertTrue(pol.getFlowName().equals("flowName"));
@@ -96,18 +94,127 @@ public class frmTest {
     public void testFlowEntryEquality() throws UnknownHostException {
         Node node = NodeCreator.createOFNode(1L);
         Node node2 = NodeCreator.createOFNode(1L);
-        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node),
-                node);
-        FlowEntry pol2 = new FlowEntry("polTest", null, getSampleFlowV6(node),
-                node2);
+        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
+        FlowEntry pol2 = new FlowEntry("polTest", null, getSampleFlowV6(node), node2);
         Assert.assertTrue(pol.equals(pol2));
     }
 
+    @Test
+    public void testFlowEntryCollision() throws UnknownHostException {
+        // Create 2 equal FlowEntry objects
+        Node node1 = NodeCreator.createOFNode(1L);
+        Node node2 = NodeCreator.createOFNode(1L);
+        FlowEntry fe1 = new FlowEntry("Junit", "flow1", getSampleFlowV6(node1), node1);
+        FlowEntry fe2 = new FlowEntry("Junit", "flow2", getSampleFlowV6(node2), node1);
+
+        // Check equality in FlowEntry and parameters
+        Assert.assertTrue(fe1.getFlow().getMatch().equals(fe2.getFlow().getMatch()));
+        Assert.assertTrue(fe1.getFlow().getMatch().getMatches() == fe2.getFlow().getMatch().getMatches());
+        Assert.assertTrue(fe1.getFlow().getMatch().hashCode() == fe2.getFlow().getMatch().hashCode());
+        Assert.assertTrue(fe1.getFlow().hashCode() == fe2.getFlow().hashCode());
+        Assert.assertTrue(fe1.equals(fe2));
+        Assert.assertTrue(fe1.hashCode() == fe2.hashCode());
+
+        // Change priority field for fe2, verify inequality
+        fe2.getFlow().setPriority((short)1000);
+
+        // Verify FlowEntry works as key in collection
+        ConcurrentMap<FlowEntry, FlowEntry> map = new ConcurrentHashMap<FlowEntry, FlowEntry>();
+        Assert.assertTrue(null == map.put(fe1, fe1));
+        Assert.assertTrue(fe1.clone().equals(map.put(fe1.clone(), fe1.clone())));
+        Assert.assertTrue(map.get(fe1.clone()).equals(fe1.clone()));
+        Assert.assertTrue(map.keySet().contains(fe1.clone()));
+        Assert.assertTrue(map.containsKey(fe1));
+
+        // Remove key
+        map.remove(fe1);
+        Assert.assertTrue(map.isEmpty());
+        Assert.assertFalse(map.containsKey(fe1));
+
+        // Verify cloned object as key
+        map.put(fe1.clone(), fe1.clone());
+        Assert.assertTrue(map.containsKey(fe1));
+
+        // Verify different key is not present
+        Assert.assertFalse(map.containsKey(fe2));
+
+        // Add different key
+        map.put(fe2.clone(), fe2.clone());
+        Assert.assertTrue(map.size() == 2);
+        Assert.assertTrue(map.containsKey(fe1));
+        Assert.assertTrue(map.containsKey(fe2));
+
+        // Make fe2 equal to fe1 again
+        fe2.getFlow().setPriority((short)300);
+        Assert.assertTrue(fe2.equals(fe1));
+        Assert.assertTrue(map.containsKey(fe2));
+
+        // Clean up
+        map.clear();
+    }
+
+    @Test
+    public void testFlowEntryInstallCollision() throws UnknownHostException {
+        // Create 2 equal FlowEntryInstall objects
+        Node node1 = NodeCreator.createOFNode(1L);
+        Node node2 = NodeCreator.createOFNode(1L);
+        FlowEntry fe1 = new FlowEntry("Junit", "flow1", getSampleFlowV6(node1), node1);
+        FlowEntry fe2 = new FlowEntry("Junit", "flow2", getSampleFlowV6(node2), node1);
+        ContainerFlow cf1 = null;
+        ContainerFlow cf2 = null;
+        FlowEntryInstall fei1 = new FlowEntryInstall(fe1, cf1);
+        FlowEntryInstall fei2 = new FlowEntryInstall(fe2, cf2);
+
+        // Check equality in FlowEntry and parameters
+        Assert.assertTrue(fei1.equals(fei2));
+        Assert.assertTrue(fei1.hashCode() == fei2.hashCode());
+
+        // Verify FlowEntryInstall works as key in collection
+        ConcurrentMap<FlowEntryInstall, FlowEntryInstall> map =
+                new ConcurrentHashMap<FlowEntryInstall, FlowEntryInstall>();
+        Assert.assertTrue(null == map.put(fei1, fei1));
+        Assert.assertTrue(map.get(fei1).equals(fei2));
+        Assert.assertTrue(map.keySet().contains(fei1));
+        Assert.assertTrue(map.keySet().contains(fei2));
+        Assert.assertTrue(map.containsKey(fei1));
+
+        // Remove key
+        map.remove(fei1);
+        Assert.assertTrue(map.isEmpty());
+        Assert.assertFalse(map.containsKey(fei1));
+
+        // Verify cloned object as key
+        map.put(fei1, fei1);
+        Assert.assertTrue(map.containsKey(fei1));
+
+        // Change fei2, change relevant hashcode info
+        fei2.getInstall().getFlow().setPriority((short)301);
+        Assert.assertFalse(fei1.equals(fei2));
+        Assert.assertFalse(fei1.hashCode() == fei2.hashCode());
+
+
+        // Verify different key is not present
+        Assert.assertFalse(map.containsKey(fei2));
+
+        // Add different key
+        map.put(fei2, fei2);
+        Assert.assertTrue(map.size() == 2);
+        Assert.assertTrue(map.containsKey(fei1));
+        Assert.assertTrue(map.containsKey(fei2));
+
+        // Make fei2 equal to fei1 again
+        fei2.getInstall().getFlow().setPriority((short)300);
+        Assert.assertTrue(fei2.equals(fei1));
+        Assert.assertTrue(map.containsKey(fei2));
+
+        // Clean up
+        map.clear();
+    }
+
     @Test
     public void testFlowEntryCloning() throws UnknownHostException {
         Node node = NodeCreator.createOFNode(1L);
-        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node),
-                node);
+        FlowEntry pol = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
         FlowEntry pol2 = pol.clone();
         Assert.assertTrue(pol.equals(pol2));
     }
@@ -162,8 +269,7 @@ public class frmTest {
         FlowConfig frmC = new FlowConfig();
         FlowConfig frmC3 = new FlowConfig();
         Node node = NodeCreator.createOFNode(1L);
-        FlowEntry entry = new FlowEntry("polTest", null, getSampleFlowV6(node),
-                node);
+        FlowEntry entry = new FlowEntry("polTest", null, getSampleFlowV6(node), node);
 
         // testing equal function
         Assert.assertFalse(frmC.equals(null));
@@ -262,8 +368,7 @@ public class frmTest {
 
         Assert.assertFalse(frmC.equals(flowC));
         frmC.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
-        Assert.assertTrue(frmC.getNode().equals(
-                Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
+        Assert.assertTrue(frmC.getNode().equals(Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
         Assert.assertFalse(frmC.equals(frmC3));
         frmC3.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
 
@@ -345,17 +450,12 @@ public class frmTest {
         FlowConfig fc2 = new FlowConfig();
         fc.setName("flow1");
         fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
-        Assert.assertFalse(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW,
-                "0")));
-        Assert.assertTrue(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW,
-                "1")));
-
-        Assert.assertTrue(fc.isByNameAndNodeIdEqual("flow1",
-                Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
-        Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow1",
-                Node.fromString(Node.NodeIDType.OPENFLOW, "0")));
-        Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow2",
-                Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
+        Assert.assertFalse(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW, "0")));
+        Assert.assertTrue(fc.onNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
+
+        Assert.assertTrue(fc.isByNameAndNodeIdEqual("flow1", Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
+        Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow1", Node.fromString(Node.NodeIDType.OPENFLOW, "0")));
+        Assert.assertFalse(fc.isByNameAndNodeIdEqual("flow2", Node.fromString(Node.NodeIDType.OPENFLOW, "1")));
 
         Assert.assertFalse(fc.isByNameAndNodeIdEqual(fc2));
         fc2.setName("flow1");
@@ -369,11 +469,11 @@ public class frmTest {
     @Test
     public void testStatusToggle() throws UnknownHostException {
         FlowConfig fc = new FlowConfig();
-        fc.toggleStatus();
+        fc.toggleInstallation();
         Assert.assertTrue(fc.installInHw());
-        fc.toggleStatus();
+        fc.toggleInstallation();
         Assert.assertFalse(fc.installInHw());
-        fc.toggleStatus();
+        fc.toggleInstallation();
         Assert.assertTrue(fc.installInHw());
 
     }
@@ -406,181 +506,216 @@ public class frmTest {
 
     @Test
     public void testValid() throws UnknownHostException {
-        StringBuffer sb = new StringBuffer();
-        sb.setLength(0);
         FlowConfig fc2 = createSampleFlowConfig();
-        Assert.assertTrue(fc2.isValid(null, sb));
+        Assert.assertTrue(fc2.validate(null).isSuccess());
 
         FlowConfig fc = new FlowConfig();
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Name is null"));
+        Status status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Invalid name"));
 
         fc.setName("Config");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Node is null"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Node is null"));
 
         fc.setNode(Node.fromString(Node.NodeIDType.OPENFLOW, "1"));
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setPriority("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains(
-                "is not in the range 0 - 65535"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("is not in the range 0 - 65535"));
 
         fc.setPriority("100000");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains(
-                "is not in the range 0 - 65535"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("is not in the range 0 - 65535"));
+
         fc.setPriority("2000");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setCookie("100");
+        Assert.assertTrue(fc.validate(null).isSuccess());
+
         fc.setIngressPort("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("is not valid for the Switch"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("is not valid for the Switch"));
+
         fc.setIngressPort("100");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setVlanId(("-1"));
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString()
-                .contains("is not in the range 0 - 4095"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("is not in the range 0 - 4095"));
+
         fc.setVlanId("5000");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString()
-                .contains("is not in the range 0 - 4095"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("is not in the range 0 - 4095"));
+
         fc.setVlanId("100");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
+
         fc.setVlanPriority("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("is not in the range 0 - 7"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("is not in the range 0 - 7"));
+
         fc.setVlanPriority("9");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("is not in the range 0 - 7"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("is not in the range 0 - 7"));
+
         fc.setVlanPriority("5");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setEtherType("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Ethernet type"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Ethernet type"));
+
         fc.setEtherType("0xfffff");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Ethernet type"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Ethernet type"));
+
         fc.setEtherType("0x800");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setTosBits("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("IP ToS bits"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("IP ToS bits"));
+
         fc.setTosBits("65");
-        sb.setLength(0);
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("IP ToS bits"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("IP ToS bits"));
+
         fc.setTosBits("60");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setSrcPort("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Transport source port"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Transport source port"));
+
         fc.setSrcPort("0xfffff");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Transport source port"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Transport source port"));
+
         fc.setSrcPort("0x00ff");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setDstPort("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Transport destination port"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Transport destination port"));
+
         fc.setDstPort("0xfffff");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Transport destination port"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Transport destination port"));
+
         fc.setDstPort("0x00ff");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setSrcMac("abc");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Ethernet source address"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Ethernet source address"));
+
         fc.setSrcMac("00:A0:C9:14:C8:29");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setDstMac("abc");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString()
-                .contains("Ethernet destination address"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Ethernet destination address"));
+
         fc.setDstMac("00:A0:C9:22:AB:11");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setSrcIp("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("IP source address"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("IP source address"));
+
         fc.setSrcIp("2001:420:281:1004:407a:57f4:4d15:c355");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains(
-                "Type mismatch between Ethernet & Src IP"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Type mismatch between Ethernet & Src IP"));
 
         fc.setEtherType("0x86dd");
-        Assert.assertTrue(fc.isValid(null, sb));
-        sb.setLength(0);
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setSrcIp("1.1.1.1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains(
-                "Type mismatch between Ethernet & Src IP"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Type mismatch between Ethernet & Src IP"));
+
         fc.setEtherType("0x800");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setDstIp("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("IP destination address"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("IP destination address"));
+
         fc.setDstIp("2001:420:281:1004:407a:57f4:4d15:c355");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains(
-                "Type mismatch between Ethernet & Dst IP"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Type mismatch between Ethernet & Dst IP"));
 
         fc.setEtherType("0x86dd");
         fc.setSrcIp("2001:420:281:1004:407a:57f4:4d15:c355");
-        Assert.assertTrue(fc.isValid(null, sb));
-        sb.setLength(0);
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setDstIp("2.2.2.2");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains(
-                "Type mismatch between Ethernet & Dst IP"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Type mismatch between Ethernet & Dst IP"));
+
         fc.setEtherType("0x800");
         fc.setSrcIp("1.1.1.1");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setEtherType(null);
         fc.setSrcIp("2001:420:281:1004:407a:57f4:4d15:c355");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("IP Src Dest Type mismatch"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("IP Src Dest Type mismatch"));
+
         fc.setSrcIp("1.1.1.1");
         fc.setIdleTimeout("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Idle Timeout value"));
-        sb.setLength(0);
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Idle Timeout value"));
+
         fc.setIdleTimeout("0xfffff");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Idle Timeout value"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Idle Timeout value"));
+
         fc.setIdleTimeout("10");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
         fc.setHardTimeout("-1");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Hard Timeout value"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Hard Timeout value"));
+
         fc.setHardTimeout("0xfffff");
-        Assert.assertFalse(fc.isValid(null, sb));
-        Assert.assertTrue(sb.toString().contains("Hard Timeout value"));
+        status = fc.validate(null);
+        Assert.assertFalse(status.isSuccess());
+        Assert.assertTrue(status.getDescription().contains("Hard Timeout value"));
+
         fc.setHardTimeout("10");
-        Assert.assertTrue(fc.isValid(null, sb));
+        Assert.assertTrue(fc.validate(null).isSuccess());
 
     }
 
@@ -588,11 +723,9 @@ public class frmTest {
         ArrayList<String> actions;
         actions = createSampleActionList();
         // actions.add(ActionType.CONTROLLER.toString());
-        FlowConfig flowConfig = new FlowConfig("true", "Config1",
-                Node.fromString(Node.NodeIDType.OPENFLOW, "1"), "100", "0",
-                "60", "2", "100", "0", "0x0800", "00:A0:C9:14:C8:29",
-                "00:A0:C9:22:AB:11", IPProtocols.TCP.toString(), "0",
-                "1.2.3.4", "2.2.2.2", "8080", "100", "300", "1000", actions);
+        FlowConfig flowConfig = new FlowConfig("true", "Config1", Node.fromString(Node.NodeIDType.OPENFLOW, "1"),
+                "100", "0", "60", "2", "100", "0", "0x0800", "00:A0:C9:14:C8:29", "00:A0:C9:22:AB:11",
+                IPProtocols.TCP.toString(), "0", "1.2.3.4", "2.2.2.2", "8080", "100", "300", "1000", actions);
         return flowConfig;
 
     }
@@ -621,24 +754,15 @@ public class frmTest {
     }
 
     private Flow getSampleFlowV6(Node node) throws UnknownHostException {
-        NodeConnector port = NodeConnectorCreator.createOFNodeConnector(
-                (short) 24, node);
-        NodeConnector oport = NodeConnectorCreator.createOFNodeConnector(
-                (short) 30, node);
-        byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
-                (byte) 0x9a, (byte) 0xbc };
-        byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,
-                (byte) 0x5e, (byte) 0x6f };
-        byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34,
-                (byte) 0x9a, (byte) 0xee };
-        InetAddress srcIP = InetAddress
-                .getByName("2001:420:281:1004:407a:57f4:4d15:c355");
-        InetAddress dstIP = InetAddress
-                .getByName("2001:420:281:1004:e123:e688:d655:a1b0");
-        InetAddress ipMask = InetAddress
-                .getByName("ffff:ffff:ffff:ffff:0:0:0:0");
-        InetAddress ipMask2 = InetAddress
-                .getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
+        NodeConnector port = NodeConnectorCreator.createOFNodeConnector((short) 24, node);
+        NodeConnector oport = NodeConnectorCreator.createOFNodeConnector((short) 30, node);
+        byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc };
+        byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d, (byte) 0x5e, (byte) 0x6f };
+        byte newMac[] = { (byte) 0x11, (byte) 0xaa, (byte) 0xbb, (byte) 0x34, (byte) 0x9a, (byte) 0xee };
+        InetAddress srcIP = InetAddress.getByName("2001:420:281:1004:407a:57f4:4d15:c355");
+        InetAddress dstIP = InetAddress.getByName("2001:420:281:1004:e123:e688:d655:a1b0");
+        InetAddress ipMask = InetAddress.getByName("ffff:ffff:ffff:ffff:0:0:0:0");
+        InetAddress ipMask2 = InetAddress.getByName("ffff:ffff:ffff:ffff:ffff:ffff:ffff:0");
         InetAddress newIP = InetAddress.getByName("2056:650::a1b0");
         short ethertype = EtherTypes.IPv6.shortValue();
         short vlan = (short) 27;
@@ -674,8 +798,6 @@ public class frmTest {
         actions.add(new PopVlan());
         actions.add(new Flood());
 
-        actions.add(new Controller());
-
         Flow flow = new Flow(match, actions);
         flow.setPriority((short) 300);
         flow.setHardTimeout((short) 240);