2 * Copyright (c) 2013 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
8 package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
10 import java.math.BigInteger;
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.openflowplugin.api.OFConstants;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsActionBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
26 * match conversion and injection test
28 public class MatchReactorTest {
30 private MatchBuilder matchBuilder;
37 matchBuilder = new MatchBuilder();
38 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
39 EthernetTypeBuilder ethernetTypeBuilder = new EthernetTypeBuilder();
40 ethernetTypeBuilder.setType(new EtherType(42L));
41 ethernetMatchBuilder.setEthernetType(ethernetTypeBuilder.build());
42 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
46 * convert for OF-1.3, inject into {@link FlowModInputBuilder}
49 public void testMatchConvertorV13_flow() {
50 FlowModInputBuilder target = new FlowModInputBuilder();
51 MatchReactor.getInstance().convert(matchBuilder.build(),
52 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
53 Assert.assertNotNull(target.getMatch());
57 * convert for OF-1.0, inject into {@link FlowModInputBuilder}
60 public void testMatchConvertorV10_flow() {
61 FlowModInputBuilder target = new FlowModInputBuilder();
62 MatchReactor.getInstance().convert(matchBuilder.build(),
63 OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
64 Assert.assertNotNull(target.getMatchV10());
68 * convert for OF-1.3, inject into {@link OxmFieldsActionBuilder}
71 public void testMatchConvertorV13_action() {
72 OxmFieldsActionBuilder target = new OxmFieldsActionBuilder();
73 MatchReactor.getInstance().convert(matchBuilder.build(),
74 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
75 Assert.assertNotNull(target.getMatchEntries());
79 * convert for OF-1.3, inject into {@link MultipartRequestFlowBuilder}
82 public void testMatchConvertorV13_mpRequestFlow() {
83 MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
84 MatchReactor.getInstance().convert(matchBuilder.build(),
85 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
86 Assert.assertNotNull(target.getMatch());
90 * convert for OF-1.0, inject into {@link MultipartRequestFlowBuilder}
93 public void testMatchConvertorV10_mpRequestFlow() {
94 MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
95 MatchReactor.getInstance().convert(matchBuilder.build(),
96 OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
97 Assert.assertNotNull(target.getMatchV10());
101 public void testMatchConvertorV10_null() {
102 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
103 MatchReactor.getInstance().convert(null,
104 OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
105 Assert.assertNotNull(target.getMatchV10());
109 * convert for OF-1.3, inject into {@link MultipartRequestAggregateBuilder}
112 public void testMatchConvertorV13_mpRequestAggregate() {
113 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
114 MatchReactor.getInstance().convert(matchBuilder.build(),
115 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
116 Assert.assertNotNull(target.getMatch());
120 public void testMatchConvertorV13_null() {
121 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
122 MatchReactor.getInstance().convert(null,
123 OFConstants.OFP_VERSION_1_3, target,BigInteger.valueOf(1));
124 Assert.assertNotNull(target.getMatch());
125 Assert.assertEquals(0, target.getMatch().getMatchEntries().size());
129 * convert for OF-1.0, inject into {@link MultipartRequestAggregateBuilder}
132 public void testMatchConvertorV10_mpRequestAggregate() {
133 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
134 MatchReactor.getInstance().convert(matchBuilder.build(),
135 OFConstants.OFP_VERSION_1_0, target,BigInteger.valueOf(1));
136 Assert.assertNotNull(target.getMatchV10());