Bug 5540 - Remove ConvertorManager singleton
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / match / MatchConvertorImpl2Test.java
index edaac8a445e37316c8827e916c7c3aead6c51fa1..184012c13c3fb8101630afc0b069cf1a85248d2f 100644 (file)
@@ -13,7 +13,8 @@ import java.util.List;
 import org.junit.Assert;\r
 import org.junit.Before;\r
 import org.junit.Test;\r
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;\r
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;\r
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;\r
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
@@ -147,6 +148,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc
 public class MatchConvertorImpl2Test {\r
 \r
     private static final MatchConvertorImpl convertor = new MatchConvertorImpl();\r
+    private ConvertorManager convertorManager;\r
 \r
     /**\r
      * Initializes OpenflowPortsUtil\r
@@ -154,26 +156,21 @@ public class MatchConvertorImpl2Test {
     @Before\r
     public void startUp() {\r
         OpenflowPortsUtil.init();\r
+        convertorManager = ConvertorManagerFactory.createDefaultManager();\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testEmptyAndNullInput() {\r
         MatchBuilder builder = new MatchBuilder();\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(null);\r
+        List<MatchEntry> entries = convertor.convert(null, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 0, entries.size());\r
 \r
-        entries = convertor.convert(match);\r
+        entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 0, entries.size());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -234,7 +231,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 24, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, InPort.class, false);\r
@@ -343,9 +340,6 @@ public class MatchConvertorImpl2Test {
         Assert.assertEquals("Wrong hasMask", hasMask, entry.isHasMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testIpv4MatchArbitraryBitMaskwithNoMask(){\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -355,7 +349,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
@@ -366,9 +360,6 @@ public class MatchConvertorImpl2Test {
         Assert.assertEquals("wrong Ipv4Address destination", "10.1.1.1",((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testIpv4MatchArbitraryBitMaskwithMask(){\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -380,7 +371,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r
@@ -391,9 +382,6 @@ public class MatchConvertorImpl2Test {
         Assert.assertEquals("wrong Ipv4Adress destination", "10.1.1.1",((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testUdpMatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -403,7 +391,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer4Match(udpMatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, UdpSrc.class, false);\r
@@ -415,9 +403,6 @@ public class MatchConvertorImpl2Test {
                 .getUdpDst().getPort().getValue().intValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testTunnelIpv4MatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -427,7 +412,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(tunnelIpv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv4Src.class, false);\r
@@ -439,9 +424,6 @@ public class MatchConvertorImpl2Test {
                 .getIpv4Address().getValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testSctpMatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -451,7 +433,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer4Match(sctpMatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, SctpSrc.class, false);\r
@@ -463,9 +445,6 @@ public class MatchConvertorImpl2Test {
                 .getSctpDst().getPort().getValue().intValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testArpMatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -482,7 +461,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(arpBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 5, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, ArpOp.class, false);\r
@@ -506,9 +485,6 @@ public class MatchConvertorImpl2Test {
                 .getArpTha().getMacAddress().getValue());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testArpMatchConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -527,7 +503,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(arpBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 4, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         entry = entries.get(0);\r
@@ -556,9 +532,6 @@ public class MatchConvertorImpl2Test {
                 ((ArpThaCase) entry.getMatchEntryValue()).getArpTha().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testIpv6MatchConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -577,7 +550,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 7, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         /* Due to conversion ambiguities, we always get "has mask" because \r
@@ -612,9 +585,6 @@ public class MatchConvertorImpl2Test {
                 true, false, true, false), ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getPseudoField());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testIpv6MatchConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -624,7 +594,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv6Src.class, true);\r
@@ -641,9 +611,6 @@ public class MatchConvertorImpl2Test {
                 ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testIpv6ExtHeaderConversion() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -655,7 +622,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6Builder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 1, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Ipv6Exthdr.class, true);\r
@@ -665,9 +632,6 @@ public class MatchConvertorImpl2Test {
                 ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testConversionWithMasks() {\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -707,7 +671,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv4MatchBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 8, entries.size());\r
         MatchEntry entry = entries.get(0);\r
         checkEntryHeader(entry, Metadata.class, true);\r
@@ -761,9 +725,6 @@ public class MatchConvertorImpl2Test {
                 ((TunnelIdCase) entry.getMatchEntryValue()).getTunnelId().getMask());\r
     }\r
 \r
-    /**\r
-     * Test {@link Convertor#convert(Object)}\r
-     */\r
     @Test\r
     public void testIpv6MatchArbitraryBitMask(){\r
         MatchBuilder builder = new MatchBuilder();\r
@@ -775,7 +736,7 @@ public class MatchConvertorImpl2Test {
         builder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());\r
         Match match = builder.build();\r
 \r
-        List<MatchEntry> entries = convertor.convert(match);\r
+        List<MatchEntry> entries = convertor.convert(match, convertorManager);\r
         Assert.assertEquals("Wrong entries size", 2, entries.size());\r
 \r
         MatchEntry entry = entries.get(0);\r