X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnorthbound%2Fintegrationtest%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnorthbound%2Fintegrationtest%2FNorthboundIT.java;h=59065fc7c11da8626ca486c1c399af1cdf5c173b;hb=8b921f98d7a20185646cb33be6d1fdb0e0874ba3;hp=f7ebfe438fb82f577581664301fa90b3a7f079ff;hpb=60e4c72f627ee42ef6fe06a39f217e9bd40165ec;p=controller.git diff --git a/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java index f7ebfe438f..59065fc7c1 100644 --- a/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java +++ b/opendaylight/northbound/integrationtest/src/test/java/org/opendaylight/controller/northbound/integrationtest/NorthboundIT.java @@ -189,6 +189,9 @@ public class NorthboundIT { } is.close(); connection.disconnect(); + if (debugMsg) { + System.out.println("Response : "+sb.toString()); + } return sb.toString(); } catch (Exception e) { return null; @@ -203,34 +206,47 @@ public class NorthboundIT { Assert.assertEquals(nodeId, (Integer) nodeInfo.getInt("id")); Assert.assertEquals(nodeType, nodeInfo.getString("type")); - JSONObject properties = node.getJSONObject("properties"); - - if (timestamp == null || timestampName == null) { - Assert.assertFalse(properties.has("timeStamp")); - } else { - Assert.assertEquals(timestamp, (Integer) properties.getJSONObject("timeStamp").getInt("value")); - Assert.assertEquals(timestampName, properties.getJSONObject("timeStamp").getString("name")); - } - if (actionsValue == null) { - Assert.assertFalse(properties.has("actions")); - } else { - Assert.assertEquals(actionsValue, (Integer) properties.getJSONObject("actions").getInt("value")); - } - if (capabilitiesValue == null) { - Assert.assertFalse(properties.has("capabilities")); - } else { - Assert.assertEquals(capabilitiesValue, - (Integer) properties.getJSONObject("capabilities").getInt("value")); - } - if (tablesValue == null) { - Assert.assertFalse(properties.has("tables")); - } else { - Assert.assertEquals(tablesValue, (Integer) properties.getJSONObject("tables").getInt("value")); - } - if (buffersValue == null) { - Assert.assertFalse(properties.has("buffers")); - } else { - Assert.assertEquals(buffersValue, (Integer) properties.getJSONObject("buffers").getInt("value")); + JSONArray propsArray = node.getJSONArray("properties"); + + for (int j = 0; j < propsArray.length(); j++) { + JSONObject properties = propsArray.getJSONObject(j); + String propName = properties.getString("name"); + if (propName.equals("timeStamp")) { + if (timestamp == null || timestampName == null) { + Assert.assertFalse("Timestamp exist", true); + } else { + Assert.assertEquals(timestamp, (Integer) properties.getInt("value")); + Assert.assertEquals(timestampName, properties.getString("timestampName")); + } + } + if (propName.equals("actions")) { + if (actionsValue == null) { + Assert.assertFalse("Actions exist", true); + } else { + Assert.assertEquals(actionsValue, (Integer) properties.getInt("value")); + } + } + if (propName.equals("capabilities")) { + if (capabilitiesValue == null) { + Assert.assertFalse("Capabilities exist", true); + } else { + Assert.assertEquals(capabilitiesValue, (Integer) properties.getInt("value")); + } + } + if (propName.equals("tables")) { + if (tablesValue == null) { + Assert.assertFalse("Tables exist", true); + } else { + Assert.assertEquals(tablesValue, (Integer) properties.getInt("value")); + } + } + if (propName.equals("buffers")) { + if (buffersValue == null) { + Assert.assertFalse("Buffers exist", true); + } else { + Assert.assertEquals(buffersValue, (Integer) properties.getInt("value")); + } + } } } @@ -240,35 +256,44 @@ public class NorthboundIT { JSONObject nodeConnector = nodeConnectorProperties.getJSONObject("nodeconnector"); 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")); - if (state == null) { - Assert.assertFalse(properties.has("state")); - } else { - Assert.assertEquals(state, (Integer) properties.getJSONObject("state").getInt("value")); - } - if (capabilities == null) { - Assert.assertFalse(properties.has("capabilities")); - } else { - Assert.assertEquals(capabilities, - (Integer) properties.getJSONObject("capabilities").getInt("value")); - } - if (bandwidth == null) { - Assert.assertFalse(properties.has("bandwidth")); - } else { - Assert.assertEquals(bandwidth, (Integer) properties.getJSONObject("bandwidth").getInt("value")); - } + JSONArray propsArray = nodeConnectorProperties.getJSONArray("properties"); + for (int j = 0; j < propsArray.length(); j++) { + JSONObject properties = propsArray.getJSONObject(j); + String propName = properties.getString("name"); + if (propName.equals("state")) { + if (state == null) { + Assert.assertFalse("State exist", true); + } else { + Assert.assertEquals(state, (Integer) properties.getInt("value")); + } + } + if (propName.equals("capabilities")) { + if (capabilities == null) { + Assert.assertFalse("Capabilities exist", true); + } else { + Assert.assertEquals(capabilities, (Integer) properties.getInt("value")); + } + } + if (propName.equals("bandwidth")) { + if (bandwidth == null) { + Assert.assertFalse("bandwidth exist", true); + } else { + Assert.assertEquals(bandwidth, (Integer) properties.getInt("value")); + } + } + } } @Test public void testSubnetsNorthbound() throws JSONException { System.out.println("Starting Subnets JAXB client."); - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnet/"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/subnetservice/"; String name1 = "testSubnet1"; String subnet1 = "1.1.1.1/24"; @@ -288,19 +313,20 @@ public class NorthboundIT { nodePortsJson3_1.append(nodePortsJson3).append(",").append(nodePortsJson2); // Test GET subnets in default container - String result = getJsonResult(baseURL + "default/subnet/all"); + String result = getJsonResult(baseURL + "default/subnets"); JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); - Assert.assertEquals("{}", result); + JSONArray subnetConfigs = json.getJSONArray("subnetConfig"); + Assert.assertEquals(subnetConfigs.length(), 0); // Test GET subnet1 expecting 404 result = getJsonResult(baseURL + "default/subnet/" + name1); Assert.assertEquals(404, httpResponseCode.intValue()); // Test POST subnet1 - JSONObject jo = new JSONObject().append("name", name1).append("subnet", subnet1); + JSONObject jo = new JSONObject().put("name", name1).put("subnet", subnet1); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name1, "POST", jo.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name1, "PUT", jo.toString()); Assert.assertTrue(httpResponseCode == 201); // Test GET subnet1 @@ -312,33 +338,33 @@ public class NorthboundIT { Assert.assertEquals(subnet1, json.getString("subnet")); // Test POST subnet2 - JSONObject jo2 = new JSONObject().append("name", name2).append("subnet", subnet2); + JSONObject jo2 = new JSONObject().put("name", name2).put("subnet", subnet2); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name2, "POST", jo2.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name2, "PUT", 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()); + result = getJsonResult(baseURL + "default/subnet/" + name2 + "/nodePorts", "PUT", jo2.toString()); Assert.assertEquals(200, httpResponseCode.intValue()); // Test POST subnet3 - JSONObject jo3 = new JSONObject().append("name", name3).append("subnet", subnet3); + JSONObject jo3 = new JSONObject().put("name", name3).put("subnet", subnet3); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "default/subnet/" + name3, "POST", jo3.toString()); + result = getJsonResult(baseURL + "default/subnet/" + name3, "PUT", 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()); + result = getJsonResult(baseURL + "default/subnet/" + name3 + "/nodePorts", "PUT", 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()); + result = getJsonResult(baseURL + "default/subnet/" + name3 + "/nodePorts", "POST", jo3.toString()); Assert.assertEquals(200, httpResponseCode.intValue()); // Test GET all subnets in default container - result = getJsonResult(baseURL + "default/subnet/all"); + result = getJsonResult(baseURL + "default/subnets"); jt = new JSONTokener(result); json = new JSONObject(jt); JSONArray subnetConfigArray = json.getJSONArray("subnetConfig"); @@ -350,14 +376,14 @@ public class NorthboundIT { 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(","); + String[] nodePortsGet2 = subnetConfig.getJSONArray("nodePorts").getString(0).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(","); + String[] nodePortsGet = subnetConfig.getJSONArray("nodePorts").getString(0).split(","); Assert.assertEquals(nodePorts3[0], nodePortsGet[0]); Assert.assertEquals(nodePorts3[1], nodePortsGet[1]); Assert.assertEquals(nodePorts3[2], nodePortsGet[2]); @@ -393,27 +419,28 @@ public class NorthboundIT { String nextHop2 = "1.1.1.1"; // Test GET static routes in default container, expecting no results - String result = getJsonResult(baseURL + "default"); + String result = getJsonResult(baseURL + "default/routes"); JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); - Assert.assertEquals("{}", result); + JSONArray staticRoutes = json.getJSONArray("staticRoute"); + Assert.assertEquals(staticRoutes.length(), 0); // Test insert static route String requestBody = "{\"name\":\"" + name1 + "\", \"prefix\":\"" + prefix1 + "\", \"nextHop\":\"" + nextHop1 + "\"}"; - result = getJsonResult(baseURL + "default/route/" + name1, "POST", requestBody); + result = getJsonResult(baseURL + "default/route/" + name1, "PUT", requestBody); Assert.assertEquals(201, httpResponseCode.intValue()); requestBody = "{\"name\":\"" + name2 + "\", \"prefix\":\"" + prefix2 + "\", \"nextHop\":\"" + nextHop2 + "\"}"; - result = getJsonResult(baseURL + "default/route/" + name2, "POST", requestBody); + result = getJsonResult(baseURL + "default/route/" + name2, "PUT", requestBody); Assert.assertEquals(201, httpResponseCode.intValue()); // Test Get all static routes - result = getJsonResult(baseURL + "default"); + result = getJsonResult(baseURL + "default/routes"); jt = new JSONTokener(result); json = new JSONObject(jt); - JSONArray staticRoutes = json.getJSONArray("staticRoute"); - Assert.assertEquals(2, staticRoutes.length()); + JSONArray staticRouteArray = json.getJSONArray("staticRoute"); + Assert.assertEquals(2, staticRouteArray.length()); JSONObject route; for (int i = 0; i < staticRoutes.length(); i++) { route = staticRoutes.getJSONObject(i); @@ -448,12 +475,14 @@ public class NorthboundIT { // Test delete static route result = getJsonResult(baseURL + "default/route/" + name1, "DELETE"); - Assert.assertEquals(200, httpResponseCode.intValue()); + Assert.assertEquals(204, httpResponseCode.intValue()); - result = getJsonResult(baseURL + "default"); + result = getJsonResult(baseURL + "default/routes"); jt = new JSONTokener(result); json = new JSONObject(jt); - JSONObject singleStaticRoute = json.getJSONObject("staticRoute"); + + staticRouteArray = json.getJSONArray("staticRoute"); + JSONObject singleStaticRoute = staticRouteArray.getJSONObject(0); Assert.assertEquals(name2, singleStaticRoute.getString("name")); } @@ -461,7 +490,7 @@ public class NorthboundIT { @Test public void testSwitchManager() throws JSONException { System.out.println("Starting SwitchManager JAXB client."); - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switch/default/"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/switchmanager/default/"; // define Node/NodeConnector attributes for test int nodeId_1 = 51966; @@ -511,7 +540,8 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_1); jt = new JSONTokener(result); json = new JSONObject(jt); - JSONObject nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + JSONArray nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + JSONObject nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1, ncType, nodeId_1, nodeType, ncState, ncCapabilities, ncBandwidth); @@ -520,7 +550,10 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_2); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); + testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState, ncCapabilities, ncBandwidth); @@ -530,7 +563,8 @@ public class NorthboundIT { jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_3, ncType, nodeId_3, nodeType, ncState, ncCapabilities, ncBandwidth); @@ -547,19 +581,31 @@ public class NorthboundIT { json = new JSONObject(jt); node = getJsonInstance(json, "nodeProperties", nodeId_1); Assert.assertNotNull(node); - Assert.assertEquals(1001, node.getJSONObject("properties").getJSONObject("tier").getInt("value")); - Assert.assertEquals("node1", node.getJSONObject("properties").getJSONObject("description").getString("value")); + + JSONArray propsArray = node.getJSONArray("properties"); + + for (int j = 0; j < propsArray.length(); j++) { + JSONObject properties = propsArray.getJSONObject(j); + String propName = properties.getString("name"); + if (propName.equals("tier")) { + Assert.assertEquals(1001, properties.getInt("value")); + } + if (propName.equals("description")) { + Assert.assertEquals("node1", properties.getString("value")); + } + } // Test delete nodeConnector property // Delete state property of nodeconnector1 result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_1 + "/STUB/" + nodeConnectorId_1 + "/property/state", "DELETE"); - Assert.assertEquals(200, httpResponseCode.intValue()); + Assert.assertEquals(204, httpResponseCode.intValue()); result = getJsonResult(baseURL + "node/STUB/" + nodeId_1); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_1, ncType, nodeId_1, nodeType, null, ncCapabilities, ncBandwidth); @@ -567,12 +613,13 @@ public class NorthboundIT { // Delete capabilities property of nodeconnector2 result = getJsonResult(baseURL + "nodeconnector/STUB/" + nodeId_2 + "/STUB/" + nodeConnectorId_2 + "/property/capabilities", "DELETE"); - Assert.assertEquals(200, httpResponseCode.intValue()); + Assert.assertEquals(204, httpResponseCode.intValue()); result = getJsonResult(baseURL + "node/STUB/" + nodeId_2); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); testNodeConnectorProperties(nodeConnectorProperties, nodeConnectorId_2, ncType, nodeId_2, nodeType, ncState, null, ncBandwidth); @@ -588,7 +635,8 @@ public class NorthboundIT { result = getJsonResult(baseURL + "node/STUB/" + nodeId_1); jt = new JSONTokener(result); json = new JSONObject(jt); - nodeConnectorProperties = json.getJSONObject("nodeConnectorProperties"); + nodeConnectorPropertiesArray = json.getJSONArray("nodeConnectorProperties"); + nodeConnectorProperties = nodeConnectorPropertiesArray.getJSONObject(0); // Check for new bandwidth value, state value removed from previous // test @@ -599,9 +647,9 @@ public class NorthboundIT { @Test public void testStatistics() throws JSONException { - final String actionTypes[] = { "drop", "loopback", "flood", "floodAll", "controller", "swPath", "hwPath", "output", - "setDlSrc", "setDlDst", "setDlType", "setVlanId", "setVlanPcp", "setVlanCfi", "popVlan", "pushVlan", - "setNwSrc", "setNwDst", "setNwTos", "setTpSrc", "setTpDst" }; + final String actionTypes[] = { "DROP", "LOOPBACK", "FLOOD", "FLOOD_ALL", "CONTROLLER", "SW_PATH", "HW_PATH", "OUTPUT", + "SET_DL_SRC", "SET_DL_DST", "SET_DL_TYPE", "SET_VLAN_ID", "SET_VLAN_PCP", "SET_VLAN_CFI", "POP_VLAN", "PUSH_VLAN", + "SET_NW_SRC", "SET_NW_DST", "SET_NW_TOS", "SET_TP_SRC", "SET_TP_DST" }; System.out.println("Starting Statistics JAXB client."); String baseURL = "http://127.0.0.1:8080/controller/nb/v2/statistics/default/"; @@ -635,7 +683,8 @@ public class NorthboundIT { Assert.assertEquals(node2.getString("type"), "STUB"); // test that port statistic results are correct - JSONObject portStat = portStatistics.getJSONObject("portStatistic"); + JSONArray portStatArray = portStatistics.getJSONArray("portStatistic"); + JSONObject portStat = portStatArray.getJSONObject(0); Assert.assertTrue(portStat.getInt("receivePackets") == 250); Assert.assertTrue(portStat.getInt("transmitPackets") == 500); Assert.assertTrue(portStat.getInt("receiveBytes") == 1000); @@ -674,7 +723,9 @@ public class NorthboundIT { Assert.assertEquals(node2.getString("type"), "STUB"); // test that port statistic results are correct - portStat = json.getJSONObject("portStatistic"); + portStatArray = json.getJSONArray("portStatistic"); + portStat = portStatArray.getJSONObject(0); + Assert.assertTrue(portStat.getInt("receivePackets") == 250); Assert.assertTrue(portStat.getInt("transmitPackets") == 500); Assert.assertTrue(portStat.getInt("receiveBytes") == 1000); @@ -703,14 +754,18 @@ public class NorthboundIT { Assert.assertTrue(flow.getInt("hardTimeout") == 2000); Assert.assertTrue(flow.getInt("id") == 12345); - JSONObject match = (flow.getJSONObject("match").getJSONObject("matchField")); + JSONArray matches = (flow.getJSONObject("match").getJSONArray("matchField")); + Assert.assertEquals(matches.length(), 1); + JSONObject match = matches.getJSONObject(0); Assert.assertTrue(match.getString("type").equals("NW_DST")); Assert.assertTrue(match.getString("value").equals("1.1.1.1")); - JSONObject act = flow.getJSONObject("actions"); - Assert.assertTrue(act.getString("@type").equals(actionType)); + JSONArray actionsArray = flow.getJSONArray("actions"); + Assert.assertEquals(actionsArray.length(), 1); + JSONObject act = actionsArray.getJSONObject(0); + Assert.assertTrue(act.getString("type").equals(actionType)); - if (act.getString("@type").equals("output")) { + if (act.getString("type").equals("OUTPUT")) { JSONObject port = act.getJSONObject("port"); JSONObject port_node = port.getJSONObject("node"); Assert.assertTrue(port.getInt("id") == 51966); @@ -719,7 +774,7 @@ public class NorthboundIT { Assert.assertTrue(port_node.getString("type").equals("STUB")); } - if (act.getString("@type").equals("setDlSrc")) { + if (act.getString("type").equals("SET_DL_SRC")) { byte srcMatch[] = { (byte) 5, (byte) 4, (byte) 3, (byte) 2, (byte) 1 }; String src = act.getString("address"); byte srcBytes[] = new byte[5]; @@ -731,7 +786,7 @@ public class NorthboundIT { Assert.assertTrue(Arrays.equals(srcBytes, srcMatch)); } - if (act.getString("@type").equals("setDlDst")) { + if (act.getString("type").equals("SET_DL_DST")) { byte dstMatch[] = { (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 }; String dst = act.getString("address"); byte dstBytes[] = new byte[5]; @@ -742,21 +797,21 @@ public class NorthboundIT { dstBytes[4] = Byte.parseByte(dst.substring(8, 10)); Assert.assertTrue(Arrays.equals(dstBytes, dstMatch)); } - if (act.getString("@type").equals("setDlType")) + if (act.getString("type").equals("SET_DL_TYPE")) Assert.assertTrue(act.getInt("dlType") == 10); - if (act.getString("@type").equals("setVlanId")) + if (act.getString("type").equals("SET_VLAN_ID")) Assert.assertTrue(act.getInt("vlanId") == 2); - if (act.getString("@type").equals("setVlanPcp")) + if (act.getString("type").equals("SET_VLAN_PCP")) Assert.assertTrue(act.getInt("pcp") == 3); - if (act.getString("@type").equals("setVlanCfi")) + if (act.getString("type").equals("SET_VLAN_CFI")) Assert.assertTrue(act.getInt("cfi") == 1); - if (act.getString("@type").equals("setNwSrc")) + if (act.getString("type").equals("SET_NW_SRC")) Assert.assertTrue(act.getString("address").equals("2.2.2.2")); - if (act.getString("@type").equals("setNwDst")) + if (act.getString("type").equals("SET_NW_DST")) Assert.assertTrue(act.getString("address").equals("1.1.1.1")); - if (act.getString("@type").equals("pushVlan")) { + if (act.getString("type").equals("PUSH_VLAN")) { int head = act.getInt("VlanHeader"); // parsing vlan header int id = head & 0xfff; @@ -768,53 +823,54 @@ public class NorthboundIT { Assert.assertTrue(pcp == 1); Assert.assertTrue(tag == 0x8100); } - if (act.getString("@type").equals("setNwTos")) + if (act.getString("type").equals("SET_NW_TOS")) Assert.assertTrue(act.getInt("tos") == 16); - if (act.getString("@type").equals("setTpSrc")) + if (act.getString("type").equals("SET_TP_SRC")) Assert.assertTrue(act.getInt("port") == 4201); - if (act.getString("@type").equals("setTpDst")) + if (act.getString("type").equals("SET_TP_DST")) Assert.assertTrue(act.getInt("port") == 8080); } @Test public void testFlowProgrammer() throws JSONException { System.out.println("Starting FlowProgrammer JAXB client."); - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flow/default/"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/flowprogrammer/default/"; // Attempt to get a flow that doesn't exit. Should return 404 // status. - String result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET"); + String result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/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 + "node/STUB/51966/static-flow/test1", "PUT", fc); + String fc = "{\"name\":\"test1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "PUT", fc); Assert.assertTrue(httpResponseCode == 201); // test get returns flow that was added. - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test1", "GET"); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "GET"); // check that result came out fine. Assert.assertTrue(httpResponseCode == 200); JSONTokener jt = new JSONTokener(result); JSONObject json = new JSONObject(jt); Assert.assertEquals(json.getString("name"), "test1"); - Assert.assertEquals(json.getString("actions"), "DROP"); + JSONArray actionsArray = json.getJSONArray("actions"); + Assert.assertEquals(actionsArray.getString(0), "DROP"); Assert.assertEquals(json.getString("installInHw"), "true"); JSONObject node = json.getJSONObject("node"); 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 + "node/STUB/51966/static-flow/test1", "PUT", fc); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test1", "PUT", fc); Assert.assertTrue(result.equals("409")); - fc = "{\"dynamic\":\"false\", \"name\":\"test2\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "PUT", fc); + fc = "{\"name\":\"test2\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/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 + "node/STUB/51966/static-flow/test2", "PUT", fc); + fc = "{\"name\":\"test2\", \"nwSrc\":\"1.1.1.1\", \"node\":{\"id\":\"51966\",\"type\":\"STUB\"}, \"actions\":[\"DROP\"]}"; + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "PUT", fc); Assert.assertTrue(httpResponseCode == 201); // check that request returns both flows given node. @@ -836,10 +892,10 @@ public class NorthboundIT { Assert.assertTrue(count == 2); // delete a flow, check that it's no longer in list. - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "DELETE"); - Assert.assertTrue(httpResponseCode == 200); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "DELETE"); + Assert.assertTrue(httpResponseCode == 204); - result = getJsonResult(baseURL + "node/STUB/51966/static-flow/test2", "GET"); + result = getJsonResult(baseURL + "node/STUB/51966/staticFlow/test2", "GET"); Assert.assertTrue(result.equals("404")); } @@ -914,7 +970,7 @@ public class NorthboundIT { Integer nodeConnectorId_2 = 34; String vlan_2 = "123"; - String baseURL = "http://127.0.0.1:8080/controller/nb/v2/host/default"; + String baseURL = "http://127.0.0.1:8080/controller/nb/v2/hosttracker/default"; // test PUT method: addHost() JSONObject fc_json = new JSONObject(); @@ -927,7 +983,7 @@ public class NorthboundIT { fc_json.put("staticHost", "true"); fc_json.put("networkAddress", networkAddress_1); - String result = getJsonResult(baseURL + "/" + networkAddress_1, "PUT", fc_json.toString()); + String result = getJsonResult(baseURL + "/address/" + networkAddress_1, "PUT", fc_json.toString()); Assert.assertTrue(httpResponseCode == 201); fc_json = new JSONObject(); @@ -940,7 +996,7 @@ public class NorthboundIT { fc_json.put("staticHost", "true"); fc_json.put("networkAddress", networkAddress_2); - result = getJsonResult(baseURL + "/" + networkAddress_2 , "PUT", fc_json.toString()); + result = getJsonResult(baseURL + "/address/" + networkAddress_2 , "PUT", fc_json.toString()); Assert.assertTrue(httpResponseCode == 201); // define variables for decoding returned strings @@ -949,7 +1005,7 @@ public class NorthboundIT { // the two hosts should be in inactive host DB // test GET method: getInactiveHosts() - result = getJsonResult(baseURL + "/inactive", "GET"); + result = getJsonResult(baseURL + "/hosts/inactive", "GET"); Assert.assertTrue(httpResponseCode == 200); JSONTokener jt = new JSONTokener(result); @@ -985,7 +1041,7 @@ public class NorthboundIT { } // test GET method: getActiveHosts() - no host expected - result = getJsonResult(baseURL, "GET"); + result = getJsonResult(baseURL + "/hosts/active", "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1007,7 +1063,7 @@ public class NorthboundIT { // verify the host shows up in active host DB - result = getJsonResult(baseURL, "GET"); + result = getJsonResult(baseURL + "/hosts/active", "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1017,7 +1073,7 @@ public class NorthboundIT { // test GET method for getHostDetails() - result = getJsonResult(baseURL + "/" + networkAddress_1, "GET"); + result = getJsonResult(baseURL + "/address/" + networkAddress_1, "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1035,13 +1091,13 @@ public class NorthboundIT { // test DELETE method for deleteFlow() - result = getJsonResult(baseURL + "/" + networkAddress_1, "DELETE"); + result = getJsonResult(baseURL + "/address/" + networkAddress_1, "DELETE"); Assert.assertTrue(httpResponseCode == 204); // verify host_1 removed from active host DB // test GET method: getActiveHosts() - no host expected - result = getJsonResult(baseURL, "GET"); + result = getJsonResult(baseURL + "/hosts/active", "GET"); Assert.assertTrue(httpResponseCode == 200); jt = new JSONTokener(result); @@ -1132,10 +1188,20 @@ public class NorthboundIT { JSONObject headNC = edge.getJSONObject("headNodeConnector"); JSONObject headNode = headNC.getJSONObject("node"); - JSONObject Props = edgeProp.getJSONObject("properties"); - JSONObject bandw = Props.getJSONObject("bandwidth"); - JSONObject stt = Props.getJSONObject("state"); - JSONObject ltc = Props.getJSONObject("latency"); + + JSONArray propsArray = edgeProp.getJSONArray("properties"); + + JSONObject bandw = null; + JSONObject stt = null; + JSONObject ltc = null; + + for (int j = 0; j < propsArray.length(); j++) { + JSONObject props = propsArray.getJSONObject(j); + String propName = props.getString("name"); + if (propName.equals("bandwidth")) bandw = props; + if (propName.equals("state")) stt = props; + if (propName.equals("latency")) ltc = props; + } if (headNC.getInt("id") == headNC1_nodeConnId) { Assert.assertEquals(headNode.getString("type"), nodeType); @@ -1174,17 +1240,17 @@ public class NorthboundIT { Integer nodeConnectorId_2 = 34; JSONObject jo = new JSONObject() - .append("name", "userLink_1") - .append("srcNodeConnector", + .put("name", "userLink_1") + .put("srcNodeConnector", nodeConnectorType_1 + "|" + nodeConnectorId_1 + "@" + nodeType_1 + "|" + nodeId_1) - .append("dstNodeConnector", + .put("dstNodeConnector", nodeConnectorType_2 + "|" + nodeConnectorId_2 + "@" + nodeType_2 + "|" + nodeId_2); // execute HTTP request and verify response code - result = getJsonResult(baseURL + "/user-link", "PUT", jo.toString()); + result = getJsonResult(baseURL + "/userLink/userLink_1", "PUT", jo.toString()); Assert.assertTrue(httpResponseCode == 201); // === test GET method for getUserLinks() - result = getJsonResult(baseURL + "/user-link", "GET"); + result = getJsonResult(baseURL + "/userLinks", "GET"); Assert.assertTrue(httpResponseCode == 200); if (debugMsg) { System.out.println("result:" + result); @@ -1229,12 +1295,12 @@ public class NorthboundIT { // === test DELETE method for deleteUserLink() String userName = "userLink_1"; - result = getJsonResult(baseURL + "/user-link/" + userName, "DELETE"); - Assert.assertTrue(httpResponseCode == 200); + result = getJsonResult(baseURL + "/userLink/" + userName, "DELETE"); + Assert.assertTrue(httpResponseCode == 204); // execute another getUserLinks() request to verify that userLink_1 is // removed - result = getJsonResult(baseURL + "/user-link", "GET"); + result = getJsonResult(baseURL + "/userLinks", "GET"); Assert.assertTrue(httpResponseCode == 200); if (debugMsg) { System.out.println("result:" + result); @@ -1289,7 +1355,7 @@ public class NorthboundIT { mavenBundle("org.opendaylight.controller", "configuration").versionAsInProject(), mavenBundle("org.opendaylight.controller", "configuration.implementation").versionAsInProject(), mavenBundle("org.opendaylight.controller", "containermanager").versionAsInProject(), - mavenBundle("org.opendaylight.controller", "containermanager.implementation").versionAsInProject(), + mavenBundle("org.opendaylight.controller", "containermanager.it.implementation").versionAsInProject(), mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(), mavenBundle("org.opendaylight.controller", "clustering.services-implementation").versionAsInProject(), mavenBundle("org.opendaylight.controller", "security").versionAsInProject().noStart(), @@ -1331,6 +1397,7 @@ public class NorthboundIT { mavenBundle("org.codehaus.jackson", "jackson-mapper-asl").versionAsInProject(), mavenBundle("org.codehaus.jackson", "jackson-core-asl").versionAsInProject(), mavenBundle("org.codehaus.jackson", "jackson-jaxrs").versionAsInProject(), + mavenBundle("org.codehaus.jackson", "jackson-xc").versionAsInProject(), mavenBundle("org.codehaus.jettison", "jettison").versionAsInProject(), mavenBundle("commons-io", "commons-io").versionAsInProject(),