Fix installInHw handling in FlowConfig 68/1568/1
authorAlessandro Boch <aboch@cisco.com>
Tue, 1 Oct 2013 02:25:08 +0000 (19:25 -0700)
committerAlessandro Boch <aboch@cisco.com>
Tue, 1 Oct 2013 02:27:37 +0000 (19:27 -0700)
Change-Id: I1a78614e04c0d2b1c345c7d4538003aa790ea8ec
Signed-off-by: Alessandro Boch <aboch@cisco.com>
opendaylight/forwardingrulesmanager/api/src/main/java/org/opendaylight/controller/forwardingrulesmanager/FlowConfig.java
opendaylight/forwardingrulesmanager/api/src/test/java/org/opendaylight/controller/forwardingrulesmanager/frmTest.java

index e0b8e9a786878fe6af6b67dd04aeee52958118db..c57dca2a88c368185c81d8d2c82476e37dc4f968 100644 (file)
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 
+import org.opendaylight.controller.forwardingrulesmanager.FlowEntry;
 import org.opendaylight.controller.sal.action.Action;
 import org.opendaylight.controller.sal.action.ActionType;
 import org.opendaylight.controller.sal.action.Controller;
@@ -188,13 +189,13 @@ public class FlowConfig implements Serializable {
     public boolean installInHw() {
         if (installInHw == null) {
             // backward compatibility
-            installInHw = "true";
+            installInHw = Boolean.toString(true);
         }
-        return installInHw.equals("true");
+        return Boolean.valueOf(installInHw);
     }
 
     public void setInstallInHw(boolean inHw) {
-        installInHw = inHw ? "true" : "false";
+        installInHw = String.valueOf(inHw);
     }
 
     public String getInstallInHw() {
@@ -1072,7 +1073,7 @@ public class FlowConfig implements Serializable {
     }
 
     public void toggleInstallation() {
-        installInHw = (installInHw == null) ? "true" : (installInHw.equals("true")) ? "false" : "true";
+        installInHw = (installInHw == null) ? Boolean.toString(false) : Boolean.toString(!Boolean.valueOf(installInHw));
     }
 
     /*
index a3e1ded14178ff8d00a3efe21d02ea798fa19af2..406970711ccf5cc8e93071f3fec172c6582f23cf 100644 (file)
@@ -469,13 +469,14 @@ public class frmTest {
 
     @Test
     public void testStatusToggle() throws UnknownHostException {
+        // default is install in Hw
         FlowConfig fc = new FlowConfig();
         fc.toggleInstallation();
-        Assert.assertTrue(fc.installInHw());
-        fc.toggleInstallation();
         Assert.assertFalse(fc.installInHw());
         fc.toggleInstallation();
         Assert.assertTrue(fc.installInHw());
+        fc.toggleInstallation();
+        Assert.assertFalse(fc.installInHw());
 
     }