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 org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.opendaylight.openflowplugin.api.OFConstants;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
23 * match conversion and injection test
25 public class MatchReactorTest {
27 private MatchBuilder matchBuilder;
34 matchBuilder = new MatchBuilder();
35 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
36 EthernetTypeBuilder ethernetTypeBuilder = new EthernetTypeBuilder();
37 ethernetTypeBuilder.setType(new EtherType(42L));
38 ethernetMatchBuilder.setEthernetType(ethernetTypeBuilder.build());
39 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
43 * convert for OF-1.3, inject into {@link FlowModInputBuilder}
46 public void testMatchConvertorV13_flow() {
47 FlowModInputBuilder target = new FlowModInputBuilder();
48 MatchReactor.getInstance().convert(matchBuilder.build(),
49 OFConstants.OFP_VERSION_1_3, target);
50 Assert.assertNotNull(target.getMatch());
54 * convert for OF-1.0, inject into {@link FlowModInputBuilder}
57 public void testMatchConvertorV10_flow() {
58 FlowModInputBuilder target = new FlowModInputBuilder();
59 MatchReactor.getInstance().convert(matchBuilder.build(),
60 OFConstants.OFP_VERSION_1_0, target);
61 Assert.assertNotNull(target.getMatchV10());
66 * convert for OF-1.3, inject into {@link MultipartRequestFlowBuilder}
69 public void testMatchConvertorV13_mpRequestFlow() {
70 MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
71 MatchReactor.getInstance().convert(matchBuilder.build(),
72 OFConstants.OFP_VERSION_1_3, target);
73 Assert.assertNotNull(target.getMatch());
77 * convert for OF-1.0, inject into {@link MultipartRequestFlowBuilder}
80 public void testMatchConvertorV10_mpRequestFlow() {
81 MultipartRequestFlowBuilder target = new MultipartRequestFlowBuilder();
82 MatchReactor.getInstance().convert(matchBuilder.build(),
83 OFConstants.OFP_VERSION_1_0, target);
84 Assert.assertNotNull(target.getMatchV10());
88 public void testMatchConvertorV10_null() {
89 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
90 MatchReactor.getInstance().convert(null,
91 OFConstants.OFP_VERSION_1_0, target);
92 Assert.assertNotNull(target.getMatchV10());
96 * convert for OF-1.3, inject into {@link MultipartRequestAggregateBuilder}
99 public void testMatchConvertorV13_mpRequestAggregate() {
100 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
101 MatchReactor.getInstance().convert(matchBuilder.build(),
102 OFConstants.OFP_VERSION_1_3, target);
103 Assert.assertNotNull(target.getMatch());
107 public void testMatchConvertorV13_null() {
108 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
109 MatchReactor.getInstance().convert(null,
110 OFConstants.OFP_VERSION_1_3, target);
111 Assert.assertNotNull(target.getMatch());
112 Assert.assertEquals(0, target.getMatch().getMatchEntry().size());
116 * convert for OF-1.0, inject into {@link MultipartRequestAggregateBuilder}
119 public void testMatchConvertorV10_mpRequestAggregate() {
120 MultipartRequestAggregateBuilder target = new MultipartRequestAggregateBuilder();
121 MatchReactor.getInstance().convert(matchBuilder.build(),
122 OFConstants.OFP_VERSION_1_0, target);
123 Assert.assertNotNull(target.getMatchV10());