You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by la...@apache.org on 2014/03/31 09:13:48 UTC
[35/52] [partial] Moving jclouds dependencies to accurate parent
directories
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java
new file mode 100644
index 0000000..3553d18
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java
@@ -0,0 +1,206 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import org.jclouds.openstack.nova.v2_0.domain.Network;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions;
+import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.openstack.v2_0.predicates.LinkPredicates;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
+/**
+ * Tests behavior of {@link ServerApi}
+ *
+ * @author Adrian Cole
+ * @author Inbar Stolberg
+ */
+@Test(groups = "live", testName = "ServerApiLiveTest")
+public class ServerApiLiveTest extends BaseNovaApiLiveTest {
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/servers")
+ public void testListServers() throws Exception {
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ for (Resource server : serverApi.list().concat()) {
+ checkResource(server);
+ }
+ }
+ }
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/servers/detail")
+ public void testListServersInDetail() throws Exception {
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ for (Server server : serverApi.listInDetail().concat()) {
+ checkServer(server);
+ }
+ }
+ }
+
+ @Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
+ public void testGetServerById() throws Exception {
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ for (Resource server : serverApi.list().concat()) {
+ Server details = serverApi.get(server.getId());
+ assertEquals(details.getId(), server.getId());
+ assertEquals(details.getName(), server.getName());
+ assertEquals(details.getLinks(), server.getLinks());
+ checkServer(details);
+ }
+ }
+ }
+
+ @Test
+ public void testCreateInAvailabilityZone() {
+ String serverId = null;
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ serverId = createServer(zoneId, "nova", Server.Status.ACTIVE).getId();
+ Server server = serverApi.get(serverId);
+ assertEquals(server.getStatus(), Server.Status.ACTIVE);
+ } finally {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+
+ /**
+ * This needs to be supported by the provider, and is usually not supported.
+ * However this can be tested on devstack:
+ * In apis/openstack-nova:
+ * mvn -Plive clean install "-Dtest.openstack-nova.endpoint=http://localhost:5000/v2.0" "-Dtest.openstack-nova.identity=demo:demo" "-Dtest.openstack-nova.credential=devstack" "-Dtest=org.jclouds.openstack.nova.v2_0.features.ServerApiLiveTest#testCreateWithNetworkOptions"
+ */
+ @Test(enabled = false)
+ public void testCreateWithNetworkOptions() {
+ String serverId = null;
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ CreateServerOptions options = CreateServerOptions.Builder.novaNetworks(
+ // This network UUID must match an existing network.
+ ImmutableSet.of(Network.builder().networkUuid("bc4cfa2b-2b27-4671-8e8f-73009623def0").fixedIp("192.168.55.56").build())
+ );
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), "1", options);
+ serverId = server.getId();
+
+ blockUntilServerInState(server.getId(), serverApi, Server.Status.ACTIVE);
+ Server serverCheck = serverApi.get(serverId);
+ assertEquals(serverCheck.getStatus(), Server.Status.ACTIVE);
+ } finally {
+ if (serverId != null) {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testCreateInWrongAvailabilityZone() {
+ String serverId = null;
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ serverId = createServer(zoneId, "err", Server.Status.ERROR).getId();
+ Server server = serverApi.get(serverId);
+ assertEquals(server.getStatus(), Server.Status.ERROR);
+ } finally {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+
+ @Test
+ public void testRebuildServer() {
+
+ String serverId = null;
+
+ for (String zoneId : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ try {
+ serverId = createServer(zoneId, Server.Status.ACTIVE).getId();
+
+ Server server = serverApi.get(serverId);
+
+ assertEquals(server.getStatus(), Server.Status.ACTIVE);
+
+ RebuildServerOptions options = new RebuildServerOptions().
+ withImage(server.getImage().getId()).
+ name("newName").
+ adminPass("password").
+ ipv4Address("1.1.1.1").
+ ipv6Address("fe80::100");
+
+ serverApi.rebuild(serverId, options);
+
+ Server rebuiltServer = serverApi.get(serverId);
+
+ assertEquals("newName", rebuiltServer.getName());
+ assertEquals("1.1.1.1", rebuiltServer.getAccessIPv4());
+ assertEquals("fe80::100", rebuiltServer.getAccessIPv6());
+
+ } finally {
+ serverApi.delete(serverId);
+ }
+ }
+ }
+
+ private Server createServer(String regionId, Server.Status serverStatus) {
+ ServerApi serverApi = api.getServerApiForZone(regionId);
+ CreateServerOptions options = new CreateServerOptions();
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(regionId), flavorRefForZone(regionId), options);
+
+ blockUntilServerInState(server.getId(), serverApi, serverStatus);
+
+ return serverApi.get(server.getId());
+ }
+
+ private Server createServer(String regionId, String availabilityZoneId, Server.Status serverStatus) {
+ ServerApi serverApi = api.getServerApiForZone(regionId);
+ CreateServerOptions options = new CreateServerOptions();
+ options = options.availabilityZone(availabilityZoneId);
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(regionId), flavorRefForZone(regionId), options);
+ blockUntilServerInState(server.getId(), serverApi, serverStatus);
+ return serverApi.get(server.getId());
+ }
+
+ private void checkResource(Resource resource) {
+ assertNotNull(resource.getId());
+ assertNotNull(resource.getName());
+ assertNotNull(resource.getLinks());
+ assertTrue(Iterables.any(resource.getLinks(), LinkPredicates.relationEquals(Relation.SELF)));
+ }
+
+ private void checkServer(Server server) {
+ checkResource(server);
+ assertFalse(server.getAddresses().isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java
new file mode 100644
index 0000000..ba4be4d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.compute.functions.CreateSecurityGroupIfNeeded;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseComputeServiceTypicalSecurityGroupTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "CreateSecurityGroupIfNeededTest")
+public class CreateSecurityGroupIfNeededTest extends BaseNovaApiExpectTest {
+ HttpRequest create = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"security_group\":{\"name\":\"jclouds_mygroup\",\"description\":\"jclouds_mygroup\"}}",
+ "application/json")).build();
+
+ public void testCreateNewGroup() throws Exception {
+
+ Builder<HttpRequest, HttpResponse> builder = ImmutableMap.builder();
+
+ builder.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ builder.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+ int groupId = 2769;
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(200)
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group\": {\"rules\": [], \"tenant_id\": \"37936628937291\", \"id\": %s, \"name\": \"jclouds_mygroup\", \"description\": \"jclouds_mygroup\"}}", groupId),
+ "application/json; charset=UTF-8")).build();
+
+ builder.put(create, createResponse);
+
+ int ruleId = 10331;
+
+ for (int port : ImmutableList.of(22,8080)) {
+
+ HttpRequest createCidrRule = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\":{\"parent_group_id\":\"%s\",\"cidr\":\"0.0.0.0/0\",\"ip_protocol\":\"tcp\",\"from_port\":\"%d\",\"to_port\":\"%d\"}}",
+ groupId, port, port), "application/json")).build();
+
+ HttpResponse createCidrRuleResponse = HttpResponse.builder().statusCode(200)
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\": {\"from_port\": %d, \"group\": {}, \"ip_protocol\": \"tcp\", \"to_port\": %d, \"parent_group_id\": %d, \"ip_range\": {\"cidr\": \"0.0.0.0/0\"}, \"id\": %d}}",
+ port, port, groupId, ruleId++), "application/json; charset=UTF-8")).build();
+
+ builder.put(createCidrRule, createCidrRuleResponse);
+
+ HttpRequest createSelfRule = HttpRequest.builder().method("POST").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build())
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\":{\"group_id\":\"%d\",\"parent_group_id\":\"%d\",\"ip_protocol\":\"tcp\",\"from_port\":\"%d\",\"to_port\":\"%d\"}}",
+ groupId, groupId, port, port), "application/json")).build();
+
+ // note server responds with group name in the rule!!
+ HttpResponse createSelfRuleResponse = HttpResponse.builder().statusCode(200)
+ .payload(
+ payloadFromStringWithContentType(
+ String.format("{\"security_group_rule\": {\"from_port\": %d, \"group\": {\"tenant_id\": \"37936628937291\", \"name\": \"jclouds_mygroup\"}, \"ip_protocol\": \"tcp\", \"to_port\": %d, \"parent_group_id\": %d, \"ip_range\": {}, \"id\": %d}}",
+ port, port, groupId, ruleId++), "application/json; charset=UTF-8")).build();
+
+ builder.put(createSelfRule, createSelfRuleResponse);
+ }
+
+ HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/" + groupId)).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse getSecurityGroupResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_details_computeservice_typical.json")).build();
+
+ builder.put(getSecurityGroup, getSecurityGroupResponse);
+
+ NovaApi apiCanCreateSecurityGroup = requestsSendResponses(builder.build());
+
+ CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiCanCreateSecurityGroup);
+
+ // we can find it
+ assertEquals(fn.apply(
+ new ZoneSecurityGroupNameAndPorts("az-1.region-a.geo-1", "jclouds_mygroup", ImmutableSet.of(22, 8080)))
+ .toString(), new SecurityGroupInZone(new ParseComputeServiceTypicalSecurityGroupTest().expected(),
+ "az-1.region-a.geo-1").toString());
+
+ }
+
+ public void testReturnExistingGroupOnAlreadyExists() throws Exception {
+
+ Builder<HttpRequest, HttpResponse> builder = ImmutableMap.builder();
+
+ builder.put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess);
+ builder.put(extensionsOfNovaRequest, extensionsOfNovaResponse);
+
+ HttpResponse createResponse = HttpResponse.builder().statusCode(400)
+ .payload(
+ payloadFromStringWithContentType(
+ "{\"badRequest\": {\"message\": \"Security group test already exists\", \"code\": 400}}",
+ "application/json; charset=UTF-8")).build();
+
+ builder.put(create, createResponse);
+
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list_details_computeservice_typical.json")).build();
+
+ builder.put(list, listResponse);
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(builder.build());
+
+ CreateSecurityGroupIfNeeded fn = new CreateSecurityGroupIfNeeded(apiWhenSecurityGroupsExist);
+
+ // we can find it
+ assertEquals(fn.apply(
+ new ZoneSecurityGroupNameAndPorts("az-1.region-a.geo-1", "jclouds_mygroup", ImmutableSet.of(22, 8080)))
+ .toString(), new SecurityGroupInZone(new ParseComputeServiceTypicalSecurityGroupTest().expected(),
+ "az-1.region-a.geo-1").toString());
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java
new file mode 100644
index 0000000..c8e2639
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.functions;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone;
+import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName;
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest;
+import org.jclouds.openstack.nova.v2_0.parse.ParseSecurityGroupListTest;
+import org.jclouds.openstack.nova.v2_0.predicates.FindSecurityGroupWithNameAndReturnTrue;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.Iterables;
+import com.google.common.util.concurrent.Atomics;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "FindSecurityGroupWithNameAndReturnTrueExpectTest")
+public class FindSecurityGroupWithNameAndReturnTrueExpectTest extends BaseNovaApiExpectTest {
+
+ public void testUpdateReferenceWhenSecurityGroupListContainsGroupName() throws Exception {
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
+ listResponse);
+
+ FindSecurityGroupWithNameAndReturnTrue predicate = new FindSecurityGroupWithNameAndReturnTrue(
+ apiWhenSecurityGroupsExist);
+
+ AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(ZoneAndName
+ .fromZoneAndName("az-1.region-a.geo-1", "name1"));
+
+ // we can find it
+ assertTrue(predicate.apply(securityGroupInZoneRef));
+
+ // the reference is now up to date, and includes the actual group found.
+ assertEquals(securityGroupInZoneRef.get().toString(), new SecurityGroupInZone(Iterables
+ .getOnlyElement(new ParseSecurityGroupListTest().expected()), "az-1.region-a.geo-1").toString());
+
+ }
+
+ public void testDoesNotUpdateReferenceWhenSecurityGroupListMissingGroupName() throws Exception {
+ HttpRequest list = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ HttpResponse listResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/securitygroup_list.json")).build();
+
+ NovaApi apiWhenSecurityGroupsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
+ responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list,
+ listResponse);
+
+ FindSecurityGroupWithNameAndReturnTrue predicate = new FindSecurityGroupWithNameAndReturnTrue(
+ apiWhenSecurityGroupsExist);
+
+ ZoneAndName zoneAndGroup = ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "name2");
+
+ AtomicReference<ZoneAndName> securityGroupInZoneRef = Atomics.newReference(zoneAndGroup);
+
+ // we cannot find it
+ assertFalse(predicate.apply(securityGroupInZoneRef));
+
+ // the reference is the same
+ assertEquals(securityGroupInZoneRef.get(), zoneAndGroup);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java
new file mode 100644
index 0000000..d1656d7
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.functions;
+
+import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
+
+import java.util.Properties;
+
+import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest;
+import org.jclouds.openstack.v2_0.config.InternalUrlModule;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Module;
+
+/**
+ * Simple live test to check the correct loading of the internal endpoint
+ * services.
+ *
+ * @author Ignacio Mulas
+ *
+ */
+@Test(groups = "live", testName = "InternalURLLiveTest")
+public class InternalURLLiveTest extends BaseNovaApiLiveTest {
+
+ @Test(description = "InternalUrl service endpoints loader")
+ public void testGetInternalUrlServiceEndpoint() throws Exception {
+ String zone = api.getConfiguredZones().iterator().next();
+ // List current servers to ensure that can reach nova with internalUrl ip
+ try {
+ api.getServerApiForZone(zone).list().concat().toList();
+ } catch (Exception e) {
+ Assert.fail("Could not retrieve servers list using the internalUrl", e);
+ }
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties properties = super.setupProperties();
+ properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, "5000");
+ return properties;
+ }
+
+ @Override
+ protected Iterable<Module> setupModules() {
+ return ImmutableSet.<Module> of(getLoggingModule(), new InternalUrlModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java
new file mode 100644
index 0000000..fe302a7
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java
@@ -0,0 +1,225 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.handlers;
+
+import static org.testng.Assert.assertEquals;
+
+import java.util.concurrent.TimeUnit;
+
+import org.jclouds.date.DateCodec;
+import org.jclouds.date.internal.DateServiceDateCodecFactory.DateServiceIso8601SecondsCodec;
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.fallbacks.HeaderToRetryAfterException;
+import org.jclouds.http.HttpCommand;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.json.internal.GsonWrapper;
+import org.jclouds.openstack.nova.v2_0.functions.OverLimitParser;
+import org.jclouds.rest.AuthorizationException;
+import org.jclouds.rest.InsufficientResourcesException;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.jclouds.rest.RetryAfterException;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Ticker;
+import com.google.gson.Gson;
+
+/**
+ *
+ * @author Adrian Cole, Steve Loughran
+ */
+@Test(groups = "unit", testName = "NovaErrorHandlerTest", singleThreaded = true)
+public class NovaErrorHandlerTest {
+
+ private HttpCommand command;
+
+ @BeforeTest
+ void setupCommand() {
+ command = command();
+ }
+
+ @Test
+ public void test401MakesAuthorizationException() {
+ fn.handleError(command, HttpResponse.builder().statusCode(401).message("Unauthorized").build());
+
+ assertEquals(command.getException().getClass(), AuthorizationException.class);
+ assertEquals(command.getException().getMessage(),
+ "POST https://nova/v1.1/servers HTTP/1.1 -> HTTP/1.1 401 Unauthorized");
+ }
+
+ @Test
+ public void test404MakesResourceNotFoundException() {
+ fn.handleError(command, HttpResponse.builder().statusCode(404).message("Not Found").build());
+
+ assertEquals(command.getException().getClass(), ResourceNotFoundException.class);
+ assertEquals(command.getException().getMessage(),
+ "POST https://nova/v1.1/servers HTTP/1.1 -> HTTP/1.1 404 Not Found");
+ }
+
+ // should wait until ips are associated w/the server
+ HttpResponse noFixedIps = HttpResponse.builder().statusCode(400)
+ .message("HTTP/1.1 400 Bad Request")
+ .payload("{\"badRequest\": {\"message\": "+
+ "\"instance |71554| has no fixed_ips. unable to associate floating ip\", \"code\": 400}}")
+ .build();
+
+ @Test
+ public void test400MakesIllegalStateExceptionOnQuotaExceededOnNoFixedIps() {
+ fn.handleError(command, noFixedIps);
+
+ assertEquals(command.getException().getClass(), IllegalStateException.class);
+ assertEquals(command.getException().getMessage(), noFixedIps.getPayload().getRawContent());
+ }
+
+ HttpResponse alreadyExists = HttpResponse.builder().statusCode(400)
+ .message("HTTP/1.1 400 Bad Request")
+ .payload("{\"badRequest\": {\"message\": \"Server with the name 'test' already exists\", \"code\": 400}}")
+ .build();
+
+ @Test
+ public void test400MakesIllegalStateExceptionOnAlreadyExists() {
+ fn.handleError(command, alreadyExists);
+
+ assertEquals(command.getException().getClass(), IllegalStateException.class);
+ assertEquals(command.getException().getMessage(), alreadyExists.getPayload().getRawContent());
+ }
+
+ HttpResponse quotaExceeded = HttpResponse.builder().statusCode(400)
+ .message("HTTP/1.1 400 Bad Request")
+ .payload("{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. " +
+ "You cannot create any more addresses\", \"code\": 400}}")
+ .build();
+
+ @Test
+ public void test400MakesInsufficientResourcesExceptionOnQuotaExceeded() {
+ fn.handleError(command, quotaExceeded);
+
+ assertEquals(command.getException().getClass(), InsufficientResourcesException.class);
+ assertEquals(command.getException().getMessage(), quotaExceeded.getPayload().getRawContent());
+ }
+
+ HttpResponse tooLarge = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{\"badRequest\": {\"message\": \"Volume quota exceeded. You cannot create a volume of size 1G\", " +
+ "\"code\": 413, \"retryAfter\": 0}}")
+ .build();
+
+ @Test
+ public void test413MakesInsufficientResourcesException() {
+ fn.handleError(command, tooLarge);
+
+ assertEquals(command.getException().getClass(), InsufficientResourcesException.class);
+ assertEquals(command.getException().getMessage(), tooLarge.getPayload().getRawContent());
+ }
+
+ /**
+ * Reponse received from Rackspace UK on November 14, 2012.
+ */
+ HttpResponse retryAt = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit' : { 'code' : 413,"
+ + " 'message' : 'OverLimit Retry...', "
+ + " 'details' : 'Error Details...',"
+ + " 'retryAt' : '2012-11-14T21:51:28UTC' }}")
+ .build();
+
+ @Test
+ public void test413WithRetryAtExceptionParsesDelta() {
+ fn.handleError(command, retryAt);
+
+ assertEquals(command.getException().getClass(), RetryAfterException.class);
+ assertEquals(command.getException().getMessage(), "retry in 3600 seconds");
+ }
+
+ /**
+ * Folsom response. This contains a delta in seconds to retry after, not a
+ * fixed time.
+ *
+ */
+ HttpResponse retryAfter = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit': { 'message': 'This request was rate-limited.', "
+ + " 'retryAfter': '54', "
+ + " 'details': 'Only 1 POST request(s) can be made to \\'*\\' every minute.'" + " }}")
+ .build();
+
+ @Test
+ public void test413WithRetryAfterExceptionFolsom() {
+ fn.handleError(command, retryAfter);
+
+ assertEquals(command.getException().getClass(), RetryAfterException.class);
+ assertEquals(command.getException().getMessage(), "retry in 54 seconds");
+ }
+
+ /**
+ * Folsom response with a retryAt field inserted -at a different date. This
+ * can be used to verify that the retryAfter field is picked up first
+ */
+ HttpResponse retryAfterTrumps = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit': {"
+ + " 'message': 'This request was rate-limited.', "
+ + " 'retryAfter': '54', "
+ + " 'retryAt' : '2012-11-14T21:51:28UTC',"
+ + " 'details': 'Only 1 POST request(s) can be made to \\'*\\' every minute.' }}")
+ .build();
+
+ @Test
+ public void test413WithRetryAfterTrumpsRetryAt() {
+ fn.handleError(command, retryAfterTrumps);
+
+ assertEquals(command.getException().getClass(), RetryAfterException.class);
+ assertEquals(command.getException().getMessage(), "retry in 54 seconds");
+ }
+
+ HttpResponse badRetryAt = HttpResponse.builder().statusCode(413)
+ .message("HTTP/1.1 413 Request Entity Too Large")
+ .payload("{ 'overLimit' : { 'code' : 413,"
+ + " 'message' : 'OverLimit Retry...', "
+ + " 'details' : 'Error Details...',"
+ + " 'retryAt' : '2012-11-~~~:51:28UTC' }}")
+ .build();
+
+ @Test
+ public void test413WithBadRetryAtFormatFallsBack() {
+ fn.handleError(command, badRetryAt);
+
+ assertEquals(command.getException().getClass(), InsufficientResourcesException.class);
+ assertEquals(command.getException().getMessage(), badRetryAt.getPayload().getRawContent());
+ }
+
+
+ DateCodec iso8601Seconds = new DateServiceIso8601SecondsCodec(new SimpleDateFormatDateService());
+
+ Ticker y2k = new Ticker() {
+
+ @Override
+ public long read() {
+ return TimeUnit.MILLISECONDS.toNanos(iso8601Seconds.toDate("2012-11-14T20:51:28UTC").getTime());
+ }
+
+ };
+
+ NovaErrorHandler fn = new NovaErrorHandler(HeaderToRetryAfterException.create(y2k, iso8601Seconds),
+ new OverLimitParser(new GsonWrapper(new Gson())));
+
+ private HttpCommand command() {
+ return new HttpCommand(HttpRequest.builder().method("POST").endpoint("https://nova/v1.1/servers").build());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java
new file mode 100644
index 0000000..6c63da5
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.internal;
+
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+
+/**
+ * Base class for writing KeyStone Rest Api Expect tests
+ *
+ * @author Adrian Cole
+ */
+public class BaseNovaApiExpectTest extends BaseNovaExpectTest<NovaApi> {
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java
new file mode 100644
index 0000000..da1847b
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.internal;
+
+import java.util.Properties;
+import java.util.Set;
+
+import org.jclouds.apis.BaseApiLiveTest;
+import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
+import org.jclouds.openstack.nova.v2_0.NovaApi;
+import org.jclouds.openstack.nova.v2_0.config.NovaProperties;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.nova.v2_0.domain.Server;
+import org.jclouds.openstack.nova.v2_0.domain.Server.Status;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
+import org.jclouds.openstack.nova.v2_0.features.ImageApi;
+import org.jclouds.openstack.nova.v2_0.features.ServerApi;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ComparisonChain;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Ordering;
+
+/**
+ * Tests behavior of {@code NovaApi}
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "live")
+public class BaseNovaApiLiveTest extends BaseApiLiveTest<NovaApi> {
+ protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
+
+ public BaseNovaApiLiveTest() {
+ provider = "openstack-nova";
+ }
+
+ protected Set<String> zones;
+
+ @BeforeClass(groups = { "integration", "live" })
+ @Override
+ public void setup() {
+ super.setup();
+ zones = api.getConfiguredZones();
+ for (String zone : zones) {
+ ServerApi serverApi = api.getServerApiForZone(zone);
+ for (Resource server : serverApi.list().concat()) {
+ if (server.getName().equals(hostName))
+ serverApi.delete(server.getId());
+ }
+ }
+ }
+
+ @Override
+ protected Properties setupProperties() {
+ Properties props = super.setupProperties();
+ setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
+ setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS);
+ return props;
+ }
+
+ protected Server createServerInZone(String zoneId) {
+ ServerApi serverApi = api.getServerApiForZone(zoneId);
+ ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId));
+ blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE);
+ return serverApi.get(server.getId());
+ }
+
+ /**
+ * Will block until the requested server is in the correct state, if Extended Server Status extension is loaded
+ * this will continue to block while any task is in progress.
+ */
+ protected void blockUntilServerInState(String serverId, ServerApi api, Status status) {
+ Server currentDetails = null;
+ for (currentDetails = api.get(serverId); currentDetails.getStatus() != status
+ || ((currentDetails.getExtendedStatus().isPresent() && currentDetails.getExtendedStatus().get()
+ .getTaskState() != null)); currentDetails = api.get(serverId)) {
+ System.out.printf("blocking on status %s%n%s%n", status, currentDetails);
+ try {
+ Thread.sleep(5 * 1000);
+ } catch (InterruptedException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+ }
+
+ protected String imageIdForZone(String zoneId) {
+ ImageApi imageApi = api.getImageApiForZone(zoneId);
+ return Iterables.getLast(imageApi.list().concat()).getId();
+ }
+
+ protected String flavorRefForZone(String zoneId) {
+ FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
+ return DEFAULT_FLAVOR_ORDERING.min(flavorApi.listInDetail().concat()).getId();
+ }
+
+ static final Ordering<Flavor> DEFAULT_FLAVOR_ORDERING = new Ordering<Flavor>() {
+ public int compare(Flavor left, Flavor right) {
+ return ComparisonChain.start().compare(left.getVcpus(), right.getVcpus()).compare(left.getRam(), right.getRam())
+ .compare(left.getDisk(), right.getDisk()).result();
+ }
+ };
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java
new file mode 100644
index 0000000..bd3b731
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.internal;
+
+import java.net.URI;
+import java.util.Properties;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.nova.v2_0.NovaApiMetadata;
+
+import com.google.common.base.Function;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.inject.Module;
+
+/**
+ * Base class for writing KeyStone Expect tests with the ComputeService abstraction
+ *
+ * @author Matt Stephenson
+ */
+public abstract class BaseNovaComputeServiceContextExpectTest<T> extends BaseNovaExpectTest<T> implements
+ Function<ComputeServiceContext, T> {
+
+ protected final HttpRequest listDetail = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/detail")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listDetailResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/image_list_detail.json")).build();
+
+ protected final HttpRequest listFlavorsDetail = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/detail")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listFlavorsDetailResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/flavor_list_detail.json")).build();
+
+ protected final HttpRequest listServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/detail")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/server_list_details.json")).build();
+
+ protected final HttpRequest listFloatingIps = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers(
+ ImmutableMultimap.<String, String> builder().put("Accept", "application/json").put("X-Auth-Token",
+ authToken).build()).build();
+
+ protected final HttpResponse listFloatingIpsResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResource("/floatingip_list.json")).build();
+
+ @Override
+ public T createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
+ return apply(createComputeServiceContext(fn, module, props));
+ }
+
+ private ComputeServiceContext createComputeServiceContext(Function<HttpRequest, HttpResponse> fn, Module module,
+ Properties props) {
+ return createInjector(fn, module, props).getInstance(ComputeServiceContext.class);
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new NovaApiMetadata();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java
new file mode 100644
index 0000000..2664e8d
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.internal;
+
+import org.jclouds.compute.ComputeService;
+import org.jclouds.compute.ComputeServiceContext;
+
+/**
+ * Base class for writing KeyStone Expect tests with the ComputeService
+ * abstraction
+ *
+ * @author Matt Stephenson
+ */
+public class BaseNovaComputeServiceExpectTest extends BaseNovaComputeServiceContextExpectTest<ComputeService> {
+
+ @Override
+ public ComputeService apply(ComputeServiceContext input) {
+ return input.getComputeService();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java
new file mode 100644
index 0000000..714930c
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.internal;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.openstack.keystone.v2_0.internal.KeystoneFixture;
+import org.jclouds.rest.internal.BaseRestApiExpectTest;
+
+/**
+ * Base class for writing Nova Expect tests
+ *
+ * @author Adrian Cole
+ */
+public class BaseNovaExpectTest<T> extends BaseRestApiExpectTest<T> {
+ protected HttpRequest keystoneAuthWithUsernameAndPassword;
+ protected HttpRequest keystoneAuthWithUsernameAndPasswordAndTenantName;
+ protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantName;
+ protected String authToken;
+ protected HttpResponse responseWithKeystoneAccess;
+ protected HttpRequest extensionsOfNovaRequest;
+ protected HttpResponse extensionsOfNovaResponse;
+ protected HttpResponse unmatchedExtensionsOfNovaResponse;
+ protected HttpRequest keystoneAuthWithAccessKeyAndSecretKeyAndTenantId;
+ protected String identityWithTenantId;
+
+ public BaseNovaExpectTest() {
+ provider = "openstack-nova";
+ keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity,
+ credential);
+ keystoneAuthWithUsernameAndPasswordAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPasswordAndTenantName(identity,
+ credential);
+ keystoneAuthWithAccessKeyAndSecretKeyAndTenantName = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantName(identity,
+ credential);
+ keystoneAuthWithAccessKeyAndSecretKeyAndTenantId = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKeyAndTenantId(identity,
+ credential);
+
+ authToken = KeystoneFixture.INSTANCE.getAuthToken();
+ responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess();
+ // now, createContext arg will need tenant prefix
+ identityWithTenantId = KeystoneFixture.INSTANCE.getTenantId() + ":" + identity;
+ identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity;
+
+ extensionsOfNovaRequest = HttpRequest.builder().method("GET")
+ // NOTE THIS IS NOVA, NOT KEYSTONE
+ .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions")
+ .addHeader("Accept", "application/json")
+ .addHeader("X-Auth-Token", authToken).build();
+
+ extensionsOfNovaResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/extension_list_full.json")).build();
+
+ unmatchedExtensionsOfNovaResponse = HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResource("/extension_list.json")).build();
+ }
+
+ @Override
+ protected HttpRequestComparisonType compareHttpRequestAsType(HttpRequest input) {
+ return HttpRequestComparisonType.JSON;
+ }
+
+ protected HttpRequest.Builder<?> authenticatedGET() {
+ return HttpRequest.builder()
+ .method("GET")
+ .addHeader("Accept", MediaType.APPLICATION_JSON)
+ .addHeader("X-Auth-Token", authToken);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java
new file mode 100644
index 0000000..9b056b9
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.net.domain.IpProtocol;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup;
+import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule;
+import org.jclouds.openstack.nova.v2_0.domain.TenantIdAndName;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseSecurityGroupTest")
+public class ParseComputeServiceTypicalSecurityGroupTest extends BaseItemParserTest<SecurityGroup> {
+
+ @Override
+ public String resource() {
+ return "/securitygroup_details_computeservice_typical.json";
+ }
+
+ @Override
+ @SelectJson("security_group")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public SecurityGroup expected() {
+
+ Set<SecurityGroupRule> securityGroupRules = ImmutableSet.of(
+ SecurityGroupRule.builder().fromPort(22)
+ .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
+ .ipRange("0.0.0.0/0").id("10331").build(),
+ SecurityGroupRule.builder().fromPort(22).group(TenantIdAndName.builder().tenantId("37936628937291").name("jclouds_mygroup").build())
+ .ipProtocol(IpProtocol.TCP).toPort(22).parentGroupId("2769")
+ .id("10332").build(),
+ SecurityGroupRule.builder().fromPort(8080)
+ .ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
+ .ipRange("0.0.0.0/0").id("10333").build(),
+ SecurityGroupRule.builder().fromPort(8080).group(TenantIdAndName.builder().tenantId("37936628937291").name("jclouds_mygroup").build())
+ .ipProtocol(IpProtocol.TCP).toPort(8080).parentGroupId("2769")
+ .id("10334").build()
+ );
+
+ return SecurityGroup.builder().description("jclouds_mygroup").id("2769").tenantId("37936628937291").rules(securityGroupRules)
+ .name("jclouds_mygroup").build();
+ }
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java
new file mode 100644
index 0000000..a125f9f
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @see FlavorApiExpectTest
+ * @author Ilja Bobkevic
+ */
+@Test(groups = "unit", testName = "ParseCreateFlavorTest")
+public class ParseCreateFlavorTest extends BaseItemParserTest<Flavor> {
+
+ @Override
+ public String resource() {
+ return "/flavor_new.json";
+ }
+
+ @Override
+ @SelectJson("flavor")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Flavor expected() {
+ return Flavor.builder()
+ .id("1cb47a44-9b84-4da4-bf81-c1976e8414ab")
+ .name("128 MB Server").ram(128).vcpus(1)
+ .disk(10).build();
+ }
+
+ @Override
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java
new file mode 100644
index 0000000..3b2a774
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.ServerCreated;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseCreatedServerTest")
+public class ParseCreatedServerTest extends BaseItemParserTest<ServerCreated> {
+
+ @Override
+ public String resource() {
+ return "/new_server.json";
+ }
+
+ @Override
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ServerCreated expected() {
+ return ServerCreated
+ .builder()
+ .id("71752")
+ .name("test-e92")
+ .adminPass("ZWuHcmTMQ7eXoHeM")
+ .links(
+ Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")),
+ Link.create(Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build();
+
+ }
+
+ @SelectJson("server")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public ServerCreated expectedWithDiskConfig(String diskConfig) {
+ return ServerCreated
+ .builder()
+ .id("71752")
+ .name("test-e92")
+ .adminPass("ZWuHcmTMQ7eXoHeM")
+ .diskConfig(diskConfig)
+ .links(
+ Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")),
+ Link.create(Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build();
+
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java
new file mode 100644
index 0000000..4fec5c0
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseExtensionListNormalTest")
+public class ParseExtensionListNormalTest extends BaseSetParserTest<Extension> {
+
+ @Override
+ public String resource() {
+ return "/extension_list_normal.json";
+ }
+
+ @Override
+ @SelectJson("extensions")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Extension> expected() {
+ return ImmutableSet.of(
+ Extension.builder().alias("os-keypairs").name("Keypairs")
+ .namespace(URI.create("http://docs.openstack.org/ext/keypairs/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-08-08T00:00:00+00:00"))
+ .description("Keypair Support").build(),
+ Extension.builder().alias("os-volumes").name("Volumes")
+ .namespace(URI.create("http://docs.openstack.org/ext/volumes/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-03-25T00:00:00+00:00"))
+ .description("Volumes support").build(),
+ Extension.builder().alias("security_groups").name("SecurityGroups")
+ .namespace(URI.create("http://docs.openstack.org/ext/securitygroups/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-07-21T00:00:00+00:00"))
+ .description("Security group support").build(),
+ Extension.builder().alias("os-floating-ips").name("Floating_ips")
+ .namespace(URI.create("http://docs.openstack.org/ext/floating_ips/api/v1.1"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-06-16T00:00:00+00:00"))
+ .description("Floating IPs support").build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java
new file mode 100644
index 0000000..ba83a85
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseExtensionListTest")
+public class ParseExtensionListTest extends BaseSetParserTest<Extension> {
+
+ @Override
+ public String resource() {
+ return "/extension_list.json";
+ }
+
+ @Override
+ @SelectJson("extensions")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Extension> expected() {
+ return ImmutableSet
+ .of(Extension
+ .builder()
+ .alias("RAX-PIE")
+ .name("Public Image Extension")
+ .namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
+ .description("Adds the capability to share an image with other users.")
+ .links(
+ ImmutableSet.of(
+ Link.create(Relation.DESCRIBEDBY, "application/pdf",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf")),
+ Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl")))).build(),
+ Extension
+ .builder()
+ .alias("RAX-CBS")
+ .name("Cloud Block Storage")
+ .namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/cbs/v1.0"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-12T11:22:33-06:00"))
+ .description("Allows mounting cloud block storage volumes.")
+ .links(
+ ImmutableSet.of(Link.create(Relation.DESCRIBEDBY, "application/pdf",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs-20111201.pdf")),
+ Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-cbs.wadl"))))
+ .build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java
new file mode 100644
index 0000000..6ba9645
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.date.internal.SimpleDateFormatDateService;
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Extension;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "ParseExtensionTest")
+public class ParseExtensionTest extends BaseItemParserTest<Extension> {
+
+ @Override
+ public String resource() {
+ return "/extension_details.json";
+ }
+
+ @Override
+ @SelectJson("extension")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Extension expected() {
+ return Extension
+ .builder()
+ .alias("RS-PIE")
+ .name("Public Image Extension")
+ .namespace(URI.create("http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0"))
+ .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2011-01-22T13:25:27-06:00"))
+ .description("Adds the capability to share an image with other users.")
+ .links(
+ ImmutableSet.of(
+ Link.create(Relation.DESCRIBEDBY, "application/pdf",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf")),
+ Link.create(Relation.DESCRIBEDBY, "application/vnd.sun.wadl+xml",
+ URI.create("http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl")))).build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java
new file mode 100644
index 0000000..27f5484
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import java.net.URI;
+import java.util.Set;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseSetParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.openstack.v2_0.domain.Resource;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ *
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseFlavorListTest")
+public class ParseFlavorListTest extends BaseSetParserTest<Resource> {
+
+ @Override
+ public String resource() {
+ return "/flavor_list.json";
+ }
+
+ @Override
+ @SelectJson("flavors")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Set<Resource> expected() {
+ return ImmutableSet
+ .of(Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f1195ff37")
+ .name("256 MB Server")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")))
+ .build(),
+ Resource
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f216543fd")
+ .name("512 MB Server")
+ .links(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")))
+ .build());
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/19c8cdaf/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java
new file mode 100644
index 0000000..9d2a011
--- /dev/null
+++ b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.jclouds.openstack.nova.v2_0.parse;
+
+import java.net.URI;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.json.BaseItemParserTest;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
+import org.jclouds.openstack.nova.v2_0.domain.Flavor;
+import org.jclouds.openstack.v2_0.domain.Link;
+import org.jclouds.openstack.v2_0.domain.Link.Relation;
+import org.jclouds.rest.annotations.SelectJson;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Jeremy Daggett
+ */
+@Test(groups = "unit", testName = "ParseFlavorTest")
+public class ParseFlavorTest extends BaseItemParserTest<Flavor> {
+
+ @Override
+ public String resource() {
+ return "/flavor_details.json";
+ }
+
+ @Override
+ @SelectJson("flavor")
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Flavor expected() {
+ return Flavor
+ .builder()
+ .id("52415800-8b69-11e0-9b19-734f1195ff37")
+ .name("256 MB Server")
+ .links(
+ ImmutableSet.of(
+ Link.create(
+ Relation.SELF,
+ URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")),
+ Link.create(
+ Relation.BOOKMARK,
+ URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37"))))
+ .ram(256).disk(10).vcpus(1).build();
+ }
+
+ protected Injector injector() {
+ return Guice.createInjector(new NovaParserModule(), new GsonModule());
+ }
+}