1 package org.opendaylight.controller.switchmanager;
3 import java.util.ArrayList;
5 import org.junit.Assert;
7 import org.opendaylight.controller.sal.core.ConstructionException;
8 import org.opendaylight.controller.sal.core.Node;
9 import org.opendaylight.controller.sal.core.NodeConnector;
10 import org.opendaylight.controller.sal.utils.Status;
12 public class SubnetConfigTest {
15 public void configuration() throws ConstructionException {
16 // Create the node connector string list
17 Node node1 = new Node(Node.NodeIDType.OPENFLOW, 1L);
18 Node node2 = new Node(Node.NodeIDType.OPENFLOW, 2L);
19 Node node3 = new Node(Node.NodeIDType.OPENFLOW, 3L);
20 NodeConnector nc1 = new NodeConnector(NodeConnector.NodeConnectorIDType.OPENFLOW, (short)1, node1);
21 NodeConnector nc2 = new NodeConnector(NodeConnector.NodeConnectorIDType.OPENFLOW, (short)2, node2);
22 NodeConnector nc3 = new NodeConnector(NodeConnector.NodeConnectorIDType.OPENFLOW, (short)3, node3);
23 List<String> portList = new ArrayList<String>();
24 portList.add(nc1.toString());
25 portList.add(nc2.toString());
26 portList.add(nc3.toString());
28 // Full subnet creation
29 SubnetConfig config = new SubnetConfig("eng", "11.1.1.254/16", portList);
30 Status status = config.validate();
31 Assert.assertTrue(status.isSuccess());
33 // No port set specified
34 config = new SubnetConfig("eng", "11.1.1.254/16", null);
35 status = config.validate();
36 Assert.assertTrue(status.isSuccess());
39 config = new SubnetConfig("eng", "11.1.1.254/16", new ArrayList<String>(0));
40 status = config.validate();
41 Assert.assertTrue(status.isSuccess());
44 config = new SubnetConfig("eng", "1.2.3.254/1", null);
45 status = config.validate();
46 Assert.assertFalse(status.isSuccess());
48 // Port set with invalid port notation
49 List<String> badPortList = new ArrayList<String>();
50 badPortList.add("1/1");
51 config = new SubnetConfig("eng", "1.2.3.254/1", badPortList);
52 status = config.validate();
53 Assert.assertFalse(status.isSuccess());