BUG-1065: translation of Ipv6ExtHeader flags to int
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / match / MatchReactorTest.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
9
10 import java.math.BigInteger;
11
12 import junit.framework.Assert;
13
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.openflowplugin.openflow.md.OFConstants;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
25
26 /**
27  * match conversion and injection test 
28  */
29 public class MatchReactorTest {
30
31     private MatchBuilder matchBuilder;
32     
33     /**
34      * prepare input match
35      */
36     @Before
37     public void setUp() {
38         matchBuilder = new MatchBuilder();
39         EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
40         EthernetTypeBuilder ethernetTypeBuilder = new EthernetTypeBuilder();
41         ethernetTypeBuilder.setType(new EtherType(42L));
42         ethernetMatchBuilder.setEthernetType(ethernetTypeBuilder.build());
43         matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
44     }
45
46     /**
47      * convert for OF-1.3, inject into {@link FlowModInputBuilder}
48      */
49     @Test
50     public void testMatchConvertorV13_flow() {
51         FlowModInputBuilder target = new FlowModInputBuilder();
52         MatchReactor.getInstance().convert(matchBuilder.build(), 
53                 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
54         Assert.assertNotNull(target.getMatch());
55     }
56     
57     /**
58      * convert for OF-1.0, inject into {@link FlowModInputBuilder}
59      */
60     @Test
61     public void testMatchConvertorV10_flow() {
62         FlowModInputBuilder target = new FlowModInputBuilder();
63         MatchReactor.getInstance().convert(matchBuilder.build(), 
64                 OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
65         Assert.assertNotNull(target.getMatchV10());
66     }
67
68     /**
69      * convert for OF-1.3, inject into {@link OxmFieldsActionBuilder}
70      */
71     @Test
72     public void testMatchConvertorV13_action() {
73         OxmFieldsActionBuilder target = new OxmFieldsActionBuilder();
74         MatchReactor.getInstance().convert(matchBuilder.build(), 
75                 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
76         Assert.assertNotNull(target.getMatchEntries());
77     }
78     
79     /**
80      * convert for OF-1.3, inject into {@link MultipartRequestFlowBuilder}
81      */
82     @Test
83     public void testMatchConvertorV13_mpRequestFlow() {
84         MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
85         MatchReactor.getInstance().convert(matchBuilder.build(), 
86                 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
87         Assert.assertNotNull(target.getMatch());
88     }
89     
90     /**
91      * convert for OF-1.0, inject into {@link MultipartRequestFlowBuilder}
92      */
93     @Test
94     public void testMatchConvertorV10_mpRequestFlow() {
95         MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
96         MatchReactor.getInstance().convert(matchBuilder.build(), 
97                 OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
98         Assert.assertNotNull(target.getMatchV10());
99     }
100     
101     /**
102      * convert for OF-1.3, inject into {@link MultipartRequestAggregateBuilder}
103      */
104     @Test
105     public void testMatchConvertorV13_mpRequestAggregate() {
106         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
107         MatchReactor.getInstance().convert(matchBuilder.build(), 
108                 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
109         Assert.assertNotNull(target.getMatch());
110     }
111     
112     /**
113      * convert for OF-1.0, inject into {@link MultipartRequestAggregateBuilder}
114      */
115     @Test
116     public void testMatchConvertorV10_mpRequestAggregate() {
117         MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
118         MatchReactor.getInstance().convert(matchBuilder.build(), 
119                 OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
120         Assert.assertNotNull(target.getMatchV10());
121     }
122     
123     
124     
125 }