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 junit.framework.Assert;
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;
27 * match conversion and injection test
29 public class MatchReactorTest {
31 private MatchBuilder matchBuilder;
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());
47 * convert for OF-1.3, inject into {@link FlowModInputBuilder}
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());
58 * convert for OF-1.0, inject into {@link FlowModInputBuilder}
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());
69 * convert for OF-1.3, inject into {@link OxmFieldsActionBuilder}
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());
80 * convert for OF-1.3, inject into {@link MultipartRequestFlowBuilder}
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());
91 * convert for OF-1.0, inject into {@link MultipartRequestFlowBuilder}
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());
102 * convert for OF-1.3, inject into {@link MultipartRequestAggregateBuilder}
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());
113 * convert for OF-1.0, inject into {@link MultipartRequestAggregateBuilder}
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());