use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testGetVirtualHostsEmptyArray.
// Tests for Virtual Hosts
/**
* Tests the result of the REST API GET when there are no virtual hosts.
*/
@Test
public void testGetVirtualHostsEmptyArray() {
NetworkId networkId = networkId4;
expect(mockVnetService.getVirtualHosts(networkId)).andReturn(ImmutableSet.of()).anyTimes();
replay(mockVnetService);
WebTarget wt = target();
String location = "vnets/" + networkId.toString() + "/hosts";
String response = wt.path(location).request().get(String.class);
assertThat(response, is("{\"hosts\":[]}"));
verify(mockVnetService);
}
use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testDeleteVirtualDevice.
/**
* Tests removing a virtual device with DELETE request.
*/
@Test
public void testDeleteVirtualDevice() {
NetworkId networkId = networkId3;
DeviceId deviceId = devId2;
mockVnetAdminService.removeVirtualDevice(networkId, deviceId);
expectLastCall();
replay(mockVnetAdminService);
WebTarget wt = target().property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
String reqLocation = "vnets/" + networkId.toString() + "/devices/" + deviceId.toString();
Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).delete();
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
verify(mockVnetAdminService);
}
use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testPostVirtualDeviceNullJsonStream.
/**
* Tests adding of a null virtual device using POST via JSON stream.
*/
@Test
public void testPostVirtualDeviceNullJsonStream() {
NetworkId networkId = networkId3;
replay(mockVnetAdminService);
WebTarget wt = target();
try {
String reqLocation = "vnets/" + networkId.toString() + "/devices";
wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(null), String.class);
fail("POST of null virtual device did not throw an exception");
} catch (BadRequestException ex) {
assertThat(ex.getMessage(), containsString("HTTP 400 Bad Request"));
}
verify(mockVnetAdminService);
}
use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testDeleteVirtualPort.
/**
* Tests removing a virtual port with DELETE request.
*/
@Test
public void testDeleteVirtualPort() {
NetworkId networkId = networkId3;
DeviceId deviceId = devId2;
PortNumber portNum = portNumber(2);
mockVnetAdminService.removeVirtualPort(networkId, deviceId, portNum);
expectLastCall();
replay(mockVnetAdminService);
WebTarget wt = target().property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
String reqLocation = "vnets/" + networkId.toString() + "/devices/" + deviceId.toString() + "/ports/" + portNum.toLong();
Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).delete();
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
verify(mockVnetAdminService);
}
use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testDeleteVirtualHost.
/**
* Tests removing a virtual host with DELETE request.
*/
@Test
public void testDeleteVirtualHost() {
NetworkId networkId = networkId3;
mockVnetAdminService.removeVirtualHost(networkId, hId1);
expectLastCall();
replay(mockVnetAdminService);
WebTarget wt = target().property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
InputStream jsonStream = VirtualNetworkWebResourceTest.class.getResourceAsStream("post-virtual-host.json");
String reqLocation = "vnets/" + networkId.toString() + "/hosts";
Response response = wt.path(reqLocation).request().method("DELETE", Entity.json(jsonStream));
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_NO_CONTENT));
verify(mockVnetAdminService);
}
Aggregations