junit for provisioning api/user defined ports to api/user defined bridges passed...
[ovsdb.git] / ovsdb / src / test / java / org / opendaylight / ovsdb / OvsdbTestAddPort.java
1 package org.opendaylight.ovsdb;
2
3 import java.net.InetAddress;
4 import java.util.ArrayList;
5 import java.util.HashMap;
6 import java.util.Map;
7
8 import org.junit.Test;
9 import org.opendaylight.controller.sal.core.Node;
10 import org.opendaylight.controller.sal.core.NodeConnector;
11 import org.opendaylight.ovsdb.database.Uuid;
12 import org.opendaylight.ovsdb.internal.*;
13 import org.opendaylight.ovsdb.sal.connection.ConnectionConstants;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 public class OvsdbTestAddPort {
18     private static final Logger logger = LoggerFactory
19             .getLogger(OvsdbTestAddPort.class);
20
21     @Test
22     public void addPort() throws Throwable{
23         Node.NodeIDType.registerIDType("OVS", String.class);
24         NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class, "OVS");
25
26         ConnectionService connectionService = new ConnectionService();
27         connectionService.init();
28         String identifier = "TEST";
29         Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
30         params.put(ConnectionConstants.ADDRESS, "172.16.58.170");
31
32         Node node = connectionService.connect(identifier, params);
33         if(node == null){
34             logger.error("Could not connect to ovsdb server");
35             return;
36         }
37         /**
38          * Create a Bridge Domain
39          * @param node Node serving this configuration service
40          * @param bridgeDomainIdentifier String representation of a Bridge Domain
41          * @param portIdentifier String representation of a user defined Port Name
42          * Temporarily add the bridge table _uuid to bridge_uuid in ConfigurationService
43          */
44         ConfigurationService configurationService = new ConfigurationService();
45         configurationService.setConnectionServiceInternal(connectionService);
46         configurationService.addPort(node, "JUNIT_BRIDGE_TEST", "Jnic1");
47     }
48 }