/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.switchmanager; import java.util.ArrayList; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.opendaylight.controller.sal.core.ConstructionException; import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.utils.Status; public class SubnetConfigTest { @Test public void configuration() throws ConstructionException { // Create the node connector string list Node node1 = new Node(Node.NodeIDType.OPENFLOW, 1L); Node node2 = new Node(Node.NodeIDType.OPENFLOW, 2L); Node node3 = new Node(Node.NodeIDType.OPENFLOW, 3L); NodeConnector nc1 = new NodeConnector(NodeConnector.NodeConnectorIDType.OPENFLOW, (short)1, node1); NodeConnector nc2 = new NodeConnector(NodeConnector.NodeConnectorIDType.OPENFLOW, (short)2, node2); NodeConnector nc3 = new NodeConnector(NodeConnector.NodeConnectorIDType.OPENFLOW, (short)3, node3); List portList = new ArrayList(); portList.add(nc1.toString()); portList.add(nc2.toString()); portList.add(nc3.toString()); // Full subnet creation SubnetConfig config = new SubnetConfig("eng", "11.1.1.254/16", portList); Status status = config.validate(); Assert.assertTrue(status.isSuccess()); // No port set specified config = new SubnetConfig("eng", "11.1.1.254/16", null); status = config.validate(); Assert.assertTrue(status.isSuccess()); // Empty port set config = new SubnetConfig("eng", "11.1.1.254/16", new ArrayList(0)); status = config.validate(); Assert.assertTrue(status.isSuccess()); // Zero subnet config = new SubnetConfig("eng", "1.2.3.254/1", null); status = config.validate(); Assert.assertFalse(status.isSuccess()); // Port set with invalid port notation List badPortList = new ArrayList(); badPortList.add("1/1"); config = new SubnetConfig("eng", "1.2.3.254/1", badPortList); status = config.validate(); Assert.assertFalse(status.isSuccess()); } }