Integer buffersValue) throws JSONException {
JSONObject nodeInfo = node.getJSONObject("node");
- Assert.assertEquals(nodeId, (Integer) nodeInfo.getInt("@id"));
- Assert.assertEquals(nodeType, nodeInfo.getString("@type"));
+ Assert.assertEquals(nodeId, (Integer) nodeInfo.getInt("id"));
+ Assert.assertEquals(nodeType, nodeInfo.getString("type"));
JSONObject properties = node.getJSONObject("properties");
JSONObject node = nodeConnector.getJSONObject("node");
JSONObject properties = nodeConnectorProperties.getJSONObject("properties");
- Assert.assertEquals(ncId, (Integer) nodeConnector.getInt("@id"));
- Assert.assertEquals(ncType, nodeConnector.getString("@type"));
- Assert.assertEquals(nodeId, (Integer) node.getInt("@id"));
- Assert.assertEquals(nodeType, node.getString("@type"));
+ Assert.assertEquals(ncId, (Integer) nodeConnector.getInt("id"));
+ Assert.assertEquals(ncType, nodeConnector.getString("type"));
+ Assert.assertEquals(nodeId, (Integer) node.getInt("id"));
+ Assert.assertEquals(nodeType, node.getString("type"));
if (state == null) {
Assert.assertFalse(properties.has("state"));
} else {
String name1 = "testSubnet1";
String subnet1 = "1.1.1.1/24";
+
String name2 = "testSubnet2";
String subnet2 = "2.2.2.2/24";
+ String[] nodePorts2 = {"2/1", "2/2", "2/3", "2/4"};
+ StringBuilder nodePortsJson2 = new StringBuilder();
+ nodePortsJson2.append(nodePorts2[0] + "," + nodePorts2[1] + "," + nodePorts2[2] + "," + nodePorts2[3]);
+
+ String name3 = "testSubnet3";
+ String subnet3 = "3.3.3.3/24";
+ String[] nodePorts3 = {"3/1", "3/2", "3/3"};
+ StringBuilder nodePortsJson3 = new StringBuilder();
+ nodePortsJson3.append(nodePorts3[0] + "," + nodePorts3[1] + "," + nodePorts3[2]);
+ StringBuilder nodePortsJson3_1 = new StringBuilder();
+ nodePortsJson3_1.append(nodePortsJson3).append(",").append(nodePortsJson2);
// Test GET subnets in default container
- String result = getJsonResult(baseURL + "default");
+ String result = getJsonResult(baseURL + "default/subnet/all");
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
Assert.assertEquals("{}", result);
// Test GET subnet1 expecting 404
- result = getJsonResult(baseURL + "default/" + name1);
+ result = getJsonResult(baseURL + "default/subnet/" + name1);
Assert.assertEquals(404, httpResponseCode.intValue());
// Test POST subnet1
- String queryParameter = new QueryParameter("subnetName", name1).add("subnet", subnet1).getString();
- result = getJsonResult(baseURL + "default/" + name1 + queryParameter, "POST");
- Assert.assertEquals(201, httpResponseCode.intValue());
+ JSONObject jo = new JSONObject().append("name", name1).append("subnet", subnet1);
+ // execute HTTP request and verify response code
+ result = getJsonResult(baseURL + "default/subnet/" + name1, "POST", jo.toString());
+ Assert.assertTrue(httpResponseCode == 201);
// Test GET subnet1
- result = getJsonResult(baseURL + "default/" + name1);
+ result = getJsonResult(baseURL + "default/subnet/" + name1);
jt = new JSONTokener(result);
json = new JSONObject(jt);
Assert.assertEquals(200, httpResponseCode.intValue());
- Assert.assertEquals(name1, json.getString("@name"));
- Assert.assertEquals(subnet1, json.getString("@subnet"));
+ Assert.assertEquals(name1, json.getString("name"));
+ Assert.assertEquals(subnet1, json.getString("subnet"));
// Test POST subnet2
- queryParameter = new QueryParameter("subnetName", name2).add("subnet", subnet2).getString();
- result = getJsonResult(baseURL + "default/" + name2 + queryParameter, "POST");
+ JSONObject jo2 = new JSONObject().append("name", name2).append("subnet", subnet2);
+ // execute HTTP request and verify response code
+ result = getJsonResult(baseURL + "default/subnet/" + name2, "POST", jo2.toString());
+ Assert.assertEquals(201, httpResponseCode.intValue());
+ // Test POST nodePorts
+ jo2.append("nodePorts", nodePortsJson2);
+ // execute HTTP request and verify response code
+ result = getJsonResult(baseURL + "default/subnet/" + name2 + "/node-ports", "POST", jo2.toString());
+ Assert.assertEquals(200, httpResponseCode.intValue());
+ // Test POST subnet3
+ JSONObject jo3 = new JSONObject().append("name", name3).append("subnet", subnet3);
+ // execute HTTP request and verify response code
+ result = getJsonResult(baseURL + "default/subnet/" + name3, "POST", jo3.toString());
Assert.assertEquals(201, httpResponseCode.intValue());
+ // Test POST nodePorts
+ jo3.append("nodePorts", nodePortsJson3);
+ // execute HTTP request and verify response code
+ result = getJsonResult(baseURL + "default/subnet/" + name3 + "/node-ports", "POST", jo3.toString());
+ Assert.assertEquals(200, httpResponseCode.intValue());
+ // Test PUT nodePorts
+ jo3.remove("nodePorts");
+ jo3.append("nodePorts", nodePortsJson3_1);
+ result = getJsonResult(baseURL + "default/subnet/" + name3 + "/node-ports", "PUT", jo3.toString());
+ Assert.assertEquals(200, httpResponseCode.intValue());
// Test GET all subnets in default container
- result = getJsonResult(baseURL + "default");
+ result = getJsonResult(baseURL + "default/subnet/all");
jt = new JSONTokener(result);
json = new JSONObject(jt);
JSONArray subnetConfigArray = json.getJSONArray("subnetConfig");
JSONObject subnetConfig;
- Assert.assertEquals(2, subnetConfigArray.length());
+ Assert.assertEquals(3, subnetConfigArray.length());
for (int i = 0; i < subnetConfigArray.length(); i++) {
subnetConfig = subnetConfigArray.getJSONObject(i);
- if (subnetConfig.getString("@name").equals(name1)) {
- Assert.assertEquals(subnet1, subnetConfig.getString("@subnet"));
- } else if (subnetConfig.getString("@name").equals(name2)) {
- Assert.assertEquals(subnet2, subnetConfig.getString("@subnet"));
+ if (subnetConfig.getString("name").equals(name1)) {
+ Assert.assertEquals(subnet1, subnetConfig.getString("subnet"));
+ } else if (subnetConfig.getString("name").equals(name2)) {
+ Assert.assertEquals(subnet2, subnetConfig.getString("subnet"));
+ String[] nodePortsGet2 = subnetConfig.getString("nodePorts").split(",");
+ Assert.assertEquals(nodePorts2[0], nodePortsGet2[0]);
+ Assert.assertEquals(nodePorts2[1], nodePortsGet2[1]);
+ Assert.assertEquals(nodePorts2[2], nodePortsGet2[2]);
+ Assert.assertEquals(nodePorts2[3], nodePortsGet2[3]);
+ } else if (subnetConfig.getString("name").equals(name3)) {
+ Assert.assertEquals(subnet3, subnetConfig.getString("subnet"));
+ String[] nodePortsGet = subnetConfig.getString("nodePorts").split(",");
+ Assert.assertEquals(nodePorts3[0], nodePortsGet[0]);
+ Assert.assertEquals(nodePorts3[1], nodePortsGet[1]);
+ Assert.assertEquals(nodePorts3[2], nodePortsGet[2]);
+ Assert.assertEquals(nodePorts2[0], nodePortsGet[3]);
+ Assert.assertEquals(nodePorts2[1], nodePortsGet[4]);
+ Assert.assertEquals(nodePorts2[2], nodePortsGet[5]);
+ Assert.assertEquals(nodePorts2[3], nodePortsGet[6]);
} else {
// Unexpected config name
Assert.assertTrue(false);
}
// Test DELETE subnet1
- result = getJsonResult(baseURL + "default/" + name1, "DELETE");
- Assert.assertEquals(200, httpResponseCode.intValue());
+ result = getJsonResult(baseURL + "default/subnet/" + name1, "DELETE");
+ Assert.assertEquals(204, httpResponseCode.intValue());
// Test GET deleted subnet1
- result = getJsonResult(baseURL + "default/" + name1);
+ result = getJsonResult(baseURL + "default/subnet/" + name1);
Assert.assertEquals(404, httpResponseCode.intValue());
-
- }
+ }
@Test
public void testStaticRoutingNorthbound() throws JSONException {
// Test insert static route
String requestBody = "{\"name\":\"" + name1 + "\", \"prefix\":\"" + prefix1 + "\", \"nextHop\":\"" + nextHop1
+ "\"}";
- result = getJsonResult(baseURL + "default/" + name1, "POST", requestBody);
+ result = getJsonResult(baseURL + "default/route/" + name1, "POST", requestBody);
Assert.assertEquals(201, httpResponseCode.intValue());
requestBody = "{\"name\":\"" + name2 + "\", \"prefix\":\"" + prefix2 + "\", \"nextHop\":\"" + nextHop2 + "\"}";
- result = getJsonResult(baseURL + "default/" + name2, "POST", requestBody);
+ result = getJsonResult(baseURL + "default/route/" + name2, "POST", requestBody);
Assert.assertEquals(201, httpResponseCode.intValue());
// Test Get all static routes
}
// Test get specific static route
- result = getJsonResult(baseURL + "default/" + name1);
+ result = getJsonResult(baseURL + "default/route/" + name1);
jt = new JSONTokener(result);
json = new JSONObject(jt);
Assert.assertEquals(prefix1, json.getString("prefix"));
Assert.assertEquals(nextHop1, json.getString("nextHop"));
- result = getJsonResult(baseURL + "default/" + name2);
+ result = getJsonResult(baseURL + "default/route/" + name2);
jt = new JSONTokener(result);
json = new JSONObject(jt);
Assert.assertEquals(nextHop2, json.getString("nextHop"));
// Test delete static route
- result = getJsonResult(baseURL + "default/" + name1, "DELETE");
+ result = getJsonResult(baseURL + "default/route/" + name1, "DELETE");
Assert.assertEquals(200, httpResponseCode.intValue());
result = getJsonResult(baseURL + "default");
JSONObject flowStatistics = getJsonInstance(json, "flowStatistics", 0xCAFE);
JSONObject node = flowStatistics.getJSONObject("node");
// test that node was returned properly
- Assert.assertTrue(node.getInt("@id") == 0xCAFE);
- Assert.assertEquals(node.getString("@type"), "STUB");
+ Assert.assertTrue(node.getInt("id") == 0xCAFE);
+ Assert.assertEquals(node.getString("type"), "STUB");
// test that flow statistics results are correct
JSONArray flowStats = flowStatistics.getJSONArray("flowStatistic");
JSONObject portStatistics = getJsonInstance(json, "portStatistics", 0xCAFE);
JSONObject node2 = portStatistics.getJSONObject("node");
// test that node was returned properly
- Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
- Assert.assertEquals(node2.getString("@type"), "STUB");
+ Assert.assertTrue(node2.getInt("id") == 0xCAFE);
+ Assert.assertEquals(node2.getString("type"), "STUB");
// test that port statistic results are correct
JSONObject portStat = portStatistics.getJSONObject("portStatistic");
json = new JSONObject(jt);
node = json.getJSONObject("node");
// test that node was returned properly
- Assert.assertTrue(node.getInt("@id") == 0xCAFE);
- Assert.assertEquals(node.getString("@type"), "STUB");
+ Assert.assertTrue(node.getInt("id") == 0xCAFE);
+ Assert.assertEquals(node.getString("type"), "STUB");
// test that flow statistics results are correct
flowStats = json.getJSONArray("flowStatistic");
json = new JSONObject(jt);
node2 = json.getJSONObject("node");
// test that node was returned properly
- Assert.assertTrue(node2.getInt("@id") == 0xCAFE);
- Assert.assertEquals(node2.getString("@type"), "STUB");
+ Assert.assertTrue(node2.getInt("id") == 0xCAFE);
+ Assert.assertEquals(node2.getString("type"), "STUB");
// test that port statistic results are correct
portStat = json.getJSONObject("portStatistic");
if (act.getString("@type").equals("output")) {
JSONObject port = act.getJSONObject("port");
JSONObject port_node = port.getJSONObject("node");
- Assert.assertTrue(port.getInt("@id") == 51966);
- Assert.assertTrue(port.getString("@type").equals("STUB"));
- Assert.assertTrue(port_node.getInt("@id") == 51966);
- Assert.assertTrue(port_node.getString("@type").equals("STUB"));
+ Assert.assertTrue(port.getInt("id") == 51966);
+ Assert.assertTrue(port.getString("type").equals("STUB"));
+ Assert.assertTrue(port_node.getInt("id") == 51966);
+ Assert.assertTrue(port_node.getString("type").equals("STUB"));
}
if (act.getString("@type").equals("setDlSrc")) {
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/";
// Attempt to get a flow that doesn't exit. Should return 404
// status.
- String result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ String result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET");
Assert.assertTrue(result.equals("404"));
// test add flow1
- String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ String fc = "{\"dynamic\":\"false\", \"name\":\"test1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc);
Assert.assertTrue(httpResponseCode == 201);
// test get returns flow that was added.
- result = getJsonResult(baseURL + "STUB/51966/test1", "GET");
+ result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET");
// check that result came out fine.
Assert.assertTrue(httpResponseCode == 200);
JSONTokener jt = new JSONTokener(result);
Assert.assertEquals(json.getString("actions"), "DROP");
Assert.assertEquals(json.getString("installInHw"), "true");
JSONObject node = json.getJSONObject("node");
- Assert.assertEquals(node.getString("@type"), "STUB");
- Assert.assertEquals(node.getString("@id"), "51966");
+ Assert.assertEquals(node.getString("type"), "STUB");
+ Assert.assertEquals(node.getString("id"), "51966");
// test adding same flow again fails due to repeat name..return 409
// code
- result = getJsonResult(baseURL + "STUB/51966/test1", "POST", fc);
+ result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "PUT", fc);
Assert.assertTrue(result.equals("409"));
- fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
- // test should return 500 for error due to same flow being added.
- Assert.assertTrue(result.equals("500"));
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc);
+ // test should return 409 for error due to same flow being added.
+ Assert.assertTrue(result.equals("409"));
// add second flow that's different
- fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"@id\":\"51966\",\"@type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
- result = getJsonResult(baseURL + "STUB/51966/test2", "POST", fc);
+ fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}";
+ result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc);
Assert.assertTrue(httpResponseCode == 201);
// check that request returns both flows given node.
- result = getJsonResult(baseURL + "STUB/51966/", "GET");
+ result = getJsonResult(baseURL + "node/STUB/51966/", "GET");
jt = new JSONTokener(result);
json = new JSONObject(jt);
Assert.assertTrue(json.get("flowConfig") instanceof JSONArray);
Assert.assertTrue(count == 2);
// delete a flow, check that it's no longer in list.
- result = getJsonResult(baseURL + "STUB/51966/test2", "DELETE");
+ result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "DELETE");
Assert.assertTrue(httpResponseCode == 200);
- result = getJsonResult(baseURL + "STUB/51966/test2", "GET");
+ result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "GET");
Assert.assertTrue(result.equals("404"));
}
JSONArray json_array = json.getJSONArray(array_name);
for (int i = 0; i < json_array.length(); i++) {
result = json_array.getJSONObject(i);
- Integer nid = result.getJSONObject("node").getInt("@id");
+ Integer nid = result.getJSONObject("node").getInt("id");
if (nid.equals(nodeId))
break;
}
} else {
result = json.getJSONObject(array_name);
- Integer nid = result.getJSONObject("node").getInt("@id");
+ Integer nid = result.getJSONObject("node").getInt("id");
if (!nid.equals(nodeId))
result = null;
}
Integer nodeId_1 = 3366;
String nodeConnectorType_1 = "STUB";
Integer nodeConnectorId_1 = 12;
- String vlan_1 = "4";
+ String vlan_1 = "";
// 2nd host
String networkAddress_2 = "10.1.1.1";
Integer nodeId_2 = 4477;
String nodeConnectorType_2 = "STUB";
Integer nodeConnectorId_2 = 34;
- String vlan_2 = "0";
+ String vlan_2 = "123";
String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default";
- // test POST method: addHost()
- String queryParameter = new QueryParameter("dataLayerAddress", dataLayerAddress_1).add("nodeType", nodeType_1)
- .add("nodeId", nodeId_1.toString()).add("nodeConnectorType", nodeConnectorType_1)
- .add("nodeConnectorId", nodeConnectorId_1.toString()).add("vlan", vlan_1).getString();
-
- String result = getJsonResult(baseURL + "/" + networkAddress_1 + queryParameter, "POST");
+ // test PUT method: addHost()
+ JSONObject fc_json = new JSONObject();
+ fc_json.put("dataLayerAddress", dataLayerAddress_1);
+ fc_json.put("nodeType", nodeType_1);
+ fc_json.put("nodeId", nodeId_1);
+ fc_json.put("nodeConnectorType", nodeType_1);
+ fc_json.put("nodeConnectorId", nodeConnectorId_1.toString());
+ fc_json.put("vlan", vlan_1);
+ fc_json.put("staticHost", "true");
+ fc_json.put("networkAddress", networkAddress_1);
+
+ String result = getJsonResult(baseURL + "/" + networkAddress_1, "PUT", fc_json.toString());
Assert.assertTrue(httpResponseCode == 201);
- // vlan is not passed through query parameter but should be
- // defaulted to "0"
- queryParameter = new QueryParameter("dataLayerAddress", dataLayerAddress_2).add("nodeType", nodeType_2)
- .add("nodeId", nodeId_2.toString()).add("nodeConnectorType", nodeConnectorType_2)
- .add("nodeConnectorId", nodeConnectorId_2.toString()).getString();
-
- result = getJsonResult(baseURL + "/" + networkAddress_2 + queryParameter, "POST");
+ fc_json = new JSONObject();
+ fc_json.put("dataLayerAddress", dataLayerAddress_2);
+ fc_json.put("nodeType", nodeType_2);
+ fc_json.put("nodeId", nodeId_2);
+ fc_json.put("nodeConnectorType", nodeType_2);
+ fc_json.put("nodeConnectorId", nodeConnectorId_2.toString());
+ fc_json.put("vlan", vlan_2);
+ fc_json.put("staticHost", "true");
+ fc_json.put("networkAddress", networkAddress_2);
+
+ result = getJsonResult(baseURL + "/" + networkAddress_2 , "PUT", fc_json.toString());
Assert.assertTrue(httpResponseCode == 201);
// define variables for decoding returned strings
JSONTokener jt = new JSONTokener(result);
JSONObject json = new JSONObject(jt);
// there should be at least two hosts in the DB
- Assert.assertTrue(json.get("host") instanceof JSONArray);
- JSONArray ja = json.getJSONArray("host");
+ Assert.assertTrue(json.get("hostConfig") instanceof JSONArray);
+ JSONArray ja = json.getJSONArray("hostConfig");
Integer count = ja.length();
Assert.assertTrue(count == 2);
for (int i = 0; i < count; i++) {
host_jo = ja.getJSONObject(i);
- dl_jo = host_jo.getJSONObject("dataLayerAddress");
- nc_jo = host_jo.getJSONObject("nodeConnector");
- node_jo = nc_jo.getJSONObject("node");
-
networkAddress = host_jo.getString("networkAddress");
if (networkAddress.equalsIgnoreCase(networkAddress_1)) {
- Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_1));
- Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_1));
- Assert.assertTrue(nc_jo.getInt("@id") == nodeConnectorId_1);
- Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(nodeType_1));
- Assert.assertTrue(node_jo.getInt("@id") == nodeId_1);
- Assert.assertTrue(host_jo.getString("vlan").equalsIgnoreCase(vlan_1));
+ Assert.assertTrue(host_jo.getString("dataLayerAddress").equalsIgnoreCase(dataLayerAddress_1));
+ Assert.assertTrue(host_jo.getString("nodeConnectorType").equalsIgnoreCase(nodeConnectorType_1));
+ Assert.assertTrue(host_jo.getInt("nodeConnectorId") == nodeConnectorId_1);
+ Assert.assertTrue(host_jo.getString("nodeType").equalsIgnoreCase(nodeType_1));
+ Assert.assertTrue(host_jo.getInt("nodeId") == nodeId_1);
+ Assert.assertTrue(host_jo.getString("vlan").equals("0"));
+ Assert.assertTrue(host_jo.getBoolean("staticHost"));
} else if (networkAddress.equalsIgnoreCase(networkAddress_2)) {
- Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_2));
- Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_2));
- Assert.assertTrue(nc_jo.getInt("@id") == nodeConnectorId_2);
- Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(nodeType_2));
- Assert.assertTrue(node_jo.getInt("@id") == nodeId_2);
+ Assert.assertTrue(host_jo.getString("dataLayerAddress").equalsIgnoreCase(dataLayerAddress_2));
+ Assert.assertTrue(host_jo.getString("nodeConnectorType").equalsIgnoreCase(nodeConnectorType_2));
+ Assert.assertTrue(host_jo.getInt("nodeConnectorId") == nodeConnectorId_2);
+ Assert.assertTrue(host_jo.getString("nodeType").equalsIgnoreCase(nodeType_2));
+ Assert.assertTrue(host_jo.getInt("nodeId") == nodeId_2);
Assert.assertTrue(host_jo.getString("vlan").equalsIgnoreCase(vlan_2));
+ Assert.assertTrue(host_jo.getBoolean("staticHost"));
} else {
Assert.assertTrue(false);
}
Assert.assertFalse(json.length() == 0);
- dl_jo = json.getJSONObject("dataLayerAddress");
- nc_jo = json.getJSONObject("nodeConnector");
- node_jo = nc_jo.getJSONObject("node");
-
- Assert.assertTrue(json.getString("networkAddress").equalsIgnoreCase(networkAddress_1));
- Assert.assertTrue(dl_jo.getString("macAddress").equalsIgnoreCase(dataLayerAddress_1));
- Assert.assertTrue(nc_jo.getString("@type").equalsIgnoreCase(nodeConnectorType_1));
- Assert.assertTrue(Integer.parseInt(nc_jo.getString("@id")) == nodeConnectorId_1);
- Assert.assertTrue(node_jo.getString("@type").equalsIgnoreCase(nodeType_1));
- Assert.assertTrue(Integer.parseInt(node_jo.getString("@id")) == nodeId_1);
- Assert.assertTrue(json.getString("vlan").equalsIgnoreCase(vlan_1));
+ Assert.assertTrue(json.getString("dataLayerAddress").equalsIgnoreCase(dataLayerAddress_1));
+ Assert.assertTrue(json.getString("nodeConnectorType").equalsIgnoreCase(nodeConnectorType_1));
+ Assert.assertTrue(json.getInt("nodeConnectorId") == nodeConnectorId_1);
+ Assert.assertTrue(json.getString("nodeType").equalsIgnoreCase(nodeType_1));
+ Assert.assertTrue(json.getInt("nodeId") == nodeId_1);
+ Assert.assertTrue(json.getString("vlan").equals("0"));
+ Assert.assertTrue(json.getBoolean("staticHost"));
// test DELETE method for deleteFlow()
result = getJsonResult(baseURL + "/" + networkAddress_1, "DELETE");
- Assert.assertTrue(httpResponseCode == 200);
+ Assert.assertTrue(httpResponseCode == 204);
// verify host_1 removed from active host DB
// test GET method: getActiveHosts() - no host expected
if (json.length() == 0) {
return false;
}
- if (json.get("host") instanceof JSONArray) {
- JSONArray ja = json.getJSONArray("host");
+ if (json.get("hostConfig") instanceof JSONArray) {
+ JSONArray ja = json.getJSONArray("hostConfig");
for (int i = 0; i < ja.length(); i++) {
String na = ja.getJSONObject(i).getString("networkAddress");
if (na.equalsIgnoreCase(hostIp))
}
return false;
} else {
- String na = json.getJSONObject("host").getString("networkAddress");
+ JSONObject ja = json.getJSONObject("hostConfig");
+ String na = ja.getString("networkAddress");
return (na.equalsIgnoreCase(hostIp)) ? true : false;
}
}
JSONObject stt = Props.getJSONObject("state");
JSONObject ltc = Props.getJSONObject("latency");
- if (headNC.getInt("@id") == headNC1_nodeConnId) {
- Assert.assertEquals(headNode.getString("@type"), nodeType);
- Assert.assertEquals(headNode.getLong("@id"), headNC1_nodeId);
- Assert.assertEquals(headNC.getString("@type"), nodeConnType);
- Assert.assertEquals(tailNode.getString("@type"),nodeType);
- Assert.assertEquals(tailNode.getString("@type"), nodeConnType);
- Assert.assertEquals(tailNC.getLong("@id"), tailNC1_nodeConnId);
+ if (headNC.getInt("id") == headNC1_nodeConnId) {
+ Assert.assertEquals(headNode.getString("type"), nodeType);
+ Assert.assertEquals(headNode.getLong("id"), headNC1_nodeId);
+ Assert.assertEquals(headNC.getString("type"), nodeConnType);
+ Assert.assertEquals(tailNode.getString("type"),nodeType);
+ Assert.assertEquals(tailNode.getString("type"), nodeConnType);
+ Assert.assertEquals(tailNC.getLong("id"), tailNC1_nodeConnId);
Assert.assertEquals(bandw.getLong("value"), bw_1);
Assert.assertTrue((short) stt.getInt("value") == state_1);
Assert.assertEquals(ltc.getLong("value"), lat_1);
- } else if (headNC.getInt("@id") == headNC2_nodeConnId) {
- Assert.assertEquals(headNode.getString("@type"),nodeType);
- Assert.assertEquals(headNode.getLong("@id"), headNC2_nodeId);
- Assert.assertEquals(headNC.getString("@type"), nodeConnType);
- Assert.assertEquals(tailNode.getString("@type"), nodeType);
- Assert.assertTrue(tailNode.getInt("@id") == tailNC2_nodeId);
- Assert.assertEquals(tailNC.getString("@type"), nodeConnType);
- Assert.assertEquals(tailNC.getLong("@id"), tailNC2_nodeConnId);
+ } else if (headNC.getInt("id") == headNC2_nodeConnId) {
+ Assert.assertEquals(headNode.getString("type"),nodeType);
+ Assert.assertEquals(headNode.getLong("id"), headNC2_nodeId);
+ Assert.assertEquals(headNC.getString("type"), nodeConnType);
+ Assert.assertEquals(tailNode.getString("type"), nodeType);
+ Assert.assertTrue(tailNode.getInt("id") == tailNC2_nodeId);
+ Assert.assertEquals(tailNC.getString("type"), nodeConnType);
+ Assert.assertEquals(tailNC.getLong("id"), tailNC2_nodeConnId);
Assert.assertEquals(bandw.getLong("value"), bw_2);
Assert.assertTrue((short) stt.getInt("value") == state_2);
Assert.assertEquals(ltc.getLong("value"), lat_2);
.append("dstNodeConnector",
nodeConnectorType_2 + "|" + nodeConnectorId_2 + "@" + nodeType_2 + "|" + nodeId_2);
// execute HTTP request and verify response code
- result = getJsonResult(baseURL + "/user-link", "POST", jo.toString());
+ result = getJsonResult(baseURL + "/user-link", "PUT", jo.toString());
Assert.assertTrue(httpResponseCode == 201);
// === test GET method for getUserLinks()
mavenBundle("org.ow2.chameleon.management", "chameleon-mbeans", "1.0.0"),
mavenBundle("org.opendaylight.controller.thirdparty", "net.sf.jung2", "2.0.1-SNAPSHOT"),
mavenBundle("org.opendaylight.controller.thirdparty", "com.sun.jersey.jersey-servlet", "1.17-SNAPSHOT"),
+ mavenBundle("org.opendaylight.controller.thirdparty", "org.apache.catalina.filters.CorsFilter",
+ "7.0.42-SNAPSHOT").noStart(),
// Jersey needs to be started before the northbound application
// bundles, using a lower start level