[ONOS-7492] Add unit test for openstack router and subnet REST API
Change-Id: Icc6b1ce00e941b66c9027db7ec43b6568e323e76
diff --git a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java
index 0f6f729..8326f40 100644
--- a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java
+++ b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResource.java
@@ -15,7 +15,6 @@
*/
package org.onosproject.openstacknetworking.web;
-import org.onlab.osgi.DefaultServiceDirectory;
import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
import org.onosproject.rest.AbstractWebResource;
import org.openstack4j.openstack.networking.domain.NeutronRouter;
@@ -55,7 +54,7 @@
private static final String ROUTERS = "routers";
private final OpenstackRouterAdminService adminService =
- DefaultServiceDirectory.getService(OpenstackRouterAdminService.class);
+ get(OpenstackRouterAdminService.class);
@Context
private UriInfo uriInfo;
@@ -148,7 +147,7 @@
@Path("{id}/remove_router_interface")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
- public Response removeRouterInterface(@PathParam("id") String id, InputStream input) {
+ public Response deleteRouterInterface(@PathParam("id") String id, InputStream input) {
log.trace(String.format(MESSAGE_ROUTER_IFACE, "DELETE " + id));
final NeutronRouterInterface osRouterIface = (NeutronRouterInterface)
diff --git a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java
index 79bc676..0c46bfc 100644
--- a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java
+++ b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResource.java
@@ -19,7 +19,6 @@
* Handles Rest API call from Neutron ML2 plugin.
*/
-import org.onlab.osgi.DefaultServiceDirectory;
import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
import org.onosproject.rest.AbstractWebResource;
import org.openstack4j.openstack.networking.domain.NeutronSubnet;
@@ -53,7 +52,7 @@
private static final String SUBNETS = "subnets";
private final OpenstackNetworkAdminService adminService =
- DefaultServiceDirectory.getService(OpenstackNetworkAdminService.class);
+ get(OpenstackNetworkAdminService.class);
@Context
private UriInfo uriInfo;
diff --git a/apps/openstacknetworking/src/test/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResourceTest.java b/apps/openstacknetworking/src/test/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResourceTest.java
new file mode 100644
index 0000000..d0a24b3
--- /dev/null
+++ b/apps/openstacknetworking/src/test/java/org/onosproject/openstacknetworking/web/OpenstackRouterWebResourceTest.java
@@ -0,0 +1,320 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknetworking.web;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.osgi.ServiceDirectory;
+import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackRouterAdminService;
+import org.onosproject.rest.resources.ResourceTest;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.InputStream;
+
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test for openstack router REST API.
+ */
+public class OpenstackRouterWebResourceTest extends ResourceTest {
+
+ final OpenstackRouterAdminService mockOpenstackRouterAdminService =
+ createMock(OpenstackRouterAdminService.class);
+ private static final String PATH = "routers";
+
+ /**
+ * Constructs an openstack router test instance.
+ */
+ public OpenstackRouterWebResourceTest() {
+ super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
+ }
+
+ /**
+ * Sets up the global values for all tests.
+ */
+ @Before
+ public void setUpTest() {
+ ServiceDirectory testDirectory =
+ new TestServiceDirectory()
+ .add(OpenstackRouterAdminService.class,
+ mockOpenstackRouterAdminService);
+ setServiceDirectory(testDirectory);
+ }
+
+ /**
+ * Tests the results of the REST API POST with creation operation.
+ */
+ @Test
+ public void testCreateRouterWithCreationOperation() {
+ mockOpenstackRouterAdminService.createRouter(anyObject());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router.json");
+
+ Response response = wt.path(PATH).request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(201));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API POST with incorrect input.
+ */
+ @Test
+ public void testCreateRouterWithIncorrectInput() {
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("dummy.json");
+
+ Response response = wt.path(PATH).request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+ }
+
+ /**
+ * Tests the results of the REST API POST with duplicated router ID.
+ */
+ @Test
+ public void testCreateRouterWithDuplicatedId() {
+ mockOpenstackRouterAdminService.createRouter(anyObject());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router.json");
+
+ Response response = wt.path(PATH).request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API PUT with updating operation.
+ */
+ @Test
+ public void testUpdateRouterWithUpdatingOperation() {
+ mockOpenstackRouterAdminService.updateRouter(anyObject());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router.json");
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(200));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API PUT with incorrect input.
+ */
+ @Test
+ public void testUpdateRouterWithIncorrectInput() {
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("dummy.json");
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+ }
+
+ /**
+ * Tests the results of the REST API PUT with non-existing router ID.
+ */
+ @Test
+ public void testUpdateRouterWithNonexistId() {
+ mockOpenstackRouterAdminService.updateRouter(anyObject());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router.json");
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API DELETE with deletion operation.
+ */
+ @Test
+ public void testDeleteRouterWithDeletionOperation() {
+ mockOpenstackRouterAdminService.removeRouter(anyString());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .delete();
+ final int status = response.getStatus();
+
+ assertThat(status, is(204));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API DELETE with non-existing router ID.
+ */
+ @Test
+ public void testDeleteRouterWithNonexistId() {
+ mockOpenstackRouterAdminService.removeRouter(anyString());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+
+ Response response = wt.path(PATH + "/non-exist-id")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .delete();
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API PUT with adding a new router interface.
+ */
+ @Test
+ public void testAddRouterInterfaceWithAdditionOperation() {
+ mockOpenstackRouterAdminService.addRouterInterface(anyObject());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router-interface.json");
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68/add_router_interface")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(200));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API PUT with non-existing router interface ID.
+ */
+ @Test
+ public void testAddRouterInterfaceWithNonexistId() {
+ mockOpenstackRouterAdminService.addRouterInterface(anyObject());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router-interface.json");
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68/add_router_interface")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API DELETE with deletion operation.
+ */
+ @Test
+ public void testDeleteRouterInterfaceWithDeletionOperation() {
+ mockOpenstackRouterAdminService.removeRouterInterface(anyString());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router-interface.json");
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68/remove_router_interface")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(200));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API DELETE with non-existing router interface ID.
+ */
+ @Test
+ public void testDeleteRouterInterfaceWithNonexistId() {
+ mockOpenstackRouterAdminService.removeRouterInterface(anyString());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackRouterAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackRouterWebResourceTest.class
+ .getResourceAsStream("openstack-router-interface.json");
+
+ Response response = wt.path(PATH + "/f49a1319-423a-4ee6-ba54-1d95a4f6cc68/remove_router_interface")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackRouterAdminService);
+ }
+}
diff --git a/apps/openstacknetworking/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResourceTest.java b/apps/openstacknetworking/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResourceTest.java
new file mode 100644
index 0000000..1dabccb
--- /dev/null
+++ b/apps/openstacknetworking/src/test/java/org/onosproject/openstacknetworking/web/OpenstackSubnetWebResourceTest.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.openstacknetworking.web;
+
+import org.glassfish.jersey.server.ResourceConfig;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.osgi.ServiceDirectory;
+import org.onlab.osgi.TestServiceDirectory;
+import org.onosproject.openstacknetworking.api.OpenstackNetworkAdminService;
+import org.onosproject.rest.resources.ResourceTest;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.io.InputStream;
+
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Unit test for openstack subnet REST API.
+ */
+public class OpenstackSubnetWebResourceTest extends ResourceTest {
+
+ final OpenstackNetworkAdminService mockOpenstackNetworkAdminService =
+ createMock(OpenstackNetworkAdminService.class);
+ private static final String PATH = "subnets";
+
+ /**
+ * Constructs an openstack subnet test instance.
+ */
+ public OpenstackSubnetWebResourceTest() {
+ super(ResourceConfig.forApplicationClass(OpenstackNetworkingWebApplication.class));
+ }
+
+ /**
+ * Sets up the global values for all tests.
+ */
+ @Before
+ public void setUpTest() {
+ ServiceDirectory testDirectory =
+ new TestServiceDirectory()
+ .add(OpenstackNetworkAdminService.class,
+ mockOpenstackNetworkAdminService);
+ setServiceDirectory(testDirectory);
+
+ }
+
+ /**
+ * Tests the results of the REST API POST with creation operation.
+ */
+ @Test
+ public void testCreateSubnetWithCreationOperation() {
+ mockOpenstackNetworkAdminService.createSubnet(anyObject());
+ replay(mockOpenstackNetworkAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackSubnetWebResourceTest.class
+ .getResourceAsStream("openstack-subnet.json");
+
+ Response response = wt.path(PATH).request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(201));
+
+ verify(mockOpenstackNetworkAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API POST with incorrect input.
+ */
+ @Test
+ public void testCreateSubnetWithIncorrectInput() {
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackSubnetWebResourceTest.class
+ .getResourceAsStream("dummy.json");
+
+ Response response = wt.path(PATH).request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+ }
+
+ /**
+ * Tests the results of the REST API POST with duplicated subnet ID.
+ */
+ @Test
+ public void testCreateSubnetWithDuplicatedId() {
+ mockOpenstackNetworkAdminService.createSubnet(anyObject());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackNetworkAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackSubnetWebResourceTest.class
+ .getResourceAsStream("openstack-subnet.json");
+
+ Response response = wt.path(PATH).request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackNetworkAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API PUT with updating operation.
+ */
+ @Test
+ public void testUpdateSubnetWithUpdatingOperation() {
+ mockOpenstackNetworkAdminService.updateSubnet(anyObject());
+ replay(mockOpenstackNetworkAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackSubnetWebResourceTest.class
+ .getResourceAsStream("openstack-subnet.json");
+
+ Response response = wt.path(PATH + "/d32019d3-bc6e-4319-9c1d-6722fc136a22")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(200));
+
+ verify(mockOpenstackNetworkAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API PUT with incorrect input.
+ */
+ @Test
+ public void testUpdateSubnetWithIncorrectInput() {
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackSubnetWebResourceTest.class
+ .getResourceAsStream("dummy.json");
+
+ Response response = wt.path(PATH + "/d32019d3-bc6e-4319-9c1d-6722fc136a22")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+ }
+
+ /**
+ * Tests the results of the REST API PUT with non-existing subnet ID.
+ */
+ @Test
+ public void testUpdateSubnetWithNonexistId() {
+ mockOpenstackNetworkAdminService.updateSubnet(anyObject());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackNetworkAdminService);
+
+ final WebTarget wt = target();
+ InputStream jsonStream = OpenstackSubnetWebResourceTest.class
+ .getResourceAsStream("openstack-subnet.json");
+
+ Response response = wt.path(PATH + "/non-exist-id")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .put(Entity.json(jsonStream));
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackNetworkAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API DELETE with deletion operation.
+ */
+ @Test
+ public void testDeleteSubnetWithDeletionOperation() {
+ mockOpenstackNetworkAdminService.removeSubnet(anyString());
+ replay(mockOpenstackNetworkAdminService);
+
+ final WebTarget wt = target();
+
+ Response response = wt.path(PATH + "/d32019d3-bc6e-4319-9c1d-6722fc136a22")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .delete();
+ final int status = response.getStatus();
+
+ assertThat(status, is(204));
+
+ verify(mockOpenstackNetworkAdminService);
+ }
+
+ /**
+ * Tests the results of the REST API DELETE with non-existing subnet ID.
+ */
+ @Test
+ public void testDeleteSubnetWithNonexistId() {
+ mockOpenstackNetworkAdminService.removeSubnet(anyString());
+ expectLastCall().andThrow(new IllegalArgumentException());
+ replay(mockOpenstackNetworkAdminService);
+
+ final WebTarget wt = target();
+
+ Response response = wt.path(PATH + "/non-exist-id")
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .delete();
+ final int status = response.getStatus();
+
+ assertThat(status, is(400));
+
+ verify(mockOpenstackNetworkAdminService);
+ }
+}
diff --git a/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-router-interface.json b/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-router-interface.json
new file mode 100644
index 0000000..7af8e0f
--- /dev/null
+++ b/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-router-interface.json
@@ -0,0 +1,8 @@
+{
+ "router_interface": {
+ "id": "f49a1319-423a-4ee6-ba54-1d95a4f6cc68",
+ "subnet_id": "f49a1319-423a-4ee6-ba54-1d95a4f6cc68",
+ "port_id": "65c0ee9f-d634-4522-8954-51021b570b0d",
+ "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa"
+ }
+}
diff --git a/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-router.json b/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-router.json
new file mode 100644
index 0000000..3cb186f
--- /dev/null
+++ b/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-router.json
@@ -0,0 +1,20 @@
+{
+ "router": {
+ "id": "f49a1319-423a-4ee6-ba54-1d95a4f6cc68",
+ "name": "router1",
+ "status": "ACTIVE",
+ "external_gateway_info": {
+ "network_id": "a87cc70a-3e15-4acf-8205-9b711a3531b7",
+ "enable_snat": false
+ },
+ "admin_state_up": true,
+ "tenant_id": "d6700c0c9ffa4f1cb322cd4a1f3906fa",
+ "routes": [
+ {
+ "destination": "string",
+ "nexthop": "string"
+ }
+ ],
+ "distributed": false
+ }
+}
diff --git a/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-subnet.json b/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-subnet.json
new file mode 100644
index 0000000..ff8307d
--- /dev/null
+++ b/apps/openstacknetworking/src/test/resources/org/onosproject/openstacknetworking/web/openstack-subnet.json
@@ -0,0 +1,27 @@
+{
+ "subnet": {
+ "id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
+ "enable_dhcp": true,
+ "network_id": "d32019d3-bc6e-4319-9c1d-6722fc136a22",
+ "tenant_id": "4fd44f30292945e481c7b8a0c8908869",
+ "dns_nameservers": [
+ "string"
+ ],
+ "allocation_pools": [
+ {
+ "start": "192.168.199.2",
+ "end": "10.10.10.254"
+ }
+ ],
+ "host_routes": [
+ {
+ "destination": "",
+ "nexthop": ""
+ }
+ ],
+ "ip_version": 4,
+ "gateway_ip": "192.168.199.1",
+ "ipv6_address_mode": "",
+ "ipv6_ra_mode": ""
+ }
+}