3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
10 package org.opendaylight.controller.sal.reader;
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;
25 public class FlowOnNodeTest {
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));
33 match.setField(MatchType.DL_TYPE, EtherTypes.IPv4.shortValue());
34 match.setField(MatchType.IN_PORT, inNC);
36 Output output = new Output(outNC);
37 ArrayList<Action> action = new ArrayList<Action>();
40 Flow flow = new Flow (match, action);
42 FlowOnNode flowOnNode = new FlowOnNode (flow);
44 Assert.assertTrue(flowOnNode.getFlow().equals(flow));
46 flowOnNode.setPacketCount((long)100);
47 flowOnNode.setByteCount((long)800);
48 flowOnNode.setTableId((byte)0x55);
49 flowOnNode.setDurationNanoseconds(40);
50 flowOnNode.setDurationSeconds(45);
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);