2 * [[ Authors will Fill in the Copyright header ]]
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
8 * Authors : Brent Salisbury, Hugo Trippaers
10 package org.opendaylight.ovsdb.plugin;
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.util.HashMap;
16 import java.util.Properties;
18 import org.opendaylight.controller.sal.connection.ConnectionConstants;
19 import org.opendaylight.controller.sal.core.Node;
20 import org.opendaylight.controller.sal.core.NodeConnector;
22 public abstract class OvsdbTestBase {
23 private final static String identifier = "TEST";
25 public Properties loadProperties() throws IOException {
30 "org/opendaylight/ovsdb/lib/message/integration-test.properties");
32 throw new IOException("Unable to load integration-test.properties");
34 Properties props = new Properties();
40 public class TestObjects {
41 public final ConnectionService connectionService;
42 public final Node node;
44 public TestObjects(ConnectionService connectionService, Node node) {
45 this.connectionService = connectionService;
50 public TestObjects getTestConnection() throws IOException {
51 Node.NodeIDType.registerIDType("OVS", String.class);
52 NodeConnector.NodeConnectorIDType.registerIDType("OVS", String.class,
54 InventoryService inventoryService = new InventoryService();
55 inventoryService.init();
57 ConnectionService connectionService = new ConnectionService();
58 connectionService.init();
60 connectionService.setInventoryServiceInternal(inventoryService);
61 Map<ConnectionConstants, String> params = new HashMap<ConnectionConstants, String>();
62 Properties props = loadProperties();
63 params.put(ConnectionConstants.ADDRESS,
64 props.getProperty("ovsdbserver.ipaddress"));
65 params.put(ConnectionConstants.PORT,
66 props.getProperty("ovsdbserver.port", "6640"));
68 Node node = connectionService.connect(identifier, params);
70 throw new IOException("Failed to connecto to ovsdb server");
72 return new TestObjects(connectionService, node);