380614f030e6220975702076445f3e04d308cc65
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / util / MatchUtilTest.java
1 /*
2  *
3  *  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
4  *  *
5  *  * This program and the accompanying materials are made available under the
6  *  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  *  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  *
9  *
10  */
11
12 package org.opendaylight.openflowplugin.impl.util;
13
14 import static org.junit.Assert.assertEquals;
15
16 import org.junit.Test;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10Builder;
21
22 public class MatchUtilTest {
23
24     private static final MacAddress ZERO_MAC_ADDRESS = new MacAddress("00:00:00:00:00:00");
25     private static final Ipv4Address ZERO_IPV4_ADDRESS = new Ipv4Address("0.0.0.0");
26
27     @Test
28     public void createEmptyV10MatchTest() {
29         MatchV10Builder expectedV10Match = expectedV10Match();
30         MatchV10Builder emptyV10Match = MatchUtil.createEmptyV10Match();
31         assertEquals(expectedV10Match.build(),emptyV10Match.build());
32     }
33
34     private MatchV10Builder expectedV10Match() {
35         Short zeroShort = Short.valueOf("0");
36         Integer zeroInteger = Integer.valueOf(0);
37         MatchV10Builder matchV10Builder = new MatchV10Builder();
38         matchV10Builder.setDlDst( ZERO_MAC_ADDRESS);
39         matchV10Builder.setDlSrc(ZERO_MAC_ADDRESS);
40         matchV10Builder.setDlType(zeroInteger);
41         matchV10Builder.setDlVlan(zeroInteger);
42         matchV10Builder.setDlVlanPcp(zeroShort);
43         matchV10Builder.setInPort(zeroInteger);
44         matchV10Builder.setNwDst(ZERO_IPV4_ADDRESS);
45         matchV10Builder.setNwDstMask(zeroShort);
46         matchV10Builder.setNwProto(zeroShort);
47         matchV10Builder.setNwSrc(ZERO_IPV4_ADDRESS);
48         matchV10Builder.setNwSrcMask(zeroShort);
49         matchV10Builder.setNwTos(zeroShort);
50         matchV10Builder.setTpDst(zeroInteger);
51         matchV10Builder.setTpSrc(zeroInteger);
52         FlowWildcardsV10 flowWildcardsV10 = new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true);
53         matchV10Builder.setWildcards(flowWildcardsV10);
54         return matchV10Builder;
55     }
56 }