Search in sources :

Example 96 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkTopologyManagerTest method testIsBroadcastUsingNullConnectPoint.

/**
 * Test isBroadcastPoint() method using a null connect point.
 */
@Test(expected = NullPointerException.class)
public void testIsBroadcastUsingNullConnectPoint() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    // test the isInfrastructure() method using a null connect point.
    Boolean isInfrastructure = topologyService.isBroadcastPoint(topology, null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 97 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkWebResourceTest method testGetVirtualNetworksByTenantId.

/**
 * Tests the result of the REST API GET for virtual networks with tenant id.
 */
@Test
public void testGetVirtualNetworksByTenantId() {
    final Set<VirtualNetwork> vnetSet = ImmutableSet.of(vnet1, vnet2, vnet3, vnet4);
    expect(mockVnetAdminService.getTenantIds()).andReturn(ImmutableSet.of(tenantId3)).anyTimes();
    replay(mockVnetAdminService);
    expect(mockVnetService.getVirtualNetworks(tenantId3)).andReturn(vnetSet).anyTimes();
    replay(mockVnetService);
    WebTarget wt = target();
    String response = wt.path("vnets/" + tenantId3.id()).request().get(String.class);
    assertThat(response, containsString("{\"vnets\":["));
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, notNullValue());
    assertThat(result.names(), hasSize(1));
    assertThat(result.names().get(0), is("vnets"));
    final JsonArray vnetJsonArray = result.get("vnets").asArray();
    assertThat(vnetJsonArray, notNullValue());
    assertEquals("Virtual networks array is not the correct size.", vnetSet.size(), vnetJsonArray.size());
    vnetSet.forEach(vnet -> assertThat(vnetJsonArray, hasVnet(vnet)));
    verify(mockVnetService);
    verify(mockVnetAdminService);
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) JsonArray(com.eclipsesource.json.JsonArray) JsonObject(com.eclipsesource.json.JsonObject) WebTarget(javax.ws.rs.client.WebTarget) Matchers.containsString(org.hamcrest.Matchers.containsString) LinksResourceTest(org.onosproject.rest.resources.LinksResourceTest) ResourceTest(org.onosproject.rest.resources.ResourceTest) HostResourceTest(org.onosproject.rest.resources.HostResourceTest) Test(org.junit.Test)

Example 98 with VirtualNetwork

use of org.onosproject.incubator.net.virtual.VirtualNetwork in project onos by opennetworkinglab.

the class VirtualNetworkWebResourceTest method testGetVirtualNetworksArray.

/**
 * Tests the result of the REST API GET when virtual networks are defined.
 */
@Test
public void testGetVirtualNetworksArray() {
    final Set<VirtualNetwork> vnetSet = ImmutableSet.of(vnet1, vnet2, vnet3, vnet4);
    expect(mockVnetAdminService.getTenantIds()).andReturn(ImmutableSet.of(tenantId3)).anyTimes();
    replay(mockVnetAdminService);
    expect(mockVnetService.getVirtualNetworks(tenantId3)).andReturn(vnetSet).anyTimes();
    replay(mockVnetService);
    WebTarget wt = target();
    String response = wt.path("vnets").request().get(String.class);
    assertThat(response, containsString("{\"vnets\":["));
    final JsonObject result = Json.parse(response).asObject();
    assertThat(result, notNullValue());
    assertThat(result.names(), hasSize(1));
    assertThat(result.names().get(0), is("vnets"));
    final JsonArray vnetJsonArray = result.get("vnets").asArray();
    assertThat(vnetJsonArray, notNullValue());
    assertEquals("Virtual networks array is not the correct size.", vnetSet.size(), vnetJsonArray.size());
    vnetSet.forEach(vnet -> assertThat(vnetJsonArray, hasVnet(vnet)));
    verify(mockVnetService);
    verify(mockVnetAdminService);
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) JsonArray(com.eclipsesource.json.JsonArray) JsonObject(com.eclipsesource.json.JsonObject) WebTarget(javax.ws.rs.client.WebTarget) Matchers.containsString(org.hamcrest.Matchers.containsString) LinksResourceTest(org.onosproject.rest.resources.LinksResourceTest) ResourceTest(org.onosproject.rest.resources.ResourceTest) HostResourceTest(org.onosproject.rest.resources.HostResourceTest) Test(org.junit.Test)

Aggregations

VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)98 Test (org.junit.Test)82 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)38 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)24 ConnectPoint (org.onosproject.net.ConnectPoint)24 TopologyService (org.onosproject.net.topology.TopologyService)24 Topology (org.onosproject.net.topology.Topology)23 DeviceService (org.onosproject.net.device.DeviceService)15 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 DisjointPath (org.onosproject.net.DisjointPath)11 LinkService (org.onosproject.net.link.LinkService)10 ArrayList (java.util.ArrayList)8 HostService (org.onosproject.net.host.HostService)8 TenantId (org.onosproject.net.TenantId)7 Path (org.onosproject.net.Path)6 PathService (org.onosproject.net.topology.PathService)5 TopologyCluster (org.onosproject.net.topology.TopologyCluster)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)4 Link (org.onosproject.net.Link)4