ee66acde9278b4e47661c51deec83acd7480468f
[ovsdb.git] / ovsdb / src / test / java / org / opendaylight / ovsdb / plugin / OvsdbTestAddVlanIT.java
1 /*
2  * [[ Authors will Fill in the Copyright header ]]
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  * Authors : Brent Salisbury, Hugo Trippaers
9  */
10 package org.opendaylight.ovsdb.plugin;
11
12 import java.util.HashMap;
13 import java.util.Map;
14
15 import org.junit.Test;
16 import org.opendaylight.controller.sal.core.Node;
17 import org.opendaylight.controller.sal.networkconfig.bridgedomain.ConfigConstants;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public class OvsdbTestAddVlanIT extends OvsdbTestBase {
22     private static final Logger logger = LoggerFactory
23             .getLogger(OvsdbTestAddVlanIT.class);
24
25     @Test
26     public void addPortVlan() throws Throwable{
27         TestObjects testObjects = getTestConnection();
28         ConnectionService connectionService = testObjects.connectionService;
29         Node node = testObjects.node;
30
31         int vlanid = 100;
32
33         /**
34          * Create a Port with a user defined VLAN, and attach it to the specified bridge.
35          *
36          * Ex. ovs-vsctl add-port JUNIT_BRIDGE_TEST Jvlanvif0 tag=100
37          * @param node Node serving this configuration service
38          * @param bridgeDomainIdentifier String representation of a Bridge Domain
39          * @param portIdentifier String representation of a user defined Port Name
40          * @param vlanid Integer note: only one VID is accepted with tag=x method
41          */
42         ConfigurationService configurationService = new ConfigurationService();
43         configurationService.setConnectionServiceInternal(connectionService);
44         Map<ConfigConstants, Object> configs = new HashMap<ConfigConstants, Object>();
45         configs.put(ConfigConstants.TYPE, "VLAN");
46         configs.put(ConfigConstants.VLAN, vlanid+"");
47         configurationService.addPort(node, "JUNIT_BRIDGE_TEST", "Jtagvif0", configs);
48     }
49 }