Bug 5540 - PacketOutConvertor
[openflowplugin.git] / openflowplugin / src / test / java / org / opendaylight / openflowplugin / openflow / md / core / sal / convertor / flow / flowflag / FlowFlagReactorTest.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.flow.flowflag;
9
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.FlowModFlags;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder;
16
17 /**
18  * match conversion and injection test
19  */
20 public class FlowFlagReactorTest {
21
22     private FlowModFlags[] flowFlags;
23
24     /**
25      * prepare input match
26      */
27     @Before
28     public void setUp() {
29         flowFlags = new FlowModFlags[] {
30                 new FlowModFlags(true, true, true, true, true),
31                 new FlowModFlags(false, false, false, false, false),
32                 new FlowModFlags(true, false, true, false, true)
33         };
34     }
35
36     /**
37      * convert for OF-1.3, inject into {@link FlowModInputBuilder}
38      */
39     @Test
40     public void testMatchConvertorV13_flow() {
41         FlowModInputBuilder target = new FlowModInputBuilder();
42         for (FlowModFlags fFlag : flowFlags) {
43             target.setFlags(null);
44             FlowFlagReactor.getInstance().convert(fFlag,
45                     OFConstants.OFP_VERSION_1_3, target);
46             Assert.assertNotNull(target.getFlags());
47         }
48     }
49
50     /**
51      * convert for OF-1.0, inject into {@link FlowModInputBuilder}
52      */
53     @Test
54     public void testMatchConvertorV10_flow() {
55         FlowModInputBuilder target = new FlowModInputBuilder();
56         for (FlowModFlags fFlag : flowFlags) {
57             target.setFlagsV10(null);
58             FlowFlagReactor.getInstance().convert(fFlag,
59                     OFConstants.OFP_VERSION_1_0, target);
60             Assert.assertNotNull(target.getFlagsV10());
61         }
62     }
63 }