package org.opendaylight.controller.northbound.integrationtest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Bundle;
-import javax.inject.Inject;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemPackages;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.osgi.framework.BundleContext;
-import static org.junit.Assert.*;
-import org.ops4j.pax.exam.junit.Configuration;
-import static org.ops4j.pax.exam.CoreOptions.*;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.util.PathUtils;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Set;
-import org.apache.commons.codec.binary.Base64;
+import javax.inject.Inject;
+import org.apache.commons.codec.binary.Base64;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.codehaus.jettison.json.JSONTokener;
-
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.opendaylight.controller.hosttracker.IfIptoHost;
import org.opendaylight.controller.sal.core.Bandwidth;
import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
import org.opendaylight.controller.switchmanager.IInventoryListener;
import org.opendaylight.controller.usermanager.IUserManager;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.PathUtils;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@RunWith(PaxExam.class)
public class NorthboundIT {
- private Logger log = LoggerFactory.getLogger(NorthboundIT.class);
+ private final Logger log = LoggerFactory.getLogger(NorthboundIT.class);
// get the OSGI bundle context
@Inject
private BundleContext bc;
- private IUserManager users = null;
+ private IUserManager userManager = null;
private IInventoryListener invtoryListener = null;
private IListenTopoUpdates topoUpdates = null;
- private Boolean debugMsg = false;
+ private final Boolean debugMsg = false;
private String stateToString(int state) {
switch (state) {
ServiceReference r = bc.getServiceReference(IUserManager.class.getName());
if (r != null) {
- this.users = (IUserManager) bc.getService(r);
+ this.userManager = (IUserManager) bc.getService(r);
}
// If UserManager is null, cannot login to run tests.
- assertNotNull(this.users);
+ assertNotNull(this.userManager);
r = bc.getServiceReference(IfIptoHost.class.getName());
if (r != null) {
try {
URL url = new URL(restUrl);
- this.users.getAuthorizationList();
- this.users.authenticate("admin", "admin");
+ this.userManager.getAuthorizationList();
+ this.userManager.authenticate("admin", "admin");
String authString = "admin:admin";
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_3, ncType, nodeId_3, nodeType, ncState,
ncCapabilities, ncBandwidth);
- // Test delete node property
- // Delete timestamp property from node1
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1 + "/property/timeStamp", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- // Check node1
- result = getJsonResult(baseURL + "nodes");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node = getJsonInstance(json, "nodeProperties", nodeId_1);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_1, nodeType, null, null, actionsValue_1, capabilitiesValue_1, tablesValue_1,
- buffersValue_1);
-
- // Delete actions property from node2
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_2 + "/property/actions", "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
-
- // Check node2
- result = getJsonResult(baseURL + "nodes");
- jt = new JSONTokener(result);
- json = new JSONObject(jt);
- node = getJsonInstance(json, "nodeProperties", nodeId_2);
- Assert.assertNotNull(node);
- testNodeProperties(node, nodeId_2, nodeType, timestamp_1, timestampName_1, null, capabilitiesValue_1,
- tablesValue_1, buffersValue_1);
-
// Test add property to node
- // Add Tier and Bandwidth property to node1
+ // Add Tier and Description property to node1
result = getJsonResult(baseURL + "node/STUB/" + nodeId_1 + "/property/tier/1001", "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
- result = getJsonResult(baseURL + "node/STUB/" + nodeId_1 + "/property/bandwidth/1002", "PUT");
- Assert.assertEquals(201, httpResponseCode.intValue());
+ Assert.assertEquals(200, httpResponseCode.intValue());
+ result = getJsonResult(baseURL + "node/STUB/" + nodeId_1 + "/property/description/node1", "PUT");
+ Assert.assertEquals(200, httpResponseCode.intValue());
// Test for first node
result = getJsonResult(baseURL + "nodes");
node = getJsonInstance(json, "nodeProperties", nodeId_1);
Assert.assertNotNull(node);
Assert.assertEquals(1001, node.getJSONObject("properties").getJSONObject("tier").getInt("tierValue"));
- Assert.assertEquals(1002, node.getJSONObject("properties").getJSONObject("bandwidth").getInt("bandwidthValue"));
+ Assert.assertEquals("node1", node.getJSONObject("properties").getJSONObject("description").getString("descriptionValue"));
// Test delete nodeConnector property
// Delete state property of nodeconnector1
@Test
public void testStatistics() throws JSONException {
- String actionTypes[] = { "drop", "loopback", "flood", "floodAll", "controller", "swPath", "hwPath", "output",
+ final String actionTypes[] = { "drop", "loopback", "flood", "floodAll", "controller", "swPath", "hwPath", "output",
"setDlSrc", "setDlDst", "setDlType", "setVlanId", "setVlanPcp", "setVlanCfi", "popVlan", "pushVlan",
"setNwSrc", "setNwDst", "setNwTos", "setTpSrc", "setTpDst" };
System.out.println("Starting Statistics JAXB client.");
for (int i = 0; i < flowStats.length(); i++) {
JSONObject flowStat = flowStats.getJSONObject(i);
- testFlowStat(flowStat, actionTypes[i]);
+ testFlowStat(flowStat, actionTypes[i], i);
}
flowStats = json.getJSONArray("flowStat");
for (int i = 0; i < flowStats.length(); i++) {
JSONObject flowStat = flowStats.getJSONObject(i);
- testFlowStat(flowStat, actionTypes[i]);
+ testFlowStat(flowStat, actionTypes[i], i);
}
result = getJsonResult(baseURL + "portstats/STUB/51966");
Assert.assertTrue(portStat.getInt("collisionCount") == 4);
}
- private void testFlowStat(JSONObject flowStat, String actionType) throws JSONException {
+ private void testFlowStat(JSONObject flowStat, String actionType, int actIndex) throws JSONException {
Assert.assertTrue(flowStat.getInt("tableId") == 1);
Assert.assertTrue(flowStat.getInt("durationSeconds") == 40);
Assert.assertTrue(flowStat.getInt("durationNanoseconds") == 400);
// test that flow information is correct
JSONObject flow = flowStat.getJSONObject("flow");
- Assert.assertTrue(flow.getInt("priority") == 3500);
+ Assert.assertTrue(flow.getInt("priority") == (3500 + actIndex));
Assert.assertTrue(flow.getInt("idleTimeout") == 1000);
Assert.assertTrue(flow.getInt("hardTimeout") == 2000);
Assert.assertTrue(flow.getInt("id") == 12345);
mavenBundle("org.opendaylight.controller", "protocol_plugins.stub", "0.4.0-SNAPSHOT"),
// List all the opendaylight modules
+ mavenBundle("org.opendaylight.controller", "configuration", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "configuration.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "containermanager", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "containermanager.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "clustering.services", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "clustering.services-implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "security", "0.4.0-SNAPSHOT").noStart(),
mavenBundle("org.opendaylight.controller", "sal", "0.5.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "sal.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "statisticsmanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "statisticsmanager.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "containermanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "containermanager.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "sal.connection", "0.1.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "sal.connection.implementation", "0.1.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "switchmanager", "0.5.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "connectionmanager", "0.1.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "connectionmanager.implementation", "0.1.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "switchmanager.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "forwardingrulesmanager", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "forwardingrulesmanager.implementation", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "statisticsmanager", "0.4.0-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller", "statisticsmanager.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "arphandler", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.services", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "clustering.services-implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "switchmanager.implementation", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration", "0.4.0-SNAPSHOT"),
- mavenBundle("org.opendaylight.controller", "configuration.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "hosttracker", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "hosttracker.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "arphandler", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "routing.dijkstra_implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "topologymanager", "0.4.0-SNAPSHOT"),
-
mavenBundle("org.opendaylight.controller", "usermanager", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "usermanager.implementation", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "logging.bridge", "0.4.0-SNAPSHOT"),
mavenBundle("org.opendaylight.controller", "clustering.test", "0.4.0-SNAPSHOT"),
-
mavenBundle("org.opendaylight.controller", "forwarding.staticrouting", "0.4.0-SNAPSHOT"),
// Northbound bundles
mavenBundle("commons-codec", "commons-codec"),
mavenBundle("virgomirror", "org.eclipse.jdt.core.compiler.batch", "3.8.0.I20120518-2145"),
mavenBundle("eclipselink", "javax.persistence", "2.0.4.v201112161009"),
+ mavenBundle("eclipselink", "javax.resource", "1.5.0.v200906010428"),
mavenBundle("orbit", "javax.activation", "1.1.0.v201211130549"),
mavenBundle("orbit", "javax.annotation", "1.1.0.v201209060031"),