* @param data convertor data
* @return the result (can be empty, if no convertor was found)
*/
- <F, T, D extends ConvertorData> Optional<T> convert(final F source, final D data);
+ <F, T, D extends ConvertorData> Optional<T> convert(F source, D data);
/**
* Lookup and use convertor by specified type, then converts source collection and returns converted result.
* @param data convertor data
* @return the result (can be empty, if no convertor was found)
*/
- <F, T, D extends ConvertorData> Optional<T> convert(final Collection<F> source, final D data);
+ <F, T, D extends ConvertorData> Optional<T> convert(Collection<F> source, D data);
}
*
* @param convertor the convertor
*/
- ConvertorManager registerConvertor(final short version, final Convertor<?, ?, ? extends ConvertorData> convertor);
-}
\ No newline at end of file
+ ConvertorManager registerConvertor(short version, Convertor<?, ?, ? extends ConvertorData> convertor);
+}
}
private interface ActionExecutor {
- void execute(final TableFeatureProperties property, final TableFeaturePropertiesBuilder propBuilder);
+ void execute(TableFeatureProperties property, TableFeaturePropertiesBuilder propBuilder);
}
}
* @param convertorExecutor convertor executor
* @return the optional
*/
- public abstract Optional<T> process(@Nonnull final F source, final D data,
- final ConvertorExecutor convertorExecutor);
+ public abstract Optional<T> process(@Nonnull F source, D data, ConvertorExecutor convertorExecutor);
/**
* Should {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorProcessor}
- * throw error when result of process method is empty?
+ * throw error when result of process method is empty.
*
* @return the boolean
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@Before
public void setup() {
OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterProvider);
- when(extensionConverterProvider.getActionConverter(any(MessageTypeKey.class))).thenReturn((ConvertorActionFromOFJava<DataContainer, AugmentationPath>) (input, path) -> new MockAction());
+ when(extensionConverterProvider.getActionConverter(any(MessageTypeKey.class)))
+ .thenReturn((ConvertorActionFromOFJava<DataContainer, AugmentationPath>) (input, path) -> new MockAction());
}
@Test
- /**
- * Trivial test for {@link ActionExtensionHelper#processAlienAction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action, org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion, org.opendaylight.openflowplugin.extension.api.path.ActionPath)}
- */
public void testProcessAlienAction() {
ActionBuilder actionBuilder = new ActionBuilder();
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.keys.ExperimenterActionSerializerKey;
+import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
+import org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey;
import org.opendaylight.openflowplugin.extension.api.ConvertorActionFromOFJava;
import org.opendaylight.openflowplugin.extension.api.ConvertorActionToOFJava;
+import org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava;
import org.opendaylight.openflowplugin.extension.api.TypeVersionKey;
import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType;
/**
- * {@link ExtensionConverterManagerImpl} test
+ * {@link ExtensionConverterManagerImpl} test.
*/
@RunWith(MockitoJUnitRunner.class)
public class ExtensionConverterManagerImplTest {
private ExtensionConverterManagerImpl manager;
@Mock
- private ConvertorActionToOFJava<Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> extConvertorToOFJava;
+ private ConvertorActionToOFJava<Action, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action
+ .rev150203.actions.grouping.Action> extConvertorToOFJava;
private TypeVersionKey<? extends Action> keyToOFJava;
@Mock
- private ConvertorActionFromOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action, ActionPath> extConvertorFromOFJava;
+ private ConvertorActionFromOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203
+ .actions.grouping.Action, ActionPath> extConvertorFromOFJava;
private ExperimenterActionSerializerKey keyFromOFJava;
private AutoCloseable regFromOFJava;
private AutoCloseable regToOFJava;
/**
- * prepare required stuff
+ * prepare required stuff.
*/
@Before
public void setUp() {
}
/**
- * tear down test case - close registrations
- *
- * @throws Exception
+ * tear down test case - close registrations.
*/
@After
public void tearDown() throws Exception {
}
/**
- * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl#unregister(org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey, org.opendaylight.openflowplugin.extension.api.ConvertorToOFJava)}.
- *
- * @throws Exception
+ * Test method for ExtensionConverterManagerImpl#unregister(ConverterExtensionKey, ConvertorToOFJava)}.
*/
@Test
public void testUnregisterConverterExtensionKeyOfQConvertorToOFJavaOfQQ() throws Exception {
}
/**
- * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl#unregister(org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey, org.opendaylight.openflowplugin.extension.api.ConvertorFromOFJava)}.
- *
- * @throws Exception
+ * Test method for {@link ExtensionConverterManagerImpl#unregister(MessageTypeKey, ConvertorFromOFJava)}.
*/
@Test
public void testUnregisterMessageTypeKeyOfQConvertorFromOFJavaOfQQ() throws Exception {
}
/**
- * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl#getConverter(org.opendaylight.openflowplugin.extension.api.ConverterExtensionKey)}.
+ * Test method for {@link ExtensionConverterManagerImpl#getConverter(ConverterExtensionKey)}.
*/
@Test
public void testGetConverterConverterExtensionKeyOfQ() {
}
/**
- * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.extension.ExtensionConverterManagerImpl#getConverter(org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey)}.
+ * Test method for {@link ExtensionConverterManagerImpl#getConverter(MessageTypeKey)}.
*/
@Test
public void testGetConverterMessageTypeKeyOfQ() {
// NOOP
}
- private static interface ActionExpCase extends Action {
+ private interface ActionExpCase extends Action {
// NOOP
}
@Mock
private ExtensionConverterProvider extensionConverterProvider;
private static final int PRESET_COUNT = 7;
- private static final MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> key = new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField.class);
+ private static final MatchEntrySerializerKey<? extends OxmClassBase, ? extends MatchField> KEY =
+ new MatchEntrySerializerKey<>(OpenflowVersion.OF13.getVersion(), MockOxmClassBase.class, MockMatchField.class);
@Before
public void setup() {
OFSessionUtil.getSessionManager().setExtensionConverterProvider(extensionConverterProvider);
- when(extensionConverterProvider.getConverter(key)).thenReturn((ConvertorFromOFJava<DataContainer, AugmentationPath>) (input, path) -> {
- MockAugmentation mockAugmentation = new MockAugmentation();
- return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey.class);
- });
+ when(extensionConverterProvider.getConverter(KEY))
+ .thenReturn((ConvertorFromOFJava<DataContainer, AugmentationPath>) (input, path) -> {
+ MockAugmentation mockAugmentation = new MockAugmentation();
+ return new ExtensionAugment<>(MockAugmentation.class, mockAugmentation, MockExtensionKey.class);
+ });
}
@Test
/**
- * Basic functionality test method for {@link org.opendaylight.openflowplugin.openflow.md.core.extension.MatchExtensionHelper#processAllExtensions(java.util.Collection, org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion, org.opendaylight.openflowplugin.extension.api.path.MatchPath)}
+ * Basic functionality test method for {@link MatchExtensionHelper#processAllExtensions(Collection,
+ * OpenflowVersion, MatchPath)}.
*/
public void testProcessAllExtensions() {
private static List<MatchEntry> createMatchEntrieses() {
List<MatchEntry> matchEntries = new ArrayList<>();
for (int i = 0; i < PRESET_COUNT; i++) {
- MatchEntryBuilder MatchEntryBuilder = new MatchEntryBuilder();
- MatchEntryBuilder.setHasMask(true);
- MatchEntryBuilder.setOxmClass(MockOxmClassBase.class);
- MatchEntryBuilder.setOxmMatchField(MockMatchField.class);
- matchEntries.add(MatchEntryBuilder.build());
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+ matchEntryBuilder.setHasMask(true);
+ matchEntryBuilder.setOxmClass(MockOxmClassBase.class);
+ matchEntryBuilder.setOxmMatchField(MockMatchField.class);
+ matchEntries.add(matchEntryBuilder.build());
}
return matchEntries;
}
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.Convertor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
/**
- * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}
+ * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager}.
*/
@RunWith(MockitoJUnitRunner.class)
public class ConvertorManagerTest {
}
/**
- * Test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager#convert(java.util.Collection, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.ConvertorData)}
- * @throws Exception
+ * Test for {@link ConvertorManager#convert(Collection, ConvertorData)}.
*/
@Test
public void testConvert1() throws Exception {
final ConvertorManager convertorManager = new ConvertorManager(OFConstants.OFP_VERSION_1_3)
- .registerConvertor(OFConstants.OFP_VERSION_1_3, new Convertor<List<Action>, String, VersionConvertorData>() {
+ .registerConvertor(OFConstants.OFP_VERSION_1_3,
+ new Convertor<List<Action>, String, VersionConvertorData>() {
@Override
public Collection<Class<?>> getTypes() {
return Collections.singleton(Action.class);
assertTrue("Failed to convert action to string", result.isPresent());
assertEquals("Result and expected result do not match", result.get(), expectedResult);
}
-}
\ No newline at end of file
+}
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.ImmutableList;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
}
/**
- * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
+ * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorwithallParameters() {
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupAll);
- final List<Bucket> bucketList = new ArrayList<Bucket>();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>();
+ final List<Bucket> bucketList = new ArrayList<>();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ actionsList = new ArrayList<>();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ actionsList1 = new ArrayList<>();
int actionOrder = 0;
groupActionBuilder1.setGroup("006");
final GroupAction groupIdaction1 = groupActionBuilder.build();
final ActionBuilder actionsB1 = new ActionBuilder();
- actionsB1.setOrder(actionOrder++).setAction(new GroupActionCaseBuilder().setGroupAction(groupIdaction1).build());
+ actionsB1.setOrder(actionOrder++).setAction(new GroupActionCaseBuilder()
+ .setGroupAction(groupIdaction1).build());
actionsList.add(actionsB.build());
actionsList.add(actionsB1.build());
final SetMplsTtlAction setMAction = setMplsTtlActionBuilder.build();
final ActionBuilder actionsB3 = new ActionBuilder();
- actionsB3.setOrder(actionOrder++).setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMAction).build());
+ actionsB3.setOrder(actionOrder++).setAction(new SetMplsTtlActionCaseBuilder()
+ .setSetMplsTtlAction(setMAction).build());
actionsList1.add(actionsB2.build());
final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
- Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
- Assert.assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
+ assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
+ assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
- Assert.assertEquals(10L, (long) outAddGroupInput.getGroupId().getValue());
- Assert.assertEquals(10, (int) outAddGroupInput.getBucketsList().get(0).getWeight());
- Assert.assertEquals(20L, (long) outAddGroupInput.getBucketsList().get(0).getWatchPort().getValue());
- Assert.assertEquals((Long) 22L, outAddGroupInput.getBucketsList().get(0).getWatchGroup());
+ assertEquals(10L, (long) outAddGroupInput.getGroupId().getValue());
+ assertEquals(10, (int) outAddGroupInput.getBucketsList().get(0).getWeight());
+ assertEquals(20L, (long) outAddGroupInput.getBucketsList().get(0).getWatchPort().getValue());
+ assertEquals((Long) 22L, outAddGroupInput.getBucketsList().get(0).getWatchGroup());
final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
for (int outItem = 0; outItem < outActionList.size(); outItem++) {
final Action action = outActionList
.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
- Assert.assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
+ assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
// TODO:setMplsTTL :OF layer doesnt have get();
}
- Assert.assertEquals((Integer) 50, outAddGroupInput.getBucketsList().get(1).getWeight());
- Assert.assertEquals((long) 60, (long) outAddGroupInput.getBucketsList().get(1).getWatchPort().getValue());
- Assert.assertEquals((Long) 70L, outAddGroupInput.getBucketsList().get(1).getWatchGroup());
+ assertEquals((Integer) 50, outAddGroupInput.getBucketsList().get(1).getWeight());
+ assertEquals((long) 60, (long) outAddGroupInput.getBucketsList().get(1).getWatchPort().getValue());
+ assertEquals((Long) 70L, outAddGroupInput.getBucketsList().get(1).getWatchGroup());
final List<Action> outActionList1 = outAddGroupInput.getBucketsList().get(1).getAction();
for (int outItem = 0; outItem < outActionList1.size(); outItem++) {
final Action action = outActionList1
.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
- Assert.assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
+ assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
}
/**
- * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
+ * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorNoBucket() {
data.setDatapathId(BigInteger.valueOf(1));
final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
- Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
- Assert.assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
+ assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
+ assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
}
/**
- * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
+ * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupFf);
- final List<Bucket> bucketList = new ArrayList<Bucket>();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>();
+ final List<Bucket> bucketList = new ArrayList<>();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ actionsList = new ArrayList<>();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ actionsList1 = new ArrayList<>();
// Action1: 005
actionsList.add(assembleActionBuilder("005", actionOrder++).build());
final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
- Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
- Assert.assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
+ assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
+ assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
- Assert.assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
+ assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
for (int outItem = 0; outItem < outActionList.size(); outItem++) {
final Action action = outActionList
.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
- Assert.assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
+ assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
}
final Action action = outActionList1
.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
- Assert.assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
+ assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
}
}
/**
- * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
+ * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertSortedBuckets() {
final int actionOrder = 0;
- final ArrayList<Bucket> bucket = new ArrayList<Bucket>();
+ final ArrayList<Bucket> bucket = new ArrayList<>();
bucket.add(new BucketBuilder()
.setBucketId(new BucketId((long) 4))
final GroupModInputBuilder outAddGroupInput = convert(input, data);
final List<BucketsList> bucketList = outAddGroupInput.getBucketsList();
- Assert.assertEquals( Long.valueOf(1), bucketList.get(0).getWatchGroup());
- Assert.assertEquals( Long.valueOf(3), bucketList.get(0).getWatchPort().getValue());
-
- Assert.assertEquals( Long.valueOf(1), bucketList.get(1).getWatchGroup());
- Assert.assertEquals( Long.valueOf(4), bucketList.get(1).getWatchPort().getValue());
+ assertEquals(Long.valueOf(1), bucketList.get(0).getWatchGroup());
+ assertEquals(Long.valueOf(3), bucketList.get(0).getWatchPort().getValue());
- Assert.assertEquals( Long.valueOf(1), bucketList.get(2).getWatchGroup());
- Assert.assertEquals( Long.valueOf(5), bucketList.get(2).getWatchPort().getValue());
+ assertEquals(Long.valueOf(1), bucketList.get(1).getWatchGroup());
+ assertEquals(Long.valueOf(4), bucketList.get(1).getWatchPort().getValue());
- Assert.assertEquals( Long.valueOf(1), bucketList.get(3).getWatchGroup());
- Assert.assertEquals( Long.valueOf(6), bucketList.get(3).getWatchPort().getValue());
+ assertEquals(Long.valueOf(1), bucketList.get(2).getWatchGroup());
+ assertEquals(Long.valueOf(5), bucketList.get(2).getWatchPort().getValue());
- Assert.assertEquals( Long.valueOf(1), bucketList.get(4).getWatchGroup());
- Assert.assertEquals( Long.valueOf(2), bucketList.get(4).getWatchPort().getValue());
+ assertEquals(Long.valueOf(1), bucketList.get(3).getWatchGroup());
+ assertEquals(Long.valueOf(6), bucketList.get(3).getWatchPort().getValue());
+ assertEquals(Long.valueOf(1), bucketList.get(4).getWatchGroup());
+ assertEquals(Long.valueOf(2), bucketList.get(4).getWatchPort().getValue());
}
- /**
- * @return
- */
private static ActionBuilder assembleSetMplsTtlActionBuilder(final int actionOrder) {
final SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
setMplsTtlActionBuilder.setMplsTtl((short) 0X1);
return actionsB3;
}
- /**
- * @return
- */
private static ActionBuilder assembleCopyTtlInBuilder(final int actionOrder) {
final CopyTtlInBuilder copyTtlB = new CopyTtlInBuilder();
final CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder();
return actionsB2;
}
- /**
- * @param groupName name of group
- * @return
- */
private static ActionBuilder assembleActionBuilder(final String groupName, final int actionOrder) {
final GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
groupActionBuilder.setGroup(groupName);
}
/**
- * test of {@link GroupConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.Group, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }
+ * test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeAll() {
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupAll);
- final List<Bucket> bucketList = new ArrayList<Bucket>();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>();
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>();
+ final List<Bucket> bucketList = new ArrayList<>();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ actionsList = new ArrayList<>();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ actionsList1 = new ArrayList<>();
// Action1
actionsList.add(assembleActionBuilder("005", actionOrder++).build());
final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
- Assert.assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
- Assert.assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
+ assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
+ assertEquals(GroupType.OFPGTALL, outAddGroupInput.getType());
- Assert.assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
+ assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
for (int outItem = 0; outItem < outActionList.size(); outItem++) {
final Action action = outActionList
.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
- Assert.assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
+ assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
- Assert.assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
+ assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
private GroupModInputBuilder convert(Group group, VersionDatapathIdConvertorData data) {
final Optional<GroupModInputBuilder> outAddGroupInputOptional = convertorManager.convert(group, data);
- Assert.assertTrue("Group convertor not found", outAddGroupInputOptional.isPresent());
+ assertTrue("Group convertor not found", outAddGroupInputOptional.isPresent());
return outAddGroupInputOptional.get();
}
}
-/*\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.openflowplugin.openflow.md.core.sal.convertor;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Optional;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.OFConstants;\r
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class GroupDescStatsResponseConvertorTest {\r
- private ConvertorManager convertorManager;\r
-\r
- @Before\r
- public void setUp() {\r
- convertorManager = ConvertorManagerFactory.createDefaultManager();\r
- }\r
-\r
- /**\r
- * Test empty GroupDescStats conversion\r
- */\r
- @Test\r
- public void test() {\r
- List<GroupDesc> groupDescStats = new ArrayList<>();\r
-\r
- VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);\r
- List<GroupDescStats> statsList = convert(groupDescStats, data);\r
- Assert.assertEquals("Wrong groupDesc stats size", 0, statsList.size());\r
- }\r
-\r
- /**\r
- * Test single GroupDescStat conversion without buckets\r
- */\r
- @Test\r
- public void testSingleGroupDescStat() {\r
- List<GroupDesc> groupDescStats = new ArrayList<>();\r
- GroupDescBuilder builder = new GroupDescBuilder();\r
- builder.setType(GroupType.OFPGTALL);\r
- builder.setGroupId(new GroupId(42L));\r
- builder.setBucketsList(new ArrayList<>());\r
- groupDescStats.add(builder.build());\r
-\r
- VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);\r
- List<GroupDescStats> statsList = convert(groupDescStats, data);\r
-\r
- Assert.assertEquals("Wrong groupDesc stats size", 1, statsList.size());\r
- GroupDescStats stat = statsList.get(0);\r
- Assert.assertEquals("Wrong type", GroupTypes.GroupAll, stat.getGroupType());\r
- Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong buckets size", 0, stat.getBuckets().getBucket().size());\r
- }\r
-\r
- /**\r
- * Test single GroupDescStats conversion\r
- */\r
- @Test\r
- public void testGroupDescStats() {\r
- List<GroupDesc> groupDescStats = new ArrayList<>();\r
-\r
- // **********************************************\r
- // First group desc\r
- // **********************************************\r
- GroupDescBuilder builder = new GroupDescBuilder();\r
- builder.setType(GroupType.OFPGTFF);\r
- builder.setGroupId(new GroupId(42L));\r
-\r
- // Buckets for first group desc\r
- List<BucketsList> bucketsList = new ArrayList<>();\r
- BucketsListBuilder bucketsBuilder = new BucketsListBuilder();\r
- bucketsBuilder.setWeight(16);\r
- bucketsBuilder.setWatchPort(new PortNumber(84L));\r
- bucketsBuilder.setWatchGroup(168L);\r
-\r
- // Actions for buckets for first group desc\r
- List<Action> actions = new ArrayList<>();\r
- ActionBuilder actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());\r
- actions.add(actionBuilder.build());\r
-\r
- // Build bucket with actions\r
- bucketsBuilder.setAction(actions);\r
- bucketsList.add(bucketsBuilder.build());\r
-\r
- // Build first group desc\r
- builder.setBucketsList(bucketsList);\r
- groupDescStats.add(builder.build());\r
-\r
- // **********************************************\r
- // Second group desc\r
- // **********************************************\r
- builder = new GroupDescBuilder();\r
- builder.setType(GroupType.OFPGTINDIRECT);\r
- builder.setGroupId(new GroupId(50L));\r
-\r
- // First buckets for second group desc\r
- bucketsList = new ArrayList<>();\r
- bucketsBuilder = new BucketsListBuilder();\r
- bucketsBuilder.setWeight(100);\r
- bucketsBuilder.setWatchPort(new PortNumber(200L));\r
- bucketsBuilder.setWatchGroup(400L);\r
-\r
- // Actions for first buckets for second group desc\r
- actions = new ArrayList<>();\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());\r
- actions.add(actionBuilder.build());\r
-\r
- // Build first bucket with actions\r
- bucketsBuilder.setAction(actions);\r
- bucketsList.add(bucketsBuilder.build());\r
-\r
- // Second buckets for second group desc\r
- bucketsBuilder = new BucketsListBuilder();\r
- bucketsBuilder.setWeight(5);\r
- bucketsBuilder.setWatchPort(new PortNumber(10L));\r
- bucketsBuilder.setWatchGroup(15L);\r
-\r
- // Actions for second buckets for second group desc\r
- actions = new ArrayList<>();\r
-\r
- // Build second bucket with actions\r
- bucketsBuilder.setAction(actions);\r
- bucketsList.add(bucketsBuilder.build());\r
-\r
- // Build second group desc\r
- builder.setBucketsList(bucketsList);\r
- groupDescStats.add(builder.build());\r
-\r
-\r
- VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);\r
- List<GroupDescStats> statsList = convert(groupDescStats, data);\r
- Assert.assertEquals("Wrong groupDesc stats size", 2, statsList.size());\r
-\r
- // **********************************************\r
- // Test first group desc\r
- // **********************************************\r
- GroupDescStats stat = statsList.get(0);\r
- Assert.assertEquals("Wrong type", GroupTypes.GroupFf, stat.getGroupType());\r
- Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().getBucket().size());\r
-\r
- // Test first bucket for first group desc\r
- Bucket bucket = stat.getBuckets().getBucket().get(0);\r
- Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong type", 16, bucket.getWeight().intValue());\r
- Assert.assertEquals("Wrong type", 168, bucket.getWatchGroup().intValue());\r
- Assert.assertEquals("Wrong type", 84, bucket.getWatchPort().intValue());\r
- Assert.assertEquals("Wrong type", 1, bucket.getAction().size());\r
-\r
- // Test first action for first bucket for first group desc\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list\r
- .Action action = bucket.getAction().get(0);\r
- Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
- + ".action.action.CopyTtlInCase", action.getAction().getImplementedInterface().getName());\r
-\r
- // **********************************************\r
- // Test second group desc\r
- // **********************************************\r
- stat = statsList.get(1);\r
- Assert.assertEquals("Wrong type", GroupTypes.GroupIndirect, stat.getGroupType());\r
- Assert.assertEquals("Wrong group-id", 50, stat.getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong key", 50, stat.getKey().getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().getBucket().size());\r
-\r
- // Test first bucket for second group desc\r
- bucket = stat.getBuckets().getBucket().get(0);\r
- Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong type", 100, bucket.getWeight().intValue());\r
- Assert.assertEquals("Wrong type", 400, bucket.getWatchGroup().intValue());\r
- Assert.assertEquals("Wrong type", 200, bucket.getWatchPort().intValue());\r
- Assert.assertEquals("Wrong type", 3, bucket.getAction().size());\r
-\r
- // Test first action for first bucket of second group desc\r
- action = bucket.getAction().get(0);\r
- Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
- + ".action.action.CopyTtlOutCase", action.getAction().getImplementedInterface().getName());\r
-\r
- // Test second action for first bucket of second group desc\r
- action = bucket.getAction().get(1);\r
- Assert.assertEquals("Wrong type", 1, action.getOrder().intValue());\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
- + ".action.action.DecNwTtlCase", action.getAction().getImplementedInterface().getName());\r
-\r
- // Test third action for first bucket of second group desc\r
- action = bucket.getAction().get(2);\r
- Assert.assertEquals("Wrong type", 2, action.getOrder().intValue());\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"\r
- + ".action.action.PopPbbActionCase", action.getAction().getImplementedInterface().getName());\r
-\r
- // Test second bucket for second group desc\r
- bucket = stat.getBuckets().getBucket().get(1);\r
- Assert.assertEquals("Wrong type", 1, bucket.getKey().getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong type", 1, bucket.getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong type", 5, bucket.getWeight().intValue());\r
- Assert.assertEquals("Wrong type", 15, bucket.getWatchGroup().intValue());\r
- Assert.assertEquals("Wrong type", 10, bucket.getWatchPort().intValue());\r
- Assert.assertEquals("Wrong type", 0, bucket.getAction().size());\r
- }\r
-\r
- private List<GroupDescStats> convert(List<GroupDesc> groupDescStats,VersionConvertorData data) {\r
- Optional<List<GroupDescStats>> statsListOptional = convertorManager.convert(groupDescStats, data);\r
- return statsListOptional.orElse(Collections.emptyList());\r
- }\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.openflowplugin.openflow.md.core.sal.convertor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopPbbCaseBuilder;
+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.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDesc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.multipart.reply.group.desc.GroupDescBuilder;
+
+/**
+ * Unit tests for GroupDescStats conversion.
+ *
+ * @author michal.polkorab
+ */
+public class GroupDescStatsResponseConvertorTest {
+ private ConvertorManager convertorManager;
+
+ @Before
+ public void setUp() {
+ convertorManager = ConvertorManagerFactory.createDefaultManager();
+ }
+
+ /**
+ * Test empty GroupDescStats conversion.
+ */
+ @Test
+ public void test() {
+ List<GroupDesc> groupDescStats = new ArrayList<>();
+
+ VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
+ List<GroupDescStats> statsList = convert(groupDescStats, data);
+ Assert.assertEquals("Wrong groupDesc stats size", 0, statsList.size());
+ }
+
+ /**
+ * Test single GroupDescStat conversion without buckets.
+ */
+ @Test
+ public void testSingleGroupDescStat() {
+ GroupDescBuilder builder = new GroupDescBuilder();
+ builder.setType(GroupType.OFPGTALL);
+ builder.setGroupId(new GroupId(42L));
+ builder.setBucketsList(new ArrayList<>());
+ List<GroupDesc> groupDescStats = new ArrayList<>();
+ groupDescStats.add(builder.build());
+
+ VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
+ List<GroupDescStats> statsList = convert(groupDescStats, data);
+
+ Assert.assertEquals("Wrong groupDesc stats size", 1, statsList.size());
+ GroupDescStats stat = statsList.get(0);
+ Assert.assertEquals("Wrong type", GroupTypes.GroupAll, stat.getGroupType());
+ Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong buckets size", 0, stat.getBuckets().getBucket().size());
+ }
+
+ /**
+ * Test single GroupDescStats conversion.
+ */
+ @Test
+ public void testGroupDescStats() {
+
+ // **********************************************
+ // First group desc
+ // **********************************************
+ GroupDescBuilder builder = new GroupDescBuilder();
+ builder.setType(GroupType.OFPGTFF);
+ builder.setGroupId(new GroupId(42L));
+
+ // Buckets for first group desc
+ BucketsListBuilder bucketsBuilder = new BucketsListBuilder();
+ bucketsBuilder.setWeight(16);
+ bucketsBuilder.setWatchPort(new PortNumber(84L));
+ bucketsBuilder.setWatchGroup(168L);
+
+ // Actions for buckets for first group desc
+ List<Action> actions = new ArrayList<>();
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
+ actions.add(actionBuilder.build());
+
+ // Build bucket with actions
+ bucketsBuilder.setAction(actions);
+ List<BucketsList> bucketsList = new ArrayList<>();
+ bucketsList.add(bucketsBuilder.build());
+
+ // Build first group desc
+ builder.setBucketsList(bucketsList);
+ List<GroupDesc> groupDescStats = new ArrayList<>();
+ groupDescStats.add(builder.build());
+
+ // **********************************************
+ // Second group desc
+ // **********************************************
+ builder = new GroupDescBuilder();
+ builder.setType(GroupType.OFPGTINDIRECT);
+ builder.setGroupId(new GroupId(50L));
+
+ // First buckets for second group desc
+ bucketsList = new ArrayList<>();
+ bucketsBuilder = new BucketsListBuilder();
+ bucketsBuilder.setWeight(100);
+ bucketsBuilder.setWatchPort(new PortNumber(200L));
+ bucketsBuilder.setWatchGroup(400L);
+
+ // Actions for first buckets for second group desc
+ actions = new ArrayList<>();
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
+ actions.add(actionBuilder.build());
+
+ // Build first bucket with actions
+ bucketsBuilder.setAction(actions);
+ bucketsList.add(bucketsBuilder.build());
+
+ // Second buckets for second group desc
+ bucketsBuilder = new BucketsListBuilder();
+ bucketsBuilder.setWeight(5);
+ bucketsBuilder.setWatchPort(new PortNumber(10L));
+ bucketsBuilder.setWatchGroup(15L);
+
+ // Actions for second buckets for second group desc
+ actions = new ArrayList<>();
+
+ // Build second bucket with actions
+ bucketsBuilder.setAction(actions);
+ bucketsList.add(bucketsBuilder.build());
+
+ // Build second group desc
+ builder.setBucketsList(bucketsList);
+ groupDescStats.add(builder.build());
+
+
+ VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
+ List<GroupDescStats> statsList = convert(groupDescStats, data);
+ Assert.assertEquals("Wrong groupDesc stats size", 2, statsList.size());
+
+ // **********************************************
+ // Test first group desc
+ // **********************************************
+ GroupDescStats stat = statsList.get(0);
+ Assert.assertEquals("Wrong type", GroupTypes.GroupFf, stat.getGroupType());
+ Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong buckets size", 1, stat.getBuckets().getBucket().size());
+
+ // Test first bucket for first group desc
+ Bucket bucket = stat.getBuckets().getBucket().get(0);
+ Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong type", 16, bucket.getWeight().intValue());
+ Assert.assertEquals("Wrong type", 168, bucket.getWatchGroup().intValue());
+ Assert.assertEquals("Wrong type", 84, bucket.getWatchPort().intValue());
+ Assert.assertEquals("Wrong type", 1, bucket.getAction().size());
+
+ // Test first action for first bucket for first group desc
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
+ .Action action = bucket.getAction().get(0);
+ Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ + ".action.action.CopyTtlInCase", action.getAction().getImplementedInterface().getName());
+
+ // **********************************************
+ // Test second group desc
+ // **********************************************
+ stat = statsList.get(1);
+ Assert.assertEquals("Wrong type", GroupTypes.GroupIndirect, stat.getGroupType());
+ Assert.assertEquals("Wrong group-id", 50, stat.getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong key", 50, stat.getKey().getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong buckets size", 2, stat.getBuckets().getBucket().size());
+
+ // Test first bucket for second group desc
+ bucket = stat.getBuckets().getBucket().get(0);
+ Assert.assertEquals("Wrong type", 0, bucket.getKey().getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong type", 0, bucket.getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong type", 100, bucket.getWeight().intValue());
+ Assert.assertEquals("Wrong type", 400, bucket.getWatchGroup().intValue());
+ Assert.assertEquals("Wrong type", 200, bucket.getWatchPort().intValue());
+ Assert.assertEquals("Wrong type", 3, bucket.getAction().size());
+
+ // Test first action for first bucket of second group desc
+ action = bucket.getAction().get(0);
+ Assert.assertEquals("Wrong type", 0, action.getOrder().intValue());
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ + ".action.action.CopyTtlOutCase", action.getAction().getImplementedInterface().getName());
+
+ // Test second action for first bucket of second group desc
+ action = bucket.getAction().get(1);
+ Assert.assertEquals("Wrong type", 1, action.getOrder().intValue());
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ + ".action.action.DecNwTtlCase", action.getAction().getImplementedInterface().getName());
+
+ // Test third action for first bucket of second group desc
+ action = bucket.getAction().get(2);
+ Assert.assertEquals("Wrong type", 2, action.getOrder().intValue());
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112"
+ + ".action.action.PopPbbActionCase", action.getAction().getImplementedInterface().getName());
+
+ // Test second bucket for second group desc
+ bucket = stat.getBuckets().getBucket().get(1);
+ Assert.assertEquals("Wrong type", 1, bucket.getKey().getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong type", 1, bucket.getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong type", 5, bucket.getWeight().intValue());
+ Assert.assertEquals("Wrong type", 15, bucket.getWatchGroup().intValue());
+ Assert.assertEquals("Wrong type", 10, bucket.getWatchPort().intValue());
+ Assert.assertEquals("Wrong type", 0, bucket.getAction().size());
+ }
+
+ private List<GroupDescStats> convert(List<GroupDesc> groupDescStats,VersionConvertorData data) {
+ Optional<List<GroupDescStats>> statsListOptional = convertorManager.convert(groupDescStats, data);
+ return statsListOptional.orElse(Collections.emptyList());
+ }
+}
-/*\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.openflowplugin.openflow.md.core.sal.convertor;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import java.util.Optional;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.OFConstants;\r
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class GroupStatsResponseConvertorTest {\r
- private ConvertorManager convertorManager;\r
-\r
- @Before\r
- public void setUp() {\r
- convertorManager = ConvertorManagerFactory.createDefaultManager();\r
- }\r
-\r
- /**\r
- * Test empty GroupStats conversion\r
- */\r
- @Test\r
- public void testEmptyGroupStats() {\r
- List<GroupStats> groupStats = new ArrayList<>();\r
-\r
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats>> salGroupStats = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
-\r
- Assert.assertFalse("Group stats response should be not present", salGroupStats.isPresent());\r
- }\r
-\r
- /**\r
- * Test single GroupStat conversion\r
- */\r
- @Test\r
- public void testSingleGroupStat() {\r
- List<GroupStats> groupStats = new ArrayList<>();\r
- GroupStatsBuilder statsBuilder = new GroupStatsBuilder();\r
- statsBuilder.setByteCount(new BigInteger("12345"));\r
- statsBuilder.setDurationNsec(1000000L);\r
- statsBuilder.setDurationSec(5000L);\r
- statsBuilder.setGroupId(new GroupId(42L));\r
- statsBuilder.setPacketCount(new BigInteger("54321"));\r
- statsBuilder.setRefCount(24L);\r
- statsBuilder.setBucketStats(new ArrayList<BucketStats>());\r
- groupStats.add(statsBuilder.build());\r
-\r
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
- Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats> salGroupStats = salGroupStatsOptional.get();\r
-\r
- Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats stat = salGroupStats.get(0);\r
- Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());\r
- Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());\r
- Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());\r
- Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());\r
- Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());\r
- }\r
-\r
- /**\r
- * Test two GroupStats conversion\r
- */\r
- @Test\r
- public void testTwoGroupStats() {\r
- List<GroupStats> groupStats = new ArrayList<>();\r
- GroupStatsBuilder statsBuilder = new GroupStatsBuilder();\r
- statsBuilder.setByteCount(new BigInteger("12345"));\r
- statsBuilder.setDurationNsec(1000000L);\r
- statsBuilder.setDurationSec(5000L);\r
- statsBuilder.setGroupId(new GroupId(42L));\r
- statsBuilder.setPacketCount(new BigInteger("54321"));\r
- statsBuilder.setRefCount(24L);\r
- statsBuilder.setBucketStats(new ArrayList<BucketStats>());\r
- groupStats.add(statsBuilder.build());\r
- statsBuilder = new GroupStatsBuilder();\r
- statsBuilder.setByteCount(new BigInteger("1"));\r
- statsBuilder.setDurationNsec(2L);\r
- statsBuilder.setDurationSec(3L);\r
- statsBuilder.setGroupId(new GroupId(4L));\r
- statsBuilder.setPacketCount(new BigInteger("5"));\r
- statsBuilder.setRefCount(6L);\r
- statsBuilder.setBucketStats(new ArrayList<BucketStats>());\r
- groupStats.add(statsBuilder.build());\r
-\r
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
- Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats> salGroupStats = salGroupStatsOptional.get();\r
-\r
- Assert.assertEquals("Wrong group stats size", 2, salGroupStats.size());\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats stat = salGroupStats.get(0);\r
- Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());\r
- Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());\r
- Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());\r
- Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());\r
- Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());\r
- stat = salGroupStats.get(1);\r
- Assert.assertEquals("Wrong group-id", 4, stat.getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong key", 4, stat.getKey().getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong ref-count", 6, stat.getRefCount().getValue().intValue());\r
- Assert.assertEquals("Wrong packet count", 5, stat.getPacketCount().getValue().intValue());\r
- Assert.assertEquals("Wrong byte count", 1, stat.getByteCount().getValue().intValue());\r
- Assert.assertEquals("Wrong duration sec", 3, stat.getDuration().getSecond().getValue().intValue());\r
- Assert.assertEquals("Wrong duration n sec", 2, stat.getDuration().getNanosecond().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());\r
- }\r
-\r
- /**\r
- * Test GroupStats with buckets conversion\r
- */\r
- @Test\r
- public void testGroupStatsWithBuckets() {\r
- List<GroupStats> groupStats = new ArrayList<>();\r
- GroupStatsBuilder statsBuilder = new GroupStatsBuilder();\r
- statsBuilder.setByteCount(new BigInteger("12345"));\r
- statsBuilder.setDurationNsec(1000000L);\r
- statsBuilder.setDurationSec(5000L);\r
- statsBuilder.setGroupId(new GroupId(42L));\r
- statsBuilder.setPacketCount(new BigInteger("54321"));\r
- statsBuilder.setRefCount(24L);\r
- List<BucketStats> bucketStats = new ArrayList<>();\r
- BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();\r
- bucketStatsBuilder.setByteCount(new BigInteger("987"));\r
- bucketStatsBuilder.setPacketCount(new BigInteger("654"));\r
- bucketStats.add(bucketStatsBuilder.build());\r
- bucketStatsBuilder = new BucketStatsBuilder();\r
- bucketStatsBuilder.setByteCount(new BigInteger("123"));\r
- bucketStatsBuilder.setPacketCount(new BigInteger("456"));\r
- bucketStats.add(bucketStatsBuilder.build());\r
- statsBuilder.setBucketStats(bucketStats);\r
- groupStats.add(statsBuilder.build());\r
-\r
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
- Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats> salGroupStats = salGroupStatsOptional.get();\r
-\r
- Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply\r
- .GroupStats stat = salGroupStats.get(0);\r
- Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());\r
- Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());\r
- Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());\r
- Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());\r
- Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());\r
- Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket stats", 2, stat.getBuckets().getBucketCounter().size());\r
- List<BucketCounter> list = stat.getBuckets().getBucketCounter();\r
- Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());\r
- Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());\r
- }\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.openflowplugin.openflow.md.core.sal.convertor;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder;
+
+/**
+ * Unit tests for GroupStats conversion.
+ *
+ * @author michal.polkorab
+ */
+public class GroupStatsResponseConvertorTest {
+ private ConvertorManager convertorManager;
+
+ @Before
+ public void setUp() {
+ convertorManager = ConvertorManagerFactory.createDefaultManager();
+ }
+
+ /**
+ * Test empty GroupStats conversion.
+ */
+ @Test
+ public void testEmptyGroupStats() {
+ List<GroupStats> groupStats = new ArrayList<>();
+
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats>> salGroupStats = convertorManager.convert(groupStats,
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+
+ Assert.assertFalse("Group stats response should be not present", salGroupStats.isPresent());
+ }
+
+ /**
+ * Test single GroupStat conversion.
+ */
+ @Test
+ public void testSingleGroupStat() {
+ GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
+ statsBuilder.setByteCount(new BigInteger("12345"));
+ statsBuilder.setDurationNsec(1000000L);
+ statsBuilder.setDurationSec(5000L);
+ statsBuilder.setGroupId(new GroupId(42L));
+ statsBuilder.setPacketCount(new BigInteger("54321"));
+ statsBuilder.setRefCount(24L);
+ statsBuilder.setBucketStats(new ArrayList<BucketStats>());
+ List<GroupStats> groupStats = new ArrayList<>();
+ groupStats.add(statsBuilder.build());
+
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats,
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats> salGroupStats = salGroupStatsOptional.get();
+
+ Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats stat = salGroupStats.get(0);
+ Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
+ Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
+ Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
+ Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
+ Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
+ }
+
+ /**
+ * Test two GroupStats conversion.
+ */
+ @Test
+ public void testTwoGroupStats() {
+ GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
+ statsBuilder.setByteCount(new BigInteger("12345"));
+ statsBuilder.setDurationNsec(1000000L);
+ statsBuilder.setDurationSec(5000L);
+ statsBuilder.setGroupId(new GroupId(42L));
+ statsBuilder.setPacketCount(new BigInteger("54321"));
+ statsBuilder.setRefCount(24L);
+ statsBuilder.setBucketStats(new ArrayList<BucketStats>());
+
+ List<GroupStats> groupStats = new ArrayList<>();
+ groupStats.add(statsBuilder.build());
+ statsBuilder = new GroupStatsBuilder();
+ statsBuilder.setByteCount(new BigInteger("1"));
+ statsBuilder.setDurationNsec(2L);
+ statsBuilder.setDurationSec(3L);
+ statsBuilder.setGroupId(new GroupId(4L));
+ statsBuilder.setPacketCount(new BigInteger("5"));
+ statsBuilder.setRefCount(6L);
+ statsBuilder.setBucketStats(new ArrayList<BucketStats>());
+ groupStats.add(statsBuilder.build());
+
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats,
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats> salGroupStats = salGroupStatsOptional.get();
+
+ Assert.assertEquals("Wrong group stats size", 2, salGroupStats.size());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats stat = salGroupStats.get(0);
+ Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
+ Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
+ Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
+ Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
+ Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
+ stat = salGroupStats.get(1);
+ Assert.assertEquals("Wrong group-id", 4, stat.getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong key", 4, stat.getKey().getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong ref-count", 6, stat.getRefCount().getValue().intValue());
+ Assert.assertEquals("Wrong packet count", 5, stat.getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong byte count", 1, stat.getByteCount().getValue().intValue());
+ Assert.assertEquals("Wrong duration sec", 3, stat.getDuration().getSecond().getValue().intValue());
+ Assert.assertEquals("Wrong duration n sec", 2, stat.getDuration().getNanosecond().getValue().intValue());
+ Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
+ }
+
+ /**
+ * Test GroupStats with buckets conversion.
+ */
+ @Test
+ public void testGroupStatsWithBuckets() {
+ GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
+ statsBuilder.setByteCount(new BigInteger("12345"));
+ statsBuilder.setDurationNsec(1000000L);
+ statsBuilder.setDurationSec(5000L);
+ statsBuilder.setGroupId(new GroupId(42L));
+ statsBuilder.setPacketCount(new BigInteger("54321"));
+ statsBuilder.setRefCount(24L);
+ List<BucketStats> bucketStats = new ArrayList<>();
+ BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
+ bucketStatsBuilder.setByteCount(new BigInteger("987"));
+ bucketStatsBuilder.setPacketCount(new BigInteger("654"));
+ bucketStats.add(bucketStatsBuilder.build());
+ bucketStatsBuilder = new BucketStatsBuilder();
+ bucketStatsBuilder.setByteCount(new BigInteger("123"));
+ bucketStatsBuilder.setPacketCount(new BigInteger("456"));
+ bucketStats.add(bucketStatsBuilder.build());
+ statsBuilder.setBucketStats(bucketStats);
+
+ List<GroupStats> groupStats = new ArrayList<>();
+ groupStats.add(statsBuilder.build());
+
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats,
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats> salGroupStats = salGroupStatsOptional.get();
+
+ Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply
+ .GroupStats stat = salGroupStats.get(0);
+ Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
+ Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
+ Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
+ Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
+ Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
+ Assert.assertEquals("Wrong bucket stats", 2, stat.getBuckets().getBucketCounter().size());
+ List<BucketCounter> list = stat.getBuckets().getBucketCounter();
+ Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue());
+ Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue());
+ Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());
+ Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());
+ }
+}
public class MeterConfigStatsResponseConvertorTest {
private static final int PRESET_COUNT = 7;
- private List<MeterConfig> createMeterConfigList(){
+ private List<MeterConfig> createMeterConfigList() {
List<MeterConfig> meterConfigs = new ArrayList<>();
MeterConfigBuilder meterConfigBuilder = new MeterConfigBuilder();
for (int i = 0; i < PRESET_COUNT; i++) {
*/
public void testToSALMeterConfigList() {
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
- Optional<List<MeterConfigStats>> meterConfigsOptional = convertorManager.convert(createMeterConfigList(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MeterConfigStats>> meterConfigsOptional = convertorManager.convert(createMeterConfigList(),
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MeterConfigStats> meterConfigs = meterConfigsOptional.orElse(Collections.emptyList());
assertEquals(PRESET_COUNT, meterConfigs.size());
int cnt = 0;
- for (MeterConfigStats meterConfigStats: meterConfigs){
+ for (MeterConfigStats meterConfigStats: meterConfigs) {
assertEquals(new Long(cnt), meterConfigStats.getMeterId().getValue());
assertTrue(meterConfigStats.getFlags().isMeterBurst());
assertFalse(meterConfigStats.getFlags().isMeterKbps());
}
}
-
- private final class MockMeterBandBuilder implements org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.MeterBand {
-
+ private final class MockMeterBandBuilder implements org.opendaylight.yang.gen.v1.urn.opendaylight.openflow
+ .protocol.rev130731.meter.band.header.MeterBand {
@Override
public Class<? extends DataContainer> getImplementedInterface() {
return MockMeterBandBuilder.class;
}
}
-
-}
\ No newline at end of file
+}
@Test
public void testMeterModCommandConvertorwithAllParameters() {
- long BURST_SIZE = 10L;
- long DROP_RATE = 20L;
+ long burstSize = 10L;
+ long dropRate = 20L;
+
// / DROP Band
- MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
MeterBandTypesBuilder meterBandTypesB = new MeterBandTypesBuilder();
MeterBandType bandFlag = new MeterBandType(true, false, false);
meterBandTypesB.setFlags(bandFlag);// _ofpmbtDrop
DropBuilder drop = new DropBuilder();
- drop.setDropBurstSize(BURST_SIZE);
- drop.setDropRate(DROP_RATE);
+ drop.setDropBurstSize(burstSize);
+ drop.setDropRate(dropRate);
Drop drp = drop.build();
+ MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
meterBandHeaderBuilder.setBandType(drp);
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
- MeterBandHeader meterBH = meterBandHeaderBuilder.build();
+ final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
// DSCP Mark
- long DSCP_REMARK_BURST_SIZE = 11L;
- long DSCP_REMARK_RATE = 21L;
- short DSCP_PERC_LEVEL = 1;
+ final long dscpRemarkBurstSize = 11L;
+ final long dscpRemarkRate = 21L;
+ final short dscpPercLevel = 1;
- MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder();
MeterBandType bandFlag1 = new MeterBandType(false, true, false);
meterBandTypesB1.setFlags(bandFlag1);
DscpRemarkBuilder dscp = new DscpRemarkBuilder();
- dscp.setDscpRemarkBurstSize(DSCP_REMARK_BURST_SIZE);
- dscp.setDscpRemarkRate(DSCP_REMARK_RATE);
- dscp.setPrecLevel(DSCP_PERC_LEVEL);
+ dscp.setDscpRemarkBurstSize(dscpRemarkBurstSize);
+ dscp.setDscpRemarkRate(dscpRemarkRate);
+ dscp.setPrecLevel(dscpPercLevel);
DscpRemark dscpRemark = dscp.build();
+
+ MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder1.setBandType(dscpRemark);
meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
- MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
+ final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
// Experimental
- long EXP_BURST_SIZE = 12L;
- long EXP_RATE = 22L;
- long EXP_EXPERIMENTER = 23L;
+ final long expBurstSize = 12L;
+ final long expRate = 22L;
+ final long expExperimenter = 23L;
- MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
MeterBandType bandFlag2 = new MeterBandType(false, false, true);
meterBandTypesB2.setFlags(bandFlag2);
ExperimenterBuilder exp = new ExperimenterBuilder();
- exp.setExperimenterBurstSize(EXP_BURST_SIZE);
- exp.setExperimenterRate(EXP_RATE);
- exp.setExperimenter(EXP_EXPERIMENTER);
+ exp.setExperimenterBurstSize(expBurstSize);
+ exp.setExperimenterRate(expRate);
+ exp.setExperimenter(expExperimenter);
Experimenter experimenter = exp.build();
+
+ MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder2.setBandType(experimenter);
meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
- List<MeterBandHeader> meterBandList = new ArrayList<MeterBandHeader>();
+ List<MeterBandHeader> meterBandList = new ArrayList<>();
meterBandList.add(0, meterBH);
meterBandList.add(1, meterBH1);
meterBandList.add(2, meterBH2);
AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
addMeterFromSAL.setMeterBandHeaders(meterBandHeaders); // MeterBands
- // added to the
- // meter command.
- Long temp = 10L;
// NodeKey key = new NodeKey(new NodeId("24"));
// InstanceIdentifier<Node> path =
assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
- assertEquals(temp, outMeterModInput.getMeterId().getValue());
+ assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue());
// BandInformation starts here:
List<Bands> bands = outMeterModInput.getBands();
for (Bands currentBand : bands) {
MeterBand meterBand = currentBand.getMeterBand();
if (meterBand instanceof MeterBandDropCase) {
-
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDROP,
- ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
- assertEquals(BURST_SIZE, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
- assertEquals(DROP_RATE, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate());
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
+ assertEquals(burstSize, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
+ assertEquals(dropRate, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate());
}
if (meterBand instanceof MeterBandDscpRemarkCase) {
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDSCPREMARK,
- ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType());
- assertEquals(DSCP_REMARK_BURST_SIZE, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
- assertEquals(DSCP_REMARK_RATE, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
- assertEquals(DSCP_PERC_LEVEL, (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTDSCPREMARK,
+ ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType());
+ assertEquals(dscpRemarkBurstSize,
+ (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
+ assertEquals(dscpRemarkRate,
+ (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
+ assertEquals(dscpPercLevel,
+ (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
}
if (meterBand instanceof MeterBandExperimenterCase) {
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTEXPERIMENTER,
- ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType());
- assertEquals(EXP_BURST_SIZE, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
- assertEquals(EXP_RATE, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTEXPERIMENTER,
+ ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType());
+ assertEquals(expBurstSize,
+ (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
+ assertEquals(expRate,
+ (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter()
.getAugmentation(ExperimenterIdMeterBand.class);
- assertEquals(EXP_EXPERIMENTER, (long) expBand.getExperimenter().getValue());
-
+ assertEquals(expExperimenter, (long) expBand.getExperimenter().getValue());
}
-
}
-
}
@Test
public void testMeterModCommandConvertorwithNoFlags() {
- long BURST_SIZE = 10L;
- long DROP_RATE = 20L;
+ long burstSize = 10L;
+ long dropRate = 20L;
// / DROP Band
- MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
MeterBandTypesBuilder meterBandTypesB = new MeterBandTypesBuilder();
MeterBandType bandFlag = new MeterBandType(true, false, false);
meterBandTypesB.setFlags(bandFlag);// _ofpmbtDrop
DropBuilder drop = new DropBuilder();
- drop.setDropBurstSize(BURST_SIZE);
- drop.setDropRate(DROP_RATE);
+ drop.setDropBurstSize(burstSize);
+ drop.setDropRate(dropRate);
Drop drp = drop.build();
+
+ MeterBandHeaderBuilder meterBandHeaderBuilder = new MeterBandHeaderBuilder();
meterBandHeaderBuilder.setBandType(drp);
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
- MeterBandHeader meterBH = meterBandHeaderBuilder.build();
+ final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
// DSCP Mark
- long DSCP_REMARK_BURST_SIZE = 11L;
- long DSCP_REMARK_RATE = 21L;
- short DSCP_PERC_LEVEL = 1;
+ final long dscpRemarkBurstSize = 11L;
+ final long dscpRemarkRate = 21L;
+ final short dscpPercLevel = 1;
- MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder();
MeterBandType bandFlag1 = new MeterBandType(false, true, false);
meterBandTypesB1.setFlags(bandFlag1);
DscpRemarkBuilder dscp = new DscpRemarkBuilder();
- dscp.setDscpRemarkBurstSize(DSCP_REMARK_BURST_SIZE);
- dscp.setDscpRemarkRate(DSCP_REMARK_RATE);
- dscp.setPrecLevel(DSCP_PERC_LEVEL);
+ dscp.setDscpRemarkBurstSize(dscpRemarkBurstSize);
+ dscp.setDscpRemarkRate(dscpRemarkRate);
+ dscp.setPrecLevel(dscpPercLevel);
DscpRemark dscpRemark = dscp.build();
+
+ MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder1.setBandType(dscpRemark);
meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
- MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
+ final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
// Experimental
- long EXP_BURST_SIZE = 12L;
- long EXP_RATE = 22L;
- long EXP_EXPERIMENTER = 23L;
+ final long expBurstSize = 12L;
+ final long expRate = 22L;
+ final long expExperimenter = 23L;
- MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
MeterBandType bandFlag2 = new MeterBandType(false, false, true);
meterBandTypesB2.setFlags(bandFlag2);
ExperimenterBuilder exp = new ExperimenterBuilder();
- exp.setExperimenterBurstSize(EXP_BURST_SIZE);
- exp.setExperimenterRate(EXP_RATE);
- exp.setExperimenter(EXP_EXPERIMENTER);
+ exp.setExperimenterBurstSize(expBurstSize);
+ exp.setExperimenterRate(expRate);
+ exp.setExperimenter(expExperimenter);
Experimenter experimenter = exp.build();
+
+ MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder2.setBandType(experimenter);
meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
- List<MeterBandHeader> meterBandList = new ArrayList<MeterBandHeader>();
+ List<MeterBandHeader> meterBandList = new ArrayList<>();
meterBandList.add(0, meterBH);
meterBandList.add(1, meterBH1);
meterBandList.add(2, meterBH2);
AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
addMeterFromSAL.setMeterBandHeaders(meterBandHeaders); // MeterBands
- // added to the
- // meter command.
- Long temp = 10L;
// NodeKey key = new NodeKey(new NodeId("24"));
// InstanceIdentifier<Node> path =
assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
assertFalse(outMeterModInput.getFlags().isOFPMFBURST());
assertTrue(outMeterModInput.getFlags().isOFPMFPKTPS());
- assertEquals(temp, outMeterModInput.getMeterId().getValue());
+ assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue());
// BandInformation starts here:
List<Bands> bands = outMeterModInput.getBands();
for (Bands currentBand : bands) {
MeterBand meterBand = currentBand.getMeterBand();
if (meterBand instanceof MeterBandDropCase) {
-
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDROP,
- ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
- assertEquals(BURST_SIZE, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
- assertEquals(DROP_RATE, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate());
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
+ assertEquals(burstSize, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
+ assertEquals(dropRate, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate());
}
if (meterBand instanceof MeterBandDscpRemarkCase) {
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDSCPREMARK,
- ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType());
- assertEquals(DSCP_REMARK_BURST_SIZE, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
- assertEquals(DSCP_REMARK_RATE, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
- assertEquals(DSCP_PERC_LEVEL, (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTDSCPREMARK,
+ ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType());
+ assertEquals(dscpRemarkBurstSize,
+ (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
+ assertEquals(dscpRemarkRate,
+ (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
+ assertEquals(dscpPercLevel,
+ (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
}
if (meterBand instanceof MeterBandExperimenterCase) {
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTEXPERIMENTER,
- ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType());
- assertEquals(EXP_BURST_SIZE, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
- assertEquals(EXP_RATE, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTEXPERIMENTER,
+ ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType());
+ assertEquals(expBurstSize,
+ (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
+ assertEquals(expRate,
+ (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter()
.getAugmentation(ExperimenterIdMeterBand.class);
- assertEquals(EXP_EXPERIMENTER, (long) expBand.getExperimenter().getValue());
-
+ assertEquals(expExperimenter, (long) expBand.getExperimenter().getValue());
}
-
}
-
}
@Test
public void testMeterModCommandConvertorBandDataisNULL() {
AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
- Long temp = 10L;
-
// NodeKey key = new NodeKey(new NodeId("24"));
// InstanceIdentifier<Node> path =
// InstanceIdentifier.builder().node(Nodes.class).node(Node.class,
assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
- assertEquals(temp, outMeterModInput.getMeterId().getValue());
+ assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue());
}
@Test
meterBandHeaderBuilder.setMeterBandTypes(meterBandTypesB.build());
- MeterBandHeader meterBH = meterBandHeaderBuilder.build();
+ final MeterBandHeader meterBH = meterBandHeaderBuilder.build();
// DSCP Mark
- MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
MeterBandTypesBuilder meterBandTypesB1 = new MeterBandTypesBuilder();
MeterBandType bandFlag1 = new MeterBandType(false, true, false);
dscp.setDscpRemarkRate(21L);
dscp.setPrecLevel((short) 1);
DscpRemark dscpRemark = dscp.build();
+
+ MeterBandHeaderBuilder meterBandHeaderBuilder1 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder1.setBandType(dscpRemark);
meterBandHeaderBuilder1.setMeterBandTypes(meterBandTypesB1.build());
- MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
+ final MeterBandHeader meterBH1 = meterBandHeaderBuilder1.build();
// Experimental
- MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
- MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
-
-
ExperimenterBuilder exp = new ExperimenterBuilder();
exp.setExperimenterBurstSize(12L);
exp.setExperimenterRate(22L);
exp.setExperimenter(23L);
Experimenter experimenter = exp.build();
+
+ MeterBandHeaderBuilder meterBandHeaderBuilder2 = new MeterBandHeaderBuilder();
meterBandHeaderBuilder2.setBandType(experimenter);
+
+ MeterBandTypesBuilder meterBandTypesB2 = new MeterBandTypesBuilder();
meterBandHeaderBuilder2.setMeterBandTypes(meterBandTypesB2.build());
MeterBandHeader meterBH2 = meterBandHeaderBuilder2.build();
- List<MeterBandHeader> meterBandList = new ArrayList<MeterBandHeader>();
+ List<MeterBandHeader> meterBandList = new ArrayList<>();
meterBandList.add(0, meterBH);
meterBandList.add(1, meterBH1);
meterBandList.add(2, meterBH2);
AddMeterInputBuilder addMeterFromSAL = new AddMeterInputBuilder();
addMeterFromSAL.setMeterBandHeaders(meterBandHeaders); // MeterBands
- // added to the
- // meter command.
- Long temp = 10L;
// NodeKey key = new NodeKey(new NodeId("24"));
// InstanceIdentifier<Node> path =
assertEquals(MeterModCommand.OFPMCADD, outMeterModInput.getCommand());
assertTrue(outMeterModInput.getFlags().isOFPMFBURST());
- assertEquals(temp, outMeterModInput.getMeterId().getValue());
+ assertEquals(Long.valueOf(10L), outMeterModInput.getMeterId().getValue());
// BandInformation starts here:
List<Bands> bands = outMeterModInput.getBands();
MeterBand meterBand = currentBand.getMeterBand();
if (meterBand instanceof MeterBandDropCase) {
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDROP,
- ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTDROP, ((MeterBandDropCase) meterBand).getMeterBandDrop().getType());
assertEquals((long) 20, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getBurstSize());
assertEquals((long) 10, (long) ((MeterBandDropCase) meterBand).getMeterBandDrop().getRate());
}
if (meterBand instanceof MeterBandDscpRemarkCase) {
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTDSCPREMARK,
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTDSCPREMARK,
((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getType());
- assertEquals((long) 11, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
- assertEquals((long) 21, (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
- assertEquals((short) 1, (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
+ assertEquals((long) 11,
+ (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getBurstSize());
+ assertEquals((long) 21,
+ (long) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getRate());
+ assertEquals((short) 1,
+ (short) ((MeterBandDscpRemarkCase) meterBand).getMeterBandDscpRemark().getPrecLevel());
}
if (meterBand instanceof MeterBandExperimenterCase) {
- assertEquals(
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandType.OFPMBTEXPERIMENTER,
+ assertEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731
+ .MeterBandType.OFPMBTEXPERIMENTER,
((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getType());
- assertEquals((long) 12, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
- assertEquals((long) 22, (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
+ assertEquals((long) 12,
+ (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getBurstSize());
+ assertEquals((long) 22,
+ (long) ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter().getRate());
ExperimenterIdMeterBand expBand = ((MeterBandExperimenterCase) meterBand).getMeterBandExperimenter()
.getAugmentation(ExperimenterIdMeterBand.class);
assertEquals((long) 23, (long) expBand.getExperimenter().getValue());
-
}
-
}
-
}
private MeterModInputBuilder convert(Meter source, VersionConvertorData data) {
Optional<MeterModInputBuilder> outMeterModInputOptional = convertorManager.convert(source, data);
return outMeterModInputOptional.orElse(MeterConvertor.defaultResult(data.getVersion()));
}
-}
\ No newline at end of file
+}
.multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats> createMeterStatsLit() {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply
- .multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats> allMeterStats = new ArrayList<>();
+ .multipart.reply.body.multipart.reply.meter._case.multipart.reply.meter.MeterStats>
+ allMeterStats = new ArrayList<>();
MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder();
for (int i = 0; i < PRESET_COUNT; i++) {
meterStatsBuilder.setByteInCount(BigInteger.valueOf(i));
*/
public void testToSALMeterStatsList() {
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
- Optional<List<MeterStats>> meterStatsListOptional = convertorManager.convert(createMeterStatsLit(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MeterStats>> meterStatsListOptional = convertorManager.convert(createMeterStatsLit(),
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MeterStats> meterStatsList = meterStatsListOptional.orElse(Collections.emptyList());
assertEquals(PRESET_COUNT, meterStatsList.size());
int cnt = 0;
for (MeterStats meterStats : meterStatsList) {
- assertEquals((new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt))).getMeterId(), meterStats.getKey().getMeterId());
- assertEquals((BigInteger.valueOf(cnt)), meterStats.getByteInCount().getValue());
+ assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918
+ .MeterId((long) cnt)).getMeterId(), meterStats.getKey().getMeterId());
+ assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue());
assertEquals(new Long(1000 * cnt), meterStats.getDuration().getNanosecond().getValue());
assertEquals(new Long(10 * cnt), meterStats.getDuration().getSecond().getValue());
assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue());
bandStatCount++;
}
- assertEquals((new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt))).getMeterId(), meterStats.getMeterId());
+ assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918
+ .MeterId((long) cnt)).getMeterId(), meterStats.getMeterId());
assertEquals(BigInteger.valueOf(cnt), meterStats.getPacketInCount().getValue());
cnt++;
}
}
-}
\ No newline at end of file
+}
-/*\r
- * Copyright (c) 2014 Cisco Systems, Inc. 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.openflowplugin.openflow.md.core.sal.convertor;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Optional;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
-import org.opendaylight.openflowplugin.api.OFConstants;\r
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;\r
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;\r
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;\r
-import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-\r
-/**\r
- * Created by Jakub Toth jatoth@cisco.com on 9/23/14.\r
- */\r
-\r
-public class PacketOutConvertorTest {\r
-\r
- private ConvertorManager convertorManager;\r
-\r
- @Before\r
- public void setUp() {\r
- convertorManager = ConvertorManagerFactory.createDefaultManager();\r
- }\r
-\r
- /**\r
- * Test for {@link PacketOutConvertor} with null parameters\r
- */\r
- @Test\r
- public void toPacketOutInputAllParmNullTest() {\r
-\r
- TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();\r
-\r
- Long bufferId = null;\r
-\r
- String NODE_ID = "0";\r
- String port = "0";\r
-\r
- NodeRef ref = createNodeRef(NODE_ID);\r
- NodeConnectorKey nodeConnKey = PacketOutConvertorTest.createNodeConnKey(NODE_ID, port);\r
- NodeConnectorRef nEgressConfRef = new NodeConnectorRef(\r
- createNodeConnRef(NODE_ID, nodeConnKey));\r
-\r
- transmitPacketInputBuilder.setBufferId(bufferId);\r
- transmitPacketInputBuilder.setConnectionCookie(null);\r
- transmitPacketInputBuilder.setAction(null);\r
- transmitPacketInputBuilder.setNode(ref);\r
- transmitPacketInputBuilder.setPayload(null);\r
- transmitPacketInputBuilder.setEgress(nEgressConfRef);\r
- transmitPacketInputBuilder.setIngress(null);\r
- TransmitPacketInput transmitPacketInput = transmitPacketInputBuilder\r
- .build();\r
-\r
- Short version = (short) 0x04;\r
- Long xid = null;\r
- PacketOutConvertorData data = new PacketOutConvertorData(version);\r
- PacketOutInput message = convert(transmitPacketInput, data);\r
-\r
- //FIXME : this has to be fixed along with actions changed in openflowjava\r
-\r
- Assert.assertEquals(buildActionForNullTransmitPacketInputAction(nodeConnKey, version), message.getAction());\r
-\r
- Assert.assertEquals(OFConstants.OFP_NO_BUFFER, message.getBufferId());\r
- Assert.assertEquals(new PortNumber(0xfffffffdL), message.getInPort());\r
- Assert.assertEquals(version, message.getVersion());\r
- Assert.assertEquals(xid, message.getXid());\r
- Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());\r
- }\r
-\r
- /**\r
- * Test for PacketOutConvertor\r
- */\r
- @Test\r
- public void toPacketOutInputAllParmTest() {\r
- TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();\r
-\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList = new ArrayList<>();\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder ab = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();\r
-\r
- OutputActionBuilder output = new OutputActionBuilder();\r
- output.setMaxLength(OFConstants.OFPCML_NO_BUFFER);\r
- Uri value = new Uri(OutputPortValues.CONTROLLER.toString());\r
- output.setOutputNodeConnector(value);\r
- ab.setAction(new OutputActionCaseBuilder().setOutputAction(\r
- output.build()).build());\r
- ab.setOrder(0);\r
- ab.setKey(new ActionKey(0));\r
- actionList.add(ab.build());\r
-\r
- Long bufferId = 0xfL;\r
-\r
- Long valueForCookie = 0xeL;\r
- ConnectionCookie connCook = new ConnectionCookie(valueForCookie);\r
-\r
- String NODE_ID = "node:1";\r
-\r
- NodeRef ref = createNodeRef(NODE_ID);\r
-\r
- String portO = "0xfffffffd";\r
- NodeConnectorKey nEgrConKey = PacketOutConvertorTest.createNodeConnKey(NODE_ID, portO);\r
- NodeConnectorRef nEgressConfRef = new NodeConnectorRef(\r
- createNodeConnRef(NODE_ID, nEgrConKey));\r
-\r
- String inPort = "2";\r
- NodeConnectorKey nIngrConKey = PacketOutConvertorTest.createNodeConnKey(NODE_ID, inPort);\r
- NodeConnectorRef nIngressConRef = new NodeConnectorRef(\r
- createNodeConnRef(NODE_ID, nIngrConKey));\r
-\r
- String _string = new String("sendOutputMsg_TEST");\r
- byte[] msg = _string.getBytes();\r
-\r
- byte[] payload = msg;\r
-\r
- transmitPacketInputBuilder.setAction(actionList);\r
- transmitPacketInputBuilder.setBufferId(bufferId);\r
- transmitPacketInputBuilder.setConnectionCookie(connCook);\r
- transmitPacketInputBuilder.setEgress(nEgressConfRef);\r
- transmitPacketInputBuilder.setIngress(nIngressConRef);\r
- transmitPacketInputBuilder.setNode(ref);\r
- transmitPacketInputBuilder.setPayload(payload);\r
-\r
- TransmitPacketInput transmitPacketInput = transmitPacketInputBuilder\r
- .build();\r
-\r
- short version = (short) 0x04;\r
- byte[] datapathIdByte = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];\r
- for (int i = 0; i < datapathIdByte.length; i++) {\r
- datapathIdByte[i] = 1;\r
- }\r
- BigInteger datapathId = new BigInteger(1, datapathIdByte);\r
- Long xid = 0xfffffL;\r
-\r
- PacketOutConvertorData data = new PacketOutConvertorData(version);\r
- data.setXid(xid);\r
- data.setDatapathId(datapathId);\r
- PacketOutInput message = convert(transmitPacketInput, data);\r
-\r
- Assert.assertEquals(transmitPacketInput.getBufferId(),\r
- message.getBufferId());\r
- Assert.assertEquals("PortNumber [_value=" + inPort + "]", message\r
- .getInPort().toString());\r
- Assert.assertEquals((Object) version,\r
- Short.valueOf(message.getVersion()));\r
- Assert.assertEquals(xid, message.getXid());\r
-\r
- ActionConvertorData actionConvertorData = new ActionConvertorData(version);\r
- actionConvertorData.setDatapathId(datapathId);\r
-\r
- Optional<List<Action>> actionsOptional = convertorManager.convert(\r
- actionList, actionConvertorData);\r
-\r
- List<Action> actions = actionsOptional.orElse(Collections.emptyList());\r
- Assert.assertEquals(actions, message.getAction());\r
- Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());\r
- }\r
-\r
- /**\r
- * create action\r
- *\r
- * @param nConKey\r
- * @param version\r
- * @return\r
- */\r
- private static List<Action> buildActionForNullTransmitPacketInputAction(\r
- final NodeConnectorKey nConKey, final short version) {\r
-\r
- PortNumber outPort = getPortNumber(nConKey, version);\r
- List<Action> actions = new ArrayList<>();\r
- ActionBuilder aBuild = new ActionBuilder();\r
-\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder outputActionCaseBuilder =\r
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder();\r
-\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder outputActionBuilder =\r
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder();\r
-\r
- outputActionBuilder.setPort(outPort);\r
- outputActionBuilder.setMaxLength(0xffff);\r
- outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());\r
- aBuild.setActionChoice(outputActionCaseBuilder.build());\r
- actions.add(aBuild.build());\r
- return actions;\r
- }\r
-\r
- /**\r
- * create PortNumber\r
- *\r
- * @param nConKey\r
- * @param ofVersion\r
- * @return\r
- */\r
- private static PortNumber getPortNumber(final NodeConnectorKey nConKey,\r
- final Short ofVersion) {\r
- Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(\r
- OpenflowVersion.get(ofVersion), nConKey.getId());\r
- return new PortNumber(port);\r
- }\r
-\r
- /**\r
- * create NodeConnectorRef\r
- *\r
- * @param nodeId\r
- * @param nConKey\r
- * @return\r
- */\r
- private static NodeConnectorRef createNodeConnRef(final String nodeId,\r
- final NodeConnectorKey nConKey) {\r
-\r
- InstanceIdentifier<NodeConnector> path = InstanceIdentifier\r
- .<Nodes>builder(Nodes.class)\r
- .<Node, NodeKey>child(Node.class,\r
- new NodeKey(new NodeId(nodeId)))\r
- .<NodeConnector, NodeConnectorKey>child(NodeConnector.class,\r
- nConKey).build();\r
-\r
- return new NodeConnectorRef(path);\r
- }\r
-\r
- /**\r
- * create NodeConnectorKey\r
- *\r
- * @param nodeId\r
- * @param port\r
- * @return\r
- */\r
- private static NodeConnectorKey createNodeConnKey(final String nodeId,\r
- final String port) {\r
- StringBuilder sBuild = new StringBuilder(nodeId).append(':').append(\r
- port);\r
-\r
- return new NodeConnectorKey(new NodeConnectorId(sBuild.toString()));\r
- }\r
-\r
- /**\r
- * create NodeRef\r
- *\r
- * @param nodeId\r
- * @return\r
- */\r
- private static NodeRef createNodeRef(final String nodeId) {\r
- NodeKey key = new NodeKey(new NodeId(nodeId));\r
- InstanceIdentifier<Node> path = InstanceIdentifier\r
- .<Nodes>builder(Nodes.class)\r
- .<Node, NodeKey>child(Node.class, key).build();\r
- return new NodeRef(path);\r
- }\r
-\r
- private PacketOutInput convert(TransmitPacketInput transmitPacketInput, PacketOutConvertorData data) {\r
- Optional<PacketOutInput> messageOptional = convertorManager.convert(transmitPacketInput, data);\r
- return messageOptional.orElse(PacketOutConvertor.defaultResult(data.getVersion()));\r
- }\r
-}\r
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. 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.openflowplugin.openflow.md.core.sal.convertor;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.PacketOutConvertorData;
+import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+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.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.ConnectionCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+/**
+ * Created by Jakub Toth jatoth@cisco.com on 9/23/14.
+ */
+
+public class PacketOutConvertorTest {
+
+ private ConvertorManager convertorManager;
+
+ @Before
+ public void setUp() {
+ convertorManager = ConvertorManagerFactory.createDefaultManager();
+ }
+
+ /**
+ * Test for {@link PacketOutConvertor} with null parameters.
+ */
+ @Test
+ public void toPacketOutInputAllParmNullTest() {
+
+ TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();
+
+ Long bufferId = null;
+
+ String nodeId = "0";
+ String port = "0";
+
+ NodeRef ref = createNodeRef(nodeId);
+ NodeConnectorKey nodeConnKey = PacketOutConvertorTest.createNodeConnKey(nodeId, port);
+ NodeConnectorRef egressConfRef = new NodeConnectorRef(
+ createNodeConnRef(nodeId, nodeConnKey));
+
+ transmitPacketInputBuilder.setBufferId(bufferId);
+ transmitPacketInputBuilder.setConnectionCookie(null);
+ transmitPacketInputBuilder.setAction(null);
+ transmitPacketInputBuilder.setNode(ref);
+ transmitPacketInputBuilder.setPayload(null);
+ transmitPacketInputBuilder.setEgress(egressConfRef);
+ transmitPacketInputBuilder.setIngress(null);
+ TransmitPacketInput transmitPacketInput = transmitPacketInputBuilder
+ .build();
+
+ Short version = (short) 0x04;
+ Long xid = null;
+ PacketOutConvertorData data = new PacketOutConvertorData(version);
+ PacketOutInput message = convert(transmitPacketInput, data);
+
+ //FIXME : this has to be fixed along with actions changed in openflowjava
+
+ Assert.assertEquals(buildActionForNullTransmitPacketInputAction(nodeConnKey, version), message.getAction());
+
+ Assert.assertEquals(OFConstants.OFP_NO_BUFFER, message.getBufferId());
+ Assert.assertEquals(new PortNumber(0xfffffffdL), message.getInPort());
+ Assert.assertEquals(version, message.getVersion());
+ Assert.assertEquals(xid, message.getXid());
+ Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());
+ }
+
+ /**
+ * Test for PacketOutConvertor.
+ */
+ @Test
+ public void toPacketOutInputAllParmTest() {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder ab =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder();
+
+ OutputActionBuilder output = new OutputActionBuilder();
+ output.setMaxLength(OFConstants.OFPCML_NO_BUFFER);
+ Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
+ output.setOutputNodeConnector(value);
+ ab.setAction(new OutputActionCaseBuilder().setOutputAction(
+ output.build()).build());
+ ab.setOrder(0);
+ ab.setKey(new ActionKey(0));
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionList =
+ new ArrayList<>();
+ actionList.add(ab.build());
+
+ Long bufferId = 0xfL;
+
+ Long valueForCookie = 0xeL;
+ ConnectionCookie connCook = new ConnectionCookie(valueForCookie);
+
+ String nodeId = "node:1";
+
+ NodeRef ref = createNodeRef(nodeId);
+
+ String portO = "0xfffffffd";
+ NodeConnectorKey egrConKey = PacketOutConvertorTest.createNodeConnKey(nodeId, portO);
+ NodeConnectorRef egressConfRef = new NodeConnectorRef(
+ createNodeConnRef(nodeId, egrConKey));
+
+ String inPort = "2";
+ NodeConnectorKey ingrConKey = PacketOutConvertorTest.createNodeConnKey(nodeId, inPort);
+ NodeConnectorRef ingressConRef = new NodeConnectorRef(
+ createNodeConnRef(nodeId, ingrConKey));
+
+ String string = new String("sendOutputMsg_TEST");
+ byte[] msg = string.getBytes();
+
+ byte[] payload = msg;
+
+ TransmitPacketInputBuilder transmitPacketInputBuilder = new TransmitPacketInputBuilder();
+ transmitPacketInputBuilder.setAction(actionList);
+ transmitPacketInputBuilder.setBufferId(bufferId);
+ transmitPacketInputBuilder.setConnectionCookie(connCook);
+ transmitPacketInputBuilder.setEgress(egressConfRef);
+ transmitPacketInputBuilder.setIngress(ingressConRef);
+ transmitPacketInputBuilder.setNode(ref);
+ transmitPacketInputBuilder.setPayload(payload);
+
+ final TransmitPacketInput transmitPacketInput = transmitPacketInputBuilder.build();
+
+ short version = (short) 0x04;
+ byte[] datapathIdByte = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+ for (int i = 0; i < datapathIdByte.length; i++) {
+ datapathIdByte[i] = 1;
+ }
+ BigInteger datapathId = new BigInteger(1, datapathIdByte);
+ Long xid = 0xfffffL;
+
+ PacketOutConvertorData data = new PacketOutConvertorData(version);
+ data.setXid(xid);
+ data.setDatapathId(datapathId);
+ PacketOutInput message = convert(transmitPacketInput, data);
+
+ Assert.assertEquals(transmitPacketInput.getBufferId(),
+ message.getBufferId());
+ Assert.assertEquals("PortNumber [_value=" + inPort + "]", message
+ .getInPort().toString());
+ Assert.assertEquals((Object) version,
+ Short.valueOf(message.getVersion()));
+ Assert.assertEquals(xid, message.getXid());
+
+ ActionConvertorData actionConvertorData = new ActionConvertorData(version);
+ actionConvertorData.setDatapathId(datapathId);
+
+ Optional<List<Action>> actionsOptional = convertorManager.convert(
+ actionList, actionConvertorData);
+
+ List<Action> actions = actionsOptional.orElse(Collections.emptyList());
+ Assert.assertEquals(actions, message.getAction());
+ Assert.assertArrayEquals(transmitPacketInput.getPayload(), message.getData());
+ }
+
+ private static List<Action> buildActionForNullTransmitPacketInputAction(
+ final NodeConnectorKey nodeConKey, final short version) {
+
+ PortNumber outPort = getPortNumber(nodeConKey, version);
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice
+ .OutputActionCaseBuilder outputActionCaseBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.OutputActionCaseBuilder();
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice
+ .output.action._case.OutputActionBuilder outputActionBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.output.action._case.OutputActionBuilder();
+
+ outputActionBuilder.setPort(outPort);
+ outputActionBuilder.setMaxLength(0xffff);
+ outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(outputActionCaseBuilder.build());
+
+ List<Action> actions = new ArrayList<>();
+ actions.add(actionBuilder.build());
+ return actions;
+ }
+
+ private static PortNumber getPortNumber(final NodeConnectorKey nodeConKey, final Short ofVersion) {
+ Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(OpenflowVersion.get(ofVersion),
+ nodeConKey.getId());
+ return new PortNumber(port);
+ }
+
+ private static NodeConnectorRef createNodeConnRef(final String nodeId, final NodeConnectorKey nodeConKey) {
+ InstanceIdentifier<NodeConnector> path = InstanceIdentifier
+ .<Nodes>builder(Nodes.class)
+ .<Node, NodeKey>child(Node.class,
+ new NodeKey(new NodeId(nodeId)))
+ .<NodeConnector, NodeConnectorKey>child(NodeConnector.class,
+ nodeConKey).build();
+
+ return new NodeConnectorRef(path);
+ }
+
+ private static NodeConnectorKey createNodeConnKey(final String nodeId, final String port) {
+ StringBuilder builder = new StringBuilder(nodeId).append(':').append(port);
+
+ return new NodeConnectorKey(new NodeConnectorId(builder.toString()));
+ }
+
+ private static NodeRef createNodeRef(final String nodeId) {
+ NodeKey key = new NodeKey(new NodeId(nodeId));
+ InstanceIdentifier<Node> path = InstanceIdentifier
+ .<Nodes>builder(Nodes.class)
+ .<Node, NodeKey>child(Node.class, key).build();
+ return new NodeRef(path);
+ }
+
+ private PacketOutInput convert(TransmitPacketInput transmitPacketInput, PacketOutConvertorData data) {
+ Optional<PacketOutInput> messageOptional = convertorManager.convert(transmitPacketInput, data);
+ return messageOptional.orElse(PacketOutConvertor.defaultResult(data.getVersion()));
+ }
+}
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.FlowCapablePort;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
public class PortConvertorTest {
- /** defautl mac address */
private static final String DEFAULT_MAC_ADDRESS = "01:02:03:04:05:06";
- private PortFeatures features = new PortFeatures(true, null, null, null, null, null, null, null, null, null, null,
- null, null, null, null, null);
+ private final PortFeatures features = new PortFeatures(true, null, null, null, null, null, null, null, null, null,
+ null, null, null, null, null, null);
- private PortConfig config = new PortConfig(false, false, false, false);
+ private final PortConfig config = new PortConfig(false, false, false, false);
- private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures portf31=
+ private final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures portf31 =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures(
null, null, null, null, null, null, null, null, null, null, true, null, null, null, null, null);
- private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig config31 =
+ private final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig config31 =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig(
false, false, false, false);
- private org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig configMask31 =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig(
+ private final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig
+ configMask31 = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig(
true, true, true, true);
- private PortConfigV10 portConfMaskV10 = new PortConfigV10(true, true, true, true, true, true, true);;
+ private final PortConfigV10 portConfMaskV10 = new PortConfigV10(true, true, true, true, true, true, true);
/**
- * test of {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.PortConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)} }
+ * test of {@link PortConvertor#convert(Port, VersionConvertorData)} }.
*/
@Test
- public void testtoPortModInputwithAllParameters()
- {
-
+ public void testtoPortModInputwithAllParameters() {
PortBuilder portBld = new PortBuilder();
portBld.setAdvertisedFeatures(features);
portBld.setConfiguration(config);
VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
Optional<PortModInput> portOutOptional = convertorManager.convert(portBld.build(), data);
- PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3));
+ final PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3));
PortConfigV10 portConfV10 = new PortConfigV10(false, false, false, false, true, true, false);
}
/**
- * test of {@link PortConvertor#toPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.FlowCapablePort , short)}
+ * test of {@link PortConvertor#toPortDesc(FlowCapablePort , short)}.
*/
@Test
- public void testtoPortDescwithAllParameters(){
+ public void testtoPortDescwithAllParameters() {
State state = new StateBuilder().setBlocked(false).setLinkDown(false).setLive(false).build();
- PortState state31= new PortState(false, false, false);
FlowCapableNodeConnectorBuilder flowCapableNodeConnectorBuilder = new FlowCapableNodeConnectorBuilder();
flowCapableNodeConnectorBuilder.setState(state);
flowCapableNodeConnectorBuilder.setSupported(features);
- Ports portsOut = PortConvertor.toPortDesc(flowCapableNodeConnectorBuilder.build(), EncodeConstants.OF13_VERSION_ID);
+ final Ports portsOut = PortConvertor.toPortDesc(
+ flowCapableNodeConnectorBuilder.build(), EncodeConstants.OF13_VERSION_ID);
PortsBuilder portsB = new PortsBuilder();
portsB.setName("foo");
portsB.setPeerFeatures(portf31);
portsB.setPortNo(42L);
- portsB.setState(state31);
+ portsB.setState(new PortState(false, false, false));
portsB.setSupportedFeatures(portf31);
Assert.assertEquals(portsB.build(), portsOut);
}
-
}
import java.math.BigInteger;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
public class TableFeaturesConvertorTest {
- private static final TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
- private static final Map<Class<? extends TableFeaturePropType>, TableFeaturePropType> augmentationsMap = new HashMap<>();
- private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction> instructionsList = new ArrayList<>();
- private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions = new ArrayList<>();
- private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch> fieldTableFeatures = new ArrayList<>();
+ private static final TablePropertiesBuilder TABLE_PROPERTIES_BUILDER = new TablePropertiesBuilder();
+ private static final Map<Class<? extends TableFeaturePropType>, TableFeaturePropType> AUGMENTATIONS_MAP =
+ new HashMap<>();
+ private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction
+ .Instruction> INSTRUCTIONS_LIST = new ArrayList<>();
+ private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
+ .Action> ACTIONS = new ArrayList<>();
+ private static final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match
+ .SetFieldMatch> FIELD_TABLE_FEATURES = new ArrayList<>();
private static void setupInstructionsList() {
- instructionsList.add(new GoToTableCaseBuilder().build());
- instructionsList.add(new WriteMetadataCaseBuilder().build());
- instructionsList.add(new WriteActionsCaseBuilder().build());
- instructionsList.add(new ApplyActionsCaseBuilder().build());
- instructionsList.add(new ClearActionsCaseBuilder().build());
- instructionsList.add(new MeterCaseBuilder().build());
+ INSTRUCTIONS_LIST.add(new GoToTableCaseBuilder().build());
+ INSTRUCTIONS_LIST.add(new WriteMetadataCaseBuilder().build());
+ INSTRUCTIONS_LIST.add(new WriteActionsCaseBuilder().build());
+ INSTRUCTIONS_LIST.add(new ApplyActionsCaseBuilder().build());
+ INSTRUCTIONS_LIST.add(new ClearActionsCaseBuilder().build());
+ INSTRUCTIONS_LIST.add(new MeterCaseBuilder().build());
}
private static void setupFieldTableFeatures() {
SetFieldMatchBuilder setFieldMatchBuilder = new SetFieldMatchBuilder();
setFieldMatchBuilder.setHasMask(true);
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
- setFieldMatchBuilder.setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class);
- fieldTableFeatures.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSha.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTha.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Code.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv4Type.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Code.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Icmpv6Type.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpDscp.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Dst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Flabel.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdSll.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTarget.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6NdTll.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Src.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsBos.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsTc.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpDst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SctpSrc.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpFlags.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Dst.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
+ setFieldMatchBuilder
+ .setMatchType(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelIpv4Src.class);
+ FIELD_TABLE_FEATURES.add(setFieldMatchBuilder.build());
}
private static void setupActions() {
- org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder _actionBuilder = new ActionBuilder();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder actionBuilder =
+ new ActionBuilder();
OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
- actions.add(_actionBuilder.setAction(outputActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(outputActionCaseBuilder.build()).build());
GroupActionCaseBuilder groupActionCaseBuilder = new GroupActionCaseBuilder();
- actions.add(_actionBuilder.setAction(groupActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(groupActionCaseBuilder.build()).build());
CopyTtlOutCaseBuilder copyTtlOutCaseBuilder = new CopyTtlOutCaseBuilder();
- actions.add(_actionBuilder.setAction(copyTtlOutCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(copyTtlOutCaseBuilder.build()).build());
CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder();
- actions.add(_actionBuilder.setAction(copyTtlInCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(copyTtlInCaseBuilder.build()).build());
SetMplsTtlActionCaseBuilder setMplsTtlActionCaseBuilder = new SetMplsTtlActionCaseBuilder();
- actions.add(_actionBuilder.setAction(setMplsTtlActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(setMplsTtlActionCaseBuilder.build()).build());
DecMplsTtlCaseBuilder decMplsTtlCaseBuilder = new DecMplsTtlCaseBuilder();
- actions.add(_actionBuilder.setAction(decMplsTtlCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(decMplsTtlCaseBuilder.build()).build());
PushVlanActionCaseBuilder pushVlanActionCaseBuilder = new PushVlanActionCaseBuilder();
- actions.add(_actionBuilder.setAction(pushVlanActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(pushVlanActionCaseBuilder.build()).build());
PopVlanActionCaseBuilder popVlanActionCaseBuilder = new PopVlanActionCaseBuilder();
- actions.add(_actionBuilder.setAction(popVlanActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(popVlanActionCaseBuilder.build()).build());
PushMplsActionCaseBuilder pushMplsActionCaseBuilder = new PushMplsActionCaseBuilder();
- actions.add(_actionBuilder.setAction(pushMplsActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(pushMplsActionCaseBuilder.build()).build());
PopMplsActionCaseBuilder popMplsActionCaseBuilder = new PopMplsActionCaseBuilder();
- actions.add(_actionBuilder.setAction(popMplsActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(popMplsActionCaseBuilder.build()).build());
SetQueueActionCaseBuilder setQueueActionCaseBuilder = new SetQueueActionCaseBuilder();
- actions.add(_actionBuilder.setAction(setQueueActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(setQueueActionCaseBuilder.build()).build());
SetNwTtlActionCaseBuilder setNwTtlActionCaseBuilder = new SetNwTtlActionCaseBuilder();
- actions.add(_actionBuilder.setAction(setNwTtlActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(setNwTtlActionCaseBuilder.build()).build());
DecNwTtlCaseBuilder decNwTtlCaseBuilder = new DecNwTtlCaseBuilder();
- actions.add(_actionBuilder.setAction(decNwTtlCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(decNwTtlCaseBuilder.build()).build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- actions.add(_actionBuilder.setAction(setFieldCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(setFieldCaseBuilder.build()).build());
PushPbbActionCaseBuilder pushPbbActionCaseBuilder = new PushPbbActionCaseBuilder();
- actions.add(_actionBuilder.setAction(pushPbbActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(pushPbbActionCaseBuilder.build()).build());
PopPbbActionCaseBuilder popPbbActionCaseBuilder = new PopPbbActionCaseBuilder();
- actions.add(_actionBuilder.setAction(popPbbActionCaseBuilder.build()).build());
+ ACTIONS.add(actionBuilder.setAction(popPbbActionCaseBuilder.build()).build());
}
setupFieldTableFeatures();
InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
List<Instruction> instructions = new ArrayList<>();
- for (int i = 0; i < instructionsList.size(); i++) {
+ for (int i = 0; i < INSTRUCTIONS_LIST.size(); i++) {
InstructionBuilder instructionBuilder = new InstructionBuilder();
- instructionBuilder.setInstruction(instructionsList.get(i));
+ instructionBuilder.setInstruction(INSTRUCTIONS_LIST.get(i));
instructions.add(instructionBuilder.build());
}
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder instructionsBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature
+ .prop.type.instructions.InstructionsBuilder instructionsBuilder1 =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
+ .feature.prop.type.instructions.InstructionsBuilder();
instructionsBuilder1.setInstruction(instructions);
instructionsBuilder.setInstructions(instructionsBuilder1.build());
- augmentationsMap.put(Instructions.class, instructionsBuilder.build());
+ AUGMENTATIONS_MAP.put(Instructions.class, instructionsBuilder.build());
InstructionsMissBuilder instructionsMissBuilder = new InstructionsMissBuilder();
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder instructionsMissBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
+ .type.instructions.miss.InstructionsMissBuilder instructionsMissBuilder1 =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
+ .feature.prop.type.instructions.miss.InstructionsMissBuilder();
instructionsMissBuilder1.setInstruction(instructions);
instructionsMissBuilder.setInstructionsMiss(instructionsMissBuilder1.build());
- augmentationsMap.put(InstructionsMiss.class, instructionsMissBuilder.build());
+ AUGMENTATIONS_MAP.put(InstructionsMiss.class, instructionsMissBuilder.build());
NextTableBuilder nextTableBuilder = new NextTableBuilder();
- augmentationsMap.put(NextTable.class, nextTableBuilder.build());
+ AUGMENTATIONS_MAP.put(NextTable.class, nextTableBuilder.build());
NextTableMissBuilder nextTableMissBuilder = new NextTableMissBuilder();
- augmentationsMap.put(NextTableMiss.class, nextTableMissBuilder.build());
+ AUGMENTATIONS_MAP.put(NextTableMiss.class, nextTableMissBuilder.build());
WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
- augmentationsMap.put(WriteActions.class, writeActionsBuilder.build());
+ AUGMENTATIONS_MAP.put(WriteActions.class, writeActionsBuilder.build());
WriteActionsMissBuilder writeActionsMissBuilder = new WriteActionsMissBuilder();
- augmentationsMap.put(WriteActionsMiss.class, writeActionsMissBuilder.build());
+ AUGMENTATIONS_MAP.put(WriteActionsMiss.class, writeActionsMissBuilder.build());
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
- augmentationsMap.put(ApplyActions.class, applyActionsBuilder.build());
+ AUGMENTATIONS_MAP.put(ApplyActions.class, applyActionsBuilder.build());
ApplyActionsMissBuilder applyActionsMissBuilder = new ApplyActionsMissBuilder();
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder applyActionsMissBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder();
- applyActionsMissBuilder1.setAction(actions);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
+ .type.apply.actions.miss.ApplyActionsMissBuilder applyActionsMissBuilder1 =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
+ .feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder();
+ applyActionsMissBuilder1.setAction(ACTIONS);
applyActionsMissBuilder.setApplyActionsMiss(applyActionsMissBuilder1.build());
- augmentationsMap.put(ApplyActionsMiss.class, applyActionsMissBuilder.build());
+ AUGMENTATIONS_MAP.put(ApplyActionsMiss.class, applyActionsMissBuilder.build());
MatchBuilder matchBuilder = new MatchBuilder();
- augmentationsMap.put(Match.class, matchBuilder.build());
+ AUGMENTATIONS_MAP.put(Match.class, matchBuilder.build());
WildcardsBuilder wildcardsBuilder = new WildcardsBuilder();
- augmentationsMap.put(Wildcards.class, wildcardsBuilder.build());
+ AUGMENTATIONS_MAP.put(Wildcards.class, wildcardsBuilder.build());
WriteSetfieldBuilder writeSetfieldBuilder = new WriteSetfieldBuilder();
- augmentationsMap.put(WriteSetfield.class, writeSetfieldBuilder.build());
+ AUGMENTATIONS_MAP.put(WriteSetfield.class, writeSetfieldBuilder.build());
WriteSetfieldMissBuilder writeSetfieldMissBuilder = new WriteSetfieldMissBuilder();
- augmentationsMap.put(WriteSetfieldMiss.class, writeSetfieldMissBuilder.build());
+ AUGMENTATIONS_MAP.put(WriteSetfieldMiss.class, writeSetfieldMissBuilder.build());
ApplySetfieldBuilder applySetfieldBuilder = new ApplySetfieldBuilder();
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder();
- applySetfieldBuilder1.setSetFieldMatch(fieldTableFeatures);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
+ .type.apply.setfield.ApplySetfieldBuilder applySetfieldBuilder1 =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
+ .feature.prop.type.apply.setfield.ApplySetfieldBuilder();
+ applySetfieldBuilder1.setSetFieldMatch(FIELD_TABLE_FEATURES);
applySetfieldBuilder.setApplySetfield(applySetfieldBuilder1.build());
- augmentationsMap.put(ApplySetfield.class, applySetfieldBuilder.build());
+ AUGMENTATIONS_MAP.put(ApplySetfield.class, applySetfieldBuilder.build());
ApplySetfieldMissBuilder applySetfieldMissBuilder = new ApplySetfieldMissBuilder();
- augmentationsMap.put(ApplySetfieldMiss.class, applySetfieldMissBuilder.build());
+ AUGMENTATIONS_MAP.put(ApplySetfieldMiss.class, applySetfieldMissBuilder.build());
}
@Test
- /**
- * Basic functionality test method for {@link TableFeaturesConvertor#toTableFeaturesRequest(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableFeatures)}
- */
public void testToTableFeaturesRequest() throws Exception {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> tableFeaturesList = new ArrayList<>();
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder tableFeaturesBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>
+ tableFeaturesList = new ArrayList<>();
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder
+ tableFeaturesBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
+ .features.TableFeaturesBuilder();
for (int i = 0; i < 10; i++) {
tableFeaturesBuilder.setTableId((short) i);
tableFeaturesBuilder.setName(String.format("table:%d", i));
tableFeaturesBuilder.setMetadataMatch(BigInteger.ONE);
tableFeaturesBuilder.setMetadataWrite(BigInteger.ONE);
- tableFeaturesBuilder.setMaxEntries((long) 1 + (10 * i));
+ tableFeaturesBuilder.setMaxEntries((long) 1 + 10 * i);
tableFeaturesBuilder.setConfig(new TableConfig(false));
tableFeaturesBuilder.setTableProperties(getTableProperties());
tableFeaturesList.add(tableFeaturesBuilder.build());
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures>> tableFeaturesesOptional =
- convertorManager.convert(tableFeatures, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
-
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures> tableFeatureses =
- tableFeaturesesOptional.orElse(Collections.emptyList());
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request
+ .multipart.request.body.multipart.request.table.features._case.multipart.request.table.features
+ .TableFeatures>> tableFeaturesesOptional =
+ convertorManager.convert(tableFeatures, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
assertNotNull(tableFeatures);
assertEquals(10, tableFeatures.getTableFeatures().size());
- List<TableFeatureProperties> tableFeaturePropertieses = tableFeatures.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties();
- assertEquals(augmentationsMap.size() + 1, tableFeaturePropertieses.size());
+ List<TableFeatureProperties> tableFeaturePropertieses = tableFeatures.getTableFeatures().get(0)
+ .getTableProperties().getTableFeatureProperties();
+ assertEquals(AUGMENTATIONS_MAP.size() + 1, tableFeaturePropertieses.size());
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss applyActionsMiss = null;
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature
+ .prop.type.ApplyActionsMiss applyActionsMiss = null;
for (int i = 0; i < tableFeaturePropertieses.size(); i++) {
- if (tableFeaturePropertieses.get(i).getTableFeaturePropType().getImplementedInterface().isAssignableFrom(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss.class)) {
- applyActionsMiss = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) tableFeaturePropertieses.get(i).getTableFeaturePropType();
+ if (tableFeaturePropertieses.get(i).getTableFeaturePropType().getImplementedInterface().isAssignableFrom(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table
+ .feature.prop.type.ApplyActionsMiss.class)) {
+ applyActionsMiss = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature
+ .prop.type.table.feature.prop.type.ApplyActionsMiss) tableFeaturePropertieses.get(i)
+ .getTableFeaturePropType();
break;
}
}
assertNotNull(applyActionsMiss);
- assertEquals(actions.size(), applyActionsMiss.getApplyActionsMiss().getAction().size());
+ assertEquals(ACTIONS.size(), applyActionsMiss.getApplyActionsMiss().getAction().size());
}
TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
List<TableFeatureProperties> tableFeaturePropertieses = new ArrayList<>();
int counter = 0;
- for (Entry<Class<? extends TableFeaturePropType>, TableFeaturePropType> entry : augmentationsMap.entrySet()) {
+ for (Entry<Class<? extends TableFeaturePropType>, TableFeaturePropType> entry : AUGMENTATIONS_MAP.entrySet()) {
counter++;
tableFeaturePropertiesBuilder.setTableFeaturePropType(entry.getValue());
tableFeaturePropertiesBuilder.setOrder(counter);
tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build());
}
tableFeaturePropertieses.add(tableFeaturePropertiesBuilder.build());
- tablePropertiesBuilder.setTableFeatureProperties(tableFeaturePropertieses);
- return tablePropertiesBuilder.build();
+ TABLE_PROPERTIES_BUILDER.setTableFeatureProperties(tableFeaturePropertieses);
+ return TABLE_PROPERTIES_BUILDER.build();
}
}
-/*\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.openflowplugin.openflow.md.core.sal.convertor;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Optional;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
-import org.opendaylight.openflowplugin.api.OFConstants;\r
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;\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.EtherType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;\r
-\r
-/**\r
- * @author michal.polkorab\r
- */\r
-public class TableFeaturesResponseConvertorTest {\r
- private ConvertorManager convertorManager;\r
-\r
- @Before\r
- public void setUp() {\r
- convertorManager = ConvertorManagerFactory.createDefaultManager();\r
- }\r
-\r
- /**\r
- * Incorrect / empty input test\r
- */\r
- @Test\r
- public void test() {\r
- List<TableFeatures> list = convert(null);\r
- Assert.assertEquals("Returned list is not empty", 0, list.size());\r
- }\r
-\r
- /**\r
- * Incorrect / empty input test\r
- */\r
- @Test\r
- public void test2() {\r
- MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();\r
- List<TableFeatures> list = convert(builder.build());\r
- Assert.assertEquals("Returned list is not empty", 0, list.size());\r
- }\r
-\r
- /**\r
- * Test correct input - without table properties\r
- */\r
- @Test\r
- public void testWithMPTableFeature() {\r
- MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart\r
- .reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features\r
- .TableFeatures> features = new ArrayList<>();\r
- TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();\r
- featuresBuilder.setTableId((short) 5);\r
- featuresBuilder.setName("Aloha");\r
- byte[] metaMatch = new byte[]{0, 1, 2, 3, 4, 5, 6, 7};\r
- featuresBuilder.setMetadataMatch(metaMatch);\r
- byte[] metaWrite = new byte[]{8, 9, 10, 11, 12, 13, 14, 15};\r
- featuresBuilder.setMetadataWrite(metaWrite);\r
- featuresBuilder.setConfig(new TableConfig(false));\r
- featuresBuilder.setMaxEntries(42L);\r
- features.add(featuresBuilder.build());\r
- builder.setTableFeatures(features);\r
- List<TableFeatures> list = convert(builder.build());\r
- Assert.assertEquals("Returned empty list", 1, list.size());\r
- TableFeatures feature = list.get(0);\r
- Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());\r
- Assert.assertEquals("Wrong name", "Aloha", feature.getName());\r
- Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch());\r
- Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite());\r
- Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());\r
- Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());\r
- Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().getTableFeatureProperties().size());\r
- }\r
-\r
- /**\r
- * Test correct input\r
- */\r
- @Test\r
- public void testWithMPTableFeatureWithProperties() {\r
- MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart\r
- .reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features\r
- .TableFeatures> features = new ArrayList<>();\r
-\r
- TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();\r
- featuresBuilder.setTableId((short) 5);\r
- featuresBuilder.setName("Aloha");\r
- byte[] metaMatch = new byte[]{0, 1, 2, 3, 4, 5, 6, 7};\r
- featuresBuilder.setMetadataMatch(metaMatch);\r
- byte[] metaWrite = new byte[]{8, 9, 10, 11, 12, 13, 14, 15};\r
- featuresBuilder.setMetadataWrite(metaWrite);\r
- featuresBuilder.setConfig(new TableConfig(false));\r
- featuresBuilder.setMaxEntries(42L);\r
-\r
- List<TableFeatureProperties> properties = new ArrayList<>();\r
- TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();\r
-\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES);\r
- NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder =\r
- new NextTableRelatedTableFeaturePropertyBuilder();\r
- List<NextTableIds> nextIds = new ArrayList<>();\r
- nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build());\r
- nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build());\r
- nextPropBuilder.setNextTableIds(nextIds);\r
- propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());\r
- properties.add(propBuilder.build());\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
-\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS);\r
- nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();\r
- nextIds = new ArrayList<>();\r
- nextIds.add(new NextTableIdsBuilder().setTableId((short) 3).build());\r
- nextPropBuilder.setNextTableIds(nextIds);\r
- propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());\r
- properties.add(propBuilder.build());\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
-\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);\r
- InstructionRelatedTableFeaturePropertyBuilder insPropBuilder =\r
- new InstructionRelatedTableFeaturePropertyBuilder();\r
-\r
- /* -------------------------------------------------- */\r
-\r
- List<Action> actions = new ArrayList<>();\r
- List<Instruction> insIds = new ArrayList<>();\r
- InstructionBuilder insBuilder = new InstructionBuilder();\r
- WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();\r
- WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();\r
- ActionBuilder actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createSetNwSrcAction());\r
- actions.add(actionBuilder.build());\r
- writeActionsBuilder.setAction(actions);\r
- writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());\r
- insBuilder.setInstructionChoice(writeActionsCaseBuilder.build());\r
- insIds.add(insBuilder.build());\r
-\r
- /* -------------------------------------------------- */\r
-\r
- insBuilder = new InstructionBuilder();\r
- GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();\r
- GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();\r
- gotoCaseBuilder.setGotoTable(gotoTableBuilder.build());\r
- insBuilder.setInstructionChoice(gotoCaseBuilder.build());\r
- insIds.add(insBuilder.build());\r
- insPropBuilder.setInstruction(insIds);\r
- propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());\r
- properties.add(propBuilder.build());\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS);\r
- insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();\r
- insIds = new ArrayList<>();\r
- insBuilder = new InstructionBuilder();\r
- WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();\r
- WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();\r
- writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());\r
- insBuilder.setInstructionChoice(writeMetadataCaseBuilder.build());\r
- insIds.add(insBuilder.build());\r
-\r
- insBuilder = new InstructionBuilder();\r
- ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();\r
- ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();\r
- applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());\r
- insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());\r
- insIds.add(insBuilder.build());\r
-\r
- insBuilder = new InstructionBuilder();\r
- MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();\r
- MeterBuilder meterBuilder = new MeterBuilder();\r
- meterCaseBuilder.setMeter(meterBuilder.build());\r
- insBuilder.setInstructionChoice(meterCaseBuilder.build());\r
- insIds.add(insBuilder.build());\r
-\r
-\r
- insBuilder = new InstructionBuilder();\r
- ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();\r
- insBuilder.setInstructionChoice(clearActionsCaseBuilder.build());\r
- insIds.add(insBuilder.build());\r
-\r
-\r
- insBuilder = new InstructionBuilder();\r
- GotoTableCaseBuilder gotoCaseBuilder2 = new GotoTableCaseBuilder();\r
- GotoTableBuilder gotoTableBuilder2 = new GotoTableBuilder();\r
- gotoCaseBuilder2.setGotoTable(gotoTableBuilder2.build());\r
- insBuilder.setInstructionChoice(gotoCaseBuilder2.build());\r
- insIds.add(insBuilder.build());\r
-\r
- insPropBuilder.setInstruction(insIds);\r
- propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());\r
- properties.add(propBuilder.build());\r
- featuresBuilder.setTableFeatureProperties(properties);\r
- features.add(featuresBuilder.build());\r
- featuresBuilder = new TableFeaturesBuilder();\r
- featuresBuilder.setTableId((short) 6);\r
- featuresBuilder.setName("Mahalo");\r
- byte[] metaMatch2 = new byte[]{8, 9, 10, 11, 12, 13, 14, 15};\r
- featuresBuilder.setMetadataMatch(metaMatch2);\r
- byte[] metaWrite2 = new byte[]{0, 1, 2, 3, 4, 5, 6, 7};\r
- featuresBuilder.setMetadataWrite(metaWrite2);\r
- featuresBuilder.setConfig(new TableConfig(false));\r
- featuresBuilder.setMaxEntries(24L);\r
-\r
- /* -------------------------------------------------- */\r
-\r
- properties = new ArrayList<>();\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH);\r
- OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(InPhyPort.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(InPort.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- oxmBuilder.setMatchEntry(entries);\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build()); //[0]\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD);\r
- oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- entries = new ArrayList<>();\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(IpProto.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(IpEcn.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- oxmBuilder.setMatchEntry(entries);\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build());//[1]\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);\r
- oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- entries = new ArrayList<>();\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(VlanVid.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- oxmBuilder.setMatchEntry(entries);\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build());//[2]\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);\r
- oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- entries = new ArrayList<>();\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(VlanPcp.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(TcpSrc.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
- oxmBuilder.setMatchEntry(entries);\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build());//[3]\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);\r
- oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- entries = new ArrayList<>();\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(UdpSrc.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(UdpDst.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
-\r
- oxmBuilder.setMatchEntry(entries);\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build());//[4]\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);\r
- oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- entries = new ArrayList<>();\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(EthSrc.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(EthDst.class);\r
- entriesBuilder.setHasMask(false);\r
- entries.add(entriesBuilder.build());\r
-\r
- oxmBuilder.setMatchEntry(entries);\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build());//[5]\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);\r
- ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();\r
- actions = new ArrayList<>();\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createSetNwSrcAction());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createSetNwSrcAction());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createSetNwSrcAction());\r
- actions.add(actionBuilder.build());\r
- actBuilder.setAction(actions);\r
- propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());\r
- properties.add(propBuilder.build());//[6]\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);\r
- actBuilder = new ActionRelatedTableFeaturePropertyBuilder();\r
-\r
- actions = new ArrayList<>();\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createGroupAction());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createCopyTtlInCase());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createCopyTtlOutCase());\r
- actions.add(actionBuilder.build());\r
- actBuilder.setAction(actions);\r
- propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());\r
- properties.add(propBuilder.build());//[7]\r
-\r
- /* -------------------------------------------------- */\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);\r
- actBuilder = new ActionRelatedTableFeaturePropertyBuilder();\r
-\r
- actions = new ArrayList<>();\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createSetMplsTtlCase());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createDecMplsTtlCase());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(pushVlanCase());\r
- actions.add(actionBuilder.build());\r
- actBuilder.setAction(actions);\r
-\r
- propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());\r
- properties.add(propBuilder.build());\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS);\r
- actBuilder = new ActionRelatedTableFeaturePropertyBuilder();\r
-\r
- actions = new ArrayList<>();\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createPopVlanCase());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createPushPbbCase());\r
- actions.add(actionBuilder.build());\r
-\r
- actionBuilder = new ActionBuilder();\r
- actionBuilder.setActionChoice(createEmptySetFieldCase());\r
- actions.add(actionBuilder.build());\r
- actBuilder.setAction(actions);\r
-\r
- propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());\r
- properties.add(propBuilder.build());\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);\r
- oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build());\r
-\r
- /* -------------------------------------------------- */\r
-\r
- propBuilder = new TableFeaturePropertiesBuilder();\r
- propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);\r
- oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();\r
- propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());\r
- properties.add(propBuilder.build());\r
-\r
- /* -------------------------------------------------- */\r
-\r
- featuresBuilder.setTableFeatureProperties(properties);\r
- features.add(featuresBuilder.build());\r
- builder.setTableFeatures(features);\r
-\r
- List<TableFeatures> list = convert(builder.build());\r
-\r
- Assert.assertEquals("Returned empty list", 2, list.size());\r
- TableFeatures feature = list.get(0);\r
- Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());\r
- Assert.assertEquals("Wrong name", "Aloha", feature.getName());\r
- Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch());\r
- Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite());\r
- Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());\r
- Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());\r
- Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().getTableFeatureProperties().size());\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties\r
- .TableFeatureProperties property = feature.getTableProperties().getTableFeatureProperties().get(0);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- NextTable propType = (NextTable) property.getTableFeaturePropType();\r
- List<Short> ids = propType.getTables().getTableIds();\r
- Assert.assertEquals("Wrong next table-id size", 2, ids.size());\r
- Assert.assertEquals("Wrong next-registry-id", 1, ids.get(0).intValue());\r
- Assert.assertEquals("Wrong next-registry-id", 2, ids.get(1).intValue());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(1);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- NextTableMiss propType2 = (NextTableMiss) property.getTableFeaturePropType();\r
- ids = propType2.getTablesMiss().getTableIds();\r
- Assert.assertEquals("Wrong next table-id size", 1, ids.size());\r
- Assert.assertEquals("Wrong next-registry-id", 3, ids.get(0).intValue());\r
-\r
- property = feature.getTableProperties().getTableFeatureProperties().get(2);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- Instructions propType3 = (Instructions) property.getTableFeaturePropType();\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list\r
- .Instruction> instructionIds = propType3.getInstructions().getInstruction();\r
- Assert.assertEquals("Wrong instruction-ids size", 2, instructionIds.size());\r
- Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase",\r
- instructionIds.get(0).getInstruction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase",\r
- instructionIds.get(1).getInstruction().getImplementedInterface().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(3);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- InstructionsMiss propType4 = (InstructionsMiss) property.getTableFeaturePropType();\r
- instructionIds = propType4.getInstructionsMiss().getInstruction();\r
- Assert.assertEquals("Wrong instruction-ids size", 5, instructionIds.size());\r
- Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCase",\r
- instructionIds.get(0).getInstruction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase",\r
- instructionIds.get(1).getInstruction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCase",\r
- instructionIds.get(2).getInstruction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase",\r
- instructionIds.get(3).getInstruction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase",\r
- instructionIds.get(4).getInstruction().getImplementedInterface().getName());\r
-\r
- feature = list.get(1);\r
- Assert.assertEquals("Wrong table-id", 6, feature.getTableId().intValue());\r
- Assert.assertEquals("Wrong name", "Mahalo", feature.getName());\r
- Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch2), feature.getMetadataMatch());\r
- Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite2), feature.getMetadataWrite());\r
- Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());\r
- Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue());\r
- Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(0);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- Match propType5 = (Match) property.getTableFeaturePropType();\r
- List<SetFieldMatch> fieldMatch = propType5.getMatchSetfield().getSetFieldMatch();\r
- Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPhyPort",\r
- fieldMatch.get(0).getMatchType().getName());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort",\r
- fieldMatch.get(1).getMatchType().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(1);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- ApplySetfield propType6 = (ApplySetfield) property.getTableFeaturePropType();\r
- fieldMatch = propType6.getApplySetfield().getSetFieldMatch();\r
- Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto",\r
- fieldMatch.get(0).getMatchType().getName());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn",\r
- fieldMatch.get(1).getMatchType().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(2);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- WriteSetfield propType7 = (WriteSetfield) property.getTableFeaturePropType();\r
- fieldMatch = propType7.getWriteSetfield().getSetFieldMatch();\r
- Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr",\r
- fieldMatch.get(0).getMatchType().getName());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid",\r
- fieldMatch.get(1).getMatchType().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(3);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- WriteSetfieldMiss propType8 = (WriteSetfieldMiss) property.getTableFeaturePropType();\r
- fieldMatch = propType8.getWriteSetfieldMiss().getSetFieldMatch();\r
- Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp",\r
- fieldMatch.get(0).getMatchType().getName());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc",\r
- fieldMatch.get(1).getMatchType().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(4);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- ApplySetfieldMiss propType9 = (ApplySetfieldMiss) property.getTableFeaturePropType();\r
- fieldMatch = propType9.getApplySetfieldMiss().getSetFieldMatch();\r
- Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc",\r
- fieldMatch.get(0).getMatchType().getName());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst",\r
- fieldMatch.get(1).getMatchType().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(5);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- Wildcards propType10 = (Wildcards) property.getTableFeaturePropType();\r
- fieldMatch = propType10.getWildcardSetfield().getSetFieldMatch();\r
- Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc",\r
- fieldMatch.get(0).getMatchType().getName());\r
- Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst",\r
- fieldMatch.get(1).getMatchType().getName());\r
-\r
- property = feature.getTableProperties().getTableFeatureProperties().get(6);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type\r
- .ApplyActions propType11 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions) property.getTableFeaturePropType();\r
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = propType11.getApplyActions().getAction();\r
- Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",\r
- actionsList.get(0).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",\r
- actionsList.get(1).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",\r
- actionsList.get(2).getAction().getImplementedInterface().getName());\r
-\r
- property = feature.getTableProperties().getTableFeatureProperties().get(7);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type\r
- .ApplyActionsMiss propType12 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type\r
- .ApplyActionsMiss) property.getTableFeaturePropType();\r
- actionsList = propType12.getApplyActionsMiss().getAction();\r
- Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase",\r
- actionsList.get(0).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase",\r
- actionsList.get(1).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase",\r
- actionsList.get(2).getAction().getImplementedInterface().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(8);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
-\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type\r
- .WriteActions propType13 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type\r
- .WriteActions) property.getTableFeaturePropType();\r
- actionsList = propType13.getWriteActions().getAction();\r
- Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase",\r
- actionsList.get(0).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase",\r
- actionsList.get(1).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase",\r
- actionsList.get(2).getAction().getImplementedInterface().getName());\r
- property = feature.getTableProperties().getTableFeatureProperties().get(9);\r
- Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss",\r
- property.getTableFeaturePropType().getImplementedInterface().getName());\r
-\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type\r
- .WriteActionsMiss propType14 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type\r
- .WriteActionsMiss) property.getTableFeaturePropType();\r
- actionsList = propType14.getWriteActionsMiss().getAction();\r
- Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase",\r
- actionsList.get(0).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase",\r
- actionsList.get(1).getAction().getImplementedInterface().getName());\r
- Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase",\r
- actionsList.get(2).getAction().getImplementedInterface().getName());\r
- }\r
-\r
- private static SetNwSrcCase createSetNwSrcAction() {\r
- final SetNwSrcCaseBuilder setNwSrcCaseBuilder;\r
- final SetNwSrcActionBuilder setNwSrcActionBuilder;\r
- setNwSrcCaseBuilder = new SetNwSrcCaseBuilder();\r
- setNwSrcActionBuilder = new SetNwSrcActionBuilder();\r
- setNwSrcActionBuilder.setIpAddress(new Ipv4Address("1.2.3.4"));\r
- setNwSrcCaseBuilder.setSetNwSrcAction(setNwSrcActionBuilder.build());\r
- return setNwSrcCaseBuilder.build();\r
- }\r
-\r
- private static GroupCase createGroupAction() {\r
- final GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();\r
- final GroupActionBuilder groupActionBuilder = new GroupActionBuilder();\r
- groupActionBuilder.setGroupId(42L);\r
- groupCaseBuilder.setGroupAction(groupActionBuilder.build());\r
- return groupCaseBuilder.build();\r
- }\r
-\r
- private static CopyTtlInCase createCopyTtlInCase() {\r
- CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder();\r
- return copyTtlInCaseBuilder.build();\r
- }\r
-\r
- private static CopyTtlOutCase createCopyTtlOutCase() {\r
- CopyTtlOutCaseBuilder copyTtlInCaseBuilder = new CopyTtlOutCaseBuilder();\r
- return copyTtlInCaseBuilder.build();\r
- }\r
-\r
- private static SetMplsTtlCase createSetMplsTtlCase() {\r
- SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();\r
- SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();\r
- setMplsTtlActionBuilder.setMplsTtl((short) 42);\r
- setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlActionBuilder.build());\r
- return setMplsTtlCaseBuilder.build();\r
- }\r
-\r
- private static DecMplsTtlCase createDecMplsTtlCase() {\r
- DecMplsTtlCaseBuilder decMplsTtlCaseBuilder = new DecMplsTtlCaseBuilder();\r
- return decMplsTtlCaseBuilder.build();\r
- }\r
-\r
- private static PushVlanCase pushVlanCase() {\r
- PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();\r
- PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();\r
- pushVlanActionBuilder.setEthertype(new EtherType(1));\r
- pushVlanCaseBuilder.setPushVlanAction(pushVlanActionBuilder.build());\r
- return pushVlanCaseBuilder.build();\r
- }\r
-\r
- private static PopVlanCase createPopVlanCase() {\r
- PopVlanCaseBuilder popVlanCaseBuilder = new PopVlanCaseBuilder();\r
- return popVlanCaseBuilder.build();\r
- }\r
-\r
- private static PushPbbCase createPushPbbCase() {\r
- PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();\r
- PushPbbActionBuilder pushPbbActionBuilder = new PushPbbActionBuilder();\r
- pushPbbActionBuilder.setEthertype(new EtherType(1));\r
- pushPbbCaseBuilder.setPushPbbAction(pushPbbActionBuilder.build());\r
- return pushPbbCaseBuilder.build();\r
- }\r
-\r
- private static SetFieldCase createEmptySetFieldCase() {\r
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();\r
- SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();\r
- List<MatchEntry> matchEntries = new ArrayList<>();\r
- MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();\r
-\r
- matchEntries.add(matchEntryBuilder.build());\r
- setFieldActionBuilder.setMatchEntry(matchEntries);\r
- setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());\r
- return setFieldCaseBuilder.build();\r
- }\r
-\r
-\r
- private List<TableFeatures> convert(MultipartReplyTableFeatures features) {\r
- Optional<List<TableFeatures>> listOptional = convertorManager.convert(features, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));\r
- return listOptional.orElse(Collections.emptyList());\r
- }\r
-}
\ No newline at end of file
+/*
+ * 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.openflowplugin.openflow.md.core.sal.convertor;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeatureProperty;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.OxmRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlInCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.CopyTtlOutCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.DecMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.GroupCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PopVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushPbbCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.PushVlanCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetMplsTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetNwSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.group._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.pbb._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.push.vlan._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.field._case.SetFieldActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.mpls.ttl._case.SetMplsTtlActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.set.nw.src._case.SetNwSrcActionBuilder;
+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.instruction.grouping.instruction.choice.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice._goto.table._case.GotoTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.write.metadata._case.WriteMetadataBuilder;
+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.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
+
+/**
+ * Unit tests for table features response conversions.
+ *
+ * @author michal.polkorab
+ */
+public class TableFeaturesResponseConvertorTest {
+ private ConvertorManager convertorManager;
+
+ @Before
+ public void setUp() {
+ convertorManager = ConvertorManagerFactory.createDefaultManager();
+ }
+
+ /**
+ * Incorrect / empty input test.
+ */
+ @Test
+ public void test() {
+ List<TableFeatures> list = convert(null);
+ Assert.assertEquals("Returned list is not empty", 0, list.size());
+ }
+
+ /**
+ * Incorrect / empty input test.
+ */
+ @Test
+ public void test2() {
+ MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
+ List<TableFeatures> list = convert(builder.build());
+ Assert.assertEquals("Returned list is not empty", 0, list.size());
+ }
+
+ /**
+ * Test correct input - without table properties.
+ */
+ @Test
+ public void testWithMPTableFeature() {
+ TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
+ featuresBuilder.setTableId((short) 5);
+ featuresBuilder.setName("Aloha");
+ byte[] metaMatch = new byte[]{0, 1, 2, 3, 4, 5, 6, 7};
+ featuresBuilder.setMetadataMatch(metaMatch);
+ byte[] metaWrite = new byte[]{8, 9, 10, 11, 12, 13, 14, 15};
+ featuresBuilder.setMetadataWrite(metaWrite);
+ featuresBuilder.setConfig(new TableConfig(false));
+ featuresBuilder.setMaxEntries(42L);
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart
+ .reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features
+ .TableFeatures> features = new ArrayList<>();
+ features.add(featuresBuilder.build());
+
+ MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
+ builder.setTableFeatures(features);
+ List<TableFeatures> list = convert(builder.build());
+ Assert.assertEquals("Returned empty list", 1, list.size());
+ TableFeatures feature = list.get(0);
+ Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());
+ Assert.assertEquals("Wrong name", "Aloha", feature.getName());
+ Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch());
+ Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite());
+ Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
+ Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());
+ Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().getTableFeatureProperties().size());
+ }
+
+ /**
+ * Test correct input.
+ */
+ @Test
+ public void testWithMPTableFeatureWithProperties() {
+ TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
+ featuresBuilder.setTableId((short) 5);
+ featuresBuilder.setName("Aloha");
+ byte[] metaMatch = new byte[]{0, 1, 2, 3, 4, 5, 6, 7};
+ featuresBuilder.setMetadataMatch(metaMatch);
+ byte[] metaWrite = new byte[]{8, 9, 10, 11, 12, 13, 14, 15};
+ featuresBuilder.setMetadataWrite(metaWrite);
+ featuresBuilder.setConfig(new TableConfig(false));
+ featuresBuilder.setMaxEntries(42L);
+
+ TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
+
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES);
+ NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder =
+ new NextTableRelatedTableFeaturePropertyBuilder();
+ List<NextTableIds> nextIds = new ArrayList<>();
+ nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build());
+ nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build());
+ nextPropBuilder.setNextTableIds(nextIds);
+ propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
+
+ List<TableFeatureProperties> properties = new ArrayList<>();
+ properties.add(propBuilder.build());
+ propBuilder = new TableFeaturePropertiesBuilder();
+
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS);
+ nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
+ nextIds = new ArrayList<>();
+ nextIds.add(new NextTableIdsBuilder().setTableId((short) 3).build());
+ nextPropBuilder.setNextTableIds(nextIds);
+ propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
+ properties.add(propBuilder.build());
+ propBuilder = new TableFeaturePropertiesBuilder();
+
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
+
+ /* -------------------------------------------------- */
+
+ List<Action> actions = new ArrayList<>();
+ WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createSetNwSrcAction());
+ actions.add(actionBuilder.build());
+ writeActionsBuilder.setAction(actions);
+
+ WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
+ writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
+
+ InstructionBuilder insBuilder = new InstructionBuilder();
+ insBuilder.setInstructionChoice(writeActionsCaseBuilder.build());
+
+ List<Instruction> insIds = new ArrayList<>();
+ insIds.add(insBuilder.build());
+
+ /* -------------------------------------------------- */
+
+ insBuilder = new InstructionBuilder();
+ GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
+ GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();
+ gotoCaseBuilder.setGotoTable(gotoTableBuilder.build());
+ insBuilder.setInstructionChoice(gotoCaseBuilder.build());
+ insIds.add(insBuilder.build());
+
+ InstructionRelatedTableFeaturePropertyBuilder insPropBuilder =
+ new InstructionRelatedTableFeaturePropertyBuilder();
+ insPropBuilder.setInstruction(insIds);
+ propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
+ properties.add(propBuilder.build());
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS);
+ insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
+ insIds = new ArrayList<>();
+ insBuilder = new InstructionBuilder();
+ WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
+ WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
+ writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
+ insBuilder.setInstructionChoice(writeMetadataCaseBuilder.build());
+ insIds.add(insBuilder.build());
+
+ insBuilder = new InstructionBuilder();
+ ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
+ ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
+ applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
+ insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
+ insIds.add(insBuilder.build());
+
+ insBuilder = new InstructionBuilder();
+ MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
+ MeterBuilder meterBuilder = new MeterBuilder();
+ meterCaseBuilder.setMeter(meterBuilder.build());
+ insBuilder.setInstructionChoice(meterCaseBuilder.build());
+ insIds.add(insBuilder.build());
+
+
+ insBuilder = new InstructionBuilder();
+ ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
+ insBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
+ insIds.add(insBuilder.build());
+
+
+ insBuilder = new InstructionBuilder();
+ GotoTableCaseBuilder gotoCaseBuilder2 = new GotoTableCaseBuilder();
+ GotoTableBuilder gotoTableBuilder2 = new GotoTableBuilder();
+ gotoCaseBuilder2.setGotoTable(gotoTableBuilder2.build());
+ insBuilder.setInstructionChoice(gotoCaseBuilder2.build());
+ insIds.add(insBuilder.build());
+
+ insPropBuilder.setInstruction(insIds);
+ propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
+ properties.add(propBuilder.build());
+ featuresBuilder.setTableFeatureProperties(properties);
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart
+ .reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features
+ .TableFeatures> features = new ArrayList<>();
+ features.add(featuresBuilder.build());
+ featuresBuilder = new TableFeaturesBuilder();
+ featuresBuilder.setTableId((short) 6);
+ featuresBuilder.setName("Mahalo");
+ byte[] metaMatch2 = new byte[]{8, 9, 10, 11, 12, 13, 14, 15};
+ featuresBuilder.setMetadataMatch(metaMatch2);
+ byte[] metaWrite2 = new byte[]{0, 1, 2, 3, 4, 5, 6, 7};
+ featuresBuilder.setMetadataWrite(metaWrite2);
+ featuresBuilder.setConfig(new TableConfig(false));
+ featuresBuilder.setMaxEntries(24L);
+
+ /* -------------------------------------------------- */
+
+ properties = new ArrayList<>();
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH);
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(InPhyPort.class);
+ entriesBuilder.setHasMask(false);
+
+ List<MatchEntry> entries = new ArrayList<>();
+ entries.add(entriesBuilder.build());
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(InPort.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+
+ OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ oxmBuilder.setMatchEntry(entries);
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build()); //[0]
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD);
+ oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ entries = new ArrayList<>();
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(IpProto.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(IpEcn.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+ oxmBuilder.setMatchEntry(entries);
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build());//[1]
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);
+ oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ entries = new ArrayList<>();
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(VlanVid.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+ oxmBuilder.setMatchEntry(entries);
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build());//[2]
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);
+ oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ entries = new ArrayList<>();
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(VlanPcp.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(TcpSrc.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+ oxmBuilder.setMatchEntry(entries);
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build());//[3]
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);
+ oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ entries = new ArrayList<>();
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(UdpSrc.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(UdpDst.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+
+ oxmBuilder.setMatchEntry(entries);
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build());//[4]
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);
+ oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ entries = new ArrayList<>();
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(EthSrc.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(EthDst.class);
+ entriesBuilder.setHasMask(false);
+ entries.add(entriesBuilder.build());
+
+ oxmBuilder.setMatchEntry(entries);
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build());//[5]
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);
+ actions = new ArrayList<>();
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createSetNwSrcAction());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createSetNwSrcAction());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createSetNwSrcAction());
+ actions.add(actionBuilder.build());
+
+ ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+ actBuilder.setAction(actions);
+ propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+ properties.add(propBuilder.build());//[6]
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);
+ actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+
+ actions = new ArrayList<>();
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createGroupAction());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createCopyTtlInCase());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createCopyTtlOutCase());
+ actions.add(actionBuilder.build());
+ actBuilder.setAction(actions);
+ propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+ properties.add(propBuilder.build());//[7]
+
+ /* -------------------------------------------------- */
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);
+ actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+
+ actions = new ArrayList<>();
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createSetMplsTtlCase());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createDecMplsTtlCase());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(pushVlanCase());
+ actions.add(actionBuilder.build());
+ actBuilder.setAction(actions);
+
+ propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+ properties.add(propBuilder.build());
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS);
+ actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
+
+ actions = new ArrayList<>();
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createPopVlanCase());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createPushPbbCase());
+ actions.add(actionBuilder.build());
+
+ actionBuilder = new ActionBuilder();
+ actionBuilder.setActionChoice(createEmptySetFieldCase());
+ actions.add(actionBuilder.build());
+ actBuilder.setAction(actions);
+
+ propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
+ properties.add(propBuilder.build());
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
+ oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build());
+
+ /* -------------------------------------------------- */
+
+ propBuilder = new TableFeaturePropertiesBuilder();
+ propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
+ oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
+ propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
+ properties.add(propBuilder.build());
+
+ /* -------------------------------------------------- */
+
+ featuresBuilder.setTableFeatureProperties(properties);
+ features.add(featuresBuilder.build());
+
+ MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
+ builder.setTableFeatures(features);
+
+ List<TableFeatures> list = convert(builder.build());
+
+ Assert.assertEquals("Returned empty list", 2, list.size());
+ TableFeatures feature = list.get(0);
+ Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());
+ Assert.assertEquals("Wrong name", "Aloha", feature.getName());
+ Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch());
+ Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite());
+ Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
+ Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());
+ Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().getTableFeatureProperties().size());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table
+ .properties.TableFeatureProperties property = feature.getTableProperties().getTableFeatureProperties()
+ .get(0);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTable",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ NextTable propType = (NextTable) property.getTableFeaturePropType();
+ List<Short> ids = propType.getTables().getTableIds();
+ Assert.assertEquals("Wrong next table-id size", 2, ids.size());
+ Assert.assertEquals("Wrong next-registry-id", 1, ids.get(0).intValue());
+ Assert.assertEquals("Wrong next-registry-id", 2, ids.get(1).intValue());
+ property = feature.getTableProperties().getTableFeatureProperties().get(1);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ NextTableMiss propType2 = (NextTableMiss) property.getTableFeaturePropType();
+ ids = propType2.getTablesMiss().getTableIds();
+ Assert.assertEquals("Wrong next table-id size", 1, ids.size());
+ Assert.assertEquals("Wrong next-registry-id", 3, ids.get(0).intValue());
+
+ property = feature.getTableProperties().getTableFeatureProperties().get(2);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.Instructions",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ Instructions propType3 = (Instructions) property.getTableFeaturePropType();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list
+ .Instruction> instructionIds = propType3.getInstructions().getInstruction();
+ Assert.assertEquals("Wrong instruction-ids size", 2, instructionIds.size());
+ Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ + "rev131026.instruction.instruction.WriteActionsCase",
+ instructionIds.get(0).getInstruction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ + "rev131026.instruction.instruction.GoToTableCase",
+ instructionIds.get(1).getInstruction().getImplementedInterface().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(3);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ InstructionsMiss propType4 = (InstructionsMiss) property.getTableFeaturePropType();
+ instructionIds = propType4.getInstructionsMiss().getInstruction();
+ Assert.assertEquals("Wrong instruction-ids size", 5, instructionIds.size());
+ Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ + "rev131026.instruction.instruction.WriteMetadataCase",
+ instructionIds.get(0).getInstruction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ + "rev131026.instruction.instruction.ApplyActionsCase",
+ instructionIds.get(1).getInstruction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ + "rev131026.instruction.instruction.MeterCase",
+ instructionIds.get(2).getInstruction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ + "rev131026.instruction.instruction.ClearActionsCase",
+ instructionIds.get(3).getInstruction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types."
+ + "rev131026.instruction.instruction.GoToTableCase",
+ instructionIds.get(4).getInstruction().getImplementedInterface().getName());
+
+ feature = list.get(1);
+ Assert.assertEquals("Wrong table-id", 6, feature.getTableId().intValue());
+ Assert.assertEquals("Wrong name", "Mahalo", feature.getName());
+ Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch2), feature.getMetadataMatch());
+ Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite2), feature.getMetadataWrite());
+ Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
+ Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue());
+ Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size());
+ property = feature.getTableProperties().getTableFeatureProperties().get(0);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.Match",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ Match propType5 = (Match) property.getTableFeaturePropType();
+ List<SetFieldMatch> fieldMatch = propType5.getMatchSetfield().getSetFieldMatch();
+ Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.InPhyPort", fieldMatch.get(0).getMatchType().getName());
+ Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.InPort", fieldMatch.get(1).getMatchType().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(1);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ ApplySetfield propType6 = (ApplySetfield) property.getTableFeaturePropType();
+ fieldMatch = propType6.getApplySetfield().getSetFieldMatch();
+ Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto",
+ fieldMatch.get(0).getMatchType().getName());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn",
+ fieldMatch.get(1).getMatchType().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(2);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ WriteSetfield propType7 = (WriteSetfield) property.getTableFeaturePropType();
+ fieldMatch = propType7.getWriteSetfield().getSetFieldMatch();
+ Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr",
+ fieldMatch.get(0).getMatchType().getName());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid",
+ fieldMatch.get(1).getMatchType().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(3);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ WriteSetfieldMiss propType8 = (WriteSetfieldMiss) property.getTableFeaturePropType();
+ fieldMatch = propType8.getWriteSetfieldMiss().getSetFieldMatch();
+ Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp",
+ fieldMatch.get(0).getMatchType().getName());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc",
+ fieldMatch.get(1).getMatchType().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(4);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ ApplySetfieldMiss propType9 = (ApplySetfieldMiss) property.getTableFeaturePropType();
+ fieldMatch = propType9.getApplySetfieldMiss().getSetFieldMatch();
+ Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc",
+ fieldMatch.get(0).getMatchType().getName());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst",
+ fieldMatch.get(1).getMatchType().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(5);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ Wildcards propType10 = (Wildcards) property.getTableFeaturePropType();
+ fieldMatch = propType10.getWildcardSetfield().getSetFieldMatch();
+ Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc",
+ fieldMatch.get(0).getMatchType().getName());
+ Assert.assertEquals("Wrong match-entry-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst",
+ fieldMatch.get(1).getMatchType().getName());
+
+ property = feature.getTableProperties().getTableFeatureProperties().get(6);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
+ .type.ApplyActions propType11 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
+ .feature.prop.type.table.feature.prop.type.ApplyActions) property.getTableFeaturePropType();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList =
+ propType11.getApplyActions().getAction();
+ Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",
+ actionsList.get(0).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",
+ actionsList.get(1).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase",
+ actionsList.get(2).getAction().getImplementedInterface().getName());
+
+ property = feature.getTableProperties().getTableFeatureProperties().get(7);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
+ .type.ApplyActionsMiss propType12 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
+ .table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) property.getTableFeaturePropType();
+ actionsList = propType12.getApplyActionsMiss().getAction();
+ Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase",
+ actionsList.get(0).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase",
+ actionsList.get(1).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase",
+ actionsList.get(2).getAction().getImplementedInterface().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(8);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
+ .type.WriteActions propType13 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
+ .feature.prop.type.table.feature.prop.type.WriteActions) property.getTableFeaturePropType();
+ actionsList = propType13.getWriteActions().getAction();
+ Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase",
+ actionsList.get(0).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase",
+ actionsList.get(1).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase",
+ actionsList.get(2).getAction().getImplementedInterface().getName());
+ property = feature.getTableProperties().getTableFeatureProperties().get(9);
+ Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types."
+ + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss",
+ property.getTableFeaturePropType().getImplementedInterface().getName());
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop
+ .type.WriteActionsMiss propType14 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
+ .table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) property.getTableFeaturePropType();
+ actionsList = propType14.getWriteActionsMiss().getAction();
+ Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase",
+ actionsList.get(0).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase",
+ actionsList.get(1).getAction().getImplementedInterface().getName());
+ Assert.assertEquals("Wrong actions-id",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase",
+ actionsList.get(2).getAction().getImplementedInterface().getName());
+ }
+
+ private static SetNwSrcCase createSetNwSrcAction() {
+ final SetNwSrcCaseBuilder setNwSrcCaseBuilder;
+ final SetNwSrcActionBuilder setNwSrcActionBuilder;
+ setNwSrcCaseBuilder = new SetNwSrcCaseBuilder();
+ setNwSrcActionBuilder = new SetNwSrcActionBuilder();
+ setNwSrcActionBuilder.setIpAddress(new Ipv4Address("1.2.3.4"));
+ setNwSrcCaseBuilder.setSetNwSrcAction(setNwSrcActionBuilder.build());
+ return setNwSrcCaseBuilder.build();
+ }
+
+ private static GroupCase createGroupAction() {
+ final GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();
+ final GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
+ groupActionBuilder.setGroupId(42L);
+ groupCaseBuilder.setGroupAction(groupActionBuilder.build());
+ return groupCaseBuilder.build();
+ }
+
+ private static CopyTtlInCase createCopyTtlInCase() {
+ CopyTtlInCaseBuilder copyTtlInCaseBuilder = new CopyTtlInCaseBuilder();
+ return copyTtlInCaseBuilder.build();
+ }
+
+ private static CopyTtlOutCase createCopyTtlOutCase() {
+ CopyTtlOutCaseBuilder copyTtlInCaseBuilder = new CopyTtlOutCaseBuilder();
+ return copyTtlInCaseBuilder.build();
+ }
+
+ private static SetMplsTtlCase createSetMplsTtlCase() {
+ SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();
+ SetMplsTtlActionBuilder setMplsTtlActionBuilder = new SetMplsTtlActionBuilder();
+ setMplsTtlActionBuilder.setMplsTtl((short) 42);
+ setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlActionBuilder.build());
+ return setMplsTtlCaseBuilder.build();
+ }
+
+ private static DecMplsTtlCase createDecMplsTtlCase() {
+ DecMplsTtlCaseBuilder decMplsTtlCaseBuilder = new DecMplsTtlCaseBuilder();
+ return decMplsTtlCaseBuilder.build();
+ }
+
+ private static PushVlanCase pushVlanCase() {
+ PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
+ PushVlanActionBuilder pushVlanActionBuilder = new PushVlanActionBuilder();
+ pushVlanActionBuilder.setEthertype(new EtherType(1));
+ pushVlanCaseBuilder.setPushVlanAction(pushVlanActionBuilder.build());
+ return pushVlanCaseBuilder.build();
+ }
+
+ private static PopVlanCase createPopVlanCase() {
+ PopVlanCaseBuilder popVlanCaseBuilder = new PopVlanCaseBuilder();
+ return popVlanCaseBuilder.build();
+ }
+
+ private static PushPbbCase createPushPbbCase() {
+ PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
+ PushPbbActionBuilder pushPbbActionBuilder = new PushPbbActionBuilder();
+ pushPbbActionBuilder.setEthertype(new EtherType(1));
+ pushPbbCaseBuilder.setPushPbbAction(pushPbbActionBuilder.build());
+ return pushPbbCaseBuilder.build();
+ }
+
+ private static SetFieldCase createEmptySetFieldCase() {
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
+ SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
+ List<MatchEntry> matchEntries = new ArrayList<>();
+ MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
+
+ matchEntries.add(matchEntryBuilder.build());
+ setFieldActionBuilder.setMatchEntry(matchEntries);
+ setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
+ return setFieldCaseBuilder.build();
+ }
+
+
+ private List<TableFeatures> convert(MultipartReplyTableFeatures features) {
+ Optional<List<TableFeatures>> listOptional =
+ convertorManager.convert(features, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ return listOptional.orElse(Collections.emptyList());
+ }
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
/**
- * test for {@link ActionConvertor}
+ * test for {@link ActionConvertor}.
*/
public class ActionConvertorTest {
@Test
public void testActionConvertorwithallParameters() {
- OutputActionData();
- CopyTtlData();
- MplsTtlActionData();
+ outputActionData();
+ copyTtlData();
+ mplsTtlActionData();
vlanActionData();
mplsActionData();
setQueueActionData();
setGroupAction();
- NwTtlAction();
+ nwTtlAction();
pbbActionData();
setFieldData();
setExperimenterData();
data.setDatapathId(BigInteger.ONE);
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>> OFActionsList =
- convertorManager.convert(actions, data);
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping
+ .Action>> ofActionsList = convertorManager.convert(actions, data);
- outputActions(OFActionsList.orElse(Collections.emptyList()));
+ outputActions(ofActionsList.orElse(Collections.emptyList()));
}
}
private void dropActionData() {
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new DropActionCaseBuilder().build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new DropActionCaseBuilder().build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
}
SetFieldBuilder setFB = new SetFieldBuilder();
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new SetFieldCaseBuilder().setSetField(setFB.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new SetFieldCaseBuilder().setSetField(setFB.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
}
PushPbbActionBuilder pushpbb = new PushPbbActionBuilder();
pushpbb.setEthernetType(10);
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new PushPbbActionCaseBuilder().setPushPbbAction(pushpbb.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new PushPbbActionCaseBuilder()
+ .setPushPbbAction(pushpbb.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
PopPbbActionBuilder popPBB = new PopPbbActionBuilder();
- ActionBuilder AB1 = new ActionBuilder();
- AB1.setOrder(actionItem).setAction(new PopPbbActionCaseBuilder().setPopPbbAction(popPBB.build()).build());
+ ActionBuilder actionBuilder1 = new ActionBuilder();
+ actionBuilder1.setOrder(actionItem).setAction(new PopPbbActionCaseBuilder()
+ .setPopPbbAction(popPBB.build()).build());
- actions.add(actionItem++, AB1.build());
+ actions.add(actionItem++, actionBuilder1.build());
}
- private void NwTtlAction() {
+ private void nwTtlAction() {
SetNwTtlActionBuilder setNwTtlActionBuilder = new SetNwTtlActionBuilder();
setNwTtlActionBuilder.setNwTtl((short) 1);
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new SetNwTtlActionCaseBuilder().setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new SetNwTtlActionCaseBuilder()
+ .setSetNwTtlAction(setNwTtlActionBuilder.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
DecNwTtlBuilder necNwTtlBuilder = new DecNwTtlBuilder();
- ActionBuilder AB1 = new ActionBuilder();
- AB1.setOrder(actionItem).setAction(new DecNwTtlCaseBuilder().setDecNwTtl(necNwTtlBuilder.build()).build());
+ ActionBuilder actionBuilder1 = new ActionBuilder();
+ actionBuilder1.setOrder(actionItem).setAction(
+ new DecNwTtlCaseBuilder().setDecNwTtl(necNwTtlBuilder.build()).build());
- actions.add(actionItem++, AB1.build());
+ actions.add(actionItem++, actionBuilder1.build());
}
GroupActionBuilder grpIdAB = new GroupActionBuilder();
grpIdAB.setGroup("98");
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new GroupActionCaseBuilder().setGroupAction(grpIdAB.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new GroupActionCaseBuilder()
+ .setGroupAction(grpIdAB.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
}
// TODO - check if this method is needed (private and never used locally) - see line 94
- private static void outputActions(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> oFActionsList) {
-
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action : oFActionsList) {
+ private static void outputActions(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
+ .action.rev150203.actions.grouping.Action> ofActionsList) {
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action
+ action : ofActionsList) {
if (action.getActionChoice() instanceof OutputActionCase) {
OutputActionCase outputActionCase = (OutputActionCase) action.getActionChoice();
- Assert.assertEquals((Integer) 10, (outputActionCase.getOutputAction().getMaxLength()));
+ Assert.assertEquals((Integer) 10, outputActionCase.getOutputAction().getMaxLength());
long port = 4294967293L;
- Assert.assertEquals(port, (long) (outputActionCase.getOutputAction().getPort().getValue()));
+ Assert.assertEquals(port, (long) outputActionCase.getOutputAction().getPort().getValue());
}
if (action.getActionChoice() instanceof CopyTtlInCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlInCase.class.getName());
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ CopyTtlInCase.class.getName());
}
if (action.getActionChoice() instanceof CopyTtlOutCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), CopyTtlOutCase.class.getName());
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ CopyTtlOutCase.class.getName());
}
- if (action.getActionChoice() instanceof
- // TODO:getMplsTtl is missing.
- SetMplsTtlCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetMplsTtlCase.class.getName());
+ if (action.getActionChoice() instanceof SetMplsTtlCase) {
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ SetMplsTtlCase.class.getName());
}
if (action.getActionChoice() instanceof DecMplsTtlCase) {
if (action.getActionChoice() instanceof PopMplsCase) {
PopMplsCase popMplsCase = (PopMplsCase) action.getActionChoice();
- Assert.assertEquals((Integer) 10, (popMplsCase.getPopMplsAction().getEthertype().getValue()));
+ Assert.assertEquals((Integer) 10, popMplsCase.getPopMplsAction().getEthertype().getValue());
}
- if (action.getActionChoice() instanceof
-
- // TODO:SetQueue,I dont have getQueueId
- SetQueueCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetQueueCase.class.getName());
+ if (action.getActionChoice() instanceof SetQueueCase) {
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ SetQueueCase.class.getName());
}
if (action.getActionChoice() instanceof GroupCase) {
GroupCase groupCase = (GroupCase) action.getActionChoice();
- Assert.assertEquals(98, (long) (groupCase.getGroupAction().getGroupId()));
+ Assert.assertEquals(98, (long) groupCase.getGroupAction().getGroupId());
}
if (action.getActionChoice() instanceof PushVlanCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PushVlanCase.class.getName());
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ PushVlanCase.class.getName());
}
if (action.getActionChoice() instanceof PopVlanCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopVlanCase.class.getName());
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ PopVlanCase.class.getName());
}
if (action.getActionChoice() instanceof SetNwTtlCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), SetNwTtlCase.class.getName());
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ SetNwTtlCase.class.getName());
}
if (action.getActionChoice() instanceof DecNwTtlCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), DecNwTtlCase.class.getName());
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ DecNwTtlCase.class.getName());
}
if (action.getActionChoice() instanceof PushPbbCase) {
PushPbbCase pushPbbCase = (PushPbbCase) action.getActionChoice();
}
if (action.getActionChoice() instanceof PopMplsCase) {
- Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(), PopMplsCase.class.getName());
+ Assert.assertEquals(action.getActionChoice().getImplementedInterface().getName(),
+ PopMplsCase.class.getName());
}
if (action.getActionChoice() instanceof SetFieldCase) {
SetFieldCase setFieldCase = (SetFieldCase) action.getActionChoice();
}
- private void OutputActionData() {
+ private void outputActionData() {
OutputActionBuilder outputB = new OutputActionBuilder();
outputB.setMaxLength(10);
Uri uri = new Uri(OutputPortValues.CONTROLLER.toString());
outputB.setOutputNodeConnector(uri);
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new OutputActionCaseBuilder().setOutputAction(outputB.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new OutputActionCaseBuilder()
+ .setOutputAction(outputB.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
}
- private void CopyTtlData() {
+ private void copyTtlData() {
CopyTtlOutBuilder copyB = new CopyTtlOutBuilder();
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyB.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new CopyTtlOutCaseBuilder().setCopyTtlOut(copyB.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
CopyTtlInBuilder copyTtlInBuilder = new CopyTtlInBuilder();
- ActionBuilder AB1 = new ActionBuilder();
- AB1.setOrder(actionItem).setAction(new CopyTtlInCaseBuilder().setCopyTtlIn(copyTtlInBuilder.build()).build());
+ ActionBuilder actionBuilder1 = new ActionBuilder();
+ actionBuilder1.setOrder(actionItem).setAction(new CopyTtlInCaseBuilder()
+ .setCopyTtlIn(copyTtlInBuilder.build()).build());
- actions.add(actionItem++, AB1.build());
+ actions.add(actionItem++, actionBuilder1.build());
}
- private void MplsTtlActionData() {
+ private void mplsTtlActionData() {
SetMplsTtlActionBuilder setMplsTtlActionB = new SetMplsTtlActionBuilder();
setMplsTtlActionB.setMplsTtl((short) 10);
- ActionBuilder AB1 = new ActionBuilder();
- AB1.setOrder(actionItem).setAction(new SetMplsTtlActionCaseBuilder().setSetMplsTtlAction(setMplsTtlActionB.build()).build());
+ ActionBuilder actionBuilder1 = new ActionBuilder();
+ actionBuilder1.setOrder(actionItem).setAction(new SetMplsTtlActionCaseBuilder()
+ .setSetMplsTtlAction(setMplsTtlActionB.build()).build());
- actions.add(actionItem++, AB1.build());
+ actions.add(actionItem++, actionBuilder1.build());
DecMplsTtlBuilder decMplsTtlB = new DecMplsTtlBuilder();
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new DecMplsTtlCaseBuilder().setDecMplsTtl(decMplsTtlB.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new DecMplsTtlCaseBuilder()
+ .setDecMplsTtl(decMplsTtlB.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
}
private void vlanActionData() {
pvB.setVlanId(new VlanId(10));
- ActionBuilder AB1 = new ActionBuilder();
- AB1.setOrder(actionItem).setAction(new PushVlanActionCaseBuilder().setPushVlanAction(pvB.build()).build());
+ ActionBuilder actionBuilder1 = new ActionBuilder();
+ actionBuilder1.setOrder(actionItem).setAction(new PushVlanActionCaseBuilder()
+ .setPushVlanAction(pvB.build()).build());
- actions.add(actionItem++, AB1.build());
+ actions.add(actionItem++, actionBuilder1.build());
PopVlanActionBuilder popVAB = new PopVlanActionBuilder();
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new PopVlanActionCaseBuilder().setPopVlanAction(popVAB.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new PopVlanActionCaseBuilder()
+ .setPopVlanAction(popVAB.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
}
PushMplsActionBuilder pushMB = new PushMplsActionBuilder();
pushMB.setEthernetType(10);
- ActionBuilder AB = new ActionBuilder();
- AB.setOrder(actionItem).setAction(new PushMplsActionCaseBuilder().setPushMplsAction(pushMB.build()).build());
+ ActionBuilder actionBuilder = new ActionBuilder();
+ actionBuilder.setOrder(actionItem).setAction(new PushMplsActionCaseBuilder()
+ .setPushMplsAction(pushMB.build()).build());
- actions.add(actionItem++, AB.build());
+ actions.add(actionItem++, actionBuilder.build());
PopMplsActionBuilder popMB = new PopMplsActionBuilder();
popMB.setEthernetType(10);
- ActionBuilder AB1 = new ActionBuilder();
- AB1.setOrder(actionItem).setAction(new PopMplsActionCaseBuilder().setPopMplsAction(popMB.build()).build());
+ ActionBuilder actionBuilder1 = new ActionBuilder();
+ actionBuilder1.setOrder(actionItem).setAction(new PopMplsActionCaseBuilder()
+ .setPopMplsAction(popMB.build()).build());
- actions.add(actionItem++, AB1.build());
+ actions.add(actionItem++, actionBuilder1.build());
}
private void setQueueActionData() {
SetQueueActionBuilder setQB = new SetQueueActionBuilder();
setQB.setQueue("99");
- ActionBuilder AB1 = new ActionBuilder();
- AB1.setOrder(actionItem).setAction(new SetQueueActionCaseBuilder().setSetQueueAction(setQB.build()).build());
-
- actions.add(actionItem++, AB1.build());
+ ActionBuilder actionBuilder1 = new ActionBuilder();
+ actionBuilder1.setOrder(actionItem).setAction(new SetQueueActionCaseBuilder()
+ .setSetQueueAction(setQB.build()).build());
+ actions.add(actionItem++, actionBuilder1.build());
}
-
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder;
/**
- * @author michal.polkorab
+ * Unit tests for v1.0 action converters.
*
+ * @author michal.polkorab
*/
public class ActionConvertorV10Test {
private ConvertorManager convertorManager;
}
/**
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)}}
+ * Test {@link ActionConvertor#convert(List, ActionConvertorData)}}.
*/
@Test
public void testGetActions() {
- List<Action> salActions = new ArrayList<>();
ActionBuilder actionBuilder = new ActionBuilder();
SetVlanPcpActionCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpActionCaseBuilder();
SetVlanPcpActionBuilder pcpBuilder = new SetVlanPcpActionBuilder();
vlanPcpCaseBuilder.setSetVlanPcpAction(pcpBuilder.build());
actionBuilder.setAction(vlanPcpCaseBuilder.build());
actionBuilder.setOrder(0);
+
+ List<Action> salActions = new ArrayList<>();
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
salActions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
- SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
ipv4Builder = new Ipv4Builder();
ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.2/32"));
nwDstBuilder.setAddress(ipv4Builder.build());
+
+ SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
actionBuilder.setAction(nwDstCaseBuilder.build());
actionBuilder.setOrder(5);
data.setDatapathId(new BigInteger("42"));
data.setIpProtocol(FlowConvertorUtil.getIpProtocolFromFlow(flow));
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>> actionsOptional =
- convertorManager.convert(salActions, data);
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping
+ .Action>> actionsOptional = convertorManager.convert(salActions, data);
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = actionsOptional.orElse(Collections.emptyList());
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>
+ actions = actionsOptional.orElse(Collections.emptyList());
Assert.assertEquals("Wrong number of actions", 12, actions.size());
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action action = actions.get(0);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action
+ action = actions.get(0);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetVlanPcpCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetVlanPcpCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetVlanPcpCase setVlanPcpCase = (SetVlanPcpCase) action.getActionChoice();
Assert.assertEquals("Wrong vlan pcp", 7, setVlanPcpCase.getSetVlanPcpAction().getVlanPcp().intValue());
action = actions.get(1);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.StripVlanCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.StripVlanCase",
+ action.getActionChoice().getImplementedInterface().getName());
action = actions.get(2);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetDlDstCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetDlDstCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetDlDstCase setDlDstCase = (SetDlDstCase) action.getActionChoice();
- Assert.assertEquals("Wrong dl dst", "00:00:00:00:00:06", setDlDstCase.getSetDlDstAction().getDlDstAddress().getValue());
+ Assert.assertEquals("Wrong dl dst", "00:00:00:00:00:06",
+ setDlDstCase.getSetDlDstAction().getDlDstAddress().getValue());
action = actions.get(3);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetDlSrcCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetDlSrcCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetDlSrcCase setDlSrcCase = (SetDlSrcCase) action.getActionChoice();
- Assert.assertEquals("Wrong dl src", "00:00:00:00:00:05", setDlSrcCase.getSetDlSrcAction().getDlSrcAddress().getValue());
+ Assert.assertEquals("Wrong dl src", "00:00:00:00:00:05",
+ setDlSrcCase.getSetDlSrcAction().getDlSrcAddress().getValue());
action = actions.get(4);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetNwSrcCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetNwSrcCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetNwSrcCase setNwSrcCase = (SetNwSrcCase) action.getActionChoice();
Assert.assertEquals("Wrong nw src", "10.0.0.0", setNwSrcCase.getSetNwSrcAction().getIpAddress().getValue());
action = actions.get(5);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetNwDstCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetNwDstCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetNwDstCase setNwDstCase = (SetNwDstCase) action.getActionChoice();
Assert.assertEquals("Wrong nw dst", "10.0.0.2", setNwDstCase.getSetNwDstAction().getIpAddress().getValue());
action = actions.get(6);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetTpSrcCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetTpSrcCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetTpSrcCase setTpSrcCase = (SetTpSrcCase) action.getActionChoice();
Assert.assertEquals("Wrong tp src", 54, setTpSrcCase.getSetTpSrcAction().getPort().getValue().intValue());
action = actions.get(7);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetTpDstCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetTpDstCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetTpDstCase setTpDstCase = (SetTpDstCase) action.getActionChoice();
Assert.assertEquals("Wrong tp dst", 45, setTpDstCase.getSetTpDstAction().getPort().getValue().intValue());
action = actions.get(8);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetNwTosCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetNwTosCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetNwTosCase setNwTosCase = (SetNwTosCase) action.getActionChoice();
Assert.assertEquals("Wrong nw tos", 18, setNwTosCase.getSetNwTosAction().getNwTos().intValue());
action = actions.get(9);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase",
+ action.getActionChoice().getImplementedInterface().getName());
SetVlanVidCase setVlanVidCase = (SetVlanVidCase) action.getActionChoice();
Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());
action = actions.get(10);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.StripVlanCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.StripVlanCase",
+ action.getActionChoice().getImplementedInterface().getName());
action = actions.get(11);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetVlanVidCase",
+ action.getActionChoice().getImplementedInterface().getName());
setVlanVidCase = (SetVlanVidCase) action.getActionChoice();
Assert.assertEquals("Wrong vlan id", 22, setVlanVidCase.getSetVlanVidAction().getVlanVid().intValue());
}
/**
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData)}}
+ * Test {@link ActionResponseConvertor#convert(List, ActionResponseConvertorData)}}.
*/
@Test
public void testToMDSalActions() {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actions = new ArrayList<>();
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder actionbuilder =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder();
-
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
- outputBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(14L));
+ outputBuilder.setPort(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(14L));
outputBuilder.setMaxLength(555);
caseBuilder.setOutputAction(outputBuilder.build());
- actionbuilder.setActionChoice(caseBuilder.build());
- actions.add(actionbuilder.build());
+
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder
+ actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions
+ .grouping.ActionBuilder();
+ actionBuilder.setActionChoice(caseBuilder.build());
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action>
+ actions = new ArrayList<>();
+ actions.add(actionBuilder.build());
ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_0);
data.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
- Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action
- .Action>> mdSalActionsOptional =
- convertorManager.convert(
- actions, data);
+ Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>>
+ mdSalActionsOptional = convertorManager.convert(actions, data);
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action
.Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types"
+ ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());
OutputActionCase outputAction = (OutputActionCase) action;
- Assert.assertEquals("Wrong output port", "14", outputAction.getOutputAction().getOutputNodeConnector().getValue());
+ Assert.assertEquals("Wrong output port", "14",
+ outputAction.getOutputAction().getOutputNodeConnector().getValue());
Assert.assertEquals("Wrong max length", 555, outputAction.getOutputAction().getMaxLength().intValue());
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder;
/**
+ * Unit tests for v1.3 action converters.
+ *
* @author michal.polkorab
*/
public class ActionConvertorV13Test {
}
/**
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionResponseConvertorData)}}
+ * Test {@link ActionResponseConvertor#convert(List, ActionResponseConvertorData)}}.
*/
@Test
public void testToMDSalActions() {
}
/**
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)}}
+ * Test {@link ActionConvertor#convert(List, ActionConvertorData)}}.
*/
//@Test
public void testToMDSalActions2() {
- List<Action> actions = new ArrayList<>();
-
- ActionBuilder actionBuilder = new ActionBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(52);
caseBuilder.setOutputAction(outputBuilder.build());
+
+ ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
+
+ List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
- SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
- SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
- List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setOxmMatchField(InPort.class);
inPortBuilder.setPortNumber(new PortNumber(1L));
inPortCaseBuilder.setInPort(inPortBuilder.build());
matchBuilder.setMatchEntryValue(inPortCaseBuilder.build());
+
+ List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
+
+ SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
+
+ SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
actionBuilder.setActionChoice(setFieldCaseBuilder.build());
actions.add(actionBuilder.build());
}
/**
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.ActionConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)} }
+ * Test {@link ActionConvertor#convert(List, ActionConvertorData)} }.
*/
@Test
public void testGetActions() {
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
- .Action> salActions = new ArrayList<>();
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
.ActionBuilder actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112
.action.list.ActionBuilder();
vlanPcpCaseBuilder.setSetVlanPcpAction(pcpBuilder.build());
actionBuilder.setAction(vlanPcpCaseBuilder.build());
actionBuilder.setOrder(0);
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>
+ salActions = new ArrayList<>();
salActions.add(actionBuilder.build());
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112
actionBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112
.action.list.ActionBuilder();
- SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
ipv4Builder = new Ipv4Builder();
ipv4Builder.setIpv4Address(new Ipv4Prefix("10.0.0.2/32"));
nwDstBuilder.setAddress(ipv4Builder.build());
+
+ SetNwDstActionCaseBuilder nwDstCaseBuilder = new SetNwDstActionCaseBuilder();
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
actionBuilder.setAction(nwDstCaseBuilder.build());
actionBuilder.setOrder(5);
Assert.assertEquals("Wrong number of actions", 12, actions.size());
Action action = actions.get(0);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
- MatchEntry entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);;
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice
+ .SetFieldCase setFieldCase =
+ (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
+ MatchEntry entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
Assert.assertEquals("Wrong vlan pcp", 7, ((VlanPcpCase) entry.getMatchEntryValue()).getVlanPcp().getVlanPcp()
.intValue());
action = actions.get(1);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
Assert.assertEquals("Wrong vlan vid", 0, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().getVlanVid()
.intValue());
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid().isCfiBit());
action = actions.get(2);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst.class, false);
Assert.assertEquals("Wrong dl dst", "00:00:00:00:00:06", ((EthDstCase) entry.getMatchEntryValue()).getEthDst()
.getMacAddress().getValue());
action = actions.get(3);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc.class, false);
Assert.assertEquals("Wrong dl src", "00:00:00:00:00:05", ((EthSrcCase) entry.getMatchEntryValue()).getEthSrc()
.getMacAddress().getValue());
action = actions.get(4);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src.class, false);
Assert.assertEquals("Wrong ipv4 src", "10.0.0.0", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src()
.getIpv4Address().getValue());
action = actions.get(5);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst.class, false);
Assert.assertEquals("Wrong ipv4 dst", "10.0.0.2", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst()
.getIpv4Address().getValue());
action = actions.get(6);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc.class, false);
Assert.assertEquals("Wrong tcp src", 54, ((TcpSrcCase) entry.getMatchEntryValue()).getTcpSrc()
.getPort().getValue().intValue());
action = actions.get(7);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
- entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);;
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst.class, false);
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
+ entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst.class, false);
Assert.assertEquals("Wrong tcp dst", 45, ((TcpDstCase) entry.getMatchEntryValue()).getTcpDst()
.getPort().getValue().intValue());
action = actions.get(8);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp.class, false);
Assert.assertEquals("Wrong ip dscp", 4, ((IpDscpCase) entry.getMatchEntryValue()).getIpDscp()
.getDscp().getValue().intValue());
action = actions.get(9);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid.class, false);
Assert.assertEquals("Wrong vlan id", 22, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid()
.getVlanVid().intValue());
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue()).getVlanVid()
.isCfiBit());
action = actions.get(10);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src.class, false);
Assert.assertEquals("Wrong ipv6 src", "::5",
((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
action = actions.get(11);
- setFieldCase =
- (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.SetFieldCase) action.getActionChoice();
+ setFieldCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping
+ .action.choice.SetFieldCase) action.getActionChoice();
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
- + ".action.rev150203.action.grouping.action.choice.SetFieldCase", action.getActionChoice().getImplementedInterface().getName());
+ + ".action.rev150203.action.grouping.action.choice.SetFieldCase",
+ action.getActionChoice().getImplementedInterface().getName());
entry = setFieldCase.getSetFieldAction().getMatchEntry().get(0);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst.class, false);
Assert.assertEquals("Wrong ipv6 dst", "::",
((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
}
-/*\r
- * Copyright (c) 2014 Brocade Communications Systems Inc 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
-package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;\r
-\r
-import java.math.BigInteger;\r
-import java.util.Arrays;\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowjava.util.ByteBufUtils;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class IpConversionUtilTest {\r
- private static Logger LOG = LoggerFactory.getLogger(IpConversionUtilTest.class);\r
-\r
- @Test\r
- public void canonicalBinaryV6AddressTest() {\r
-\r
- byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Address(new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0001"));\r
- byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1};\r
-\r
- Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));\r
- try {\r
- Assert.assertEquals("Incorrect canonicalization - string", "::1", IpConversionUtil.byteArrayV6AddressToString(ipv6binary));\r
- } catch (java.net.UnknownHostException e) {\r
- Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);\r
- }\r
- }\r
-\r
- @Test\r
- public void canonicalBinaryV6AddressPrefixTest() {\r
-\r
- byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Prefix(new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/64"));\r
- byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 64};\r
-\r
- Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));\r
- try {\r
- Assert.assertEquals("Incorrect canonicalization - string", "::/64", IpConversionUtil.byteArrayV6PrefixToString(ipv6binary));\r
- } catch (java.net.UnknownHostException e){\r
- Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);\r
- }\r
- }\r
-\r
- @Test\r
- public void testCountBitsAsCIDRReplacement() throws Exception {\r
- BigInteger maskSeed = new BigInteger("1ffffffffffffffffffffffffffffffff", 16);\r
- byte[] maskArray = new byte[16];\r
- LOG.debug("maskSeed= {}", ByteBufUtils.bytesToHexString(maskSeed.toByteArray()));\r
-\r
- for (int i = 0; i <= 128; i++) {\r
- System.arraycopy(maskSeed.toByteArray(), 1, maskArray, 0, 16);\r
- LOG.debug("maskHex[{}] = {}", i, ByteBufUtils.bytesToHexString(maskArray));\r
- int cidr = IpConversionUtil.countBits(maskArray);\r
- LOG.debug("cidr = {}", cidr);\r
- Assert.assertEquals(128 - i, cidr);\r
-\r
- maskSeed = maskSeed.clearBit(i);\r
- }\r
- }\r
-\r
- @Test\r
- public void testcountBitsAsGetIpv4Mask() {\r
- byte[][] maskInputs = new byte[][]{\r
- {(byte) 255, (byte) 255, (byte) 255, (byte) 255},\r
- {(byte) 255, (byte) 255, (byte) 254, 0},\r
- {(byte) 128, 0, 0, 0},\r
- {0, 0, 0, 0},\r
- };\r
-\r
- int[] maskOutputs = new int[]{\r
- 32, 23, 1, 0\r
- };\r
-\r
- for (int i = 0; i < maskInputs.length; i++) {\r
- int mask = IpConversionUtil.countBits(maskInputs[i]);\r
- Assert.assertEquals(maskOutputs[i], mask);\r
- }\r
- }\r
-\r
- @Test\r
- public void convertArbitraryMaskToByteArrayTest() {\r
- int value = 0xffffffff;\r
- byte[] bytes = new byte[]{\r
- (byte)(value >>> 24), (byte)(value >> 16 & 0xff), (byte)(value >> 8 & 0xff), (byte)(value & 0xff) };\r
- byte[] maskBytes;\r
- maskBytes = IpConversionUtil.convertArbitraryMaskToByteArray(new DottedQuad("255.255.255.255"));\r
- for (int i=0; i<bytes.length;i++) {\r
- int mask = maskBytes[i];\r
- Assert.assertEquals(bytes[i],mask);\r
- }\r
- }\r
-\r
- @Test\r
- public void isArbitraryBitMaskTest() {\r
- boolean arbitraryBitMask;\r
- arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(new byte[] {1,1,1,1});\r
- Assert.assertEquals(arbitraryBitMask,true);\r
- arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(new byte[] {-1,-1,-1,-1});\r
- Assert.assertEquals(arbitraryBitMask,false);\r
- arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(new byte[] {-1,-1,0,-1});\r
- Assert.assertEquals(arbitraryBitMask,true);\r
- arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(null);\r
- Assert.assertEquals(arbitraryBitMask,false);\r
- }\r
-\r
- @Test\r
- public void extractIpv4AddressTest() {\r
- Ipv4Address ipv4Address;\r
- ipv4Address = IpConversionUtil.extractIpv4Address(new Ipv4Prefix("1.0.1.0/16"));\r
- Assert.assertEquals(ipv4Address.getValue(),"1.0.1.0");\r
- }\r
-\r
- @Test\r
- public void extractIpv4AddressMaskTest() {\r
- DottedQuad dottedQuad;\r
- dottedQuad = IpConversionUtil.extractIpv4AddressMask(new Ipv4Prefix("1.1.1.1/24"));\r
- Assert.assertEquals(dottedQuad.getValue(),"255.255.255.0");\r
- }\r
-\r
- @Test\r
- public void convertipv6ArbitraryMaskToByteArrayTest() {\r
- byte[] bytes = {-5,-96,-1,-74,-1,-16,-1,-16, -1,-16,-1,-16,-1,-16,-91,85};\r
- byte[] maskBytes = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));\r
- for(int i=0; i<bytes.length;i++){\r
- int mask = maskBytes[i];\r
- Assert.assertEquals(bytes[i],mask);\r
- }\r
- }\r
-\r
- @Test\r
- public void createArbitraryBitMaskTest() {\r
- byte[] bytes = {-1,-1,-1,0};\r
- DottedQuad dottedQuad;\r
- dottedQuad = IpConversionUtil.createArbitraryBitMask(bytes);\r
- Assert.assertEquals(dottedQuad.getValue(),"255.255.255.0");\r
- DottedQuad dottedQuadNull;\r
- dottedQuadNull = IpConversionUtil.createArbitraryBitMask(null);\r
- Assert.assertEquals(dottedQuadNull.getValue(),"255.255.255.255");\r
- }\r
-\r
- @Test\r
- public void createIpv6ArbitraryBitMaskTest() {\r
- byte[] bytes = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};\r
- Ipv6ArbitraryMask ipv6ArbitraryMask;\r
- ipv6ArbitraryMask = IpConversionUtil.createIpv6ArbitraryBitMask(bytes);\r
- Assert.assertEquals(ipv6ArbitraryMask.getValue(),"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");\r
- Ipv6ArbitraryMask ipv6ArbitraryMaskNull;\r
- ipv6ArbitraryMaskNull = IpConversionUtil.createIpv6ArbitraryBitMask(null);\r
- Assert.assertEquals(ipv6ArbitraryMaskNull.getValue(),"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");\r
- }\r
-\r
- @Test\r
- public void extractIpv6AddressMaskTest() {\r
- Ipv6ArbitraryMask ipv6IpAddressMask;\r
- Ipv6Prefix ipv6Prefix = new Ipv6Prefix("1:2:3:4:5:6:7:8/16");\r
- ipv6IpAddressMask = IpConversionUtil.extractIpv6AddressMask(ipv6Prefix);\r
- Assert.assertEquals(ipv6IpAddressMask.getValue(),"ffff:0:0:0:0:0:0:0");\r
- }\r
-\r
- @Test\r
- public void isIpv6ArbitraryBitMaskTest() {\r
- byte[] bytes = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};\r
- boolean falseCase = false;\r
- boolean trueCase = true;\r
- Assert.assertEquals(falseCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytes));\r
- byte[] bytesArbitraryMask = {-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};\r
- Assert.assertEquals(trueCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytesArbitraryMask));\r
- Assert.assertEquals(falseCase,IpConversionUtil.isIpv6ArbitraryBitMask(null));\r
- byte[] bytesMask = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0};\r
- Assert.assertEquals(falseCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytesMask));\r
- byte[] bytesArbMask = {0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};\r
- Assert.assertEquals(trueCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytesArbMask));\r
- }\r
-\r
- @Test\r
- public void extractIpv6AddressTest() {\r
- Ipv6Address ipv6Address;\r
- ipv6Address = IpConversionUtil.extractIpv6Address(new Ipv6Prefix("1:2:3:4:5:6:7:8/16"));\r
- Assert.assertEquals(ipv6Address.getValue(),"1:2:3:4:5:6:7:8");\r
- }\r
-\r
- @Test\r
- public void extractIpv6PrefixTest() {\r
- int ipv6Address;\r
- ipv6Address = IpConversionUtil.extractIpv6Prefix(new Ipv6Prefix("1:2:3:4:5:6:7:8/16"));\r
- Assert.assertEquals(ipv6Address,16);\r
- }\r
-\r
- @Test\r
- public void compressedIpv6MaskFormatTest() {\r
- Ipv6ArbitraryMask compressedIpv6Mask;\r
- Ipv6ArbitraryMask ipv6IpAddressMask;\r
- // zero compression\r
- ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF:0000:0000:0:0:0:1001:1000");\r
- compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);\r
- Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff::1001:1000");\r
- // :: present - no compression\r
- ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF::F000:0:0:1000");\r
- compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);\r
- Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff::f000:0:0:1000");\r
- // more zero sequences - compress only one\r
- ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF:0:0:F000:0000:0:0:1000");\r
- compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);\r
- Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff:0:0:f000::1000");\r
- }\r
-\r
- @Test\r
- public void compressedIpv6AddressFormatTest() {\r
- Ipv6Address compressedIpv6Address;\r
- Ipv6Address ipv6IpAddressMask;\r
- // zero compression\r
- ipv6IpAddressMask = new Ipv6Address("FFFF:0000:0000:0:0:0:1001:1000");\r
- compressedIpv6Address = IpConversionUtil.compressedIpv6AddressFormat(ipv6IpAddressMask);\r
- Assert.assertEquals(compressedIpv6Address.getValue(), "ffff::1001:1000");\r
- // :: present - no compression\r
- ipv6IpAddressMask = new Ipv6Address("FFFF::F000:0:0:1000");\r
- compressedIpv6Address = IpConversionUtil.compressedIpv6AddressFormat(ipv6IpAddressMask);\r
- Assert.assertEquals(compressedIpv6Address.getValue(), "ffff::f000:0:0:1000");\r
- // more zero sequences - compress only one\r
- ipv6IpAddressMask = new Ipv6Address("FFFF:0:0:F000:0000:0:0:1000");\r
- compressedIpv6Address = IpConversionUtil.compressedIpv6AddressFormat(ipv6IpAddressMask);\r
- Assert.assertEquals(compressedIpv6Address.getValue(), "ffff:0:0:f000::1000");\r
- }\r
-\r
-}\r
+/*
+ * Copyright (c) 2014 Brocade Communications Systems Inc 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.openflowplugin.openflow.md.core.sal.convertor.common;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.opendaylight.ipv6.arbitrary.bitmask.fields.rev160224.Ipv6ArbitraryMask;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IpConversionUtilTest {
+ private static Logger LOG = LoggerFactory.getLogger(IpConversionUtilTest.class);
+
+ @Test
+ public void canonicalBinaryV6AddressTest() {
+
+ byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Address(
+ new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0001"));
+ byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,1};
+
+ Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));
+ try {
+ Assert.assertEquals("Incorrect canonicalization - string", "::1",
+ IpConversionUtil.byteArrayV6AddressToString(ipv6binary));
+ } catch (java.net.UnknownHostException e) {
+ Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);
+ }
+ }
+
+ @Test
+ public void canonicalBinaryV6AddressPrefixTest() {
+
+ byte [] ipv6binary = IpConversionUtil.canonicalBinaryV6Prefix(
+ new Ipv6Prefix("0000:0000:0000:0000:0000:0000:0000:0001/64"));
+ byte [] expected = {0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 64};
+
+ Assert.assertTrue("Incorrect canonicalization - binary", Arrays.equals(ipv6binary, expected));
+ try {
+ Assert.assertEquals("Incorrect canonicalization - string", "::/64",
+ IpConversionUtil.byteArrayV6PrefixToString(ipv6binary));
+ } catch (java.net.UnknownHostException e) {
+ Assert.assertTrue("Incorrect canonicalization - wrong length of byte[]", false);
+ }
+ }
+
+ @Test
+ public void testCountBitsAsCIDRReplacement() throws Exception {
+ BigInteger maskSeed = new BigInteger("1ffffffffffffffffffffffffffffffff", 16);
+ byte[] maskArray = new byte[16];
+ LOG.debug("maskSeed= {}", ByteBufUtils.bytesToHexString(maskSeed.toByteArray()));
+
+ for (int i = 0; i <= 128; i++) {
+ System.arraycopy(maskSeed.toByteArray(), 1, maskArray, 0, 16);
+ LOG.debug("maskHex[{}] = {}", i, ByteBufUtils.bytesToHexString(maskArray));
+ int cidr = IpConversionUtil.countBits(maskArray);
+ LOG.debug("cidr = {}", cidr);
+ Assert.assertEquals(128 - i, cidr);
+
+ maskSeed = maskSeed.clearBit(i);
+ }
+ }
+
+ @Test
+ public void testcountBitsAsGetIpv4Mask() {
+ byte[][] maskInputs = new byte[][]{
+ {(byte) 255, (byte) 255, (byte) 255, (byte) 255},
+ {(byte) 255, (byte) 255, (byte) 254, 0},
+ {(byte) 128, 0, 0, 0},
+ {0, 0, 0, 0},
+ };
+
+ int[] maskOutputs = new int[] { 32, 23, 1, 0 };
+
+ for (int i = 0; i < maskInputs.length; i++) {
+ int mask = IpConversionUtil.countBits(maskInputs[i]);
+ Assert.assertEquals(maskOutputs[i], mask);
+ }
+ }
+
+ @Test
+ public void convertArbitraryMaskToByteArrayTest() {
+ int value = 0xffffffff;
+ byte[] bytes = new byte[] { (byte) (value >>> 24), (byte) (value >> 16 & 0xff), (byte) (value >> 8 & 0xff),
+ (byte) (value & 0xff) };
+ byte[] maskBytes;
+ maskBytes = IpConversionUtil.convertArbitraryMaskToByteArray(new DottedQuad("255.255.255.255"));
+ for (int i = 0; i < bytes.length; i++) {
+ int mask = maskBytes[i];
+ Assert.assertEquals(bytes[i],mask);
+ }
+ }
+
+ @Test
+ public void isArbitraryBitMaskTest() {
+ boolean arbitraryBitMask;
+ arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(new byte[] {1,1,1,1});
+ Assert.assertEquals(arbitraryBitMask,true);
+ arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(new byte[] {-1,-1,-1,-1});
+ Assert.assertEquals(arbitraryBitMask,false);
+ arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(new byte[] {-1,-1,0,-1});
+ Assert.assertEquals(arbitraryBitMask,true);
+ arbitraryBitMask = IpConversionUtil.isArbitraryBitMask(null);
+ Assert.assertEquals(arbitraryBitMask,false);
+ }
+
+ @Test
+ public void extractIpv4AddressTest() {
+ Ipv4Address ipv4Address;
+ ipv4Address = IpConversionUtil.extractIpv4Address(new Ipv4Prefix("1.0.1.0/16"));
+ Assert.assertEquals(ipv4Address.getValue(),"1.0.1.0");
+ }
+
+ @Test
+ public void extractIpv4AddressMaskTest() {
+ DottedQuad dottedQuad;
+ dottedQuad = IpConversionUtil.extractIpv4AddressMask(new Ipv4Prefix("1.1.1.1/24"));
+ Assert.assertEquals(dottedQuad.getValue(),"255.255.255.0");
+ }
+
+ @Test
+ public void convertipv6ArbitraryMaskToByteArrayTest() {
+ byte[] bytes = {-5,-96,-1,-74,-1,-16,-1,-16, -1,-16,-1,-16,-1,-16,-91,85};
+ byte[] maskBytes = IpConversionUtil.convertIpv6ArbitraryMaskToByteArray(
+ new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));
+ for (int i = 0; i < bytes.length; i++) {
+ int mask = maskBytes[i];
+ Assert.assertEquals(bytes[i],mask);
+ }
+ }
+
+ @Test
+ public void createArbitraryBitMaskTest() {
+ byte[] bytes = {-1,-1,-1,0};
+ DottedQuad dottedQuad;
+ dottedQuad = IpConversionUtil.createArbitraryBitMask(bytes);
+ Assert.assertEquals(dottedQuad.getValue(),"255.255.255.0");
+ DottedQuad dottedQuadNull;
+ dottedQuadNull = IpConversionUtil.createArbitraryBitMask(null);
+ Assert.assertEquals(dottedQuadNull.getValue(),"255.255.255.255");
+ }
+
+ @Test
+ public void createIpv6ArbitraryBitMaskTest() {
+ byte[] bytes = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
+ Ipv6ArbitraryMask ipv6ArbitraryMask;
+ ipv6ArbitraryMask = IpConversionUtil.createIpv6ArbitraryBitMask(bytes);
+ Assert.assertEquals(ipv6ArbitraryMask.getValue(),"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+ Ipv6ArbitraryMask ipv6ArbitraryMaskNull;
+ ipv6ArbitraryMaskNull = IpConversionUtil.createIpv6ArbitraryBitMask(null);
+ Assert.assertEquals(ipv6ArbitraryMaskNull.getValue(),"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff");
+ }
+
+ @Test
+ public void extractIpv6AddressMaskTest() {
+ Ipv6ArbitraryMask ipv6IpAddressMask;
+ Ipv6Prefix ipv6Prefix = new Ipv6Prefix("1:2:3:4:5:6:7:8/16");
+ ipv6IpAddressMask = IpConversionUtil.extractIpv6AddressMask(ipv6Prefix);
+ Assert.assertEquals(ipv6IpAddressMask.getValue(),"ffff:0:0:0:0:0:0:0");
+ }
+
+ @Test
+ public void isIpv6ArbitraryBitMaskTest() {
+ byte[] bytes = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
+ boolean falseCase = false;
+ boolean trueCase = true;
+ Assert.assertEquals(falseCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytes));
+ byte[] bytesArbitraryMask = {-1,-1,-1,-1,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
+ Assert.assertEquals(trueCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytesArbitraryMask));
+ Assert.assertEquals(falseCase,IpConversionUtil.isIpv6ArbitraryBitMask(null));
+ byte[] bytesMask = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0};
+ Assert.assertEquals(falseCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytesMask));
+ byte[] bytesArbMask = {0,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
+ Assert.assertEquals(trueCase,IpConversionUtil.isIpv6ArbitraryBitMask(bytesArbMask));
+ }
+
+ @Test
+ public void extractIpv6AddressTest() {
+ Ipv6Address ipv6Address;
+ ipv6Address = IpConversionUtil.extractIpv6Address(new Ipv6Prefix("1:2:3:4:5:6:7:8/16"));
+ Assert.assertEquals(ipv6Address.getValue(),"1:2:3:4:5:6:7:8");
+ }
+
+ @Test
+ public void extractIpv6PrefixTest() {
+ int ipv6Address;
+ ipv6Address = IpConversionUtil.extractIpv6Prefix(new Ipv6Prefix("1:2:3:4:5:6:7:8/16"));
+ Assert.assertEquals(ipv6Address,16);
+ }
+
+ @Test
+ public void compressedIpv6MaskFormatTest() {
+ Ipv6ArbitraryMask compressedIpv6Mask;
+ Ipv6ArbitraryMask ipv6IpAddressMask;
+ // zero compression
+ ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF:0000:0000:0:0:0:1001:1000");
+ compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);
+ Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff::1001:1000");
+ // :: present - no compression
+ ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF::F000:0:0:1000");
+ compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);
+ Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff::f000:0:0:1000");
+ // more zero sequences - compress only one
+ ipv6IpAddressMask = new Ipv6ArbitraryMask("FFFF:0:0:F000:0000:0:0:1000");
+ compressedIpv6Mask = IpConversionUtil.compressedIpv6MaskFormat(ipv6IpAddressMask);
+ Assert.assertEquals(compressedIpv6Mask.getValue(), "ffff:0:0:f000::1000");
+ }
+
+ @Test
+ public void compressedIpv6AddressFormatTest() {
+ Ipv6Address compressedIpv6Address;
+ Ipv6Address ipv6IpAddressMask;
+ // zero compression
+ ipv6IpAddressMask = new Ipv6Address("FFFF:0000:0000:0:0:0:1001:1000");
+ compressedIpv6Address = IpConversionUtil.compressedIpv6AddressFormat(ipv6IpAddressMask);
+ Assert.assertEquals(compressedIpv6Address.getValue(), "ffff::1001:1000");
+ // :: present - no compression
+ ipv6IpAddressMask = new Ipv6Address("FFFF::F000:0:0:1000");
+ compressedIpv6Address = IpConversionUtil.compressedIpv6AddressFormat(ipv6IpAddressMask);
+ Assert.assertEquals(compressedIpv6Address.getValue(), "ffff::f000:0:0:1000");
+ // more zero sequences - compress only one
+ ipv6IpAddressMask = new Ipv6Address("FFFF:0:0:F000:0000:0:0:1000");
+ compressedIpv6Address = IpConversionUtil.compressedIpv6AddressFormat(ipv6IpAddressMask);
+ Assert.assertEquals(compressedIpv6Address.getValue(), "ffff:0:0:f000::1000");
+ }
+}
*/
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common;
+import static org.junit.Assert.fail;
+
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Ordered;
import org.opendaylight.yangtools.yang.binding.DataContainer;
/**
- * To test OrderComparator
+ * To test OrderComparator.
*/
public class OrderComparatorTest {
public void testBothObjectsNull() {
try {
OrderComparator.<MockOrderedObject>build().compare(null, null);
- org.junit.Assert.fail("Passing null to OrderCompartor should raise " +
- "a NullPointerException");
+ fail("Passing null to OrderCompartor should raise a NullPointerException");
} catch (NullPointerException npe) {
// expected
}
MockOrderedObject obj2 = null;
OrderComparator.<MockOrderedObject>build().compare(obj1, obj2);
- org.junit.Assert.fail("Passing null to OrderCompartor should raise " +
- "a NullPointerException");
+ fail("Passing null to OrderCompartor should raise a NullPointerException");
} catch (NullPointerException npe) {
// expected
}
obj2.setOrder(1);
OrderComparator.<MockOrderedObject>build().compare(obj1, obj2);
- org.junit.Assert.fail("Passing null to OrderCompartor should raise " +
- "a NullPointerException");
+ fail("Passing null to OrderCompartor should raise a NullPointerException");
} catch (NullPointerException npe) {
// expected
}
return Ordered.class;
}
}
-
}
-/*\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.openflowplugin.openflow.md.core.sal.convertor.flow;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Optional;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.OFConstants;\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.core.sal.convertor.data.VersionDatapathIdConvertorData;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.clear.actions._case.ClearActionsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;\r
-import org.opendaylight.yangtools.yang.binding.Augmentation;\r
-import org.opendaylight.yangtools.yang.binding.DataContainer;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class FlowConvertorTest {\r
- private ConvertorManager convertorManager;\r
-\r
- @Before\r
- public void setUp() {\r
- convertorManager = ConvertorManagerFactory.createDefaultManager();\r
- }\r
-\r
- /**\r
- * Tests {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }\r
- */\r
- @Test\r
- public void test() {\r
- RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();\r
- flowBuilder.setBarrier(false);\r
- flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));\r
- flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));\r
- flowBuilder.setTableId((short) 6);\r
- flowBuilder.setStrict(true);\r
- flowBuilder.setIdleTimeout(50);\r
- flowBuilder.setHardTimeout(500);\r
- flowBuilder.setPriority(40);\r
- flowBuilder.setBufferId(18L);\r
- flowBuilder.setOutPort(new BigInteger("65535"));\r
- flowBuilder.setOutGroup(5000L);\r
- flowBuilder.setFlags(null);\r
- flowBuilder.setMatch(null);\r
- RemoveFlowInput flow = flowBuilder.build();\r
-\r
- VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- data.setDatapathId(new BigInteger("42"));\r
-\r
- List<FlowModInputBuilder> flowMod = convert(flow, data);\r
-\r
- Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());\r
- Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());\r
- Assert.assertEquals("Wrong cookie mask", 5, flowMod.get(0).getCookieMask().intValue());\r
- Assert.assertEquals("Wrong table id", 6, flowMod.get(0).getTableId().getValue().intValue());\r
- Assert.assertEquals("Wrong command", FlowModCommand.OFPFCDELETESTRICT, flowMod.get(0).getCommand());\r
- Assert.assertEquals("Wrong idle timeout", 50, flowMod.get(0).getIdleTimeout().intValue());\r
- Assert.assertEquals("Wrong hard timeout", 500, flowMod.get(0).getHardTimeout().intValue());\r
- Assert.assertEquals("Wrong priority", 40, flowMod.get(0).getPriority().intValue());\r
- Assert.assertEquals("Wrong buffer id", 18, flowMod.get(0).getBufferId().intValue());\r
- Assert.assertEquals("Wrong out port", 65535, flowMod.get(0).getOutPort().getValue().intValue());\r
- Assert.assertEquals("Wrong out group", 5000, flowMod.get(0).getOutGroup().intValue());\r
- Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowMod.get(0).getFlags());\r
- Assert.assertEquals("Wrong match", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType",\r
- flowMod.get(0).getMatch().getType().getName());\r
- Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());\r
- }\r
-\r
- /**\r
- * Tests {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }\r
- */\r
- @Test\r
- public void testOnlyModifyStrictCommand() {\r
- UpdatedFlowBuilder flowBuilder = new UpdatedFlowBuilder();\r
- flowBuilder.setStrict(true);\r
- UpdatedFlow flow = flowBuilder.build();\r
-\r
- VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- data.setDatapathId(new BigInteger("42"));\r
-\r
- List<FlowModInputBuilder> flowMod = convert(flow, data);\r
-\r
- Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());\r
- Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());\r
- }\r
-\r
- /**\r
- * Tests {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.flow.FlowConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }\r
- */\r
- @Test\r
- public void testInstructionsTranslation() {\r
- AddFlowInputBuilder flowBuilder = new AddFlowInputBuilder();\r
- InstructionsBuilder instructionsBuilder = new InstructionsBuilder();\r
- List<Instruction> instructions = new ArrayList<>();\r
- InstructionBuilder instructionBuilder = new InstructionBuilder();\r
- GoToTableCaseBuilder goToCaseBuilder = new GoToTableCaseBuilder();\r
- GoToTableBuilder goToBuilder = new GoToTableBuilder();\r
- goToBuilder.setTableId((short) 1);\r
- goToCaseBuilder.setGoToTable(goToBuilder.build());\r
- instructionBuilder.setInstruction(goToCaseBuilder.build());\r
- instructionBuilder.setOrder(0);\r
- instructions.add(instructionBuilder.build());\r
- instructionBuilder = new InstructionBuilder();\r
- WriteMetadataCaseBuilder metaCaseBuilder = new WriteMetadataCaseBuilder();\r
- WriteMetadataBuilder metaBuilder = new WriteMetadataBuilder();\r
- metaBuilder.setMetadata(new BigInteger("2"));\r
- metaBuilder.setMetadataMask(new BigInteger("3"));\r
- metaCaseBuilder.setWriteMetadata(metaBuilder.build());\r
- instructionBuilder.setInstruction(metaCaseBuilder.build());\r
- instructionBuilder.setOrder(1);\r
- instructions.add(instructionBuilder.build());\r
- instructionBuilder = new InstructionBuilder();\r
- WriteActionsCaseBuilder writeCaseBuilder = new WriteActionsCaseBuilder();\r
- WriteActionsBuilder writeBuilder = new WriteActionsBuilder();\r
- List<Action> actions = new ArrayList<>();\r
- writeBuilder.setAction(actions);\r
- writeCaseBuilder.setWriteActions(writeBuilder.build());\r
- instructionBuilder.setInstruction(writeCaseBuilder.build());\r
- instructionBuilder.setOrder(2);\r
- instructions.add(instructionBuilder.build());\r
- instructionBuilder = new InstructionBuilder();\r
- ApplyActionsCaseBuilder applyCaseBuilder = new ApplyActionsCaseBuilder();\r
- ApplyActionsBuilder applyBuilder = new ApplyActionsBuilder();\r
- actions = new ArrayList<>();\r
- applyBuilder.setAction(actions);\r
- applyCaseBuilder.setApplyActions(applyBuilder.build());\r
- instructionBuilder.setInstruction(applyCaseBuilder.build());\r
- instructionBuilder.setOrder(3);\r
- instructions.add(instructionBuilder.build());\r
- instructionBuilder = new InstructionBuilder();\r
- ClearActionsCaseBuilder clearCaseBuilder = new ClearActionsCaseBuilder();\r
- ClearActionsBuilder clearBuilder = new ClearActionsBuilder();\r
- actions = new ArrayList<>();\r
- clearBuilder.setAction(actions);\r
- clearCaseBuilder.setClearActions(clearBuilder.build());\r
- instructionBuilder.setInstruction(clearCaseBuilder.build());\r
- instructionBuilder.setOrder(4);\r
- instructions.add(instructionBuilder.build());\r
- instructionBuilder = new InstructionBuilder();\r
- MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();\r
- MeterBuilder meterBuilder = new MeterBuilder();\r
- meterBuilder.setMeterId(new MeterId(5L));\r
- meterCaseBuilder.setMeter(meterBuilder.build());\r
- instructionBuilder.setInstruction(meterCaseBuilder.build());\r
- instructionBuilder.setOrder(5);\r
- instructions.add(instructionBuilder.build());\r
- instructionsBuilder.setInstruction(instructions);\r
- flowBuilder.setInstructions(instructionsBuilder.build());\r
- AddFlowInput flow = flowBuilder.build();\r
-\r
- VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- data.setDatapathId(new BigInteger("42"));\r
- List<FlowModInputBuilder> flowMod = convert(flow, data);\r
-\r
- Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());\r
- Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());\r
- Assert.assertEquals("Wrong instructions size", 6, flowMod.get(0).getInstruction().size());\r
- org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions\r
- .grouping.Instruction instruction = flowMod.get(0).getInstruction().get(0);\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
- + ".instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase", instruction.getInstructionChoice().getImplementedInterface().getName());\r
- GotoTableCase gotoTableCase = (GotoTableCase) instruction.getInstructionChoice();\r
- Assert.assertEquals("Wrong table id", 1, gotoTableCase.getGotoTable().getTableId().intValue());\r
- instruction = flowMod.get(0).getInstruction().get(1);\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
- + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase", instruction.getInstructionChoice().getImplementedInterface().getName());\r
- WriteMetadataCase writeMetadataCase = (WriteMetadataCase) instruction.getInstructionChoice();\r
- Assert.assertArrayEquals("Wrong metadata", new byte[]{0, 0, 0, 0, 0, 0, 0, 2},\r
- writeMetadataCase.getWriteMetadata().getMetadata());\r
- Assert.assertArrayEquals("Wrong metadata mask", new byte[]{0, 0, 0, 0, 0, 0, 0, 3},\r
- writeMetadataCase.getWriteMetadata().getMetadataMask());\r
- \r
- instruction = flowMod.get(0).getInstruction().get(2);\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
- + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());\r
- WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstructionChoice();\r
- Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().getAction().size());\r
- instruction = flowMod.get(0).getInstruction().get(3);\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
- + ".instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());\r
- ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstructionChoice();\r
- Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().getAction().size());\r
- instruction = flowMod.get(0).getInstruction().get(4);\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
- + ".instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());\r
- instruction = flowMod.get(0).getInstruction().get(5);\r
- Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"\r
- + ".instruction.rev130731.instruction.grouping.instruction.choice.MeterCase", instruction.getInstructionChoice().getImplementedInterface().getName());\r
- MeterCase meterCase = (MeterCase) instruction.getInstructionChoice();\r
- Assert.assertEquals("Wrong meter id", 5, meterCase.getMeter().getMeterId().intValue());\r
- }\r
-\r
- @Test\r
- public void testCloneAndAugmentFlowWithSetVlanId() {\r
- MockFlow mockFlow = new MockFlow();\r
- Action action1 = createAction(\r
- new SetVlanIdActionCaseBuilder().setSetVlanIdAction(\r
- new SetVlanIdActionBuilder().setVlanId(new VlanId(10)).build())\r
- .build(),\r
- 0);\r
-\r
- mockFlow.setMatch(new MatchBuilder().setEthernetMatch(createEthernetMatch()).build());\r
- mockFlow.setInstructions(toApplyInstruction(Collections.singletonList(action1)));\r
-\r
- VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- data.setDatapathId(BigInteger.ONE);\r
-\r
- List<FlowModInputBuilder> flowModInputBuilders = convert(mockFlow, data);\r
-\r
- Assert.assertEquals(2, flowModInputBuilders.size());\r
-\r
- }\r
-\r
- private List<FlowModInputBuilder> convert(Flow flow, VersionDatapathIdConvertorData data) {\r
- Optional<List<FlowModInputBuilder>> flowModOptional = convertorManager.convert(flow, data);\r
- Assert.assertTrue("Flow convertor not found", flowModOptional.isPresent());\r
- return flowModOptional.get();\r
- }\r
-\r
- private static Action createAction(final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionCase,\r
- final int order) {\r
- Action action = new ActionBuilder().setOrder(order).setAction(actionCase).build();\r
- return action;\r
- }\r
-\r
- private static EthernetMatch createEthernetMatch() {\r
- EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();\r
- ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(33024L)).build());\r
- return ethernetMatchBuilder.build();\r
- }\r
-\r
- private static Instructions toApplyInstruction(\r
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {\r
- return new InstructionsBuilder()\r
- .setInstruction(\r
- Collections.singletonList(\r
- new InstructionBuilder()\r
- .setOrder(0)\r
- .setInstruction(\r
- new ApplyActionsCaseBuilder()\r
- .setApplyActions((new ApplyActionsBuilder()).setAction(actions).build())\r
- .build()\r
- ).build())\r
- ).build();\r
- }\r
-\r
- private static class MockFlow implements AddFlowInput {\r
- private Instructions instructions;\r
- private Match match;\r
-\r
- public void setInstructions(final Instructions instructions) {\r
- this.instructions = instructions;\r
- }\r
-\r
- public void setMatch(final Match match) {\r
- this.match = match;\r
- }\r
-\r
-\r
- @Override\r
- public FlowRef getFlowRef() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public <E extends Augmentation<AddFlowInput>> E getAugmentation(final Class<E> augmentationType) {\r
- return null;\r
- }\r
-\r
- @Override\r
- public FlowTableRef getFlowTable() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Match getMatch() {\r
- return match;\r
- }\r
-\r
- @Override\r
- public Instructions getInstructions() {\r
- return instructions;\r
- }\r
-\r
- @Override\r
- public String getContainerName() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public FlowCookie getCookieMask() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Long getBufferId() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public BigInteger getOutPort() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Long getOutGroup() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags getFlags() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public String getFlowName() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Boolean isInstallHw() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Boolean isBarrier() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Boolean isStrict() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Integer getPriority() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Integer getIdleTimeout() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Integer getHardTimeout() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public FlowCookie getCookie() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Short getTableId() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public NodeRef getNode() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Uri getTransactionUri() {\r
- return null;\r
- }\r
-\r
- @Override\r
- public Class<? extends DataContainer> getImplementedInterface() {\r
- return Flow.class;\r
- }\r
- }\r
-}
\ No newline at end of file
+/*
+ * 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.openflowplugin.openflow.md.core.sal.convertor.flow;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.clear.actions._case.ClearActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModCommand;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+/**
+ * Unit tests for flow conversion.
+ *
+ * @author michal.polkorab
+ */
+public class FlowConvertorTest {
+ private ConvertorManager convertorManager;
+
+ @Before
+ public void setUp() {
+ convertorManager = ConvertorManagerFactory.createDefaultManager();
+ }
+
+ /**
+ * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
+ */
+ @Test
+ public void test() {
+ RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();
+ flowBuilder.setBarrier(false);
+ flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));
+ flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));
+ flowBuilder.setTableId((short) 6);
+ flowBuilder.setStrict(true);
+ flowBuilder.setIdleTimeout(50);
+ flowBuilder.setHardTimeout(500);
+ flowBuilder.setPriority(40);
+ flowBuilder.setBufferId(18L);
+ flowBuilder.setOutPort(new BigInteger("65535"));
+ flowBuilder.setOutGroup(5000L);
+ flowBuilder.setFlags(null);
+ flowBuilder.setMatch(null);
+ RemoveFlowInput flow = flowBuilder.build();
+
+ VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ data.setDatapathId(new BigInteger("42"));
+
+ List<FlowModInputBuilder> flowMod = convert(flow, data);
+
+ Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());
+ Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());
+ Assert.assertEquals("Wrong cookie mask", 5, flowMod.get(0).getCookieMask().intValue());
+ Assert.assertEquals("Wrong table id", 6, flowMod.get(0).getTableId().getValue().intValue());
+ Assert.assertEquals("Wrong command", FlowModCommand.OFPFCDELETESTRICT, flowMod.get(0).getCommand());
+ Assert.assertEquals("Wrong idle timeout", 50, flowMod.get(0).getIdleTimeout().intValue());
+ Assert.assertEquals("Wrong hard timeout", 500, flowMod.get(0).getHardTimeout().intValue());
+ Assert.assertEquals("Wrong priority", 40, flowMod.get(0).getPriority().intValue());
+ Assert.assertEquals("Wrong buffer id", 18, flowMod.get(0).getBufferId().intValue());
+ Assert.assertEquals("Wrong out port", 65535, flowMod.get(0).getOutPort().getValue().intValue());
+ Assert.assertEquals("Wrong out group", 5000, flowMod.get(0).getOutGroup().intValue());
+ Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false),
+ flowMod.get(0).getFlags());
+ Assert.assertEquals("Wrong match",
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType",
+ flowMod.get(0).getMatch().getType().getName());
+ Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
+ }
+
+ /**
+ * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
+ */
+ @Test
+ public void testOnlyModifyStrictCommand() {
+ UpdatedFlowBuilder flowBuilder = new UpdatedFlowBuilder();
+ flowBuilder.setStrict(true);
+ UpdatedFlow flow = flowBuilder.build();
+
+ VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ data.setDatapathId(new BigInteger("42"));
+
+ List<FlowModInputBuilder> flowMod = convert(flow, data);
+
+ Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
+ Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
+ }
+
+ /**
+ * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
+ */
+ @Test
+ public void testInstructionsTranslation() {
+ InstructionBuilder instructionBuilder = new InstructionBuilder();
+ GoToTableCaseBuilder goToCaseBuilder = new GoToTableCaseBuilder();
+ GoToTableBuilder goToBuilder = new GoToTableBuilder();
+ goToBuilder.setTableId((short) 1);
+ goToCaseBuilder.setGoToTable(goToBuilder.build());
+ instructionBuilder.setInstruction(goToCaseBuilder.build());
+ instructionBuilder.setOrder(0);
+
+ List<Instruction> instructions = new ArrayList<>();
+ instructions.add(instructionBuilder.build());
+ instructionBuilder = new InstructionBuilder();
+ WriteMetadataCaseBuilder metaCaseBuilder = new WriteMetadataCaseBuilder();
+ WriteMetadataBuilder metaBuilder = new WriteMetadataBuilder();
+ metaBuilder.setMetadata(new BigInteger("2"));
+ metaBuilder.setMetadataMask(new BigInteger("3"));
+ metaCaseBuilder.setWriteMetadata(metaBuilder.build());
+ instructionBuilder.setInstruction(metaCaseBuilder.build());
+ instructionBuilder.setOrder(1);
+ instructions.add(instructionBuilder.build());
+ instructionBuilder = new InstructionBuilder();
+ WriteActionsCaseBuilder writeCaseBuilder = new WriteActionsCaseBuilder();
+ WriteActionsBuilder writeBuilder = new WriteActionsBuilder();
+ List<Action> actions = new ArrayList<>();
+ writeBuilder.setAction(actions);
+ writeCaseBuilder.setWriteActions(writeBuilder.build());
+ instructionBuilder.setInstruction(writeCaseBuilder.build());
+ instructionBuilder.setOrder(2);
+ instructions.add(instructionBuilder.build());
+ instructionBuilder = new InstructionBuilder();
+ ApplyActionsCaseBuilder applyCaseBuilder = new ApplyActionsCaseBuilder();
+ ApplyActionsBuilder applyBuilder = new ApplyActionsBuilder();
+ actions = new ArrayList<>();
+ applyBuilder.setAction(actions);
+ applyCaseBuilder.setApplyActions(applyBuilder.build());
+ instructionBuilder.setInstruction(applyCaseBuilder.build());
+ instructionBuilder.setOrder(3);
+ instructions.add(instructionBuilder.build());
+ instructionBuilder = new InstructionBuilder();
+ ClearActionsCaseBuilder clearCaseBuilder = new ClearActionsCaseBuilder();
+ ClearActionsBuilder clearBuilder = new ClearActionsBuilder();
+ actions = new ArrayList<>();
+ clearBuilder.setAction(actions);
+ clearCaseBuilder.setClearActions(clearBuilder.build());
+ instructionBuilder.setInstruction(clearCaseBuilder.build());
+ instructionBuilder.setOrder(4);
+ instructions.add(instructionBuilder.build());
+ instructionBuilder = new InstructionBuilder();
+ MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
+ MeterBuilder meterBuilder = new MeterBuilder();
+ meterBuilder.setMeterId(new MeterId(5L));
+ meterCaseBuilder.setMeter(meterBuilder.build());
+ instructionBuilder.setInstruction(meterCaseBuilder.build());
+ instructionBuilder.setOrder(5);
+ instructions.add(instructionBuilder.build());
+
+ InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
+ instructionsBuilder.setInstruction(instructions);
+
+ AddFlowInputBuilder flowBuilder = new AddFlowInputBuilder();
+ flowBuilder.setInstructions(instructionsBuilder.build());
+ AddFlowInput flow = flowBuilder.build();
+
+ VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ data.setDatapathId(new BigInteger("42"));
+ List<FlowModInputBuilder> flowMod = convert(flow, data);
+
+ Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
+ Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
+ Assert.assertEquals("Wrong instructions size", 6, flowMod.get(0).getInstruction().size());
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions
+ .grouping.Instruction instruction = flowMod.get(0).getInstruction().get(0);
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ + ".instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase",
+ instruction.getInstructionChoice().getImplementedInterface().getName());
+ GotoTableCase gotoTableCase = (GotoTableCase) instruction.getInstructionChoice();
+ Assert.assertEquals("Wrong table id", 1, gotoTableCase.getGotoTable().getTableId().intValue());
+ instruction = flowMod.get(0).getInstruction().get(1);
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase",
+ instruction.getInstructionChoice().getImplementedInterface().getName());
+ WriteMetadataCase writeMetadataCase = (WriteMetadataCase) instruction.getInstructionChoice();
+ Assert.assertArrayEquals("Wrong metadata", new byte[]{0, 0, 0, 0, 0, 0, 0, 2},
+ writeMetadataCase.getWriteMetadata().getMetadata());
+ Assert.assertArrayEquals("Wrong metadata mask", new byte[]{0, 0, 0, 0, 0, 0, 0, 3},
+ writeMetadataCase.getWriteMetadata().getMetadataMask());
+
+ instruction = flowMod.get(0).getInstruction().get(2);
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase",
+ instruction.getInstructionChoice().getImplementedInterface().getName());
+ WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstructionChoice();
+ Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().getAction().size());
+ instruction = flowMod.get(0).getInstruction().get(3);
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ + ".instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase",
+ instruction.getInstructionChoice().getImplementedInterface().getName());
+ ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
+ Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().getAction().size());
+ instruction = flowMod.get(0).getInstruction().get(4);
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ + ".instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase",
+ instruction.getInstructionChoice().getImplementedInterface().getName());
+ instruction = flowMod.get(0).getInstruction().get(5);
+ Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common"
+ + ".instruction.rev130731.instruction.grouping.instruction.choice.MeterCase",
+ instruction.getInstructionChoice().getImplementedInterface().getName());
+ MeterCase meterCase = (MeterCase) instruction.getInstructionChoice();
+ Assert.assertEquals("Wrong meter id", 5, meterCase.getMeter().getMeterId().intValue());
+ }
+
+ @Test
+ public void testCloneAndAugmentFlowWithSetVlanId() {
+ MockFlow mockFlow = new MockFlow();
+ Action action1 = createAction(
+ new SetVlanIdActionCaseBuilder().setSetVlanIdAction(
+ new SetVlanIdActionBuilder().setVlanId(new VlanId(10)).build())
+ .build(),
+ 0);
+
+ mockFlow.setMatch(new MatchBuilder().setEthernetMatch(createEthernetMatch()).build());
+ mockFlow.setInstructions(toApplyInstruction(Collections.singletonList(action1)));
+
+ VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ data.setDatapathId(BigInteger.ONE);
+
+ List<FlowModInputBuilder> flowModInputBuilders = convert(mockFlow, data);
+
+ Assert.assertEquals(2, flowModInputBuilders.size());
+
+ }
+
+ private List<FlowModInputBuilder> convert(Flow flow, VersionDatapathIdConvertorData data) {
+ Optional<List<FlowModInputBuilder>> flowModOptional = convertorManager.convert(flow, data);
+ Assert.assertTrue("Flow convertor not found", flowModOptional.isPresent());
+ return flowModOptional.get();
+ }
+
+ private static Action createAction(
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionCase,
+ final int order) {
+ Action action = new ActionBuilder().setOrder(order).setAction(actionCase).build();
+ return action;
+ }
+
+ private static EthernetMatch createEthernetMatch() {
+ EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
+ ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(33024L)).build());
+ return ethernetMatchBuilder.build();
+ }
+
+ private static Instructions toApplyInstruction(
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {
+ return new InstructionsBuilder().setInstruction(Collections.singletonList(new InstructionBuilder().setOrder(0)
+ .setInstruction(new ApplyActionsCaseBuilder()
+ .setApplyActions(new ApplyActionsBuilder().setAction(actions).build()).build())
+ .build())).build();
+ }
+
+ private static class MockFlow implements AddFlowInput {
+ private Instructions instructions;
+ private Match match;
+
+ public void setInstructions(final Instructions instructions) {
+ this.instructions = instructions;
+ }
+
+ public void setMatch(final Match match) {
+ this.match = match;
+ }
+
+
+ @Override
+ public FlowRef getFlowRef() {
+ return null;
+ }
+
+ @Override
+ public <E extends Augmentation<AddFlowInput>> E getAugmentation(final Class<E> augmentationType) {
+ return null;
+ }
+
+ @Override
+ public FlowTableRef getFlowTable() {
+ return null;
+ }
+
+ @Override
+ public Match getMatch() {
+ return match;
+ }
+
+ @Override
+ public Instructions getInstructions() {
+ return instructions;
+ }
+
+ @Override
+ public String getContainerName() {
+ return null;
+ }
+
+ @Override
+ public FlowCookie getCookieMask() {
+ return null;
+ }
+
+ @Override
+ public Long getBufferId() {
+ return null;
+ }
+
+ @Override
+ public BigInteger getOutPort() {
+ return null;
+ }
+
+ @Override
+ public Long getOutGroup() {
+ return null;
+ }
+
+ @Override
+ public org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags getFlags() {
+ return null;
+ }
+
+ @Override
+ public String getFlowName() {
+ return null;
+ }
+
+ @Override
+ public Boolean isInstallHw() {
+ return null;
+ }
+
+ @Override
+ public Boolean isBarrier() {
+ return null;
+ }
+
+ @Override
+ public Boolean isStrict() {
+ return null;
+ }
+
+ @Override
+ public Integer getPriority() {
+ return null;
+ }
+
+ @Override
+ public Integer getIdleTimeout() {
+ return null;
+ }
+
+ @Override
+ public Integer getHardTimeout() {
+ return null;
+ }
+
+ @Override
+ public FlowCookie getCookie() {
+ return null;
+ }
+
+ @Override
+ public Short getTableId() {
+ return null;
+ }
+
+ @Override
+ public NodeRef getNode() {
+ return null;
+ }
+
+ @Override
+ public Uri getTransactionUri() {
+ return null;
+ }
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return Flow.class;
+ }
+ }
+}
private static final int PRESET_COUNT = 7;
/**
- * Test method for {@link FlowInstructionResponseConvertor#convert(java.util.List, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)} }
+ * Test method for {@link FlowInstructionResponseConvertor#convert(List, VersionConvertorData)} }.
*/
@Test
public void testToSALInstruction() {
for (int i = 0; i < PRESET_COUNT; i++) {
WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
-
+
metadataBuilder.setMetadata(BigInteger.TEN.setBit(i).toByteArray());
metadataBuilder.setMetadataMask(BigInteger.ONE.setBit(i).toByteArray());
metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
private static final class MockActionBase extends ActionBase {
// for testing purposes
}
-}
\ No newline at end of file
+}
inPort, nwProto, nwTos, tpDst, tpSrc);
}
- public FlowWildcardsV10Builder setAll(boolean b) {
- dlDst = b;
- dlSrc = b;
- dlType = b;
- dlVlan = b;
- dlVlanPcp = b;
- inPort = b;
- nwProto = b;
- nwTos = b;
- tpDst = b;
- tpSrc = b;
+ public FlowWildcardsV10Builder setAll(boolean value) {
+ dlDst = value;
+ dlSrc = value;
+ dlType = value;
+ dlVlan = value;
+ dlVlanPcp = value;
+ inPort = value;
+ nwProto = value;
+ nwTos = value;
+ tpDst = value;
+ tpSrc = value;
return this;
}
- public FlowWildcardsV10Builder setDlDst(boolean b) {
- dlDst = b;
+ public FlowWildcardsV10Builder setDlDst(boolean value) {
+ dlDst = value;
return this;
}
- public FlowWildcardsV10Builder setDlSrc(boolean b) {
- dlSrc = b;
+ public FlowWildcardsV10Builder setDlSrc(boolean value) {
+ dlSrc = value;
return this;
}
- public FlowWildcardsV10Builder setDlType(boolean b) {
- dlType = b;
+ public FlowWildcardsV10Builder setDlType(boolean value) {
+ dlType = value;
return this;
}
- public FlowWildcardsV10Builder setDlVlan(boolean b) {
- dlVlan = b;
+ public FlowWildcardsV10Builder setDlVlan(boolean value) {
+ dlVlan = value;
return this;
}
- public FlowWildcardsV10Builder setDlVlanPcp(boolean b) {
- dlVlanPcp = b;
+ public FlowWildcardsV10Builder setDlVlanPcp(boolean value) {
+ dlVlanPcp = value;
return this;
}
- public FlowWildcardsV10Builder setInPort(boolean b) {
- inPort = b;
+ public FlowWildcardsV10Builder setInPort(boolean value) {
+ inPort = value;
return this;
}
- public FlowWildcardsV10Builder setNwProto(boolean b) {
- nwProto = b;
+ public FlowWildcardsV10Builder setNwProto(boolean value) {
+ nwProto = value;
return this;
}
- public FlowWildcardsV10Builder setNwTos(boolean b) {
- nwTos = b;
+ public FlowWildcardsV10Builder setNwTos(boolean value) {
+ nwTos = value;
return this;
}
- public FlowWildcardsV10Builder setTpDst(boolean b) {
- tpDst = b;
+ public FlowWildcardsV10Builder setTpDst(boolean value) {
+ tpDst = value;
return this;
}
- public FlowWildcardsV10Builder setTpSrc(boolean b) {
- tpSrc = b;
+ public FlowWildcardsV10Builder setTpSrc(boolean value) {
+ tpSrc = value;
return this;
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCase;
/**
+ * Unit tests for match conversion.
+ *
* @author michal.polkorab
*/
public class MatchConvertorTest {
private ConvertorManager converterManager;
/**
- * Initializes OpenflowPortsUtil
+ * Initializes OpenflowPortsUtil.
*/
@Before
public void startUp() {
builder.setLayer3Match(ipv4MatchBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 24, entries.size());
MatchEntry entry = entries.get(0);
entry = entries.get(1);
checkEntryHeader(entry, InPhyPort.class, false);
- Assert.assertEquals("Wrong in phy port", 2, ((InPhyPortCase) entry.getMatchEntryValue()).
- getInPhyPort().getPortNumber().getValue().intValue());
+ Assert.assertEquals("Wrong in phy port", 2, ((InPhyPortCase) entry.getMatchEntryValue())
+ .getInPhyPort().getPortNumber().getValue().intValue());
entry = entries.get(2);
checkEntryHeader(entry, Metadata.class, false);
Assert.assertEquals("Wrong cfi bit", true, ((VlanVidCase) entry.getMatchEntryValue())
.getVlanVid().isCfiBit());
entry = entries.get(7);
- checkEntryHeader(entry, org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
+ checkEntryHeader(entry,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp.class, false);
Assert.assertEquals("Wrong vlan pcp", 7, ((VlanPcpCase) entry.getMatchEntryValue())
.getVlanPcp().getVlanPcp().intValue());
entry = entries.get(8);
}
@Test
- public void testIpv4MatchArbitraryBitMaskwithNoMask(){
+ public void testIpv4MatchArbitraryBitMaskwithNoMask() {
MatchBuilder builder = new MatchBuilder();
- Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder= new Ipv4MatchArbitraryBitMaskBuilder();
- ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask( new Ipv4Address("10.2.2.2"));
- ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask( new Ipv4Address("10.1.1.1"));
+ Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = new Ipv4MatchArbitraryBitMaskBuilder();
+ ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(new Ipv4Address("10.2.2.2"));
+ ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address("10.1.1.1"));
builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match,
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
- checkEntryHeader(entry,Ipv4Src.class,false);
- Assert.assertEquals("wrong Ipv4Address source", "10.2.2.2",((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
+ checkEntryHeader(entry, Ipv4Src.class, false);
+ Assert.assertEquals("wrong Ipv4Address source", "10.2.2.2",
+ ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
entry = entries.get(1);
- checkEntryHeader(entry,Ipv4Dst.class,false);
- Assert.assertEquals("wrong Ipv4Address destination", "10.1.1.1",((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
+ checkEntryHeader(entry, Ipv4Dst.class, false);
+ Assert.assertEquals("wrong Ipv4Address destination", "10.1.1.1",
+ ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
}
@Test
- public void testIpv4MatchArbitraryBitMaskwithMask(){
- MatchBuilder builder = new MatchBuilder();
- Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder= new Ipv4MatchArbitraryBitMaskBuilder();
- ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask( new Ipv4Address("10.2.2.2"));
+ public void testIpv4MatchArbitraryBitMaskwithMask() {
+ Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = new Ipv4MatchArbitraryBitMaskBuilder();
+ ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(new Ipv4Address("10.2.2.2"));
ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceArbitraryBitmask(new DottedQuad("0.0.255.0"));
- ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask( new Ipv4Address("10.1.1.1"));
+ ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address("10.1.1.1"));
ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationArbitraryBitmask(new DottedQuad("0.240.0.0"));
+
+ MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match,
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
- checkEntryHeader(entry,Ipv4Src.class,true);
- Assert.assertEquals("wrong Ipv4Address source", "10.2.2.2",((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
+ checkEntryHeader(entry, Ipv4Src.class, true);
+ Assert.assertEquals("wrong Ipv4Address source", "10.2.2.2",
+ ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
entry = entries.get(1);
- checkEntryHeader(entry,Ipv4Dst.class,true);
- Assert.assertEquals("wrong Ipv4Adress destination", "10.1.1.1",((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
+ checkEntryHeader(entry, Ipv4Dst.class, true);
+ Assert.assertEquals("wrong Ipv4Adress destination", "10.1.1.1",
+ ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
}
@Test
builder.setLayer4Match(udpMatchBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
builder.setLayer3Match(tunnelIpv4MatchBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
builder.setLayer4Match(sctpMatchBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
@Test
public void testArpMatchConversion() {
- MatchBuilder builder = new MatchBuilder();
ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
arpBuilder.setArpOp(5);
arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.3/32"));
ArpTargetHardwareAddressBuilder dstHwBuilder = new ArpTargetHardwareAddressBuilder();
dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
+
+ MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(arpBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 5, entries.size());
MatchEntry entry = entries.get(0);
@Test
public void testArpMatchConversionWithMasks() {
- MatchBuilder builder = new MatchBuilder();
ArpMatchBuilder arpBuilder = new ArpMatchBuilder();
/* Use canonnical prefixes !!! */
arpBuilder.setArpSourceTransportAddress(new Ipv4Prefix("10.0.0.0/8"));
dstHwBuilder.setAddress(new MacAddress("00:00:00:00:00:06"));
dstHwBuilder.setMask(new MacAddress("00:00:00:00:00:09"));
arpBuilder.setArpTargetHardwareAddress(dstHwBuilder.build());
+
+ MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(arpBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 4, entries.size());
MatchEntry entry = entries.get(0);
@Test
public void testIpv6MatchConversion() {
- MatchBuilder builder = new MatchBuilder();
Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
ipv6Builder.setIpv6Source(new Ipv6Prefix("::1/128"));
ipv6Builder.setIpv6Destination(new Ipv6Prefix("::2/128"));
Ipv6ExtHeaderBuilder extHdrBuilder = new Ipv6ExtHeaderBuilder();
extHdrBuilder.setIpv6Exthdr(153);
ipv6Builder.setIpv6ExtHeader(extHdrBuilder.build());
+
+ MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(ipv6Builder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 7, entries.size());
MatchEntry entry = entries.get(0);
entry = entries.get(6);
checkEntryHeader(entry, Ipv6Exthdr.class, false);
Assert.assertEquals("Wrong ipv6 ext hdr", new Ipv6ExthdrFlags(false, true, false, true, false,
- true, false, true, false), ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getPseudoField());
+ true, false, true, false), ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getPseudoField());
}
@Test
builder.setLayer3Match(ipv6Builder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
Assert.assertEquals("Wrong ipv6 src", "::",
((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0}, ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getMask());
+ 0, 0, 0, 0, 0, 0, 0, 0, 0}, ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getMask());
entry = entries.get(1);
checkEntryHeader(entry, Ipv6Dst.class, true);
Assert.assertEquals("Wrong ipv6 dst", "::",
((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
Assert.assertArrayEquals("Wrong ipv6 src mask", new byte[]{(byte) 255, (byte) 255, (byte) 255, (byte) 255,
- (byte) 255, (byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0},
- ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getMask());
+ (byte) 255, (byte) 255, (byte) 255, (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0},
+ ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getMask());
}
@Test
public void testIpv6ExtHeaderConversion() {
- MatchBuilder builder = new MatchBuilder();
Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
Ipv6ExtHeaderBuilder extHdrBuilder = new Ipv6ExtHeaderBuilder();
extHdrBuilder.setIpv6Exthdr(358);
extHdrBuilder.setIpv6ExthdrMask(258);
ipv6Builder.setIpv6ExtHeader(extHdrBuilder.build());
+
+ MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(ipv6Builder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 1, entries.size());
MatchEntry entry = entries.get(0);
builder.setLayer3Match(ipv4MatchBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional =
+ converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 8, entries.size());
MatchEntry entry = entries.get(0);
}
@Test
- public void testIpv6MatchArbitraryBitMask(){
+ public void testIpv6MatchArbitraryBitMask() {
+ Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder = new Ipv6MatchArbitraryBitMaskBuilder();
+ ipv6MatchArbitraryBitMaskBuilder
+ .setIpv6SourceAddressNoMask(new Ipv6Address("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0"));
+ ipv6MatchArbitraryBitMaskBuilder
+ .setIpv6SourceArbitraryBitmask(new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));
+ ipv6MatchArbitraryBitMaskBuilder
+ .setIpv6DestinationAddressNoMask(new Ipv6Address("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0"));
+ ipv6MatchArbitraryBitMaskBuilder
+ .setIpv6DestinationArbitraryBitmask(new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));
+
MatchBuilder builder = new MatchBuilder();
- Ipv6MatchArbitraryBitMaskBuilder ipv6MatchArbitraryBitMaskBuilder= new Ipv6MatchArbitraryBitMaskBuilder();
- ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceAddressNoMask(new Ipv6Address("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0"));
- ipv6MatchArbitraryBitMaskBuilder.setIpv6SourceArbitraryBitmask(new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));
- ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationAddressNoMask(new Ipv6Address("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0"));
- ipv6MatchArbitraryBitMaskBuilder.setIpv6DestinationArbitraryBitmask(new Ipv6ArbitraryMask("fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:A555"));
builder.setLayer3Match(ipv6MatchArbitraryBitMaskBuilder.build());
Match match = builder.build();
- Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
+ Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match,
+ new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
- checkEntryHeader(entry,Ipv6Src.class,true);
- Assert.assertEquals("wrong Ipv6Adress source", "fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0",((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
+ checkEntryHeader(entry, Ipv6Src.class, true);
+ Assert.assertEquals("wrong Ipv6Adress source", "fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0",
+ ((Ipv6SrcCase) entry.getMatchEntryValue()).getIpv6Src().getIpv6Address().getValue());
entry = entries.get(1);
- checkEntryHeader(entry,Ipv6Dst.class,true);
- Assert.assertEquals("wrong Ipv6Adress destination", "fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0",((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
+ checkEntryHeader(entry, Ipv6Dst.class, true);
+ Assert.assertEquals("wrong Ipv6Adress destination", "fbA0:FFB6:FFF0:FFF0:FFF0:FFF0:FFF0:AFF0",
+ ((Ipv6DstCase) entry.getMatchEntryValue()).getIpv6Dst().getIpv6Address().getValue());
}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
public class MatchConvertorUtilTest {
private static Logger LOG = LoggerFactory
.getLogger(MatchConvertorUtilTest.class);
/**
- * Test method for {@link MatchConvertorUtil#ipv6ExthdrFlagsToInt(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags)}.
- *
- * @throws Exception
+ * Test method for {@link MatchConvertorUtil#ipv6ExthdrFlagsToInt(Ipv6ExthdrFlags)}.
*/
-
@Test
public void testIpv6ExthdrFlagsToInt() throws Exception {
- Ipv6ExthdrFlags pField;
+ Ipv6ExthdrFlags flags;
Constructor<Ipv6ExthdrFlags> ctor = Ipv6ExthdrFlags.class.getConstructor(
Boolean.class, Boolean.class, Boolean.class, Boolean.class,
Boolean.class, Boolean.class, Boolean.class, Boolean.class, Boolean.class);
- int[] expectedFlagCumulants = new int[]{
- 4, 8, 2, 16, 64, 1, 32, 128, 256
- };
+ int[] expectedFlagCumulants = new int[] { 4, 8, 2, 16, 64, 1, 32, 128, 256 };
for (int i = 0; i < 9; i++) {
- pField = ctor.newInstance(createIpv6ExthdrFlagsCtorParams(i));
- int intResult = MatchConvertorUtil.ipv6ExthdrFlagsToInt(pField);
- LOG.debug("{}:Ipv6ExthdrFlags[{}] as int = {}", i, pField, intResult);
+ flags = ctor.newInstance(createIpv6ExthdrFlagsCtorParams(i));
+ int intResult = MatchConvertorUtil.ipv6ExthdrFlagsToInt(flags);
+ LOG.debug("{}:Ipv6ExthdrFlags[{}] as int = {}", i, flags, intResult);
Assert.assertEquals(expectedFlagCumulants[i], intResult);
}
- pField = new Ipv6ExthdrFlags(
+ flags = new Ipv6ExthdrFlags(
false, false, false, false, false, false, false, false, false);
- Assert.assertEquals(0, MatchConvertorUtil.ipv6ExthdrFlagsToInt(pField).intValue());
+ Assert.assertEquals(0, MatchConvertorUtil.ipv6ExthdrFlagsToInt(flags).intValue());
- pField = new Ipv6ExthdrFlags(
+ flags = new Ipv6ExthdrFlags(
true, true, true, true, true, true, true, true, true);
- Assert.assertEquals(511, MatchConvertorUtil.ipv6ExthdrFlagsToInt(pField).intValue());
+ Assert.assertEquals(511, MatchConvertorUtil.ipv6ExthdrFlagsToInt(flags).intValue());
}
- /**
- * @return
- */
-
private static Object[] createIpv6ExthdrFlagsCtorParams(final int trueIndex) {
Boolean[] flags = new Boolean[]{false, false, false, false, false, false, false, false, false};
flags[trueIndex] = true;
return flags;
}
-
}
import static org.junit.Assert.assertEquals;
-import java.math.BigInteger;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
*/
public class MatchConvertorV10Test {
- private static final MatchV10Convertor matchConvertorV10 = new MatchV10Convertor();
- private static final BigInteger dataPathId = BigInteger.TEN;
private static final long ETH_TYPE_802_3 = 0x0000;
private static final MacAddress ZERO_MAC = MacAddress.getDefaultInstance("00:00:00:00:00:00");
private static final MacAddress FF_MAC = MacAddress.getDefaultInstance("ff:ff:ff:ff:ff:ff");
private static final String DSCP = "0";
private static final short IP_PROTOCOL = 6;
private static final PortNumber DEFAULT_PORT = new PortNumber(9999);
- private static final Ipv4Prefix ipv4Prefix = Ipv4Prefix.getDefaultInstance("10.0.0.1/24");
+ private static final Ipv4Prefix IPV4_PREFIX = Ipv4Prefix.getDefaultInstance("10.0.0.1/24");
private static final VlanId DEFAULT_VLAN_ID = new VlanId(42);
private static final Ipv4Address DEFAULT_IPV4_ADDRESS = new Ipv4Address("10.0.0.1");
private static final short DEFAULT_MASK = 24;
Optional<MatchV10> matchV10Optional = converterManager.convert(match,
new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
MatchV10 matchV10 = matchV10Optional.get();
- Integer zero = 0;
- boolean wcTpSrc = true;
- boolean wcTpDst = true;
- FlowWildcardsV10 wc = new FlowWildcardsV10(
- false, false, false, true, true, false, false, false,
- wcTpDst, wcTpSrc);
+ final Integer zero = 0;
+
assertEquals(ZERO_MAC, matchV10.getDlDst());
assertEquals(FF_MAC, matchV10.getDlSrc());
assertEquals(0, matchV10.getDlType().intValue());
assertEquals(0, matchV10.getNwTos().shortValue());
assertEquals(zero, matchV10.getTpSrc());
assertEquals(zero, matchV10.getTpDst());
+
+ boolean wcTpSrc = true;
+ boolean wcTpDst = true;
+ FlowWildcardsV10 wc = new FlowWildcardsV10(
+ false, false, false, true, true, false, false, false,
+ wcTpDst, wcTpSrc);
assertEquals(wc, matchV10.getWildcards());
// Specify ICMP type only.
Integer icmpType = 55;
- Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder().
- setIcmpv4Type(icmpType.shortValue());
+ Icmpv4MatchBuilder icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue());
wcTpSrc = false;
wc = new FlowWildcardsV10(
false, false, false, true, true, false, false, false,
wcTpDst, wcTpSrc);
- match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
- build();
+ match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
matchV10Optional = converterManager.convert(match,
new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
matchV10 = matchV10Optional.get();
// Specify ICMP code only.
Integer icmpCode = 31;
- icmpv4MatchBuilder = new Icmpv4MatchBuilder().
- setIcmpv4Type(null).setIcmpv4Code(icmpCode.shortValue());
+ icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(null).setIcmpv4Code(icmpCode.shortValue());
wcTpSrc = true;
wcTpDst = false;
wc = new FlowWildcardsV10(
false, false, false, true, true, false, false, false,
wcTpDst, wcTpSrc);
- match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
- build();
+ match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
matchV10Optional = converterManager.convert(match,
new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
matchV10 = matchV10Optional.get();
// Specify both ICMP type and code.
icmpType = 11;
icmpCode = 22;
- icmpv4MatchBuilder = new Icmpv4MatchBuilder().
- setIcmpv4Type(icmpType.shortValue()).
- setIcmpv4Code(icmpCode.shortValue());
+ icmpv4MatchBuilder = new Icmpv4MatchBuilder().setIcmpv4Type(icmpType.shortValue())
+ .setIcmpv4Code(icmpCode.shortValue());
wcTpSrc = false;
wcTpDst = false;
wc = new FlowWildcardsV10(
false, false, false, true, true, false, false, false,
wcTpDst, wcTpSrc);
- match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).
- build();
+ match = matchBuilder.setIcmpv4Match(icmpv4MatchBuilder.build()).build();
matchV10Optional = converterManager.convert(match,
new VersionConvertorData(OFConstants.OFP_VERSION_1_0));
matchV10 = matchV10Optional.get();
}
private static MatchBuilder createVlanTcpMatch() {
- MatchBuilder matchBuilder = createL4TcpMatch();
+ final MatchBuilder matchBuilder = createL4TcpMatch();
VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder();
VlanIdBuilder vlanIdBuilder = new VlanIdBuilder();
vlanIdBuilder.setVlanId(DEFAULT_VLAN_ID);
}
private static MatchBuilder createMatchBuilderWithDefaults() {
- MatchBuilder matchBuilder = new MatchBuilder();
EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
EthernetTypeBuilder ethernetTypeBuilder = new EthernetTypeBuilder();
ethernetSourceBuilder.setMask(FF_MAC);
ethernetSourceBuilder.setAddress(FF_MAC);
ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
+
+ MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
NodeConnectorId nodeConnectorId = NodeConnectorId.getDefaultInstance(NODE_CONNECTOR_ID);
matchBuilder.setIpMatch(ipMatchBuilder.build());
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
- ipv4MatchBuilder.setIpv4Destination(ipv4Prefix);
- ipv4MatchBuilder.setIpv4Source(ipv4Prefix);
+ ipv4MatchBuilder.setIpv4Destination(IPV4_PREFIX);
+ ipv4MatchBuilder.setIpv4Source(IPV4_PREFIX);
matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
matchBuilder.setInPort(new NodeConnectorId(NODE_CONNECTOR_ID));
return matchBuilder;
-/*\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.openflowplugin.openflow.md.core.sal.convertor.match;\r
-\r
-import java.math.BigInteger;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Optional;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.OFConstants;\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.core.sal.convertor.data.VersionDatapathIdConvertorData;\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
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;\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.PortNumber;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthTypeBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProtoBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6ExthdrBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSllBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTllBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabelBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTcBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsidBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelIdBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- */\r
-public class MatchResponseConvertor2Test {\r
-\r
- private ConvertorManager convertorManager;\r
-\r
- /**\r
- * Initializes OpenflowPortsUtil\r
- */\r
- @Before\r
- public void startUp() {\r
- convertorManager = ConvertorManagerFactory.createDefaultManager();\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test(expected = NullPointerException.class)\r
- public void testEmptyMatch() {\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
- convert(new MatchBuilder().build(), datapathIdConvertorData);\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testEmptyMatchEntry() {\r
-\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getEthernetMatch());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getIcmpv4Match());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getIcmpv6Match());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getInPhyPort());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getInPort());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getIpMatch());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getMetadata());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getProtocolMatchFields());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong match entries", null, builtMatch.getTunnel());\r
-\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryNoMasks() {\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort.class);\r
- entriesBuilder.setHasMask(false);\r
- final InPortCaseBuilder caseBuilder = new InPortCaseBuilder();\r
- final InPortBuilder portBuilder = new InPortBuilder();\r
- portBuilder.setPortNumber(new PortNumber(1L));\r
- caseBuilder.setInPort(portBuilder.build());\r
- entriesBuilder.setMatchEntryValue(caseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- final InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort.class);\r
- entriesBuilder.setHasMask(false);\r
- final InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();\r
- inPhyPortBuilder.setPortNumber(new PortNumber(2L));\r
- inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());\r
- entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(false);\r
- final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
- metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});\r
- metadataCaseBuilder.setMetadata(metadataBuilder.build());\r
- entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(EthDst.class);\r
- entriesBuilder.setHasMask(false);\r
- final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
- final EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
- ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
- ethDstCaseBuilder.setEthDst(ethDstBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(EthSrc.class);\r
- entriesBuilder.setHasMask(false);\r
- final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
- final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
- ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
- ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(EthType.class);\r
- entriesBuilder.setHasMask(false);\r
- final EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();\r
-\r
- final EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();\r
- ethTypeBuilder.setEthType(new EtherType(3));\r
- ethTypeCaseBuilder.setEthType(ethTypeBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ethTypeCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(VlanVid.class);\r
- final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
- entriesBuilder.setHasMask(false);\r
- final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
- vlanVidBuilder.setVlanVid(4);\r
- vlanVidBuilder.setCfiBit(true);\r
- vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());\r
- entriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(VlanPcp.class);\r
- final VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();\r
- entriesBuilder.setHasMask(false);\r
- final VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();\r
- vlanPcpBuilder.setVlanPcp((short) 5);\r
- vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());\r
- entriesBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(IpDscp.class);\r
- entriesBuilder.setHasMask(false);\r
- final IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();\r
- final IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();\r
- ipDscpBuilder.setDscp(new Dscp((short) 6));\r
- ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(IpEcn.class);\r
- entriesBuilder.setHasMask(false);\r
- final IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();\r
- final IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();\r
- ipEcnBuilder.setEcn((short) 7);\r
- ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(IpProto.class);\r
- final IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();\r
- entriesBuilder.setHasMask(false);\r
- final IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();\r
- ipProtoBuilder.setProtocolNumber((short) 8);\r
- ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipProtoCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();\r
- final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));\r
- ipv4AddressBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4AddressBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- final Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();\r
- ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));\r
- ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(TcpSrc.class);\r
- entriesBuilder.setHasMask(false);\r
- final TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();\r
- final TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();\r
- tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
- .inet.types.rev130715.PortNumber(9));\r
- tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(TcpDst.class);\r
- entriesBuilder.setHasMask(false);\r
- final TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();\r
- final TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();\r
- tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
- .inet.types.rev130715.PortNumber(10));\r
- tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());\r
- entriesBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Icmpv4Type.class);\r
- entriesBuilder.setHasMask(false);\r
- final Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();\r
- final Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();\r
- icmpv4TypeBuilder.setIcmpv4Type((short) 15);\r
- icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());\r
- entriesBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Icmpv4Code.class);\r
- entriesBuilder.setHasMask(false);\r
- final Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();\r
- final Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();\r
- icmpv4CodeBuilder.setIcmpv4Code((short) 16);\r
- icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());\r
- entriesBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Icmpv6Type.class);\r
- entriesBuilder.setHasMask(false);\r
- final Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();\r
- final Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();\r
- icmpv6TypeBuilder.setIcmpv6Type((short) 19);\r
- icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());\r
- entriesBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Icmpv6Code.class);\r
- entriesBuilder.setHasMask(false);\r
- final Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();\r
- final Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();\r
- icmpv6CodeBuilder.setIcmpv6Code((short) 20);\r
- icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());\r
- entriesBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(MplsLabel.class);\r
- entriesBuilder.setHasMask(false);\r
- final MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();\r
-\r
- final MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();\r
- mplsLabelBuilder.setMplsLabel(21L);\r
- mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build());\r
- entriesBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(MplsTc.class);\r
- entriesBuilder.setHasMask(false);\r
- final MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();\r
- final MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();\r
- mplsTcBuilder.setTc((short) 22);\r
- mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(mplsTcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(MplsBos.class);\r
- entriesBuilder.setHasMask(false);\r
- final MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();\r
- final MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();\r
- mplsBosBuilder.setBos(true);\r
- mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());\r
- entriesBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(PbbIsid.class);\r
- entriesBuilder.setHasMask(false);\r
- final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
- final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
- pbbIsidBuilder.setIsid(23L);\r
- pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());\r
- entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());\r
-\r
- entries.add(entriesBuilder.build());\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(TunnelId.class);\r
- entriesBuilder.setHasMask(false);\r
- final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
- final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
- tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});\r
- tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());\r
- entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setMatchEntry(entries);\r
-\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue());\r
- Assert.assertEquals("Wrong in phy port", "openflow:42:2", builtMatch.getInPhyPort().getValue());\r
- Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}), builtMatch.getMetadata().getMetadata());\r
- Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress());\r
- Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress());\r
- Assert.assertEquals("Wrong eth type", 3, builtMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());\r
- Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());\r
- Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());\r
- Assert.assertEquals("Wrong vlan pcp", 5, builtMatch.getVlanMatch().getVlanPcp().getValue().intValue());\r
- Assert.assertEquals("Wrong ip dscp", 6, builtMatch.getIpMatch().getIpDscp().getValue().intValue());\r
- Assert.assertEquals("Wrong ip ecn", 7, builtMatch.getIpMatch().getIpEcn().intValue());\r
- Assert.assertEquals("Wrong ip proto", null, builtMatch.getIpMatch().getIpProto());\r
- Assert.assertEquals("Wrong ip protocol", 8, builtMatch.getIpMatch().getIpProtocol().intValue());\r
-\r
- final TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong tcp src port", 9, tcpMatch.getTcpSourcePort().getValue().intValue());\r
- Assert.assertEquals("Wrong tcp dst port", 10, tcpMatch.getTcpDestinationPort().getValue().intValue());\r
- Assert.assertEquals("Wrong icmpv4 type", 15, builtMatch.getIcmpv4Match().getIcmpv4Type().intValue());\r
- Assert.assertEquals("Wrong icmpv4 code", 16, builtMatch.getIcmpv4Match().getIcmpv4Code().intValue());\r
- Assert.assertEquals("Wrong icmpv6 type", 19, builtMatch.getIcmpv6Match().getIcmpv6Type().intValue());\r
- Assert.assertEquals("Wrong icmpv6 code", 20, builtMatch.getIcmpv6Match().getIcmpv6Code().intValue());\r
-\r
- final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/32", ipv4Match.getIpv4Source().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/32", ipv4Match.getIpv4Destination().getValue());\r
- Assert.assertEquals("Wrong mpls label", 21, builtMatch.getProtocolMatchFields().getMplsLabel().intValue());\r
- Assert.assertEquals("Wrong mpls bos", 1, builtMatch.getProtocolMatchFields().getMplsBos().intValue());\r
- Assert.assertEquals("Wrong mpls tc", 22, builtMatch.getProtocolMatchFields().getMplsTc().intValue());\r
- Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());\r
- Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}),\r
- builtMatch.getTunnel().getTunnelId());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithMasks() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
-\r
- final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case.MetadataBuilder();\r
- metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});\r
- metadataBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 1});\r
- metadataCaseBuilder.setMetadata(metadataBuilder.build());\r
- entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(EthDst.class);\r
- entriesBuilder.setHasMask(true);\r
- final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();\r
- final EthDstBuilder ethDstBuilder = new EthDstBuilder();\r
- ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
- ethDstBuilder.setMask(new byte[]{0, 0, 0, 0, 1, 1});\r
- ethDstCaseBuilder.setEthDst(ethDstBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(EthSrc.class);\r
- entriesBuilder.setHasMask(true);\r
- final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();\r
- final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();\r
- ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
- ethSrcBuilder.setMask(new byte[]{0, 0, 0, 0, 2, 2});\r
- ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(VlanVid.class);\r
- entriesBuilder.setHasMask(true);\r
- final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();\r
- final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();\r
- vlanVidBuilder.setVlanVid(4);\r
- vlanVidBuilder.setCfiBit(true);\r
- vlanVidBuilder.setMask(new byte[]{0, 4});\r
- vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());\r
- entriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
- final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
- ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
- ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
- ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});\r
- ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(PbbIsid.class);\r
- entriesBuilder.setHasMask(true);\r
- final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();\r
-\r
- final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();\r
- pbbIsidBuilder.setIsid(23L);\r
- pbbIsidBuilder.setMask(new byte[]{0, 0, 7});\r
- pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());\r
- entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(TunnelId.class);\r
- entriesBuilder.setHasMask(true);\r
- final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();\r
- final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();\r
- tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});\r
- tunnelIdBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 8});\r
- tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());\r
- entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}), builtMatch.getMetadata().getMetadata());\r
- Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[]{0, 0, 0, 0, 0, 0, 0, 1}),\r
- builtMatch.getMetadata().getMetadataMask());\r
- Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress());\r
- Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:01:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask());\r
- Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress());\r
- Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"), builtMatch.getEthernetMatch().getEthernetSource().getMask());\r
- Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());\r
- Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());\r
- final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.0.0.0/24", ipv4Match.getIpv4Source().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.0/20", ipv4Match.getIpv4Destination().getValue());\r
- Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());\r
- Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}),\r
- builtMatch.getTunnel().getTunnelId());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithArbitraryMasks() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
- final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));\r
- ipv4SrcBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 255, 0});\r
- ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));\r
- ipv4AddressBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 240, 0});\r
- ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithSrcCidrMaskAndDstArbitraryBitMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
- final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));\r
- ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
- ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));\r
- ipv4AddressBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 240, 0});\r
- ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithSrcArbitraryBitMaskAndDstCidrMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
- final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));\r
- ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 0, (byte) 255, 0});\r
- ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));\r
- ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});\r
- ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());\r
- }\r
-\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithDstArbitraryBitMaskAndSrcCidrMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));\r
- ipv4AddressBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 240, 0});\r
- ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
- final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));\r
- ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
- ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithDstCidrMaskAndSrcArbitraryBitMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();\r
- final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();\r
- ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));\r
- ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});\r
- ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv4Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();\r
- final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();\r
- ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));\r
- ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 0, (byte) 255, 0});\r
- ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatch = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();\r
-\r
- final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",\r
- ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testLayer4MatchUdp() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc.class);\r
- entriesBuilder.setHasMask(false);\r
- final UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();\r
- final UdpSrcBuilder portBuilder = new UdpSrcBuilder();\r
- portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
- .inet.types.rev130715.PortNumber(11));\r
- udpSrcCaseBuilder.setUdpSrc(portBuilder.build());\r
- entriesBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(UdpDst.class);\r
- entriesBuilder.setHasMask(false);\r
- final UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();\r
- final UdpDstBuilder udpDstBuilder = new UdpDstBuilder();\r
- udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
- .inet.types.rev130715.PortNumber(12));\r
- udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());\r
- entriesBuilder.setMatchEntryValue(udpDstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder builtMatch = convert(builder.build(), datapathIdConvertorData);\r
-\r
- final UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong udp src port", 11, udpMatch.getUdpSourcePort().getValue().intValue());\r
- Assert.assertEquals("Wrong udp dst port", 12, udpMatch.getUdpDestinationPort().getValue().intValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testLayer4MatchSctp() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(SctpSrc.class);\r
- entriesBuilder.setHasMask(false);\r
- final SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();\r
- final SctpSrcBuilder portBuilder = new SctpSrcBuilder();\r
- portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
- .inet.types.rev130715.PortNumber(13));\r
- sctpSrcCaseBuilder.setSctpSrc(portBuilder.build());\r
- entriesBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(SctpDst.class);\r
- entriesBuilder.setHasMask(false);\r
- final SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();\r
- final SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();\r
- sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf\r
- .inet.types.rev130715.PortNumber(14));\r
- sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());\r
- entriesBuilder.setMatchEntryValue(sctpDstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
- builder.setMatchEntry(entries);\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong sctp src port", 13, udpMatch.getSctpSourcePort().getValue().intValue());\r
- Assert.assertEquals("Wrong sctp dst port", 14, udpMatch.getSctpDestinationPort().getValue().intValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testLayer3MatchIpv6() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
- final Ipv6SrcBuilder ipv6AddressBuilder = new Ipv6SrcBuilder();\r
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9657"));\r
- ipv6SrcCaseBuilder.setIpv6Src(ipv6AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
- final Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();\r
- ipv6DstBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9658"));\r
- ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Flabel.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();\r
- final Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();\r
- ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(18L));\r
- ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();\r
- final Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();\r
- ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9659"));\r
- ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6NdSll.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();\r
- final Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();\r
- ipv6NdSllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:05"));\r
- ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6NdTll.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();\r
- final Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();\r
- ipv6NdTllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:06"));\r
- ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
- entriesBuilder.setHasMask(false);\r
- final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
- final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
- ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));\r
- ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());\r
- builder.setMatchEntry(entries);\r
- entries.add(entriesBuilder.build());\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 src address", "2001:cdba::3257:9657/128",\r
- ipv6Match.getIpv6Source().getValue());\r
- Assert.assertEquals("Wrong ipv6 dst address", "2001:cdba::3257:9658/128",\r
- ipv6Match.getIpv6Destination().getValue());\r
- Assert.assertEquals("Wrong ipv6 nd target", "2001:cdba:0000:0000:0000:0000:3257:9659",\r
- ipv6Match.getIpv6NdTarget().getValue());\r
- Assert.assertEquals("Wrong ipv6 flabel", 18, ipv6Match.getIpv6Label().getIpv6Flabel().getValue().intValue());\r
- Assert.assertEquals("Wrong ipv6 nd sll", new MacAddress("00:00:00:00:00:05"), ipv6Match.getIpv6NdSll());\r
- Assert.assertEquals("Wrong ipv6 nd tll", new MacAddress("00:00:00:00:00:06"), ipv6Match.getIpv6NdTll());\r
- Assert.assertEquals("Wrong ipv6 ext header", 358, ipv6Match.getIpv6ExtHeader().getIpv6Exthdr().intValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testLayer3MatchIpv6ExtHeader2() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- final MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();\r
- final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();\r
- ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false));\r
- ipv6ExthdrBuilder.setMask(new byte[]{1, 2});\r
- ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
- builder.setMatchEntry(entries);\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 ext header", 153, ipv6Match.getIpv6ExtHeader().getIpv6Exthdr().intValue());\r
- Assert.assertEquals("Wrong ipv6 ext header mask", 258, ipv6Match.getIpv6ExtHeader().getIpv6ExthdrMask().intValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testLayer3MatchArp() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(ArpOp.class);\r
- entriesBuilder.setHasMask(false);\r
- final ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();\r
- final ArpOpBuilder arpOpBuilder = new ArpOpBuilder();\r
- arpOpBuilder.setOpCode(17);\r
- arpOpCaseBuilder.setArpOp(arpOpBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpOpCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(ArpSpa.class);\r
- entriesBuilder.setHasMask(false);\r
- final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
- final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
- arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));\r
- arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(ArpTpa.class);\r
- entriesBuilder.setHasMask(false);\r
- final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
- final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
- arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));\r
- arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(ArpSha.class);\r
- entriesBuilder.setHasMask(false);\r
- final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
- final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
- arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));\r
- arpShaCaseBuilder.setArpSha(arpShaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);\r
- entriesBuilder.setHasMask(false);\r
- final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
- final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
- arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));\r
- arpThaCaseBuilder.setArpTha(arpThaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
- builder.setMatchEntry(entries);\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong arp op", 17, arpMatch.getArpOp().intValue());\r
- Assert.assertEquals("Wrong arp spa", "10.0.0.3/32", arpMatch.getArpSourceTransportAddress().getValue());\r
- Assert.assertEquals("Wrong arp tpa", "10.0.0.4/32", arpMatch.getArpTargetTransportAddress().getValue());\r
- Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03", arpMatch.getArpSourceHardwareAddress().getAddress().getValue());\r
- Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04", arpMatch.getArpTargetHardwareAddress().getAddress().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testLayer3MatchArpWithMasks() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(ArpSpa.class);\r
- entriesBuilder.setHasMask(true);\r
- final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();\r
- final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();\r
- arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));\r
- arpSpaBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});\r
- arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(ArpTpa.class);\r
- entriesBuilder.setHasMask(true);\r
- final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();\r
- final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();\r
- arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));\r
- arpTpaBuilder.setMask(new byte[]{(byte) 255, (byte) 128, 0, 0});\r
- arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(ArpSha.class);\r
- entriesBuilder.setHasMask(true);\r
- final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();\r
- final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();\r
- arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));\r
- arpShaBuilder.setMask(new byte[]{0, 0, 1, 0, 4, 0});\r
- arpShaCaseBuilder.setArpSha(arpShaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);\r
- entriesBuilder.setHasMask(true);\r
- final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();\r
- final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();\r
- arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));\r
- arpThaBuilder.setMask(new byte[]{1, 1, 1, 2, 2, 2});\r
- arpThaCaseBuilder.setArpTha(arpThaBuilder.build());\r
- entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong arp spa", "10.0.0.3/24", arpMatch.getArpSourceTransportAddress().getValue());\r
- Assert.assertEquals("Wrong arp tpa", "10.0.0.0/9", arpMatch.getArpTargetTransportAddress().getValue());\r
- Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03", arpMatch.getArpSourceHardwareAddress().getAddress().getValue());\r
- Assert.assertEquals("Wrong arp sha mask", "00:00:01:00:04:00", arpMatch.getArpSourceHardwareAddress().getMask().getValue());\r
- Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04", arpMatch.getArpTargetHardwareAddress().getAddress().getValue());\r
- Assert.assertEquals("Wrong arp tha mask", "01:01:01:02:02:02", arpMatch.getArpTargetHardwareAddress().getMask().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithIpv6ArbitraryMasks() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
- final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();\r
- ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));\r
- ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});\r
- ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
- final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();\r
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));\r
- ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});\r
- ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
- ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002",\r
- ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithIpv6SrcCidrlMaskAndDstArbitraryBitMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
- final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();\r
- ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));\r
- ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});\r
- ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
- final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();\r
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));\r
- ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});\r
- ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
- ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002",\r
- ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithIpv6SrcArbitraryBitMaskAndDstCidrMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
- final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();\r
- ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));\r
- ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});\r
- ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
- final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();\r
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));\r
- ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});\r
- ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
- ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002",\r
- ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());\r
- }\r
-\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithIpv6DstArbitraryBitMaskAndSrcCidrMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
- final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();\r
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));\r
- ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});\r
- ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
- final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();\r
- ipv6SrcBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));\r
- ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});\r
- ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 src address", "2002:2002:2002:2002:2002:2002:2002:2002",\r
- ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv6 dst address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
- ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());\r
- }\r
-\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWithMatchEntryWithIpv6DstCidrMaskAndSrcArbitraryBitMask() {\r
- final MatchBuilder builder = new MatchBuilder();\r
- builder.setType(OxmMatchType.class);\r
- final List<MatchEntry> entries = new ArrayList<>();\r
- MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);\r
- entriesBuilder.setHasMask(true);\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Dst.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();\r
- final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();\r
- ipv6AddressBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));\r
- ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});\r
- ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- entriesBuilder = new MatchEntryBuilder();\r
- entriesBuilder.setOxmClass(OpenflowBasicClass.class);\r
- entriesBuilder.setOxmMatchField(Ipv6Src.class);\r
- entriesBuilder.setHasMask(true);\r
- final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();\r
- final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();\r
- ipv6SrcBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));\r
- ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});\r
- ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());\r
- entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());\r
- entries.add(entriesBuilder.build());\r
-\r
- builder.setMatchEntry(entries);\r
- final Match match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);\r
- final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();\r
-\r
- final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong ipv6 src address", "2002:2002:2002:2002:2002:2002:2002:2002",\r
- ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());\r
- Assert.assertEquals("Wrong ipv6 dst address", "1001:1001:1001:1001:1001:1001:1001:1001",\r
- ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());\r
- }\r
-\r
- private org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder convert(Match match, VersionDatapathIdConvertorData data) {\r
- final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow\r
- .MatchBuilder> salMatchOptional = convertorManager.convert(match, data);\r
-\r
- return salMatchOptional\r
- .orElse(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder());\r
- }\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.openflowplugin.openflow.md.core.sal.convertor.match;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Dscp;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6FlowLabel;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.SctpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSha;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpSpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpDscp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Exthdr;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Flabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdSll;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTarget;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6NdTll;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Ipv6Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsBos;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MplsTc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.PbbIsid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TunnelId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanVid;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpOpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpShaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpSpaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpThaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ArpTpaCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPhyPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.InPortCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpEcnCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpProtoCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv4SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6DstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6ExthdrCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6FlabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdSllCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTargetCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6NdTllCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Ipv6SrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsBosCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsLabelCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.MplsTcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.PbbIsidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TunnelIdCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.op._case.ArpOpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.sha._case.ArpShaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.spa._case.ArpSpaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tha._case.ArpThaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.arp.tpa._case.ArpTpaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.dst._case.EthDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.src._case.EthSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.phy.port._case.InPhyPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.in.port._case.InPortBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.ecn._case.IpEcnBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.proto._case.IpProtoBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.dst._case.Ipv4DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv4.src._case.Ipv4SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.dst._case.Ipv6DstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.exthdr._case.Ipv6ExthdrBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.flabel._case.Ipv6FlabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.sll._case.Ipv6NdSllBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.target._case.Ipv6NdTargetBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.nd.tll._case.Ipv6NdTllBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ipv6.src._case.Ipv6SrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.bos._case.MplsBosBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.label._case.MplsLabelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.mpls.tc._case.MplsTcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.pbb.isid._case.PbbIsidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.dst._case.SctpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tunnel.id._case.TunnelIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder;
+
+/**
+ * Unit tests for match response conversions.
+ *
+ * @author michal.polkorab
+ */
+public class MatchResponseConvertor2Test {
+
+ private ConvertorManager convertorManager;
+
+ /**
+ * Initializes OpenflowPortsUtil.
+ */
+ @Before
+ public void startUp() {
+ convertorManager = ConvertorManagerFactory.createDefaultManager();
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test(expected = NullPointerException.class)
+ public void testEmptyMatch() {
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+ convert(new MatchBuilder().build(), datapathIdConvertorData);
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testEmptyMatchEntry() {
+
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getEthernetMatch());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getIcmpv4Match());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getIcmpv6Match());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getInPhyPort());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getInPort());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getIpMatch());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getLayer3Match());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getLayer4Match());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getMetadata());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getProtocolMatchFields());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getVlanMatch());
+ Assert.assertEquals("Wrong match entries", null, builtMatch.getTunnel());
+
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryNoMasks() {
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort.class);
+ entriesBuilder.setHasMask(false);
+ final InPortCaseBuilder caseBuilder = new InPortCaseBuilder();
+ final InPortBuilder portBuilder = new InPortBuilder();
+ portBuilder.setPortNumber(new PortNumber(1L));
+ caseBuilder.setInPort(portBuilder.build());
+ entriesBuilder.setMatchEntryValue(caseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ final InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPhyPort.class);
+ entriesBuilder.setHasMask(false);
+ final InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
+ inPhyPortBuilder.setPortNumber(new PortNumber(2L));
+ inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
+ entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(false);
+ final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match
+ .entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn
+ .opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case
+ .MetadataBuilder();
+ metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});
+ metadataCaseBuilder.setMetadata(metadataBuilder.build());
+ entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(EthDst.class);
+ entriesBuilder.setHasMask(false);
+ final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
+ final EthDstBuilder ethDstBuilder = new EthDstBuilder();
+ ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));
+ ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
+ entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(EthSrc.class);
+ entriesBuilder.setHasMask(false);
+ final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
+ final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
+ ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));
+ ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(EthType.class);
+ entriesBuilder.setHasMask(false);
+ final EthTypeCaseBuilder ethTypeCaseBuilder = new EthTypeCaseBuilder();
+
+ final EthTypeBuilder ethTypeBuilder = new EthTypeBuilder();
+ ethTypeBuilder.setEthType(new EtherType(3));
+ ethTypeCaseBuilder.setEthType(ethTypeBuilder.build());
+ entriesBuilder.setMatchEntryValue(ethTypeCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(VlanVid.class);
+ final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+ entriesBuilder.setHasMask(false);
+ final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+ vlanVidBuilder.setVlanVid(4);
+ vlanVidBuilder.setCfiBit(true);
+ vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+ entriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(VlanPcp.class);
+ final VlanPcpCaseBuilder vlanPcpCaseBuilder = new VlanPcpCaseBuilder();
+ entriesBuilder.setHasMask(false);
+ final VlanPcpBuilder vlanPcpBuilder = new VlanPcpBuilder();
+ vlanPcpBuilder.setVlanPcp((short) 5);
+ vlanPcpCaseBuilder.setVlanPcp(vlanPcpBuilder.build());
+ entriesBuilder.setMatchEntryValue(vlanPcpCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(IpDscp.class);
+ entriesBuilder.setHasMask(false);
+ final IpDscpCaseBuilder ipDscpCaseBuilder = new IpDscpCaseBuilder();
+ final IpDscpBuilder ipDscpBuilder = new IpDscpBuilder();
+ ipDscpBuilder.setDscp(new Dscp((short) 6));
+ ipDscpCaseBuilder.setIpDscp(ipDscpBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipDscpCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(IpEcn.class);
+ entriesBuilder.setHasMask(false);
+ final IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
+ final IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
+ ipEcnBuilder.setEcn((short) 7);
+ ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(IpProto.class);
+ final IpProtoCaseBuilder ipProtoCaseBuilder = new IpProtoCaseBuilder();
+ entriesBuilder.setHasMask(false);
+ final IpProtoBuilder ipProtoBuilder = new IpProtoBuilder();
+ ipProtoBuilder.setProtocolNumber((short) 8);
+ ipProtoCaseBuilder.setIpProto(ipProtoBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipProtoCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Src.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv4SrcCaseBuilder ipv4AddressBuilder = new Ipv4SrcCaseBuilder();
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.1"));
+ ipv4AddressBuilder.setIpv4Src(ipv4SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4AddressBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Dst.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ final Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
+ ipv4DstBuilder.setIpv4Address(new Ipv4Address("10.0.0.2"));
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(TcpSrc.class);
+ entriesBuilder.setHasMask(false);
+ final TcpSrcCaseBuilder tcpSrcCaseBuilder = new TcpSrcCaseBuilder();
+ final TcpSrcBuilder tcpSrcBuilder = new TcpSrcBuilder();
+ tcpSrcBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+ .inet.types.rev130715.PortNumber(9));
+ tcpSrcCaseBuilder.setTcpSrc(tcpSrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(tcpSrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(TcpDst.class);
+ entriesBuilder.setHasMask(false);
+ final TcpDstCaseBuilder tcpDstCaseBuilder = new TcpDstCaseBuilder();
+ final TcpDstBuilder tcpDstBuilder = new TcpDstBuilder();
+ tcpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+ .inet.types.rev130715.PortNumber(10));
+ tcpDstCaseBuilder.setTcpDst(tcpDstBuilder.build());
+ entriesBuilder.setMatchEntryValue(tcpDstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Icmpv4Type.class);
+ entriesBuilder.setHasMask(false);
+ final Icmpv4TypeCaseBuilder icmpv4TypeCaseBuilder = new Icmpv4TypeCaseBuilder();
+ final Icmpv4TypeBuilder icmpv4TypeBuilder = new Icmpv4TypeBuilder();
+ icmpv4TypeBuilder.setIcmpv4Type((short) 15);
+ icmpv4TypeCaseBuilder.setIcmpv4Type(icmpv4TypeBuilder.build());
+ entriesBuilder.setMatchEntryValue(icmpv4TypeCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Icmpv4Code.class);
+ entriesBuilder.setHasMask(false);
+ final Icmpv4CodeCaseBuilder icmpv4CodeCaseBuilder = new Icmpv4CodeCaseBuilder();
+ final Icmpv4CodeBuilder icmpv4CodeBuilder = new Icmpv4CodeBuilder();
+ icmpv4CodeBuilder.setIcmpv4Code((short) 16);
+ icmpv4CodeCaseBuilder.setIcmpv4Code(icmpv4CodeBuilder.build());
+ entriesBuilder.setMatchEntryValue(icmpv4CodeCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Icmpv6Type.class);
+ entriesBuilder.setHasMask(false);
+ final Icmpv6TypeCaseBuilder icmpv6TypeCaseBuilder = new Icmpv6TypeCaseBuilder();
+ final Icmpv6TypeBuilder icmpv6TypeBuilder = new Icmpv6TypeBuilder();
+ icmpv6TypeBuilder.setIcmpv6Type((short) 19);
+ icmpv6TypeCaseBuilder.setIcmpv6Type(icmpv6TypeBuilder.build());
+ entriesBuilder.setMatchEntryValue(icmpv6TypeCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Icmpv6Code.class);
+ entriesBuilder.setHasMask(false);
+ final Icmpv6CodeCaseBuilder icmpv6CodeCaseBuilder = new Icmpv6CodeCaseBuilder();
+ final Icmpv6CodeBuilder icmpv6CodeBuilder = new Icmpv6CodeBuilder();
+ icmpv6CodeBuilder.setIcmpv6Code((short) 20);
+ icmpv6CodeCaseBuilder.setIcmpv6Code(icmpv6CodeBuilder.build());
+ entriesBuilder.setMatchEntryValue(icmpv6CodeCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(MplsLabel.class);
+ entriesBuilder.setHasMask(false);
+ final MplsLabelCaseBuilder mplsLabelCaseBuilder = new MplsLabelCaseBuilder();
+
+ final MplsLabelBuilder mplsLabelBuilder = new MplsLabelBuilder();
+ mplsLabelBuilder.setMplsLabel(21L);
+ mplsLabelCaseBuilder.setMplsLabel(mplsLabelBuilder.build());
+ entriesBuilder.setMatchEntryValue(mplsLabelCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(MplsTc.class);
+ entriesBuilder.setHasMask(false);
+ final MplsTcCaseBuilder mplsTcCaseBuilder = new MplsTcCaseBuilder();
+ final MplsTcBuilder mplsTcBuilder = new MplsTcBuilder();
+ mplsTcBuilder.setTc((short) 22);
+ mplsTcCaseBuilder.setMplsTc(mplsTcBuilder.build());
+ entriesBuilder.setMatchEntryValue(mplsTcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(MplsBos.class);
+ entriesBuilder.setHasMask(false);
+ final MplsBosCaseBuilder mplsBosCaseBuilder = new MplsBosCaseBuilder();
+ final MplsBosBuilder mplsBosBuilder = new MplsBosBuilder();
+ mplsBosBuilder.setBos(true);
+ mplsBosCaseBuilder.setMplsBos(mplsBosBuilder.build());
+ entriesBuilder.setMatchEntryValue(mplsBosCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(PbbIsid.class);
+ entriesBuilder.setHasMask(false);
+ final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();
+ final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();
+ pbbIsidBuilder.setIsid(23L);
+ pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());
+ entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());
+
+ entries.add(entriesBuilder.build());
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(TunnelId.class);
+ entriesBuilder.setHasMask(false);
+ final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
+ final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
+ tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});
+ tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
+ entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setMatchEntry(entries);
+
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ Assert.assertEquals("Wrong in port", "openflow:42:1", builtMatch.getInPort().getValue());
+ Assert.assertEquals("Wrong in phy port", "openflow:42:2", builtMatch.getInPhyPort().getValue());
+ Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }),
+ builtMatch.getMetadata().getMetadata());
+ Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"),
+ builtMatch.getEthernetMatch().getEthernetDestination().getAddress());
+ Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"),
+ builtMatch.getEthernetMatch().getEthernetSource().getAddress());
+ Assert.assertEquals("Wrong eth type", 3,
+ builtMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
+ Assert.assertEquals("Wrong vlan id", 4,
+ builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
+ Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());
+ Assert.assertEquals("Wrong vlan pcp", 5, builtMatch.getVlanMatch().getVlanPcp().getValue().intValue());
+ Assert.assertEquals("Wrong ip dscp", 6, builtMatch.getIpMatch().getIpDscp().getValue().intValue());
+ Assert.assertEquals("Wrong ip ecn", 7, builtMatch.getIpMatch().getIpEcn().intValue());
+ Assert.assertEquals("Wrong ip proto", null, builtMatch.getIpMatch().getIpProto());
+ Assert.assertEquals("Wrong ip protocol", 8, builtMatch.getIpMatch().getIpProtocol().intValue());
+
+ final TcpMatch tcpMatch = (TcpMatch) builtMatch.getLayer4Match();
+ Assert.assertEquals("Wrong tcp src port", 9, tcpMatch.getTcpSourcePort().getValue().intValue());
+ Assert.assertEquals("Wrong tcp dst port", 10, tcpMatch.getTcpDestinationPort().getValue().intValue());
+ Assert.assertEquals("Wrong icmpv4 type", 15, builtMatch.getIcmpv4Match().getIcmpv4Type().intValue());
+ Assert.assertEquals("Wrong icmpv4 code", 16, builtMatch.getIcmpv4Match().getIcmpv4Code().intValue());
+ Assert.assertEquals("Wrong icmpv6 type", 19, builtMatch.getIcmpv6Match().getIcmpv6Type().intValue());
+ Assert.assertEquals("Wrong icmpv6 code", 20, builtMatch.getIcmpv6Match().getIcmpv6Code().intValue());
+
+ final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv4 src address", "10.0.0.1/32", ipv4Match.getIpv4Source().getValue());
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.2/32", ipv4Match.getIpv4Destination().getValue());
+ Assert.assertEquals("Wrong mpls label", 21, builtMatch.getProtocolMatchFields().getMplsLabel().intValue());
+ Assert.assertEquals("Wrong mpls bos", 1, builtMatch.getProtocolMatchFields().getMplsBos().intValue());
+ Assert.assertEquals("Wrong mpls tc", 22, builtMatch.getProtocolMatchFields().getMplsTc().intValue());
+ Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());
+ Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}),
+ builtMatch.getTunnel().getTunnelId());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithMasks() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+
+ final MetadataCaseBuilder metadataCaseBuilder = new MetadataCaseBuilder();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match
+ .entry.value.metadata._case.MetadataBuilder metadataBuilder = new org.opendaylight.yang.gen.v1.urn
+ .opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.metadata._case
+ .MetadataBuilder();
+ metadataBuilder.setMetadata(new byte[]{0, 1, 2, 3, 4, 5, 6, 7});
+ metadataBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 1});
+ metadataCaseBuilder.setMetadata(metadataBuilder.build());
+ entriesBuilder.setMatchEntryValue(metadataCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(EthDst.class);
+ entriesBuilder.setHasMask(true);
+ final EthDstCaseBuilder ethDstCaseBuilder = new EthDstCaseBuilder();
+ final EthDstBuilder ethDstBuilder = new EthDstBuilder();
+ ethDstBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));
+ ethDstBuilder.setMask(new byte[]{0, 0, 0, 0, 1, 1});
+ ethDstCaseBuilder.setEthDst(ethDstBuilder.build());
+ entriesBuilder.setMatchEntryValue(ethDstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(EthSrc.class);
+ entriesBuilder.setHasMask(true);
+ final EthSrcCaseBuilder ethSrcCaseBuilder = new EthSrcCaseBuilder();
+ final EthSrcBuilder ethSrcBuilder = new EthSrcBuilder();
+ ethSrcBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));
+ ethSrcBuilder.setMask(new byte[]{0, 0, 0, 0, 2, 2});
+ ethSrcCaseBuilder.setEthSrc(ethSrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ethSrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(VlanVid.class);
+ entriesBuilder.setHasMask(true);
+ final VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
+ final VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
+ vlanVidBuilder.setVlanVid(4);
+ vlanVidBuilder.setCfiBit(true);
+ vlanVidBuilder.setMask(new byte[]{0, 4});
+ vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
+ entriesBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));
+ ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});
+ ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));
+ ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(PbbIsid.class);
+ entriesBuilder.setHasMask(true);
+ final PbbIsidCaseBuilder pbbIsidCaseBuilder = new PbbIsidCaseBuilder();
+
+ final PbbIsidBuilder pbbIsidBuilder = new PbbIsidBuilder();
+ pbbIsidBuilder.setIsid(23L);
+ pbbIsidBuilder.setMask(new byte[]{0, 0, 7});
+ pbbIsidCaseBuilder.setPbbIsid(pbbIsidBuilder.build());
+ entriesBuilder.setMatchEntryValue(pbbIsidCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(TunnelId.class);
+ entriesBuilder.setHasMask(true);
+ final TunnelIdCaseBuilder tunnelIdCaseBuilder = new TunnelIdCaseBuilder();
+ final TunnelIdBuilder tunnelIdBuilder = new TunnelIdBuilder();
+ tunnelIdBuilder.setTunnelId(new byte[]{1, 2, 3, 4, 5, 6, 7, 8});
+ tunnelIdBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 0, 0, 8});
+ tunnelIdCaseBuilder.setTunnelId(tunnelIdBuilder.build());
+ entriesBuilder.setMatchEntryValue(tunnelIdCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ Assert.assertEquals("Wrong metadata", new BigInteger(1, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}),
+ builtMatch.getMetadata().getMetadata());
+ Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[]{0, 0, 0, 0, 0, 0, 0, 1}),
+ builtMatch.getMetadata().getMetadataMask());
+ Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"),
+ builtMatch.getEthernetMatch().getEthernetDestination().getAddress());
+ Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:01:01"),
+ builtMatch.getEthernetMatch().getEthernetDestination().getMask());
+ Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"),
+ builtMatch.getEthernetMatch().getEthernetSource().getAddress());
+ Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"),
+ builtMatch.getEthernetMatch().getEthernetSource().getMask());
+ Assert.assertEquals("Wrong vlan id", 4,
+ builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
+ Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());
+ final Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv4 src address", "10.0.0.0/24", ipv4Match.getIpv4Source().getValue());
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.0.0/20", ipv4Match.getIpv4Destination().getValue());
+ Assert.assertEquals("Wrong pbb isid", 23, builtMatch.getProtocolMatchFields().getPbb().getPbbIsid().intValue());
+ Assert.assertEquals("Wrong tunnel id", new BigInteger(1, new byte[]{1, 2, 3, 4, 5, 6, 7, 8}),
+ builtMatch.getTunnel().getTunnelId());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithArbitraryMasks() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
+ ipv4SrcBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 255, 0});
+ ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
+ ipv4AddressBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 240, 0});
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask =
+ (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithSrcCidrMaskAndDstArbitraryBitMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
+ ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});
+ ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
+ ipv4AddressBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 240, 0});
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask =
+ (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithSrcArbitraryBitMaskAndDstCidrMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
+ ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 0, (byte) 255, 0});
+ ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
+ ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask =
+ (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
+ }
+
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithDstArbitraryBitMaskAndSrcCidrMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
+ ipv4AddressBuilder.setMask(new byte[]{(byte) 255, 0, (byte) 240, 0});
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
+ ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});
+ ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask =
+ (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithDstCidrMaskAndSrcArbitraryBitMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
+ final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
+ ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
+ ipv4AddressBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 240, 0});
+ ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv4Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
+ final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
+ ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
+ ipv4SrcBuilder.setMask(new byte[]{(byte) 255, (byte) 0, (byte) 255, 0});
+ ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatch = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatch.build();
+
+ final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask =
+ (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1",
+ ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testLayer4MatchUdp() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc.class);
+ entriesBuilder.setHasMask(false);
+ final UdpSrcCaseBuilder udpSrcCaseBuilder = new UdpSrcCaseBuilder();
+ final UdpSrcBuilder portBuilder = new UdpSrcBuilder();
+ portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+ .inet.types.rev130715.PortNumber(11));
+ udpSrcCaseBuilder.setUdpSrc(portBuilder.build());
+ entriesBuilder.setMatchEntryValue(udpSrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(UdpDst.class);
+ entriesBuilder.setHasMask(false);
+ final UdpDstCaseBuilder udpDstCaseBuilder = new UdpDstCaseBuilder();
+ final UdpDstBuilder udpDstBuilder = new UdpDstBuilder();
+ udpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+ .inet.types.rev130715.PortNumber(12));
+ udpDstCaseBuilder.setUdpDst(udpDstBuilder.build());
+ entriesBuilder.setMatchEntryValue(udpDstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder builtMatch = convert(builder.build(), datapathIdConvertorData);
+
+ final UdpMatch udpMatch = (UdpMatch) builtMatch.getLayer4Match();
+ Assert.assertEquals("Wrong udp src port", 11, udpMatch.getUdpSourcePort().getValue().intValue());
+ Assert.assertEquals("Wrong udp dst port", 12, udpMatch.getUdpDestinationPort().getValue().intValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testLayer4MatchSctp() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(SctpSrc.class);
+ entriesBuilder.setHasMask(false);
+ final SctpSrcCaseBuilder sctpSrcCaseBuilder = new SctpSrcCaseBuilder();
+ final SctpSrcBuilder portBuilder = new SctpSrcBuilder();
+ portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+ .inet.types.rev130715.PortNumber(13));
+ sctpSrcCaseBuilder.setSctpSrc(portBuilder.build());
+ entriesBuilder.setMatchEntryValue(sctpSrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(SctpDst.class);
+ entriesBuilder.setHasMask(false);
+ final SctpDstCaseBuilder sctpDstCaseBuilder = new SctpDstCaseBuilder();
+ final SctpDstBuilder sctpDstBuilder = new SctpDstBuilder();
+ sctpDstBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
+ .inet.types.rev130715.PortNumber(14));
+ sctpDstCaseBuilder.setSctpDst(sctpDstBuilder.build());
+ entriesBuilder.setMatchEntryValue(sctpDstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+ builder.setMatchEntry(entries);
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final SctpMatch udpMatch = (SctpMatch) builtMatch.getLayer4Match();
+ Assert.assertEquals("Wrong sctp src port", 13, udpMatch.getSctpSourcePort().getValue().intValue());
+ Assert.assertEquals("Wrong sctp dst port", 14, udpMatch.getSctpDestinationPort().getValue().intValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testLayer3MatchIpv6() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Src.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+ final Ipv6SrcBuilder ipv6AddressBuilder = new Ipv6SrcBuilder();
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9657"));
+ ipv6SrcCaseBuilder.setIpv6Src(ipv6AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+ final Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
+ ipv6DstBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9658"));
+ ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Flabel.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
+ final Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
+ ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(18L));
+ ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
+ final Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
+ ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9659"));
+ ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6NdSll.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();
+ final Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();
+ ipv6NdSllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:05"));
+ ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6NdTll.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();
+ final Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();
+ ipv6NdTllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:06"));
+ ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
+ entriesBuilder.setHasMask(false);
+ final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();
+ final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();
+ ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));
+ ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());
+ builder.setMatchEntry(entries);
+ entries.add(entriesBuilder.build());
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv6 src address", "2001:cdba::3257:9657/128",
+ ipv6Match.getIpv6Source().getValue());
+ Assert.assertEquals("Wrong ipv6 dst address", "2001:cdba::3257:9658/128",
+ ipv6Match.getIpv6Destination().getValue());
+ Assert.assertEquals("Wrong ipv6 nd target", "2001:cdba:0000:0000:0000:0000:3257:9659",
+ ipv6Match.getIpv6NdTarget().getValue());
+ Assert.assertEquals("Wrong ipv6 flabel", 18, ipv6Match.getIpv6Label().getIpv6Flabel().getValue().intValue());
+ Assert.assertEquals("Wrong ipv6 nd sll", new MacAddress("00:00:00:00:00:05"), ipv6Match.getIpv6NdSll());
+ Assert.assertEquals("Wrong ipv6 nd tll", new MacAddress("00:00:00:00:00:06"), ipv6Match.getIpv6NdTll());
+ Assert.assertEquals("Wrong ipv6 ext header", 358, ipv6Match.getIpv6ExtHeader().getIpv6Exthdr().intValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testLayer3MatchIpv6ExtHeader2() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ final MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();
+ final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();
+ ipv6ExthdrBuilder.setPseudoField(
+ new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false));
+ ipv6ExthdrBuilder.setMask(new byte[]{1, 2});
+ ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+ builder.setMatchEntry(entries);
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv6 ext header", 153, ipv6Match.getIpv6ExtHeader().getIpv6Exthdr().intValue());
+ Assert.assertEquals("Wrong ipv6 ext header mask", 258,
+ ipv6Match.getIpv6ExtHeader().getIpv6ExthdrMask().intValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testLayer3MatchArp() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(ArpOp.class);
+ entriesBuilder.setHasMask(false);
+ final ArpOpCaseBuilder arpOpCaseBuilder = new ArpOpCaseBuilder();
+ final ArpOpBuilder arpOpBuilder = new ArpOpBuilder();
+ arpOpBuilder.setOpCode(17);
+ arpOpCaseBuilder.setArpOp(arpOpBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpOpCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(ArpSpa.class);
+ entriesBuilder.setHasMask(false);
+ final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
+ final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
+ arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));
+ arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(ArpTpa.class);
+ entriesBuilder.setHasMask(false);
+ final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
+ final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
+ arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.4"));
+ arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(ArpSha.class);
+ entriesBuilder.setHasMask(false);
+ final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
+ final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
+ arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));
+ arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);
+ entriesBuilder.setHasMask(false);
+ final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
+ final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
+ arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));
+ arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+ builder.setMatchEntry(entries);
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong arp op", 17, arpMatch.getArpOp().intValue());
+ Assert.assertEquals("Wrong arp spa", "10.0.0.3/32", arpMatch.getArpSourceTransportAddress().getValue());
+ Assert.assertEquals("Wrong arp tpa", "10.0.0.4/32", arpMatch.getArpTargetTransportAddress().getValue());
+ Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03",
+ arpMatch.getArpSourceHardwareAddress().getAddress().getValue());
+ Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04",
+ arpMatch.getArpTargetHardwareAddress().getAddress().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testLayer3MatchArpWithMasks() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(ArpSpa.class);
+ entriesBuilder.setHasMask(true);
+ final ArpSpaCaseBuilder arpSpaCaseBuilder = new ArpSpaCaseBuilder();
+ final ArpSpaBuilder arpSpaBuilder = new ArpSpaBuilder();
+ arpSpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.3"));
+ arpSpaBuilder.setMask(new byte[]{(byte) 255, (byte) 255, (byte) 255, 0});
+ arpSpaCaseBuilder.setArpSpa(arpSpaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpSpaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(ArpTpa.class);
+ entriesBuilder.setHasMask(true);
+ final ArpTpaCaseBuilder arpTpaCaseBuilder = new ArpTpaCaseBuilder();
+ final ArpTpaBuilder arpTpaBuilder = new ArpTpaBuilder();
+ arpTpaBuilder.setIpv4Address(new Ipv4Address("10.0.0.0"));
+ arpTpaBuilder.setMask(new byte[]{(byte) 255, (byte) 128, 0, 0});
+ arpTpaCaseBuilder.setArpTpa(arpTpaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpTpaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(ArpSha.class);
+ entriesBuilder.setHasMask(true);
+ final ArpShaCaseBuilder arpShaCaseBuilder = new ArpShaCaseBuilder();
+ final ArpShaBuilder arpShaBuilder = new ArpShaBuilder();
+ arpShaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03"));
+ arpShaBuilder.setMask(new byte[]{0, 0, 1, 0, 4, 0});
+ arpShaCaseBuilder.setArpSha(arpShaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpShaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpTha.class);
+ entriesBuilder.setHasMask(true);
+ final ArpThaCaseBuilder arpThaCaseBuilder = new ArpThaCaseBuilder();
+ final ArpThaBuilder arpThaBuilder = new ArpThaBuilder();
+ arpThaBuilder.setMacAddress(new MacAddress("00:00:00:00:00:04"));
+ arpThaBuilder.setMask(new byte[]{1, 1, 1, 2, 2, 2});
+ arpThaCaseBuilder.setArpTha(arpThaBuilder.build());
+ entriesBuilder.setMatchEntryValue(arpThaCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final ArpMatch arpMatch = (ArpMatch) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong arp spa", "10.0.0.3/24", arpMatch.getArpSourceTransportAddress().getValue());
+ Assert.assertEquals("Wrong arp tpa", "10.0.0.0/9", arpMatch.getArpTargetTransportAddress().getValue());
+ Assert.assertEquals("Wrong arp sha", "00:00:00:00:00:03",
+ arpMatch.getArpSourceHardwareAddress().getAddress().getValue());
+ Assert.assertEquals("Wrong arp sha mask", "00:00:01:00:04:00",
+ arpMatch.getArpSourceHardwareAddress().getMask().getValue());
+ Assert.assertEquals("Wrong arp tha", "00:00:00:00:00:04",
+ arpMatch.getArpTargetHardwareAddress().getAddress().getValue());
+ Assert.assertEquals("Wrong arp tha mask", "01:01:01:02:02:02",
+ arpMatch.getArpTargetHardwareAddress().getMask().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithIpv6ArbitraryMasks() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+ final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+ ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
+ ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});
+ ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+ final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));
+ ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});
+ ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask =
+ (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",
+ ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002",
+ ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithIpv6SrcCidrlMaskAndDstArbitraryBitMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+ final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+ ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
+ ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
+ ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+ final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));
+ ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});
+ ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask =
+ (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",
+ ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002",
+ ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
+ }
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithIpv6SrcArbitraryBitMaskAndDstCidrMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+ final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+ ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
+ ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});
+ ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+ final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));
+ ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
+ ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask =
+ (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001",
+ ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002",
+ ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
+ }
+
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithIpv6DstArbitraryBitMaskAndSrcCidrMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+ final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
+ ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});
+ ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+ final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+ ipv6SrcBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));
+ ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
+ ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask =
+ (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv6 src address", "2002:2002:2002:2002:2002:2002:2002:2002",
+ ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv6 dst address", "1001:1001:1001:1001:1001:1001:1001:1001",
+ ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
+ }
+
+
+ /**
+ * Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWithMatchEntryWithIpv6DstCidrMaskAndSrcArbitraryBitMask() {
+ final MatchBuilder builder = new MatchBuilder();
+ builder.setType(OxmMatchType.class);
+ final List<MatchEntry> entries = new ArrayList<>();
+ MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
+ entriesBuilder.setHasMask(true);
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Dst.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
+ final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
+ ipv6AddressBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
+ ipv6AddressBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0});
+ ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ entriesBuilder = new MatchEntryBuilder();
+ entriesBuilder.setOxmClass(OpenflowBasicClass.class);
+ entriesBuilder.setOxmMatchField(Ipv6Src.class);
+ entriesBuilder.setHasMask(true);
+ final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
+ final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
+ ipv6SrcBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));
+ ipv6SrcBuilder.setMask(new byte[]{(byte) 255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte) 255});
+ ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
+ entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
+ entries.add(entriesBuilder.build());
+
+ builder.setMatchEntry(entries);
+ final Match match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch =
+ salMatchBuilder.build();
+
+ final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask =
+ (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();
+ Assert.assertEquals("Wrong ipv6 src address", "2002:2002:2002:2002:2002:2002:2002:2002",
+ ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
+ Assert.assertEquals("Wrong ipv6 dst address", "1001:1001:1001:1001:1001:1001:1001:1001",
+ ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
+ }
+
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder convert(Match match, VersionDatapathIdConvertorData data) {
+ final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow
+ .MatchBuilder> salMatchOptional = convertorManager.convert(match, data);
+
+ return salMatchOptional
+ .orElse(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder());
+ }
+}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthSrc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.EthType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping;
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.OxmMatchType;
}
/**
- * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchEntriesGrouping, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }.
+ * Test method for {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testFromOFMatchToSALMatch() {
List<MatchEntry> entries = createDefaultMatchEntry();
int[] vids = {
- // Match packet with VLAN tag regardless of its value.
- -1,
+ // Match packet with VLAN tag regardless of its value.
+ -1,
- // Match untagged frame.
- 0,
+ // Match untagged frame.
+ 0,
- // Match packet with VLAN tag and VID equals the specified value.
- 1, 20, 4095,
+ // Match packet with VLAN tag and VID equals the specified value.
+ 1, 20, 4095,
};
for (int vid : vids) {
- List<MatchEntry> MatchEntry =
- new ArrayList<MatchEntry>(entries);
- MatchEntry.add(toOfVlanVid(vid));
+ List<MatchEntry> matchEntry = new ArrayList<>(entries);
+ matchEntry.add(toOfVlanVid(vid));
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match ofMatch =
- createOFMatch(MatchEntry);
+ createOFMatch(matchEntry);
final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(DPID);
final MatchBuilder builder = convert(ofMatch, data);
checkDefault(builder);
VlanMatch vlanMatch = builder.getVlanMatch();
- int expectedVid = (vid < 0) ? 0 : vid;
+ int expectedVid = vid < 0 ? 0 : vid;
Boolean expectedCfi = vid != 0;
- assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().
- getValue().intValue());
+ assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().getValue().intValue());
assertEquals(expectedCfi, vlanMatch.getVlanId().isVlanIdPresent());
assertEquals(null, vlanMatch.getVlanPcp());
}
}
/**
- * Test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)} }.
+ * Test method for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testFromOFMatchV10ToSALMatch() {
int[] vids = {
- // Match untagged frame.
- DL_VLAN_NONE,
+ // Match untagged frame.
+ DL_VLAN_NONE,
- // Match packet with VLAN tag and VID equals the specified value.
- 1, 20, 4095,
- };
- short[] dscps = {
- 0, 1, 20, 40, 62, 63,
+ // Match packet with VLAN tag and VID equals the specified value.
+ 1, 20, 4095,
};
+ short[] dscps = { 0, 1, 20, 40, 62, 63, };
FlowWildcardsV10Builder wcBuilder = new FlowWildcardsV10Builder();
for (int vid : vids) {
for (short dscp : dscps) {
short tos = (short) (dscp << 2);
MatchV10Builder builder = new MatchV10Builder();
- builder.setDlSrc(MAC_SRC).setDlDst(MAC_DST).setDlVlan(vid).
- setDlVlanPcp(VLAN_PCP).setDlType(ETHTYPE_IPV4).
- setInPort(IN_PORT.intValue()).
- setNwSrc(IPV4_SRC).setNwDst(IPV4_DST).setNwTos(tos);
- wcBuilder.setAll(false).setNwProto(true).setTpSrc(true).
- setTpDst(true);
+ builder.setDlSrc(MAC_SRC).setDlDst(MAC_DST).setDlVlan(vid).setDlVlanPcp(VLAN_PCP)
+ .setDlType(ETHTYPE_IPV4).setInPort(IN_PORT.intValue()).setNwSrc(IPV4_SRC).setNwDst(IPV4_DST)
+ .setNwTos(tos);
+ wcBuilder.setAll(false).setNwProto(true).setTpSrc(true).setTpDst(true);
if (vid == DL_VLAN_NONE) {
wcBuilder.setDlVlanPcp(true);
}
FlowWildcardsV10 wc = wcBuilder.build();
MatchV10 ofMatch = builder.setWildcards(wc).build();
- final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ final VersionDatapathIdConvertorData data =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
data.setDatapathId(DPID);
Match match = convert(ofMatch, data).build();
checkDefaultV10(match, wc, vid);
assertEquals(null, ethMatch.getEthernetSource().getMask());
assertEquals(MAC_DST, ethMatch.getEthernetDestination().getAddress());
assertEquals(null, ethMatch.getEthernetDestination().getMask());
- assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().
- getValue().intValue());
+ assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().getValue().intValue());
NodeConnectorId inPort = builder.getInPort();
assertEquals(URI_IN_PORT, inPort.getValue());
}
- private static org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match createOFMatch(final List<MatchEntry> entries) {
+ private static org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match
+ createOFMatch(final List<MatchEntry> entries) {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder builder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder();
- return builder.setType(OxmMatchType.class).setMatchEntry(entries).
- build();
+ return builder.setType(OxmMatchType.class).setMatchEntry(entries).build();
}
private static List<MatchEntry> createDefaultMatchEntry() {
byte[] mask = null;
builder.setOxmClass(OpenflowBasicClass.class);
builder.setOxmMatchField(VlanVid.class);
- VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
if (vid == 0) {
// Match untagged frame.
cfi = false;
if (hasMask) {
vlanVidBuilder.setMask(mask);
}
+ VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
builder.setHasMask(hasMask);
builder.setMatchEntryValue(vlanVidCaseBuilder.build());
assertEquals(null, match.getLayer3Match());
} else {
assert ethMatch != null;
- assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().
- getValue().intValue());
+ assertEquals(ETHTYPE_IPV4, ethMatch.getEthernetType().getType().getValue().intValue());
Ipv4Match ipv4Match = (Ipv4Match) match.getLayer3Match();
assertEquals(IPV4_SRC.getValue() + "/32",
expectedVid = vid;
expectedCfi = Boolean.TRUE;
}
- assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().
- getValue().intValue());
+ assertEquals(expectedVid, vlanMatch.getVlanId().getVlanId().getValue().intValue());
assertEquals(expectedCfi, vlanMatch.getVlanId().isVlanIdPresent());
if (wc.isDLVLANPCP()) {
return salMatchOptional.orElse(new MatchBuilder());
}
- private MatchBuilder convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match match, VersionDatapathIdConvertorData data) {
+ private MatchBuilder convert(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match match,
+ VersionDatapathIdConvertorData data) {
final Optional<MatchBuilder> salMatchOptional = convertorManager.convert(match, data);
return salMatchOptional.orElse(new MatchBuilder());
-/*\r
- * Copyright (c) 2014, 2015 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.openflowplugin.openflow.md.core.sal.convertor.match;\r
-\r
-import java.math.BigInteger;\r
-import java.util.Optional;\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.opendaylight.openflowplugin.api.OFConstants;\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.core.sal.convertor.data.VersionDatapathIdConvertorData;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;\r
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;\r
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;\r
-\r
-/**\r
- * @author michal.polkorab\r
- *\r
- */\r
-public class MatchV10ResponseConvertorTest {\r
-\r
- private ConvertorManager convertorManager;\r
-\r
- /**\r
- * Initializes OpenflowPortsUtil\r
- */\r
- @Before\r
- public void startUp() {\r
- convertorManager = ConvertorManagerFactory.createDefaultManager();\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void test() {\r
- MatchV10Builder builder = new MatchV10Builder();\r
- builder.setWildcards(new FlowWildcardsV10(false, false, false, false,\r
- false, false, false, false, false, false));\r
- builder.setNwSrcMask((short) 24);\r
- builder.setNwDstMask((short) 16);\r
- builder.setInPort(6653);\r
- builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));\r
- builder.setDlDst(new MacAddress("02:02:02:02:02:02"));\r
- builder.setDlVlan(128);\r
- builder.setDlVlanPcp((short) 2);\r
- builder.setDlType(15);\r
- builder.setNwTos((short) 16);\r
- builder.setNwProto((short) 6);\r
- builder.setNwSrc(new Ipv4Address("1.1.1.2"));\r
- builder.setNwDst(new Ipv4Address("32.16.8.1"));\r
- builder.setTpSrc(2048);\r
- builder.setTpDst(4096);\r
- MatchV10 match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final Match salMatch = convert(match, datapathIdConvertorData).build();\r
-\r
- Assert.assertEquals("Wrong in port", "openflow:42:6653", salMatch.getInPort().getValue());\r
- Assert.assertEquals("Wrong dl src", new MacAddress("01:01:01:01:01:01"), salMatch.getEthernetMatch()\r
- .getEthernetSource().getAddress());\r
- Assert.assertEquals("Wrong dl dst", new MacAddress("02:02:02:02:02:02"), salMatch.getEthernetMatch()\r
- .getEthernetDestination().getAddress());\r
- Assert.assertEquals("Wrong dl type", 15, salMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());\r
- Assert.assertEquals("Wrong dl vlan", 128, salMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());\r
- Assert.assertEquals("Wrong dl vlan pcp", 2, salMatch.getVlanMatch().getVlanPcp().getValue().intValue());\r
- Ipv4Match ipv4Match = (Ipv4Match) salMatch.getLayer3Match();\r
- Assert.assertEquals("Wrong nw src address", "1.1.1.2/24", ipv4Match.getIpv4Source().getValue());\r
- Assert.assertEquals("Wrong nw dst address", "32.16.8.1/16", ipv4Match.getIpv4Destination().getValue());\r
- Assert.assertEquals("Wrong ip protocol", 6, salMatch.getIpMatch().getIpProtocol().intValue());\r
- Assert.assertEquals("Wrong ip proto", null, salMatch.getIpMatch().getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, salMatch.getIpMatch().getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", 4, salMatch.getIpMatch().getIpDscp().getValue().intValue());\r
- TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong tp dst", 4096, tcpMatch.getTcpDestinationPort().getValue().intValue());\r
- Assert.assertEquals("Wrong tp src", 2048, tcpMatch.getTcpSourcePort().getValue().intValue());\r
- Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWildcardedMatch() {\r
- MatchV10Builder builder = new MatchV10Builder();\r
- builder.setWildcards(new FlowWildcardsV10(true, true, true, true,\r
- true, true, true, true, true, true));\r
- builder.setNwSrcMask((short) 24);\r
- builder.setNwDstMask((short) 16);\r
- builder.setInPort(6653);\r
- builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));\r
- builder.setDlDst(new MacAddress("02:02:02:02:02:02"));\r
- builder.setDlVlan(128);\r
- builder.setDlVlanPcp((short) 2);\r
- builder.setDlType(15);\r
- builder.setNwTos((short) 14);\r
- builder.setNwProto((short) 6);\r
- builder.setNwSrc(new Ipv4Address("1.1.1.2"));\r
- builder.setNwDst(new Ipv4Address("32.16.8.1"));\r
- builder.setTpSrc(2048);\r
- builder.setTpDst(4096);\r
- MatchV10 match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final Match salMatch = convert(match, datapathIdConvertorData).build();\r
-\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());\r
- Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());\r
- Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testWildcardedMatchWithNoValuesSet() {\r
- MatchV10Builder builder = new MatchV10Builder();\r
- builder.setWildcards(new FlowWildcardsV10(true, true, true, true,\r
- true, true, true, true, true, true));\r
- MatchV10 match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final Match salMatch = convert(match, datapathIdConvertorData).build();\r
-\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());\r
- Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());\r
- Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testMatchWithValuesUnset() {\r
- MatchV10Builder builder = new MatchV10Builder();\r
- builder.setWildcards(new FlowWildcardsV10(false, false, false, false,\r
- false, false, false, false, false, false));\r
- builder.setNwProto((short) 17);\r
- builder.setTpSrc(2048);\r
- builder.setTpDst(4096);\r
- MatchV10 match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final Match salMatch = convert(match, datapathIdConvertorData).build();\r
-\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());\r
- Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());\r
- UdpMatch udpMatch = (UdpMatch) salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong udp dst", 4096, udpMatch.getUdpDestinationPort().getValue().intValue());\r
- Assert.assertEquals("Wrong udp src", 2048, udpMatch.getUdpSourcePort().getValue().intValue());\r
- Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());\r
- }\r
-\r
- /**\r
- * Test {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test(expected=NullPointerException.class)\r
- public void testEmptyMatch() {\r
- MatchV10Builder builder = new MatchV10Builder();\r
- MatchV10 match = builder.build();\r
-\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(new BigInteger("42"));\r
-\r
- final Match salMatch = convert(match, datapathIdConvertorData).build();\r
- }\r
-\r
- /**\r
- * ICMPv4 match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testIcmpv4Match() {\r
- // NW_PROTO, TP_SRC, TP_DST are wildcarded.\r
- Long dlType = 0x800L;\r
- FlowWildcardsV10 wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, true, true, true, true);\r
- MatchV10Builder builder = new MatchV10Builder().\r
- setWildcards(wc).\r
- setDlType(dlType.intValue());\r
- MatchV10 match = builder.build();\r
-\r
- BigInteger dpid = BigInteger.valueOf(12345L);\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(dpid);\r
-\r
- Match salMatch = convert(match, datapathIdConvertorData).build();\r
-\r
- EthernetMatch etherMatch = salMatch.getEthernetMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // NW_PROTO is not wildcarded but null.\r
- wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, true, true);\r
- match = builder.setWildcards(wc).build();\r
-\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify ICMPv4 protocol.\r
- Short ipProto = 1;\r
- match = builder.setNwProto(ipProto).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- IpMatch ipMatch = salMatch.getIpMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // TP_SRC is not wildcarded but null.\r
- wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, true, false);\r
- match = builder.setWildcards(wc).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify ICMPv4 type.\r
- Short icmpType = 10;\r
- match = builder.setTpSrc(icmpType.intValue()).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- Icmpv4Match icmpv4Match = salMatch.getIcmpv4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 type",\r
- icmpType, icmpv4Match.getIcmpv4Type());\r
- Assert.assertEquals("Wrong ICMPv4 code",\r
- null, icmpv4Match.getIcmpv4Code());\r
-\r
- // TP_DST is not wildcarded but null.\r
- wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, false, false);\r
- match = builder.setWildcards(wc).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- icmpv4Match = salMatch.getIcmpv4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 type",\r
- icmpType, icmpv4Match.getIcmpv4Type());\r
- Assert.assertEquals("Wrong ICMPv4 code",\r
- null, icmpv4Match.getIcmpv4Code());\r
-\r
- // Specify ICMPv4 code only.\r
- Short icmpCode = 33;\r
- match = builder.setTpSrc(null).setTpDst(icmpCode.intValue()).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- icmpv4Match = salMatch.getIcmpv4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 type",\r
- null, icmpv4Match.getIcmpv4Type());\r
- Assert.assertEquals("Wrong ICMPv4 code",\r
- icmpCode, icmpv4Match.getIcmpv4Code());\r
-\r
- // Specify both ICMPv4 type and code.\r
- icmpType = 0;\r
- icmpCode = 8;\r
- match = builder.setTpSrc(icmpType.intValue()).\r
- setTpDst(icmpCode.intValue()).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- icmpv4Match = salMatch.getIcmpv4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 type",\r
- icmpType, icmpv4Match.getIcmpv4Type());\r
- Assert.assertEquals("Wrong ICMPv4 code",\r
- icmpCode, icmpv4Match.getIcmpv4Code());\r
- }\r
-\r
- /**\r
- * TCP match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testTcpMatch() {\r
- // TP_SRC, TP_DST are wildcarded.\r
- // NW_PROTO is not wildcarded but null.\r
- Long dlType = 0x800L;\r
- FlowWildcardsV10 wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, true, true);\r
- MatchV10Builder builder = new MatchV10Builder().\r
- setWildcards(wc).\r
- setDlType(dlType.intValue());\r
- MatchV10 match = builder.build();\r
-\r
- BigInteger dpid = BigInteger.valueOf(12345L);\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(dpid);\r
-\r
- Match salMatch = convert(match, datapathIdConvertorData).build();\r
- EthernetMatch etherMatch = salMatch.getEthernetMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify TCP protocol.\r
- Short ipProto = 6;\r
- match = builder.setNwProto(ipProto).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- IpMatch ipMatch = salMatch.getIpMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // TP_SRC is not wildcarded but null.\r
- wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, true, false);\r
- match = builder.setWildcards(wc).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify TCP source port.\r
- Integer srcPort = 60000;\r
- match = builder.setTpSrc(srcPort).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- TcpMatch tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong TCP src", srcPort,\r
- tcpMatch.getTcpSourcePort().getValue());\r
- Assert.assertEquals("Wrong TCP dst", null,\r
- tcpMatch.getTcpDestinationPort());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // TP_DST is not wildcarded but null.\r
- wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, false, false);\r
- match = builder.setWildcards(wc).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong TCP src", srcPort,\r
- tcpMatch.getTcpSourcePort().getValue());\r
- Assert.assertEquals("Wrong TCP dst", null,\r
- tcpMatch.getTcpDestinationPort());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify TCP destination port only.\r
- Integer dstPort = 6653;\r
- match = builder.setTpSrc(null).setTpDst(dstPort).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong TCP src", null,\r
- tcpMatch.getTcpSourcePort());\r
- Assert.assertEquals("Wrong TCP dst", dstPort,\r
- tcpMatch.getTcpDestinationPort().getValue());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify both source and destination port.\r
- srcPort = 32767;\r
- dstPort = 9999;\r
- match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- tcpMatch = (TcpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong TCP src", srcPort,\r
- tcpMatch.getTcpSourcePort().getValue());\r
- Assert.assertEquals("Wrong TCP dst", dstPort,\r
- tcpMatch.getTcpDestinationPort().getValue());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
- }\r
-\r
- /**\r
- * UDP match test for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.MatchV10ResponseConvertor#convert(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10, org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)}\r
- */\r
- @Test\r
- public void testUdpMatch() {\r
- // TP_SRC, TP_DST are wildcarded.\r
- // NW_PROTO is not wildcarded but null.\r
- Long dlType = 0x800L;\r
- FlowWildcardsV10 wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, true, true);\r
- MatchV10Builder builder = new MatchV10Builder().\r
- setWildcards(wc).\r
- setDlType(dlType.intValue());\r
- MatchV10 match = builder.build();\r
-\r
- BigInteger dpid = BigInteger.valueOf(12345L);\r
- final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);\r
- datapathIdConvertorData.setDatapathId(dpid);\r
-\r
- Match salMatch = convert(match, datapathIdConvertorData).build();\r
- EthernetMatch etherMatch = salMatch.getEthernetMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify UDP protocol.\r
- Short ipProto = 17;\r
- match = builder.setNwProto(ipProto).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- IpMatch ipMatch = salMatch.getIpMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // TP_SRC is not wildcarded but null.\r
- wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, true, false);\r
- match = builder.setWildcards(wc).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify UDP source port.\r
- Integer srcPort = 60000;\r
- match = builder.setTpSrc(srcPort).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- UdpMatch udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong UDP src", srcPort,\r
- udpMatch.getUdpSourcePort().getValue());\r
- Assert.assertEquals("Wrong UDP dst", null,\r
- udpMatch.getUdpDestinationPort());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // TP_DST is not wildcarded but null.\r
- wc = new FlowWildcardsV10(\r
- true, true, false, true, true, true, false, true, false, false);\r
- match = builder.setWildcards(wc).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong UDP src", srcPort,\r
- udpMatch.getUdpSourcePort().getValue());\r
- Assert.assertEquals("Wrong UDP dst", null,\r
- udpMatch.getUdpDestinationPort());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify UDP destination port only.\r
- Integer dstPort = 6653;\r
- match = builder.setTpSrc(null).setTpDst(dstPort).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong UDP src", null,\r
- udpMatch.getUdpSourcePort());\r
- Assert.assertEquals("Wrong UDP dst", dstPort,\r
- udpMatch.getUdpDestinationPort().getValue());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
-\r
- // Specify both source and destination port.\r
- srcPort = 32767;\r
- dstPort = 9999;\r
- match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();\r
- salMatch = convert(match, datapathIdConvertorData).build();\r
- etherMatch = salMatch.getEthernetMatch();\r
- ipMatch = salMatch.getIpMatch();\r
- udpMatch = (UdpMatch)salMatch.getLayer4Match();\r
- Assert.assertEquals("Wrong in port", null, salMatch.getInPort());\r
- Assert.assertEquals("Wrong dl src",\r
- null, etherMatch.getEthernetSource());\r
- Assert.assertEquals("Wrong dl dst",\r
- null, etherMatch.getEthernetDestination());\r
- Assert.assertEquals("Wrong dl type", dlType,\r
- etherMatch.getEthernetType().getType().getValue());\r
- Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());\r
- Assert.assertEquals("Wrong ip protocol",\r
- ipProto, ipMatch.getIpProtocol());\r
- Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());\r
- Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());\r
- Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());\r
- Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());\r
- Assert.assertEquals("Wrong UDP src", srcPort,\r
- udpMatch.getUdpSourcePort().getValue());\r
- Assert.assertEquals("Wrong UDP dst", dstPort,\r
- udpMatch.getUdpDestinationPort().getValue());\r
- Assert.assertEquals("Wrong ICMPv4 match",\r
- null, salMatch.getIcmpv4Match());\r
- }\r
-\r
- private MatchBuilder convert(MatchV10 match, VersionDatapathIdConvertorData data) {\r
- final Optional<MatchBuilder> salMatchOptional = convertorManager.convert(match, data);\r
-\r
- return salMatchOptional.orElse(new MatchBuilder());\r
- }\r
-}\r
+/*
+ * Copyright (c) 2014, 2015 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.openflowplugin.openflow.md.core.sal.convertor.match;
+
+import java.math.BigInteger;
+import java.util.Optional;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
+
+/**
+ * Unit tests for v1.0 match conversion.
+ *
+ * @author michal.polkorab
+ */
+public class MatchV10ResponseConvertorTest {
+
+ private ConvertorManager convertorManager;
+
+ /**
+ * Initializes OpenflowPortsUtil.
+ */
+ @Before
+ public void startUp() {
+ convertorManager = ConvertorManagerFactory.createDefaultManager();
+ }
+
+ /**
+ * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void test() {
+ MatchV10Builder builder = new MatchV10Builder();
+ builder.setWildcards(new FlowWildcardsV10(false, false, false, false,
+ false, false, false, false, false, false));
+ builder.setNwSrcMask((short) 24);
+ builder.setNwDstMask((short) 16);
+ builder.setInPort(6653);
+ builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+ builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
+ builder.setDlVlan(128);
+ builder.setDlVlanPcp((short) 2);
+ builder.setDlType(15);
+ builder.setNwTos((short) 16);
+ builder.setNwProto((short) 6);
+ builder.setNwSrc(new Ipv4Address("1.1.1.2"));
+ builder.setNwDst(new Ipv4Address("32.16.8.1"));
+ builder.setTpSrc(2048);
+ builder.setTpDst(4096);
+ MatchV10 match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final Match salMatch = convert(match, datapathIdConvertorData).build();
+
+ Assert.assertEquals("Wrong in port", "openflow:42:6653", salMatch.getInPort().getValue());
+ Assert.assertEquals("Wrong dl src", new MacAddress("01:01:01:01:01:01"), salMatch.getEthernetMatch()
+ .getEthernetSource().getAddress());
+ Assert.assertEquals("Wrong dl dst", new MacAddress("02:02:02:02:02:02"), salMatch.getEthernetMatch()
+ .getEthernetDestination().getAddress());
+ Assert.assertEquals("Wrong dl type", 15,
+ salMatch.getEthernetMatch().getEthernetType().getType().getValue().intValue());
+ Assert.assertEquals("Wrong dl vlan", 128,
+ salMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());
+ Assert.assertEquals("Wrong dl vlan pcp", 2, salMatch.getVlanMatch().getVlanPcp().getValue().intValue());
+ Ipv4Match ipv4Match = (Ipv4Match) salMatch.getLayer3Match();
+ Assert.assertEquals("Wrong nw src address", "1.1.1.2/24", ipv4Match.getIpv4Source().getValue());
+ Assert.assertEquals("Wrong nw dst address", "32.16.8.1/16", ipv4Match.getIpv4Destination().getValue());
+ Assert.assertEquals("Wrong ip protocol", 6, salMatch.getIpMatch().getIpProtocol().intValue());
+ Assert.assertEquals("Wrong ip proto", null, salMatch.getIpMatch().getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, salMatch.getIpMatch().getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", 4, salMatch.getIpMatch().getIpDscp().getValue().intValue());
+ TcpMatch tcpMatch = (TcpMatch) salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong tp dst", 4096, tcpMatch.getTcpDestinationPort().getValue().intValue());
+ Assert.assertEquals("Wrong tp src", 2048, tcpMatch.getTcpSourcePort().getValue().intValue());
+ Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
+ }
+
+ /**
+ * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWildcardedMatch() {
+ MatchV10Builder builder = new MatchV10Builder();
+ builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
+ true, true, true, true, true, true));
+ builder.setNwSrcMask((short) 24);
+ builder.setNwDstMask((short) 16);
+ builder.setInPort(6653);
+ builder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
+ builder.setDlDst(new MacAddress("02:02:02:02:02:02"));
+ builder.setDlVlan(128);
+ builder.setDlVlanPcp((short) 2);
+ builder.setDlType(15);
+ builder.setNwTos((short) 14);
+ builder.setNwProto((short) 6);
+ builder.setNwSrc(new Ipv4Address("1.1.1.2"));
+ builder.setNwDst(new Ipv4Address("32.16.8.1"));
+ builder.setTpSrc(2048);
+ builder.setTpDst(4096);
+ MatchV10 match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final Match salMatch = convert(match, datapathIdConvertorData).build();
+
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
+ Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());
+ Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
+ }
+
+ /**
+ * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testWildcardedMatchWithNoValuesSet() {
+ MatchV10Builder builder = new MatchV10Builder();
+ builder.setWildcards(new FlowWildcardsV10(true, true, true, true,
+ true, true, true, true, true, true));
+ MatchV10 match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final Match salMatch = convert(match, datapathIdConvertorData).build();
+
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
+ Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong layer 4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ip match", null, salMatch.getIpMatch());
+ Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
+ }
+
+ /**
+ * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testMatchWithValuesUnset() {
+ MatchV10Builder builder = new MatchV10Builder();
+ builder.setWildcards(new FlowWildcardsV10(false, false, false, false,
+ false, false, false, false, false, false));
+ builder.setNwProto((short) 17);
+ builder.setTpSrc(2048);
+ builder.setTpDst(4096);
+ MatchV10 match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final Match salMatch = convert(match, datapathIdConvertorData).build();
+
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl match", null, salMatch.getEthernetMatch());
+ Assert.assertEquals("Wrong dl vlan match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong layer 3 match", null, salMatch.getLayer3Match());
+ UdpMatch udpMatch = (UdpMatch) salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong udp dst", 4096, udpMatch.getUdpDestinationPort().getValue().intValue());
+ Assert.assertEquals("Wrong udp src", 2048, udpMatch.getUdpSourcePort().getValue().intValue());
+ Assert.assertEquals("Wrong ICMPv4 match", null, salMatch.getIcmpv4Match());
+ }
+
+ /**
+ * Test {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test(expected = NullPointerException.class)
+ public void testEmptyMatch() {
+ MatchV10Builder builder = new MatchV10Builder();
+ MatchV10 match = builder.build();
+
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(new BigInteger("42"));
+
+ final Match salMatch = convert(match, datapathIdConvertorData).build();
+ }
+
+ /**
+ * ICMPv4 match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testIcmpv4Match() {
+ // NW_PROTO, TP_SRC, TP_DST are wildcarded.
+ Long dlType = 0x800L;
+ FlowWildcardsV10 wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, true, true, true, true);
+ MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
+ MatchV10 match = builder.build();
+
+ BigInteger dpid = BigInteger.valueOf(12345L);
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(dpid);
+
+ Match salMatch = convert(match, datapathIdConvertorData).build();
+
+ EthernetMatch etherMatch = salMatch.getEthernetMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // NW_PROTO is not wildcarded but null.
+ wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, true, true);
+ match = builder.setWildcards(wc).build();
+
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify ICMPv4 protocol.
+ Short ipProto = 1;
+ match = builder.setNwProto(ipProto).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ IpMatch ipMatch = salMatch.getIpMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // TP_SRC is not wildcarded but null.
+ wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, true, false);
+ match = builder.setWildcards(wc).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify ICMPv4 type.
+ Short icmpType = 10;
+ match = builder.setTpSrc(icmpType.intValue()).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ Icmpv4Match icmpv4Match = salMatch.getIcmpv4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 type",
+ icmpType, icmpv4Match.getIcmpv4Type());
+ Assert.assertEquals("Wrong ICMPv4 code",
+ null, icmpv4Match.getIcmpv4Code());
+
+ // TP_DST is not wildcarded but null.
+ wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, false, false);
+ match = builder.setWildcards(wc).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ icmpv4Match = salMatch.getIcmpv4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 type",
+ icmpType, icmpv4Match.getIcmpv4Type());
+ Assert.assertEquals("Wrong ICMPv4 code",
+ null, icmpv4Match.getIcmpv4Code());
+
+ // Specify ICMPv4 code only.
+ Short icmpCode = 33;
+ match = builder.setTpSrc(null).setTpDst(icmpCode.intValue()).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ icmpv4Match = salMatch.getIcmpv4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 type",
+ null, icmpv4Match.getIcmpv4Type());
+ Assert.assertEquals("Wrong ICMPv4 code",
+ icmpCode, icmpv4Match.getIcmpv4Code());
+
+ // Specify both ICMPv4 type and code.
+ icmpType = 0;
+ icmpCode = 8;
+ match = builder.setTpSrc(icmpType.intValue()).setTpDst(icmpCode.intValue()).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ icmpv4Match = salMatch.getIcmpv4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 type",
+ icmpType, icmpv4Match.getIcmpv4Type());
+ Assert.assertEquals("Wrong ICMPv4 code",
+ icmpCode, icmpv4Match.getIcmpv4Code());
+ }
+
+ /**
+ * TCP match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testTcpMatch() {
+ // TP_SRC, TP_DST are wildcarded.
+ // NW_PROTO is not wildcarded but null.
+ Long dlType = 0x800L;
+ FlowWildcardsV10 wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, true, true);
+ MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
+ MatchV10 match = builder.build();
+
+ BigInteger dpid = BigInteger.valueOf(12345L);
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(dpid);
+
+ Match salMatch = convert(match, datapathIdConvertorData).build();
+ EthernetMatch etherMatch = salMatch.getEthernetMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify TCP protocol.
+ Short ipProto = 6;
+ match = builder.setNwProto(ipProto).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ IpMatch ipMatch = salMatch.getIpMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // TP_SRC is not wildcarded but null.
+ wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, true, false);
+ match = builder.setWildcards(wc).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify TCP source port.
+ Integer srcPort = 60000;
+ match = builder.setTpSrc(srcPort).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ TcpMatch tcpMatch = (TcpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong TCP src", srcPort,
+ tcpMatch.getTcpSourcePort().getValue());
+ Assert.assertEquals("Wrong TCP dst", null,
+ tcpMatch.getTcpDestinationPort());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // TP_DST is not wildcarded but null.
+ wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, false, false);
+ match = builder.setWildcards(wc).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ tcpMatch = (TcpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong TCP src", srcPort,
+ tcpMatch.getTcpSourcePort().getValue());
+ Assert.assertEquals("Wrong TCP dst", null,
+ tcpMatch.getTcpDestinationPort());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify TCP destination port only.
+ Integer dstPort = 6653;
+ match = builder.setTpSrc(null).setTpDst(dstPort).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ tcpMatch = (TcpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong TCP src", null,
+ tcpMatch.getTcpSourcePort());
+ Assert.assertEquals("Wrong TCP dst", dstPort,
+ tcpMatch.getTcpDestinationPort().getValue());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify both source and destination port.
+ srcPort = 32767;
+ dstPort = 9999;
+ match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ tcpMatch = (TcpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong TCP src", srcPort,
+ tcpMatch.getTcpSourcePort().getValue());
+ Assert.assertEquals("Wrong TCP dst", dstPort,
+ tcpMatch.getTcpDestinationPort().getValue());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+ }
+
+ /**
+ * UDP match test for {@link MatchV10ResponseConvertor#convert(MatchV10, VersionDatapathIdConvertorData)}.
+ */
+ @Test
+ public void testUdpMatch() {
+ // TP_SRC, TP_DST are wildcarded.
+ // NW_PROTO is not wildcarded but null.
+ Long dlType = 0x800L;
+ FlowWildcardsV10 wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, true, true);
+ MatchV10Builder builder = new MatchV10Builder().setWildcards(wc).setDlType(dlType.intValue());
+ MatchV10 match = builder.build();
+
+ BigInteger dpid = BigInteger.valueOf(12345L);
+ final VersionDatapathIdConvertorData datapathIdConvertorData =
+ new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
+ datapathIdConvertorData.setDatapathId(dpid);
+
+ Match salMatch = convert(match, datapathIdConvertorData).build();
+ EthernetMatch etherMatch = salMatch.getEthernetMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong IP match", null, salMatch.getIpMatch());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify UDP protocol.
+ Short ipProto = 17;
+ match = builder.setNwProto(ipProto).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ IpMatch ipMatch = salMatch.getIpMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // TP_SRC is not wildcarded but null.
+ wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, true, false);
+ match = builder.setWildcards(wc).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong L4 match", null, salMatch.getLayer4Match());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify UDP source port.
+ Integer srcPort = 60000;
+ match = builder.setTpSrc(srcPort).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ UdpMatch udpMatch = (UdpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong UDP src", srcPort,
+ udpMatch.getUdpSourcePort().getValue());
+ Assert.assertEquals("Wrong UDP dst", null,
+ udpMatch.getUdpDestinationPort());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // TP_DST is not wildcarded but null.
+ wc = new FlowWildcardsV10(
+ true, true, false, true, true, true, false, true, false, false);
+ match = builder.setWildcards(wc).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ udpMatch = (UdpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong UDP src", srcPort,
+ udpMatch.getUdpSourcePort().getValue());
+ Assert.assertEquals("Wrong UDP dst", null,
+ udpMatch.getUdpDestinationPort());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify UDP destination port only.
+ Integer dstPort = 6653;
+ match = builder.setTpSrc(null).setTpDst(dstPort).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ udpMatch = (UdpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong UDP src", null,
+ udpMatch.getUdpSourcePort());
+ Assert.assertEquals("Wrong UDP dst", dstPort,
+ udpMatch.getUdpDestinationPort().getValue());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+
+ // Specify both source and destination port.
+ srcPort = 32767;
+ dstPort = 9999;
+ match = builder.setTpSrc(srcPort).setTpDst(dstPort).build();
+ salMatch = convert(match, datapathIdConvertorData).build();
+ etherMatch = salMatch.getEthernetMatch();
+ ipMatch = salMatch.getIpMatch();
+ udpMatch = (UdpMatch)salMatch.getLayer4Match();
+ Assert.assertEquals("Wrong in port", null, salMatch.getInPort());
+ Assert.assertEquals("Wrong dl src",
+ null, etherMatch.getEthernetSource());
+ Assert.assertEquals("Wrong dl dst",
+ null, etherMatch.getEthernetDestination());
+ Assert.assertEquals("Wrong dl type", dlType,
+ etherMatch.getEthernetType().getType().getValue());
+ Assert.assertEquals("Wrong VLAN match", null, salMatch.getVlanMatch());
+ Assert.assertEquals("Wrong ip protocol",
+ ipProto, ipMatch.getIpProtocol());
+ Assert.assertEquals("Wrong ip proto", null, ipMatch.getIpProto());
+ Assert.assertEquals("Wrong ip ecn", null, ipMatch.getIpEcn());
+ Assert.assertEquals("Wrong ip dscp", null, ipMatch.getIpDscp());
+ Assert.assertEquals("Wrong L3 match", null, salMatch.getLayer3Match());
+ Assert.assertEquals("Wrong UDP src", srcPort,
+ udpMatch.getUdpSourcePort().getValue());
+ Assert.assertEquals("Wrong UDP dst", dstPort,
+ udpMatch.getUdpDestinationPort().getValue());
+ Assert.assertEquals("Wrong ICMPv4 match",
+ null, salMatch.getIcmpv4Match());
+ }
+
+ private MatchBuilder convert(MatchV10 match, VersionDatapathIdConvertorData data) {
+ final Optional<MatchBuilder> salMatchOptional = convertorManager.convert(match, data);
+
+ return salMatchOptional.orElse(new MatchBuilder());
+ }
+}
import org.opendaylight.openflowplugin.extension.api.core.session.ExtensionSessionManager;
/**
- * test of {@link ExtensionSessionManagerImpl}
+ * test of {@link ExtensionSessionManagerImpl}.
*/
@RunWith(MockitoJUnitRunner.class)
public class ExtensionSessionManagerImplTest {
/**
- * prepare session manager
+ * prepare session manager.
*/
@Before
public void setUp() {
sm.setExtensionConverterProvider(extensionConverterManager);
assertEquals(extensionConverterManager, sm.getExtensionConverterProvider());
}
-
}
/**
* Copyright (c) 2014 Cisco Systems, Inc. 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
import org.junit.Assert;
import org.junit.Test;
+
/**
- * test of {@link ActionUtil}
+ * test of {@link ActionUtil}.
*/
public class ActionUtilTest {
*/
public class ByteUtilTest {
- private static final String hexString = "64,65,66,ff";
- private static final String hexString00 = "00,00,00,00";
- private static final String hexStringFF = "ff,ff,ff,ff";
+ private static final String HEX_STRING = "64,65,66,ff";
+ private static final String HEX_STRING00 = "00,00,00,00";
+ private static final String HEX_STRINGFF = "ff,ff,ff,ff";
- private static final byte[] testBytes = {100, 101, 102, (byte) 255};
- private static final byte[] testBytes00 = {0, 0, 0, 0};
- private static final byte[] testBytesFF = {(byte) 255, (byte) 255, (byte) 255, (byte) 255};
+ private static final byte[] TEST_BYTES = {100, 101, 102, (byte) 255};
+ private static final byte[] TEST_BYTES00 = {0, 0, 0, 0};
+ private static final byte[] TEST_BYTESFF = {(byte) 255, (byte) 255, (byte) 255, (byte) 255};
- private static final byte[] test3Bytes = {100, 101, 102};
- private static final byte[] test3Bytes00 = {0, 0, 0};
- private static final byte[] test3BytesFF = {(byte) 255, (byte) 255, (byte) 255};
+ private static final byte[] TEST3_BYTES = {100, 101, 102};
+ private static final byte[] TEST3_BYTES00 = {0, 0, 0};
+ private static final byte[] TEST3_BYTESFF = {(byte) 255, (byte) 255, (byte) 255};
- private static final BigInteger bigInteger = new BigInteger("1684367103");
- private static final BigInteger bigIntFF = new BigInteger("4294967295");
+ private static final BigInteger BIG_INTEGER = new BigInteger("1684367103");
+ private static final BigInteger BIG_INTFF = new BigInteger("4294967295");
- private static final Integer mediumInteger = new Integer("6579558");
- private static final Integer mediumIntegerFF = new Integer("16777215");
- private static final int int00 = 0;
+ private static final Integer MEDIUM_INTEGER = new Integer("6579558");
+ private static final Integer MEDIUM_INTEGERFF = new Integer("16777215");
+ private static final int INT00 = 0;
- private static final int shortByteLength = 2;
- private static final int mediumByteLength = 3;
- private static final int intByteLength = 4;
+ private static final int SHORT_BYTE_LENGTH = 2;
+ private static final int MEDIUM_BYTE_LENGTH = 3;
+ private static final int INT_BYTE_LENGTH = 4;
/**
- * test of {@link ByteUtil#bytesToHexstring(byte[], String)}
+ * test of {@link ByteUtil#bytesToHexstring(byte[], String)}.
*/
@Test
public void testBytesToHexstring() {
- assertEquals(hexString, ByteUtil.bytesToHexstring(testBytes, ","));
- assertEquals(hexString00, ByteUtil.bytesToHexstring(testBytes00, ","));
- assertEquals(hexStringFF, ByteUtil.bytesToHexstring(testBytesFF, ","));
+ assertEquals(HEX_STRING, ByteUtil.bytesToHexstring(TEST_BYTES, ","));
+ assertEquals(HEX_STRING00, ByteUtil.bytesToHexstring(TEST_BYTES00, ","));
+ assertEquals(HEX_STRINGFF, ByteUtil.bytesToHexstring(TEST_BYTESFF, ","));
}
@Test
public void testConvertBigIntegerToNBytes() {
- byte[] bigIntAsBytes = ByteUtil.convertBigIntegerToNBytes(bigInteger, 4);
+ byte[] bigIntAsBytes = ByteUtil.convertBigIntegerToNBytes(BIG_INTEGER, 4);
assertEquals(4, bigIntAsBytes.length);
- bigIntAsBytes = ByteUtil.convertBigIntegerToNBytes(bigInteger, 6);
+ bigIntAsBytes = ByteUtil.convertBigIntegerToNBytes(BIG_INTEGER, 6);
assertEquals(6, bigIntAsBytes.length);
- bigIntAsBytes = ByteUtil.convertBigIntegerToNBytes(bigInteger, 8);
+ bigIntAsBytes = ByteUtil.convertBigIntegerToNBytes(BIG_INTEGER, 8);
assertEquals(8, bigIntAsBytes.length);
}
@Test
public void testBytesToUnsignedInt() {
- long unsigned = ByteUtil.bytesToUnsignedInt(testBytes);
- assertEquals(bigInteger.longValue(), unsigned);
+ long unsigned = ByteUtil.bytesToUnsignedInt(TEST_BYTES);
+ assertEquals(BIG_INTEGER.longValue(), unsigned);
- unsigned = ByteUtil.bytesToUnsignedInt(testBytes00);
+ unsigned = ByteUtil.bytesToUnsignedInt(TEST_BYTES00);
assertEquals(0, unsigned);
- unsigned = ByteUtil.bytesToUnsignedInt(testBytesFF);
- assertEquals(bigIntFF.longValue(), unsigned);
+ unsigned = ByteUtil.bytesToUnsignedInt(TEST_BYTESFF);
+ assertEquals(BIG_INTFF.longValue(), unsigned);
}
@Test
byte[] twoBytes = {100, 101};
int unsigned = ByteUtil.bytesToUnsignedShort(twoBytes);
- assertEquals(bigInteger.shiftRight(16).shortValue(), unsigned);
+ assertEquals(BIG_INTEGER.shiftRight(16).shortValue(), unsigned);
twoBytes = new byte[]{0, 0};
unsigned = ByteUtil.bytesToUnsignedShort(twoBytes);
- assertEquals(int00, unsigned);
+ assertEquals(INT00, unsigned);
twoBytes = new byte[]{(byte) 255, (byte) 255};
unsigned = ByteUtil.bytesToUnsignedShort(twoBytes);
- assertEquals(bigIntFF.shiftRight(16).intValue(), unsigned);
+ assertEquals(BIG_INTFF.shiftRight(16).intValue(), unsigned);
}
@Test
public void testBytesToUnsignedMedium() {
- long unsigned = ByteUtil.bytesToUnsignedMedium(test3Bytes);
- assertEquals(mediumInteger.longValue(), unsigned);
+ long unsigned = ByteUtil.bytesToUnsignedMedium(TEST3_BYTES);
+ assertEquals(MEDIUM_INTEGER.longValue(), unsigned);
- unsigned = ByteUtil.bytesToUnsignedMedium(test3Bytes00);
+ unsigned = ByteUtil.bytesToUnsignedMedium(TEST3_BYTES00);
assertEquals(0, unsigned);
- unsigned = ByteUtil.bytesToUnsignedMedium(test3BytesFF);
- assertEquals(mediumIntegerFF.longValue(), unsigned);
+ unsigned = ByteUtil.bytesToUnsignedMedium(TEST3_BYTESFF);
+ assertEquals(MEDIUM_INTEGERFF.longValue(), unsigned);
}
@Test(expected = IllegalArgumentException.class)
public void exceptionTestBytesToUnsignedShort() {
- ByteUtil.bytesToUnsignedShort(testBytes);
+ ByteUtil.bytesToUnsignedShort(TEST_BYTES);
}
@Test(expected = IllegalArgumentException.class)
long intValue = 255;
byte[] bytes = ByteUtil.unsignedIntToBytes(intValue);
- assertTrue(bytes.length == intByteLength);
+ assertTrue(bytes.length == INT_BYTE_LENGTH);
intValue += 256;
bytes = ByteUtil.unsignedIntToBytes(intValue);
- assertTrue(bytes.length == intByteLength);
+ assertTrue(bytes.length == INT_BYTE_LENGTH);
intValue += 256;
bytes = ByteUtil.unsignedIntToBytes(intValue);
- assertTrue(bytes.length == intByteLength);
+ assertTrue(bytes.length == INT_BYTE_LENGTH);
}
@Test
int intValue = 255;
byte[] bytes = ByteUtil.unsignedShortToBytes(intValue);
- assertTrue(bytes.length == shortByteLength);
+ assertTrue(bytes.length == SHORT_BYTE_LENGTH);
intValue += 256;
bytes = ByteUtil.unsignedShortToBytes(intValue);
- assertTrue(bytes.length == shortByteLength);
+ assertTrue(bytes.length == SHORT_BYTE_LENGTH);
intValue += 256;
bytes = ByteUtil.unsignedShortToBytes(intValue);
- assertTrue(bytes.length == shortByteLength);
+ assertTrue(bytes.length == SHORT_BYTE_LENGTH);
}
@Test
long intValue = 255;
byte[] bytes = ByteUtil.unsignedMediumToBytes(intValue);
- assertTrue(bytes.length == mediumByteLength);
+ assertTrue(bytes.length == MEDIUM_BYTE_LENGTH);
intValue += 256;
bytes = ByteUtil.unsignedMediumToBytes(intValue);
- assertTrue(bytes.length == mediumByteLength);
+ assertTrue(bytes.length == MEDIUM_BYTE_LENGTH);
intValue += 256;
bytes = ByteUtil.unsignedMediumToBytes(intValue);
- assertTrue(bytes.length == mediumByteLength);
+ assertTrue(bytes.length == MEDIUM_BYTE_LENGTH);
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValuesV10;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-/**
- *
- */
@RunWith(MockitoJUnitRunner.class)
public class InventoryDataServiceUtilTest {
*/
@Test
public void testNodeConnectorBuilderFromDatapathIdPortNo() {
- NodeConnectorBuilder nodeConnectorBuilder = InventoryDataServiceUtil.nodeConnectorBuilderFromDatapathIdPortNo(PATH_ID,
- PORT_NO, OpenflowVersion.OF10);
+ NodeConnectorBuilder nodeConnectorBuilder = InventoryDataServiceUtil
+ .nodeConnectorBuilderFromDatapathIdPortNo(PATH_ID, PORT_NO, OpenflowVersion.OF10);
assertNotNull(nodeConnectorBuilder);
nodeConnectorBuilder = InventoryDataServiceUtil.nodeConnectorBuilderFromDatapathIdPortNo(PATH_ID,
}
/**
- * Test method for {@link InventoryDataServiceUtil#nodeConnectorUpdatedBuilderFromDatapathIdPortNo(BigInteger datapathId,
- * Long portNo, OpenflowVersion ofVersion)}
+ * Test method for {@link InventoryDataServiceUtil#nodeConnectorUpdatedBuilderFromDatapathIdPortNo(
+ * BigInteger datapathId, Long portNo, OpenflowVersion ofVersion)}.
*/
@Test
public void testNodeConnectorUpdatedBuilderFromDatapathIdPortNo() {
- NodeConnectorUpdatedBuilder nodeConnectorUpdatedBuilder = InventoryDataServiceUtil.nodeConnectorUpdatedBuilderFromDatapathIdPortNo(PATH_ID,
- PORT_NO, OpenflowVersion.OF10);
+ NodeConnectorUpdatedBuilder nodeConnectorUpdatedBuilder = InventoryDataServiceUtil
+ .nodeConnectorUpdatedBuilderFromDatapathIdPortNo(PATH_ID, PORT_NO, OpenflowVersion.OF10);
assertNotNull(nodeConnectorUpdatedBuilder);
nodeConnectorUpdatedBuilder = InventoryDataServiceUtil.nodeConnectorUpdatedBuilderFromDatapathIdPortNo(PATH_ID,
}
/**
- * Test method for {@link InventoryDataServiceUtil#nodeConnectorInstanceIdentifierFromDatapathIdPortno(BigInteger datapathId, Long portNo, OpenflowVersion ofVersion)}
+ * Test method for {@link InventoryDataServiceUtil#nodeConnectorInstanceIdentifierFromDatapathIdPortno(
+ * BigInteger datapathId, Long portNo, OpenflowVersion ofVersion)}.
*/
@Test
public void testNodeConnectorInstanceIdentifierFromDatapathIdPortno() {
- InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier = InventoryDataServiceUtil.nodeConnectorInstanceIdentifierFromDatapathIdPortno(BigInteger.ONE,
- PORT_NO, OpenflowVersion.OF10);
+ InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier = InventoryDataServiceUtil
+ .nodeConnectorInstanceIdentifierFromDatapathIdPortno(BigInteger.ONE, PORT_NO, OpenflowVersion.OF10);
assertNotNull(nodeConnectorInstanceIdentifier);
}
/**
- * Test method for {@link InventoryDataServiceUtil#nodeConnectorRefFromDatapathIdPortno(BigInteger datapathId, Long portNo, OpenflowVersion ofVersion)}
+ * Test method for {@link InventoryDataServiceUtil#nodeConnectorRefFromDatapathIdPortno(
+ * BigInteger datapathId, Long portNo, OpenflowVersion ofVersion)}.
*/
@Test
public void testNodeConnectorRefFromDatapathIdPortno() {
public void testDataPathIdFromNodeId() {
String string = "openflow:";
NodeId[] nodeIds = new NodeId[]{
- // 0x00000000 000004d2
- new NodeId(string + "1234"),
- // 0x8db2089e 01391a86
- new NodeId(string + "10210232779920710278"),
- // 0xffffffff ffffffff
- new NodeId(string + "18446744073709551615"),
+ // 0x00000000 000004d2
+ new NodeId(string + "1234"),
+ // 0x8db2089e 01391a86
+ new NodeId(string + "10210232779920710278"),
+ // 0xffffffff ffffffff
+ new NodeId(string + "18446744073709551615"),
};
- long[] expectedDPIDs = new long[]{
- 1234L,
- -8236511293788841338L,
- -1L
- };
+ long[] expectedDPIDs = new long[] { 1234L, -8236511293788841338L, -1L };
for (int i = 0; i < nodeIds.length; i++) {
BigInteger datapathId = InventoryDataServiceUtil.dataPathIdFromNodeId(nodeIds[i]);
@Test
public void testLongToPaddedHex() {
BigInteger[] dpids = new BigInteger[]{
- // 0x00000000 000004d2
- new BigInteger("1234"),
- // 0x8db2089e 01391a86
- new BigInteger("10210232779920710278"),
- // 0xffffffff ffffffff
- new BigInteger("18446744073709551615"),
+ // 0x00000000 000004d2
+ new BigInteger("1234"),
+ // 0x8db2089e 01391a86
+ new BigInteger("10210232779920710278"),
+ // 0xffffffff ffffffff
+ new BigInteger("18446744073709551615"),
};
- String[] expectedPaddedHexes = new String[]{
- "00000000000004d2",
- "8db2089e01391a86",
- "ffffffffffffffff"
- };
+ String[] expectedPaddedHexes = new String[] { "00000000000004d2", "8db2089e01391a86", "ffffffffffffffff" };
for (int i = 0; i < dpids.length; i++) {
String datapathIdHex = InventoryDataServiceUtil.bigIntegerToPaddedHex(dpids[i]);
*/
@Test
public void testNodeConnectorIDToPortNoString() {
- String[] nodeConnectorIDs = new String[]{
- "openflow:2",
- "openflow:2:3411",
- "INPORT",
- "openflow:628192264910264962"
- };
-
- String[] expectedPortNoStrings = new String[]{
- "2",
- "3411",
- "INPORT",
- "628192264910264962"
- };
-
- for (int i = 0; i < nodeConnectorIDs.length; i++) {
- String portNoString = InventoryDataServiceUtil.portNoStringfromNodeConnectorID(nodeConnectorIDs[i]);
- Assert.assertEquals(expectedPortNoStrings[i], portNoString);
- }
+ String[] nodeConnectorIDs = new String[] { "openflow:2", "openflow:2:3411", "INPORT",
+ "openflow:628192264910264962" };
+
+ String[] expectedPortNoStrings = new String[] { "2", "3411", "INPORT", "628192264910264962" };
+
+ for (int i = 0; i < nodeConnectorIDs.length; i++) {
+ String portNoString = InventoryDataServiceUtil.portNoStringfromNodeConnectorID(nodeConnectorIDs[i]);
+ Assert.assertEquals(expectedPortNoStrings[i], portNoString);
+ }
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
/**
+ * Unit tests for OpenflowPortsUtil.
+ *
* @author: Kamal Rameshan (kramesha@cisco.com)
* @since : 6/2/14
*/
private static Map<OpenflowVersion, Map<String, Long>> mapVersionToPorts;
/**
- * initiation before testing - once for all
+ * initiation before testing - once for all.
*/
@BeforeClass
public static void setupClass() {
- mapOF10Ports = new HashMap<String, Long>();
+ mapOF10Ports = new HashMap<>();
mapOF10Ports.put(OutputPortValues.MAX.getName(), 65280L);
mapOF10Ports.put(OutputPortValues.INPORT.getName(), 65528L);
mapOF10Ports.put(OutputPortValues.TABLE.getName(), 65529L);
mapOF10Ports.put(OutputPortValues.LOCAL.getName(), 65534L);
mapOF10Ports.put(OutputPortValues.NONE.getName(), 65535L);
- mapOF13Ports = new HashMap<String, Long>();
+ mapOF13Ports = new HashMap<>();
mapOF13Ports.put(OutputPortValues.MAX.getName(), 4294967040L);
mapOF13Ports.put(OutputPortValues.INPORT.getName(), 4294967288L);
mapOF13Ports.put(OutputPortValues.TABLE.getName(), 4294967289L);
mapOF13Ports.put(OutputPortValues.LOCAL.getName(), 4294967294L);
mapOF13Ports.put(OutputPortValues.ANY.getName(), 4294967295L);
- mapVersionToPorts = new HashMap<OpenflowVersion, Map<String, Long>>();
+ mapVersionToPorts = new HashMap<>();
mapVersionToPorts.put(OpenflowVersion.OF10, mapOF10Ports);
mapVersionToPorts.put(OpenflowVersion.OF13, mapOF13Ports);
}
/**
- * tearing down initiated values after all tests done
+ * tearing down initiated values after all tests done.
*/
@AfterClass
public static void tearDownClass() {
//helper
private static void matchGetLogicalName(final OpenflowVersion version, final String logicalName) {
- Assert.assertEquals("Controller reserve port not matching to logical-name for "+ version,
+ Assert.assertEquals("Controller reserve port not matching to logical-name for " + version,
logicalName,
OpenflowPortsUtil.getPortLogicalName(version, mapVersionToPorts.get(version).get(logicalName)));
}
//helper
private static void matchGetPortfromLogicalName(final OpenflowVersion version, final String logicalName) {
- Assert.assertEquals("Controller reserve port not matching to logical-name for "+ version,
- mapVersionToPorts.get(version).get(logicalName), OpenflowPortsUtil.getPortFromLogicalName(version, logicalName));
+ Assert.assertEquals("Controller reserve port not matching to logical-name for " + version,
+ mapVersionToPorts.get(version).get(logicalName),
+ OpenflowPortsUtil.getPortFromLogicalName(version, logicalName));
}
/**
- * test for method {@link OpenflowPortsUtil#getPortLogicalName(OpenflowVersion, Long)}
+ * test for method {@link OpenflowPortsUtil#getPortLogicalName(OpenflowVersion, Long)}.
*/
@Test
public void testGetPortLogicalName() {
- String s = OutputPortValues.INPORT.getName();
matchGetLogicalName(OpenflowVersion.OF10, OutputPortValues.MAX.getName());
matchGetLogicalName(OpenflowVersion.OF10, OutputPortValues.INPORT.getName());
matchGetLogicalName(OpenflowVersion.OF10, OutputPortValues.TABLE.getName());
Assert.assertNull("Invalid port number should return a null",
OpenflowPortsUtil.getPortLogicalName(OpenflowVersion.OF13, 99999L));
- Assert.assertFalse(s.equals("a"));
+
+ String name = OutputPortValues.INPORT.getName();
+ Assert.assertFalse(name.equals("a"));
}
/**
- * test for method {@link OpenflowPortsUtil#getPortFromLogicalName(OpenflowVersion, String)}
+ * test for method {@link OpenflowPortsUtil#getPortFromLogicalName(OpenflowVersion, String)}.
*/
@Test
public void testGetPortFromLogicalName() {
}
/**
- * test for method {@link OpenflowPortsUtil#checkPortValidity(OpenflowVersion, Long)} - OF-1.0
+ * test for method {@link OpenflowPortsUtil#checkPortValidity(OpenflowVersion, Long)} - OF-1.0.
*/
@Test
public void testCheckPortValidity10() {
}
/**
- * test for method {@link OpenflowPortsUtil#checkPortValidity(OpenflowVersion, Long)} - OF-1.3
+ * test for method {@link OpenflowPortsUtil#checkPortValidity(OpenflowVersion, Long)} - OF-1.3.
*/
@Test
public void testCheckPortValidity13() {
}
/**
- * test for method {@link OpenflowPortsUtil}
+ * test for method {@link OpenflowPortsUtil}.
*/
@Test
public void testPortNumberToString() {
portNumber = new PortNumberUni((String) null);
Assert.assertNotNull(portNumber);
-
}
-
}