Merge "BUG-2329 Add test for anyxmls inside rpc resonse for netcfon-connector"
[controller.git] / opendaylight / adsal / sal / api / src / test / java / org / opendaylight / controller / sal / reader / FlowOnNodeTest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 package org.opendaylight.controller.sal.reader;
11
12 import java.util.ArrayList;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.controller.sal.action.Action;
16 import org.opendaylight.controller.sal.action.Output;
17 import org.opendaylight.controller.sal.core.NodeConnector;
18 import org.opendaylight.controller.sal.flowprogrammer.Flow;
19 import org.opendaylight.controller.sal.match.Match;
20 import org.opendaylight.controller.sal.match.MatchType;
21 import org.opendaylight.controller.sal.utils.EtherTypes;
22 import org.opendaylight.controller.sal.utils.NodeConnectorCreator;
23 import org.opendaylight.controller.sal.utils.NodeCreator;
24
25 public class FlowOnNodeTest {
26
27                 @Test
28                 public void testFlowOnNodeMethods () {
29                 Match match = new Match();
30                 NodeConnector inNC = NodeConnectorCreator.createNodeConnector((short)10, NodeCreator.createOFNode((long)10));
31                 NodeConnector outNC = NodeConnectorCreator.createNodeConnector((short)20, NodeCreator.createOFNode((long)20));
32
33                 match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
34                 match.setField(MatchType.IN_PORT, inNC);
35
36                 Output output = new Output(outNC);
37                 ArrayList<Action> action = new ArrayList<Action>();
38                 action.add(output);
39
40                 Flow flow = new Flow (match, action);
41
42                 FlowOnNode flowOnNode = new FlowOnNode (flow);
43
44                 Assert.assertTrue(flowOnNode.getFlow().equals(flow));
45
46                 flowOnNode.setPacketCount((long)100);
47                 flowOnNode.setByteCount((long)800);
48                 flowOnNode.setTableId((byte)0x55);
49                 flowOnNode.setDurationNanoseconds(40);
50                 flowOnNode.setDurationSeconds(45);
51
52                 Assert.assertTrue(flowOnNode.getPacketCount() == 100);
53                 Assert.assertTrue(flowOnNode.getByteCount() == 800);
54                 Assert.assertTrue(flowOnNode.getDurationNanoseconds() == 40);
55                 Assert.assertTrue(flowOnNode.getDurationSeconds() == 45);
56                 Assert.assertTrue(flowOnNode.getTableId() == (byte)0x55);
57         }
58 }