--- /dev/null
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class CodeKeyMakerFactoryTest {\r
+\r
+ /**\r
+ * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testMatchEntriesKeyMaker() {\r
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null key maker", keyMaker);\r
+\r
+ ByteBuf buffer = BufferHelper.buildBuffer("80 00 00 04 00 00 00 01");\r
+ buffer.skipBytes(4); // skip XID\r
+ MessageCodeKey codeKey = keyMaker.make(buffer);\r
+\r
+ Assert.assertNotNull("Null key", codeKey);\r
+ Assert.assertEquals("Wrong key", new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 32768, 0), codeKey);\r
+ Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes());\r
+ }\r
+\r
+ /**\r
+ * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testExperimenterMatchEntriesKeyMaker() {\r
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null key maker", keyMaker);\r
+\r
+ ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 04 00 00 00 01");\r
+ buffer.skipBytes(4); // skip XID\r
+ MessageCodeKey codeKey = keyMaker.make(buffer);\r
+\r
+ Assert.assertNotNull("Null key", codeKey);\r
+ MatchEntryDeserializerKey comparationKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 0);\r
+ comparationKey.setExperimenterId(1L);\r
+ Assert.assertEquals("Wrong key", comparationKey, codeKey);\r
+ Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes());\r
+ }\r
+\r
+ /**\r
+ * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testActionKeyMaker() {\r
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null key maker", keyMaker);\r
+\r
+ ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00");\r
+ buffer.skipBytes(4); // skip XID\r
+ MessageCodeKey codeKey = keyMaker.make(buffer);\r
+\r
+ Assert.assertNotNull("Null key", codeKey);\r
+ Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 0, null), codeKey);\r
+ Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes());\r
+ }\r
+\r
+ /**\r
+ * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testExperimenterActionKeyMaker() {\r
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null key maker", keyMaker);\r
+\r
+ ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01");\r
+ buffer.skipBytes(4); // skip XID\r
+ MessageCodeKey codeKey = keyMaker.make(buffer);\r
+\r
+ Assert.assertNotNull("Null key", codeKey);\r
+ Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 65535, 1L), codeKey);\r
+ Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes());\r
+ }\r
+\r
+ /**\r
+ * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testInstructionKeyMaker() {\r
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null key maker", keyMaker);\r
+\r
+ ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 08");\r
+ buffer.skipBytes(4); // skip XID\r
+ MessageCodeKey codeKey = keyMaker.make(buffer);\r
+\r
+ Assert.assertNotNull("Null key", codeKey);\r
+ Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 0, null), codeKey);\r
+ Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes());\r
+ }\r
+\r
+ /**\r
+ * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testExperimenterInstructionKeyMaker() {\r
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null key maker", keyMaker);\r
+\r
+ ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01");\r
+ buffer.skipBytes(4); // skip XID\r
+ MessageCodeKey codeKey = keyMaker.make(buffer);\r
+\r
+ Assert.assertNotNull("Null key", codeKey);\r
+ Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 65535, 1L), codeKey);\r
+ Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes());\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import java.util.List;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.PooledByteBufAllocator;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Mock;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;\r
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
+import org.opendaylight.yangtools.yang.binding.DataObject;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+@RunWith(MockitoJUnitRunner.class)\r
+public class ListDeserializerTest {\r
+\r
+ @Mock CodeKeyMaker keyMaker;\r
+ @Mock DeserializerRegistry registry;\r
+\r
+ /**\r
+ * Tests {@link ListDeserializer#deserializeList(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)}\r
+ */\r
+ @Test\r
+ public void test() {\r
+ ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
+ List<DataObject> list = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID,\r
+ 42, buffer, keyMaker, registry);\r
+\r
+ Assert.assertNull("List is not null", list);\r
+ }\r
+\r
+ /**\r
+ * Tests {@link ListDeserializer#deserializeHeaders(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)}\r
+ */\r
+ @Test\r
+ public void test2() {\r
+ ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
+ List<DataObject> list = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID,\r
+ 42, buffer, keyMaker, registry);\r
+\r
+ Assert.assertNull("List is not null", list);\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import io.netty.buffer.ByteBuf;\r
+import io.netty.buffer.PooledByteBufAllocator;\r
+\r
+import java.util.List;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Mock;\r
+import org.mockito.runners.MockitoJUnitRunner;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+@RunWith(MockitoJUnitRunner.class)\r
+public class ListSerializerTest {\r
+\r
+ @Mock TypeKeyMaker<Action> keyMaker;\r
+ @Mock SerializerRegistry registry;\r
+\r
+ /**\r
+ * Tests {@link ListSerializer#serializeHeaderList(List, TypeKeyMaker, SerializerRegistry, ByteBuf)}\r
+ * with null List\r
+ */\r
+ @Test\r
+ public void test() {\r
+ ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();\r
+ ListSerializer.serializeHeaderList(null, keyMaker, registry, buffer);\r
+\r
+ Assert.assertEquals("Data written to buffer", 0, buffer.readableBytes());\r
+ }\r
+}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpOp;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha;\r
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa;\r
Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask());\r
Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class));\r
}\r
+\r
+ /**\r
+ * Testing standard match type\r
+ */\r
+ @Test\r
+ public void testStandardMatch() {\r
+ ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 10 80 00 04 08 00 00 00 00 00 00 00 01");\r
+\r
+ Match match = matchDeserializer.deserialize(buffer);\r
+\r
+ Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType());\r
+ Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size());\r
+ }\r
}
\ No newline at end of file
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.StandardMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match;
Match match = builder.build();
return match;
}
-
-
-}
+ /**
+ * Test Standard match type
+ */
+ @Test
+ public void testStandardMatchType() {
+ MatchBuilder builder = new MatchBuilder();
+ builder.setType(StandardMatchType.class);
+ Match match = builder.build();
+ ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+
+ matchSerializer.serialize(match, out);
+
+ Assert.assertEquals("Wrong match type", 0, out.readUnsignedShort());
+ Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort());
+ Assert.assertEquals("Wrong padding", 0, out.readUnsignedInt());
+ Assert.assertEquals("Unexpected data", 0, out.readableBytes());
+ }
+
+ /**
+ * Test serialize experimenter match entry - with no experimenter
+ * match entry serializer registered
+ */
+ @Test(expected=IllegalStateException.class)
+ public void testSerializeExperimenterMatchEntry() {
+ List<MatchEntries> entries = new ArrayList<>();
+ MatchEntriesBuilder builder = new MatchEntriesBuilder();
+ builder.setOxmClass(ExperimenterClass.class);
+ builder.setOxmMatchField(OxmMatchFieldClass.class);
+ builder.setHasMask(true);
+ ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder();
+ expIdBuilder.setExperimenter(new ExperimenterId(42L));
+ builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build());
+ entries.add(builder.build());
+ ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
+
+ ((OF13MatchSerializer) matchSerializer).serializeMatchEntries(entries, out);
+ }
+
+ private class OxmMatchFieldClass extends MatchField {
+ // only for testing purposes
+ }
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.impl.util;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey;\r
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Experimenter;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public class TypeKeyMakerFactoryTest {\r
+\r
+ /**\r
+ * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testActionKeyMaker() {\r
+ TypeKeyMaker<Action> keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null keyMaker", keyMaker);\r
+\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(Output.class);\r
+ Action action = builder.build();\r
+ MessageTypeKey<?> key = keyMaker.make(action);\r
+\r
+ Assert.assertNotNull("Null key", key);\r
+ Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
+ Output.class, null), key);\r
+ }\r
+\r
+ /**\r
+ * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testExperimenterActionKeyMaker() {\r
+ TypeKeyMaker<Action> keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null keyMaker", keyMaker);\r
+\r
+ ActionBuilder builder = new ActionBuilder();\r
+ builder.setType(Experimenter.class);\r
+ ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder();\r
+ expIdBuilder.setExperimenter(new ExperimenterId(42L));\r
+ expIdBuilder.setSubType(ActionSubtypeClass.class);\r
+ builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build());\r
+ Action action = builder.build();\r
+ MessageTypeKey<?> key = keyMaker.make(action);\r
+\r
+ Assert.assertNotNull("Null key", key);\r
+ Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L,\r
+ ActionSubtypeClass.class), key);\r
+ }\r
+\r
+ /**\r
+ * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testInstructionKeyMaker() {\r
+ TypeKeyMaker<Instruction> keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null keyMaker", keyMaker);\r
+\r
+ InstructionBuilder builder = new InstructionBuilder();\r
+ builder.setType(GotoTable.class);\r
+ Instruction instruction = builder.build();\r
+ MessageTypeKey<?> key = keyMaker.make(instruction);\r
+\r
+ Assert.assertNotNull("Null key", key);\r
+ Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
+ GotoTable.class, null), key);\r
+ }\r
+\r
+ /**\r
+ * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testExperimenterInstructionKeyMaker() {\r
+ TypeKeyMaker<Instruction> keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null keyMaker", keyMaker);\r
+\r
+ InstructionBuilder builder = new InstructionBuilder();\r
+ builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow\r
+ .common.instruction.rev130731.Experimenter.class);\r
+ ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder();\r
+ expIdBuilder.setExperimenter(new ExperimenterId(42L));\r
+ builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build());\r
+ Instruction instruction = builder.build();\r
+ MessageTypeKey<?> key = keyMaker.make(instruction);\r
+\r
+ Assert.assertNotNull("Null key", key);\r
+ Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID,\r
+ 42L), key);\r
+ }\r
+\r
+ /**\r
+ * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testMatchEntriesKeyMaker() {\r
+ TypeKeyMaker<MatchEntries> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null keyMaker", keyMaker);\r
+\r
+ MatchEntriesBuilder builder = new MatchEntriesBuilder();\r
+ builder.setOxmClass(OpenflowBasicClass.class);\r
+ builder.setOxmMatchField(InPort.class);\r
+ builder.setHasMask(true);\r
+ MatchEntries entry = builder.build();\r
+ MessageTypeKey<?> key = keyMaker.make(entry);\r
+\r
+ Assert.assertNotNull("Null key", key);\r
+ MatchEntrySerializerKey<?, ?> comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
+ OpenflowBasicClass.class, InPort.class);\r
+ Assert.assertEquals("Wrong key", comparationKey, key);\r
+ }\r
+\r
+ /**\r
+ * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)}\r
+ */\r
+ @Test\r
+ public void testExperimenterMatchEntriesKeyMaker() {\r
+ TypeKeyMaker<MatchEntries> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);\r
+ Assert.assertNotNull("Null keyMaker", keyMaker);\r
+\r
+ MatchEntriesBuilder builder = new MatchEntriesBuilder();\r
+ builder.setOxmClass(ExperimenterClass.class);\r
+ builder.setOxmMatchField(OxmMatchFieldClass.class);\r
+ builder.setHasMask(true);\r
+ ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder();\r
+ expIdBuilder.setExperimenter(new ExperimenterId(42L));\r
+ builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build());\r
+ MatchEntries entry = builder.build();\r
+ MessageTypeKey<?> key = keyMaker.make(entry);\r
+\r
+ Assert.assertNotNull("Null key", key);\r
+ MatchEntrySerializerKey<?, ?> comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,\r
+ ExperimenterClass.class, OxmMatchFieldClass.class);\r
+ comparationKey.setExperimenterId(42L);\r
+ Assert.assertEquals("Wrong key", comparationKey, key);\r
+ }\r
+\r
+ private class ActionSubtypeClass extends ExperimenterActionSubType {\r
+ // only for testing purposes\r
+ }\r
+\r
+ private class OxmMatchFieldClass extends MatchField {\r
+ // only for testing purposes\r
+ }\r
+}
\ No newline at end of file