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