本文整理汇总了Java中org.onosproject.incubator.net.virtual.NetworkId.toString方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkId.toString方法的具体用法?Java NetworkId.toString怎么用?Java NetworkId.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.incubator.net.virtual.NetworkId
的用法示例。
在下文中一共展示了NetworkId.toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPostVirtualDevice
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例2: testPostVirtualDeviceNullJsonStream
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例3: testDeleteVirtualDevice
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例4: testGetVirtualPortsEmptyArray
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Tests the result of the REST API GET when there are no virtual ports.
*/
@Test
public void testGetVirtualPortsEmptyArray() {
NetworkId networkId = networkId4;
DeviceId deviceId = devId2;
expect(mockVnetService.getVirtualPorts(networkId, deviceId))
.andReturn(ImmutableSet.of()).anyTimes();
replay(mockVnetService);
WebTarget wt = target();
String location = "vnets/" + networkId.toString()
+ "/devices/" + deviceId.toString() + "/ports";
String response = wt.path(location).request().get(String.class);
assertThat(response, is("{\"ports\":[]}"));
verify(mockVnetService);
}
示例5: testPostVirtualPort
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
Port port1 = new DefaultPort(physDevice, portNumber(1), true);
expect(mockVnetAdminService.createVirtualPort(networkId, deviceId, portNumber(22), port1))
.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);
}
示例6: testPostVirtualPortNullJsonStream
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例7: testDeleteVirtualPort
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例8: testPostVirtualLink
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例9: testPostVirtualLinkNullJsonStream
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Tests adding of a null virtual link using POST via JSON stream.
*/
@Test
public void testPostVirtualLinkNullJsonStream() {
NetworkId networkId = networkId3;
replay(mockVnetAdminService);
WebTarget wt = target();
try {
String reqLocation = "vnets/" + networkId.toString() + "/links";
wt.path(reqLocation)
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.json(null), String.class);
fail("POST of null virtual link did not throw an exception");
} catch (BadRequestException ex) {
assertThat(ex.getMessage(), containsString("HTTP 400 Bad Request"));
}
verify(mockVnetAdminService);
}
示例10: testDeleteVirtualLink
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例11: testPostVirtualPort
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例12: testPostVirtualHost
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Tests adding of new virtual host using POST via JSON stream.
*/
@Test
public void testPostVirtualHost() {
NetworkId networkId = networkId3;
expect(mockVnetAdminService.createVirtualHost(networkId, hId1, mac1, vlan1, loc1, ipSet1))
.andReturn(vhost1);
replay(mockVnetAdminService);
WebTarget wt = target();
InputStream jsonStream = VirtualNetworkWebResourceTest.class
.getResourceAsStream("post-virtual-host.json");
String reqLocation = "vnets/" + networkId.toString() + "/hosts";
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);
}
示例13: testPostVirtualHostNullJsonStream
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Tests adding of a null virtual host using POST via JSON stream.
*/
@Test
public void testPostVirtualHostNullJsonStream() {
NetworkId networkId = networkId3;
replay(mockVnetAdminService);
WebTarget wt = target();
try {
String reqLocation = "vnets/" + networkId.toString() + "/hosts";
wt.path(reqLocation)
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.json(null), String.class);
fail("POST of null virtual host did not throw an exception");
} catch (BadRequestException ex) {
assertThat(ex.getMessage(), containsString("HTTP 400 Bad Request"));
}
verify(mockVnetAdminService);
}
示例14: testDeleteVirtualHost
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* 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);
}
示例15: testGetVirtualDevicesEmptyArray
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Tests the result of the REST API GET when there are no virtual devices.
*/
@Test
public void testGetVirtualDevicesEmptyArray() {
NetworkId networkId = networkId4;
expect(mockVnetService.getVirtualDevices(networkId)).andReturn(ImmutableSet.of()).anyTimes();
replay(mockVnetService);
WebTarget wt = target();
String location = "vnets/" + networkId.toString() + "/devices";
String response = wt.path(location).request().get(String.class);
assertThat(response, is("{\"devices\":[]}"));
verify(mockVnetService);
}