Add checkstyle rule UpperEll and fix all code accordingly.
[controller.git] / opendaylight / protocol_plugins / openflow / src / test / java / org / opendaylight / controller / protocol_plugin / openflow / internal / FlowProgrammerServiceTest.java
index 297223392ded7f0cac8620381011089222cd406d..a751948de7d5a73d22696f66a0bcefb15ca82b53 100644 (file)
@@ -17,7 +17,6 @@ import java.util.List;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.opendaylight.controller.protocol_plugin.openflow.internal.FlowConverter;
 import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match;
 import org.openflow.protocol.OFMatch;
 import org.openflow.protocol.action.OFAction;
@@ -52,7 +51,7 @@ public class FlowProgrammerServiceTest {
 
     @Test
     public void testSALtoOFFlowConverter() throws UnknownHostException {
-        Node node = NodeCreator.createOFNode(1000l);
+        Node node = NodeCreator.createOFNode(1000L);
         NodeConnector port = NodeConnectorCreator.createNodeConnector(
                 (short) 24, node);
         NodeConnector oport = NodeConnectorCreator.createNodeConnector(
@@ -179,9 +178,58 @@ public class FlowProgrammerServiceTest {
         }
     }
 
+    @Test
+    public void testVlanNoneIdFlowConversion() throws Exception {
+        Node node = NodeCreator.createOFNode(1000L);
+
+        /*
+         * The value 0 is used to indicate that no VLAN ID is set
+         * for SAL Flow.
+         */
+        short vlan = (short) 0;
+
+        /*
+         * Create a SAL Flow aFlow
+         */
+        Match match = new Match();
+        match.setField(MatchType.DL_VLAN, vlan);
+
+        List<Action> actions = new ArrayList<Action>();
+
+        Flow aFlow = new Flow(match, actions);
+
+        /*
+         * Convert the SAL aFlow to OF Flow
+         */
+        FlowConverter salToOF = new FlowConverter(aFlow);
+        OFMatch ofMatch = salToOF.getOFMatch();
+        List<OFAction> ofActions = salToOF.getOFActions();
+
+        /*
+         * The value 0xffff (OFP_VLAN_NONE) is used to indicate
+         * that no VLAN ID is set for OF Flow.
+         */
+        Assert.assertEquals((short) 0xffff, ofMatch.getDataLayerVirtualLan());
+
+        /*
+         * Convert the OF Flow to SAL Flow bFlow
+         */
+        FlowConverter ofToSal = new FlowConverter(ofMatch, ofActions);
+        Flow bFlow = ofToSal.getFlow(node);
+        Match bMatch = bFlow.getMatch();
+
+        /*
+         * Verify the converted SAL flow bFlow is equivalent to the original SAL Flow
+         */
+        Assert
+                .assertTrue(((Short) match.getField(MatchType.DL_VLAN)
+                        .getValue()).equals((Short) bMatch.getField(
+                        MatchType.DL_VLAN).getValue()));
+    }
+
     @Test
     public void testV6toSALFlowConversion() throws Exception {
-        Node node = NodeCreator.createOFNode(12l);
+        Node node = NodeCreator.createOFNode(12L);
         NodeConnector port = NodeConnectorCreator.createNodeConnector(
                 (short) 34, node);
         NodeConnector oport = NodeConnectorCreator.createNodeConnector(
@@ -317,7 +365,7 @@ public class FlowProgrammerServiceTest {
     public void testV6MatchToSALMatchToV6MatchConversion()
             throws UnknownHostException {
         NodeConnector port = NodeConnectorCreator.createNodeConnector(
-                (short) 24, NodeCreator.createOFNode(6l));
+                (short) 24, NodeCreator.createOFNode(6L));
         byte srcMac[] = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
                 (byte) 0x9a, (byte) 0xbc };
         byte dstMac[] = { (byte) 0x1a, (byte) 0x2b, (byte) 0x3c, (byte) 0x4d,