2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertNotNull;
14 import static org.junit.Assert.assertNull;
15 import static org.junit.Assert.assertTrue;
17 import org.junit.Test;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
28 * Created by Martin Bobak mbobak@cisco.com on 9/17/14.
30 public class NxmExtensionsConvertorTest {
33 private static final Integer TCP_FLAG = new Integer(42);
34 private static final Ipv4Prefix IPV_4_PREFIX = new Ipv4Prefix("10.0.0.1/24");
38 * Trivial test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.NxmExtensionsConvertor#toNxmTcpFlag(Integer)} }
40 public void testToNxmTcpFlag() {
41 MatchEntries matchEntries = NxmExtensionsConvertor.toNxmTcpFlag(TCP_FLAG);
42 assertNotNull(matchEntries.getAugmentation(TcpFlagMatchEntry.class));
43 assertFalse(matchEntries.isHasMask());
44 assertEquals(Nxm1Class.class, matchEntries.getOxmClass());
45 assertEquals(TcpFlag.class, matchEntries.getOxmMatchField());
50 * Trivial test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.NxmExtensionsConvertor#toNxmIpv4Tunnel(Class, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix)} }
52 public void testToNxmIpv4Tunnel() {
53 MatchEntries matchEntries = NxmExtensionsConvertor.toNxmIpv4Tunnel(MockMatchField.class, IPV_4_PREFIX);
54 assertNotNull(matchEntries.getAugmentation(MaskMatchEntry.class));
55 assertNotNull(matchEntries.getAugmentation(Ipv4AddressMatchEntry.class));
56 assertTrue(matchEntries.isHasMask());
57 assertEquals(Nxm1Class.class, matchEntries.getOxmClass());
58 assertEquals(MockMatchField.class, matchEntries.getOxmMatchField());
63 * Trivial test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.NxmExtensionsConvertor#addNxmIpv4PrefixAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix)} }
65 public void testAddNxmIpv4PrefixAugmentation() {
66 assertTrue(NxmExtensionsConvertor.addNxmIpv4PrefixAugmentation(new MatchEntriesBuilder(), IPV_4_PREFIX));
72 * Trivial test method for {@link org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match.NxmExtensionsConvertor#addNxmMaskAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder, byte[])} }
74 public void testAddNxmMaskAugmentation() {
75 MatchEntriesBuilder matchEntryBuilder = new MatchEntriesBuilder();
76 byte[] mask = new byte[0];
77 assertNull(matchEntryBuilder.getAugmentation(MaskMatchEntry.class));
78 NxmExtensionsConvertor.addNxmMaskAugmentation(matchEntryBuilder, mask);
79 assertNotNull(matchEntryBuilder.getAugmentation(MaskMatchEntry.class));
83 private class MockMatchField extends org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField {