-/*\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
+/*
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.openflowjava.protocol.impl.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterInstructionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdInstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.experimenter.id._case.ExperimenterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.GotoTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ExperimenterClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;
+
+/**
+ * @author michal.polkorab
+ *
+ */
+public class TypeKeyMakerFactoryTest {
+
+ /**
+ * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)}
+ */
+ @Test
+ public void testActionKeyMaker() {
+ TypeKeyMaker<Action> keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ Assert.assertNotNull("Null keyMaker", keyMaker);
+
+ ActionBuilder builder = new ActionBuilder();
+ builder.setActionChoice(new OutputActionCaseBuilder().build());
+ Action action = builder.build();
+ MessageTypeKey<?> key = keyMaker.make(action);
+
+ Assert.assertNotNull("Null key", key);
+ Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ OutputActionCase.class, null), key);
+ }
+
+ /**
+ * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)}
+ */
+ @Test
+ public void testExperimenterActionKeyMaker() {
+ TypeKeyMaker<Action> keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ Assert.assertNotNull("Null keyMaker", keyMaker);
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder builder = new ActionBuilder();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice
+ .ExperimenterIdCaseBuilder caseBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments
+ .rev150225.action.container.action.choice.ExperimenterIdCaseBuilder();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.action.container.action.choice
+ .experimenter.id._case.ExperimenterBuilder expIdBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight
+ .openflow.augments.rev150225.action.container.action.choice.experimenter.id._case.ExperimenterBuilder();
+ expIdBuilder.setExperimenter(new ExperimenterId(42L));
+ expIdBuilder.setSubType(ActionSubtypeClass.class);
+ caseBuilder.setExperimenter(expIdBuilder.build());
+ builder.setActionChoice(caseBuilder.build());
+ Action action = builder.build();
+ MessageTypeKey<?> key = keyMaker.make(action);
+
+ Assert.assertNotNull("Null key", key);
+ Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L,
+ ActionSubtypeClass.class), key);
+ }
+
+ /**
+ * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)}
+ */
+ @Test
+ public void testInstructionKeyMaker() {
+ TypeKeyMaker<Instruction> keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ Assert.assertNotNull("Null keyMaker", keyMaker);
+
+ InstructionBuilder builder = new InstructionBuilder();
+ builder.setType(GotoTable.class);
+ Instruction instruction = builder.build();
+ MessageTypeKey<?> key = keyMaker.make(instruction);
+
+ Assert.assertNotNull("Null key", key);
+ Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ GotoTable.class, null), key);
+ }
+
+ /**
+ * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)}
+ */
+ @Test
+ public void testExperimenterInstructionKeyMaker() {
+ TypeKeyMaker<Instruction> keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ Assert.assertNotNull("Null keyMaker", keyMaker);
+
+ InstructionBuilder builder = new InstructionBuilder();
+ builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
+ .common.instruction.rev130731.Experimenter.class);
+ ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder();
+ expIdBuilder.setExperimenter(new ExperimenterId(42L));
+ builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build());
+ Instruction instruction = builder.build();
+ MessageTypeKey<?> key = keyMaker.make(instruction);
+
+ Assert.assertNotNull("Null key", key);
+ Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID,
+ 42L), key);
+ }
+
+ /**
+ * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)}
+ */
+ @Test
+ public void testMatchEntriesKeyMaker() {
+ TypeKeyMaker<MatchEntry> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ Assert.assertNotNull("Null keyMaker", keyMaker);
+
+ MatchEntryBuilder builder = new MatchEntryBuilder();
+ builder.setOxmClass(OpenflowBasicClass.class);
+ builder.setOxmMatchField(InPort.class);
+ builder.setHasMask(true);
+ MatchEntry entry = builder.build();
+ MessageTypeKey<?> key = keyMaker.make(entry);
+
+ Assert.assertNotNull("Null key", key);
+ MatchEntrySerializerKey<?, ?> comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ OpenflowBasicClass.class, InPort.class);
+ Assert.assertEquals("Wrong key", comparationKey, key);
+ }
+
+ /**
+ * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)}
+ */
+ @Test
+ public void testExperimenterMatchEntriesKeyMaker() {
+ TypeKeyMaker<MatchEntry> keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ Assert.assertNotNull("Null keyMaker", keyMaker);
+
+ MatchEntryBuilder builder = new MatchEntryBuilder();
+ builder.setOxmClass(ExperimenterClass.class);
+ builder.setOxmMatchField(OxmMatchFieldClass.class);
+ builder.setHasMask(true);
+ ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
+ ExperimenterBuilder expBuilder = new ExperimenterBuilder();
+ expBuilder.setExperimenter(new ExperimenterId(42L));
+ caseBuilder.setExperimenter(expBuilder.build());
+ builder.setMatchEntryValue(caseBuilder.build());
+ MatchEntry entry = builder.build();
+ MessageTypeKey<?> key = keyMaker.make(entry);
+
+ Assert.assertNotNull("Null key", key);
+ MatchEntrySerializerKey<?, ?> comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID,
+ ExperimenterClass.class, OxmMatchFieldClass.class);
+ comparationKey.setExperimenterId(42L);
+ Assert.assertEquals("Wrong key", comparationKey, key);
+ }
+
+ private class ActionSubtypeClass extends ExperimenterActionSubType {
+ // only for testing purposes
+ }
+
+ private class OxmMatchFieldClass extends MatchField {
+ // only for testing purposes
+ }
}
\ No newline at end of file