use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testDeleteVirtualLink.
/**
* Tests removing a virtual link with DELETE request.
*/
@Test
public void testDeleteVirtualLink() {
NetworkId networkId = networkId3;
mockVnetAdminService.removeVirtualLink(networkId, cp22, cp11);
expectLastCall();
replay(mockVnetAdminService);
WebTarget wt = target().property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
InputStream jsonStream = VirtualNetworkWebResourceTest.class.getResourceAsStream("post-virtual-link.json");
String reqLocation = "vnets/" + networkId.toString() + "/links";
Response response = wt.path(reqLocation).request().method("DELETE", Entity.json(jsonStream));
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 testPostVirtualPortNullJsonStream.
/**
* Tests adding of a null virtual port using POST via JSON stream.
*/
@Test
public void testPostVirtualPortNullJsonStream() {
NetworkId networkId = networkId3;
DeviceId deviceId = devId2;
replay(mockVnetAdminService);
WebTarget wt = target();
try {
String reqLocation = "vnets/" + networkId.toString() + "/devices/" + deviceId.toString() + "/ports";
wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(null), String.class);
fail("POST of null virtual port 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 testPostVirtualPort.
/**
* Tests adding of new virtual port using POST via JSON stream.
*/
@Test
public void testPostVirtualPort() {
NetworkId networkId = networkId3;
DeviceId deviceId = devId22;
DefaultAnnotations annotations = DefaultAnnotations.builder().build();
Device physDevice = new DefaultDevice(null, DeviceId.deviceId("dev1"), null, null, null, null, null, null, annotations);
ConnectPoint cp1 = new ConnectPoint(physDevice.id(), portNumber(1));
expect(mockVnetAdminService.createVirtualPort(networkId, deviceId, portNumber(22), cp1)).andReturn(vport22);
replay(mockVnetAdminService);
WebTarget wt = target();
InputStream jsonStream = VirtualNetworkWebResourceTest.class.getResourceAsStream("post-virtual-port.json");
String reqLocation = "vnets/" + networkId.toString() + "/devices/" + deviceId.toString() + "/ports";
Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(jsonStream));
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));
verify(mockVnetAdminService);
}
use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testPostVirtualDevice.
/**
* Tests adding of new virtual device using POST via JSON stream.
*/
@Test
public void testPostVirtualDevice() {
NetworkId networkId = networkId3;
DeviceId deviceId = devId2;
expect(mockVnetAdminService.createVirtualDevice(networkId, deviceId)).andReturn(vdev2);
expectLastCall();
replay(mockVnetAdminService);
WebTarget wt = target();
InputStream jsonStream = VirtualNetworkWebResourceTest.class.getResourceAsStream("post-virtual-device.json");
String reqLocation = "vnets/" + networkId.toString() + "/devices";
Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(jsonStream));
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));
String location = response.getLocation().getPath();
assertThat(location, Matchers.startsWith("/" + reqLocation + "/" + vdev2.id().toString()));
verify(mockVnetAdminService);
}
use of org.onosproject.incubator.net.virtual.NetworkId in project onos by opennetworkinglab.
the class VirtualNetworkWebResourceTest method testPostVirtualLink.
/**
* Tests adding of new virtual link using POST via JSON stream.
*/
@Test
public void testPostVirtualLink() {
NetworkId networkId = networkId3;
expect(mockVnetAdminService.createVirtualLink(networkId, cp22, cp11)).andReturn(vlink1);
replay(mockVnetAdminService);
WebTarget wt = target();
InputStream jsonStream = VirtualNetworkWebResourceTest.class.getResourceAsStream("post-virtual-link.json");
String reqLocation = "vnets/" + networkId.toString() + "/links";
Response response = wt.path(reqLocation).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(jsonStream));
assertThat(response.getStatus(), is(HttpURLConnection.HTTP_CREATED));
String location = response.getLocation().getPath();
assertThat(location, Matchers.startsWith("/" + reqLocation));
verify(mockVnetAdminService);
}
Aggregations