You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/08/14 15:07:45 UTC
[39/51] [abbrv] [partial] stratos git commit: Upgrading to jclouds
1.9.1
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
deleted file mode 100644
index c11d04e..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Address;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Lists;
-
-public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private static final String ADDRESS_NAME = "address-api-live-test-address";
- private static final int TIME_WAIT = 30;
-
- private AddressApi api() {
- return api.getAddressApiForProject(userProject.get());
- }
-
- @Test(groups = "live")
- public void testInsertAddress() {
-
- assertRegionOperationDoneSucessfully(api().createInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
- }
-
- @Test(groups = "live", dependsOnMethods = "testInsertAddress")
- public void testGetAddress() {
- Address address = api().getInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME);
- assertNotNull(address);
- assertEquals(address.getName(), ADDRESS_NAME);
- }
-
- @Test(groups = "live", dependsOnMethods = "testGetAddress")
- public void testListAddress() {
-
- PagedIterable<Address> addresss = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder()
- .filter("name eq " + ADDRESS_NAME));
-
- List<Address> addresssAsList = Lists.newArrayList(addresss.concat());
-
- assertEquals(addresssAsList.size(), 1);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testListAddress")
- public void testDeleteAddress() {
-
- assertRegionOperationDoneSucessfully(api().deleteInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT);
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
deleted file mode 100644
index 6aaf8fa..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseDiskListTest;
-import org.jclouds.googlecomputeengine.parse.ParseDiskTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit")
-public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
- public static final String IMAGE_URL = "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/images/foo";
-
- public void testGetDiskResponseIs2xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/disk_get.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.getInZone("us-central1-a", "testimage1"),
- new ParseDiskTest().expected());
- }
-
- public void testGetDiskResponseIs4xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
-
- assertNull(api.getInZone("us-central1-a", "testimage1"));
- }
-
- public void testInsertDiskResponseIs2xx() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert,
- insertDiskResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
- }
-
- public void testInsertDiskFromImageResponseIs2xx() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
- + "?sourceImage=" + IMAGE_URL.replaceAll(":", "%3A"))
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert,
- insertDiskResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.createFromImageWithSizeInZone(IMAGE_URL, "testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
- }
-
- public void testCreateSnapshotResponseIs2xx() {
- HttpRequest createSnapshotRequest = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
- + "/testimage1/createSnapshot")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_create_snapshot.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse createSnapshotResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, createSnapshotRequest,
- createSnapshotResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"), new ParseOperationTest().expected());
- }
-
- public void testCreateSnapshotResponseIs4xx() {
- HttpRequest createSnapshotRequest = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
- + "/testimage1/createSnapshot")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/disk_create_snapshot.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse createSnapshotResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, createSnapshotRequest,
- createSnapshotResponse).getDiskApiForProject("myproject");
-
- assertNull(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"));
- }
-
- public void testDeleteDiskResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.deleteInZone("us-central1-a", "testimage1"),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteDiskResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
-
- assertNull(api.deleteInZone("us-central1-a", "testimage1"));
- }
-
- public void testListDisksResponseIs2xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/disk_list.json")).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
-
- assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
- new ParseDiskListTest().expected().toString());
- }
-
- public void testListDisksResponseIs4xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
-
- assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
deleted file mode 100644
index bd26621..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Disk;
-import org.jclouds.googlecomputeengine.domain.Project;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- public static final String DISK_NAME = "disk-api-live-test-disk";
- public static final int TIME_WAIT = 30;
- public static final int sizeGb = 1;
-
- private DiskApi api() {
- return api.getDiskApiForProject(userProject.get());
- }
-
- @Test(groups = "live")
- public void testInsertDisk() {
- Project project = api.getProjectApi().get(userProject.get());
- assertZoneOperationDoneSucessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testInsertDisk")
- public void testGetDisk() {
-
- Disk disk = api().getInZone(DEFAULT_ZONE_NAME, DISK_NAME);
- assertNotNull(disk);
- assertDiskEquals(disk);
- }
-
- @Test(groups = "live", dependsOnMethods = "testGetDisk")
- public void testListDisk() {
-
- PagedIterable<Disk> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder()
- .filter("name eq " + DISK_NAME));
-
- List<Disk> disksAsList = Lists.newArrayList(disks.concat());
-
- assertEquals(disksAsList.size(), 1);
-
- assertDiskEquals(Iterables.getOnlyElement(disksAsList));
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testListDisk")
- public void testDeleteDisk() {
-
- assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT);
- }
-
- private void assertDiskEquals(Disk result) {
- assertEquals(result.getName(), DISK_NAME);
- assertEquals(result.getSizeGb(), sizeGb);
- assertEquals(result.getZone(), getDefaultZoneUrl(userProject.get()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
deleted file mode 100644
index 7a5759b..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static com.google.common.base.Joiner.on;
-import static com.google.common.collect.Iterables.transform;
-import static java.lang.String.format;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.jclouds.io.Payloads.newStringPayload;
-import static org.jclouds.util.Strings2.toStringAndClose;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Set;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.domain.Firewall;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.FirewallOptions;
-import org.jclouds.googlecomputeengine.parse.ParseFirewallListTest;
-import org.jclouds.googlecomputeengine.parse.ParseFirewallTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.io.Payload;
-import org.jclouds.net.domain.IpProtocol;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableSet;
-
-@Test(groups = "unit")
-public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- public static final HttpRequest GET_FIREWALL_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static HttpResponse GET_FIREWALL_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/firewall_get.json")).build();
-
- public void testGetFirewallResponseIs2xx() throws Exception {
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApiForProject("myproject");
-
- assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected());
- }
-
-
- public static Payload firewallPayloadFirewallOfName(String firewallName,
- String networkName,
- Set<String> sourceRanges,
- Set<String> sourceTags,
- Set<String> targetTags,
- Set<String> portRanges) throws IOException {
- Function<String, String> addQuotes = new Function<String, String>() {
- @Override
- public String apply(String input) {
- return "\"" + input + "\"";
- }
- };
-
- String ports = on(",").skipNulls().join(transform(portRanges, addQuotes));
-
- Payload payload = newStringPayload(
- format(toStringAndClose(FirewallApiExpectTest.class.getResourceAsStream("/firewall_insert.json")),
- firewallName,
- networkName,
- on(",").skipNulls().join(transform(sourceRanges, addQuotes)),
- on(",").skipNulls().join(transform(sourceTags, addQuotes)),
- on(",").skipNulls().join(transform(targetTags, addQuotes)),
- ports,
- ports));
- payload.getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
- return payload;
- }
-
-
- public void testGetFirewallResponseIs4xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getFirewallApiForProject("myproject");
-
- assertNull(api.get("jclouds-test"));
- }
-
- public void testInsertFirewallResponseIs2xx() throws IOException {
-
- HttpRequest request = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(firewallPayloadFirewallOfName(
- "myfw",
- "default",
- ImmutableSet.<String>of("10.0.1.0/32"),
- ImmutableSet.<String>of("tag1"),
- ImmutableSet.<String>of("tag2"),
- ImmutableSet.<String>of("22", "23-24")))
- .build();
-
- HttpResponse insertFirewallResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"),
- new FirewallOptions()
- .addAllowedRule(Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .addPortRange(23, 24).build())
- .addSourceTag("tag1")
- .addSourceRange("10.0.1.0/32")
- .addTargetTag("tag2")), new ParseOperationTest().expected());
-
- }
-
- public void testUpdateFirewallResponseIs2xx() throws IOException {
- HttpRequest update = HttpRequest
- .builder()
- .method("PUT")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(firewallPayloadFirewallOfName(
- "myfw",
- "default",
- ImmutableSet.<String>of("10.0.1.0/32"),
- ImmutableSet.<String>of("tag1"),
- ImmutableSet.<String>of("tag2"),
- ImmutableSet.<String>of("22", "23-24")))
- .build();
-
- HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, update,
- updateFirewallResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.update("myfw",
- new FirewallOptions()
- .name("myfw")
- .network(URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"))
- .addAllowedRule(Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .addPortRange(23, 24).build())
- .addSourceTag("tag1")
- .addSourceRange("10.0.1.0/32")
- .addTargetTag("tag2")), new ParseOperationTest().expected());
- }
-
- public void testPatchFirewallResponseIs2xx() throws IOException {
- HttpRequest update = HttpRequest
- .builder()
- .method("PATCH")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(firewallPayloadFirewallOfName(
- "myfw",
- "default",
- ImmutableSet.<String>of("10.0.1.0/32"),
- ImmutableSet.<String>of("tag1"),
- ImmutableSet.<String>of("tag2"),
- ImmutableSet.<String>of("22", "23-24")))
- .build();
-
- HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, update,
- updateFirewallResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.patch("myfw",
- new FirewallOptions()
- .name("myfw")
- .network(URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"))
- .addAllowedRule(Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .addPortRange(23, 24).build())
- .addSourceTag("tag1")
- .addSourceRange("10.0.1.0/32")
- .addTargetTag("tag2")), new ParseOperationTest().expected());
- }
-
- public void testDeleteFirewallResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.delete("default-allow-internal"),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteFirewallResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
-
- assertNull(api.delete("default-allow-internal"));
- }
-
- public void testListFirewallsResponseIs2xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/firewall_list.json")).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
-
- assertEquals(api.listFirstPage().toString(),
- new ParseFirewallListTest().expected().toString());
- }
-
- public void testListFirewallsResponseIs4xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/firewalls")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
-
- assertTrue(api.list().concat().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
deleted file mode 100644
index 669046f..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.List;
-
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Firewall;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.FirewallOptions;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.net.domain.IpProtocol;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
-
-@Test(groups = "live", testName = "FirewallApiLiveTest")
-public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private static final String FIREWALL_NAME = "firewall-api-live-test-firewall";
- private static final String FIREWALL_NETWORK_NAME = "firewall-api-live-test-network";
- private static final String IPV4_RANGE = "10.0.0.0/8";
- private static final int TIME_WAIT = 30;
-
- private FirewallApi api() {
- return api.getFirewallApiForProject(userProject.get());
- }
-
- @Test(groups = "live")
- public void testInsertFirewall() {
-
- // need to create the network first
- assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
- (FIREWALL_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
-
- FirewallOptions firewall = new FirewallOptions()
- .addAllowedRule(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22).build())
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2");
-
- assertGlobalOperationDoneSucessfully(api().createInNetwork(FIREWALL_NAME, getNetworkUrl(userProject.get(),
- FIREWALL_NETWORK_NAME), firewall), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testInsertFirewall")
- public void testUpdateFirewall() {
-
- FirewallOptions firewall = new FirewallOptions()
- .name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2")
- .allowedRules(ImmutableSet.of(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(23)
- .build()));
-
-
- assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testUpdateFirewall")
- public void testPatchFirewall() {
-
- FirewallOptions firewall = new FirewallOptions()
- .name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
- .allowedRules(ImmutableSet.of(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .build(),
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(23)
- .build()))
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2");
-
- assertGlobalOperationDoneSucessfully(api().update(FIREWALL_NAME, firewall), TIME_WAIT);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testPatchFirewall")
- public void testGetFirewall() {
-
- FirewallOptions patchedFirewall = new FirewallOptions()
- .name(FIREWALL_NAME)
- .network(getNetworkUrl(userProject.get(), FIREWALL_NETWORK_NAME))
- .allowedRules(ImmutableSet.of(
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(22)
- .build(),
- Firewall.Rule.builder()
- .IpProtocol(IpProtocol.TCP)
- .addPort(23)
- .build()))
- .addSourceRange("10.0.0.0/8")
- .addSourceTag("tag1")
- .addTargetTag("tag2");
-
- Firewall firewall = api().get(FIREWALL_NAME);
- assertNotNull(firewall);
- assertFirewallEquals(firewall, patchedFirewall);
- }
-
- @Test(groups = "live", dependsOnMethods = "testGetFirewall")
- public void testListFirewall() {
-
- PagedIterable<Firewall> firewalls = api().list(new ListOptions.Builder()
- .filter("name eq " + FIREWALL_NAME));
-
- List<Firewall> firewallsAsList = Lists.newArrayList(firewalls.concat());
-
- assertEquals(firewallsAsList.size(), 1);
-
- }
-
- @Test(groups = "live", dependsOnMethods = "testListFirewall")
- public void testDeleteFirewall() {
-
- assertGlobalOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT);
- assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
- (FIREWALL_NETWORK_NAME), TIME_WAIT);
- }
-
- private void assertFirewallEquals(Firewall result, FirewallOptions expected) {
- assertEquals(result.getName(), expected.getName());
- assertEquals(getOnlyElement(result.getSourceRanges()), getOnlyElement(expected.getSourceRanges()));
- assertEquals(getOnlyElement(result.getSourceTags()), getOnlyElement(expected.getSourceTags()));
- assertEquals(getOnlyElement(result.getTargetTags()), getOnlyElement(expected.getTargetTags()));
- assertEquals(result.getAllowed(), expected.getAllowed());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
deleted file mode 100644
index 7fac1d7..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.jclouds.googlecomputeengine.parse.ParseOperationListTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit")
-public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/operations";
-
- public static final HttpRequest GET_GLOBAL_OPERATION_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint(OPERATIONS_URL_PREFIX + "/operation-1354084865060-4cf88735faeb8-bbbb12cb")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse GET_GLOBAL_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/global_operation.json")).build();
-
- public void testGetOperationResponseIs2xx() throws Exception {
-
- GlobalOperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getGlobalOperationApiForProject("myproject");
-
- assertEquals(operationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
- new ParseOperationTest().expected());
- }
-
- public void testGetOperationResponseIs4xx() throws Exception {
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getGlobalOperationApiForProject("myproject");
-
- assertNull(globalOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"));
- }
-
- public void testDeleteOperationResponseIs2xx() throws Exception {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
-
- GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
-
- globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
- }
-
- public void testDeleteOperationResponseIs4xx() throws Exception {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
-
- globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
- }
-
- public void testLisOperationWithNoOptionsResponseIs2xx() {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint(OPERATIONS_URL_PREFIX)
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/global_operation_list.json")).build();
-
- GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
-
- assertEquals(globalOperationApi.listFirstPage().toString(),
- new ParseOperationListTest().expected().toString());
- }
-
- public void testListOperationWithPaginationOptionsResponseIs2xx() {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint(OPERATIONS_URL_PREFIX +
- "?pageToken=CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcG" +
- "VyYXRpb24tMTM1MjI0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz&" +
- "filter=" +
- "status%20eq%20done&" +
- "maxResults=3")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/global_operation_list.json")).build();
-
- GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
-
- assertEquals(globalOperationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
- "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
- new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(),
- new ParseOperationListTest().expected().toString());
- }
-
- public void testListOperationWithPaginationOptionsResponseIs4xx() {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint(OPERATIONS_URL_PREFIX)
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
-
- assertTrue(globalOperationApi.list().concat().isEmpty());
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
deleted file mode 100644
index 704df02..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static org.jclouds.googlecomputeengine.features.ProjectApiLiveTest.addItemToMetadata;
-import static org.jclouds.googlecomputeengine.features.ProjectApiLiveTest.deleteItemFromMetadata;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Operation;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private static final String METADATA_ITEM_KEY = "operationLiveTestTestProp";
- private static final String METADATA_ITEM_VALUE = "operationLiveTestTestValue";
- private Operation addOperation;
- private Operation deleteOperation;
-
- private GlobalOperationApi api() {
- return api.getGlobalOperationApiForProject(userProject.get());
- }
-
-
- @Test(groups = "live")
- public void testCreateOperations() {
- //create some operations by adding and deleting metadata items
- // this will make sure there is stuff to listFirstPage
- addOperation = assertGlobalOperationDoneSucessfully(addItemToMetadata(api.getProjectApi(),
- userProject.get(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE), 20);
- deleteOperation = assertGlobalOperationDoneSucessfully(deleteItemFromMetadata(api
- .getProjectApi(), userProject.get(), METADATA_ITEM_KEY), 20);
-
- assertNotNull(addOperation);
- assertNotNull(deleteOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
- public void testGetOperation() {
- Operation operation = api().get(addOperation.getName());
- assertNotNull(operation);
- assertOperationEquals(operation, this.addOperation);
- }
-
- @Test(groups = "live", dependsOnMethods = "testCreateOperations")
- public void testListOperationsWithFiltersAndPagination() {
- PagedIterable<Operation> operations = api().list(new ListOptions.Builder()
- .filter("operationType eq setMetadata")
- .maxResults(1));
-
- // make sure that in spite of having only one result per page we get at least two results
- final AtomicInteger counter = new AtomicInteger();
- operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() {
-
- @Override
- public boolean apply(IterableWithMarker<Operation> input) {
- counter.addAndGet(Iterables.size(input));
- return counter.get() == 2;
- }
- });
- }
-
- private void assertOperationEquals(Operation result, Operation expected) {
- assertEquals(result.getName(), expected.getName());
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
deleted file mode 100644
index 1deb178..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseImageListTest;
-import org.jclouds.googlecomputeengine.parse.ParseImageTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit")
-public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- public static final HttpRequest LIST_PROJECT_IMAGES_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/images")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse LIST_PROJECT_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/image_list.json")).build();
-
- public static final HttpRequest LIST_CENTOS_IMAGES_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse LIST_CENTOS_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/image_list_centos.json")).build();
-
- public static final HttpRequest LIST_DEBIAN_IMAGES_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse LIST_DEBIAN_IMAGES_RESPONSE =
- HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/image_list_debian.json")).build();
-
- public void testGetImageResponseIs2xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/image_get.json")).build();
-
- ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
-
- assertEquals(imageApi.get("centos-6-2-v20120326"),
- new ParseImageTest().expected());
- }
-
- public void testGetImageResponseIs4xx() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
-
- assertNull(imageApi.get("centos-6-2-v20120326"));
- }
-
- public void testDeleteImageResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/images/centos-6-2-v20120326")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/operation.json")).build();
-
- ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject");
-
- assertEquals(imageApi.delete("centos-6-2-v20120326"),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteImageResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/images/centos-6-2-v20120326")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject");
-
- assertNull(imageApi.delete("centos-6-2-v20120326"));
- }
-
- public void testListImagesResponseIs2xx() {
-
- ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApiForProject
- ("myproject");
-
- assertEquals(imageApi.listFirstPage().toString(),
- new ParseImageListTest().expected().toString());
- }
-
- public void testListImagesResponseIs4xx() {
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApiForProject("myproject");
-
- assertTrue(imageApi.list().concat().isEmpty());
- }
-}
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
deleted file mode 100644
index a4922b4..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertSame;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.jclouds.collect.IterableWithMarker;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.googlecomputeengine.domain.Image;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
-import org.jclouds.googlecomputeengine.options.ListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
-
- private Image image;
-
- private ImageApi api() {
- return api.getImageApiForProject("centos-cloud");
- }
-
- @Test(groups = "live")
- public void testListImage() {
-
- PagedIterable<Image> images = api().list(new ListOptions.Builder().maxResults(1));
-
- Iterator<IterableWithMarker<Image>> pageIterator = images.iterator();
- assertTrue(pageIterator.hasNext());
-
- IterableWithMarker<Image> singlePageIterator = pageIterator.next();
- List<Image> imageAsList = Lists.newArrayList(singlePageIterator);
-
- assertSame(imageAsList.size(), 1);
-
- this.image = Iterables.getOnlyElement(imageAsList);
- }
-
-
- @Test(groups = "live", dependsOnMethods = "testListImage")
- public void testGetImage() {
- Image image = api().get(this.image.getName());
- assertNotNull(image);
- assertImageEquals(image, this.image);
- }
-
- private void assertImageEquals(Image result, Image expected) {
- assertEquals(result.getName(), expected.getName());
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
deleted file mode 100644
index f460de6..0000000
--- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * 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.googlecomputeengine.features;
-
-import static java.net.URI.create;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
-import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
-import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_REQUEST;
-import static org.jclouds.googlecomputeengine.features.ProjectApiExpectTest.GET_PROJECT_RESPONSE;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.net.URI;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.domain.Instance;
-import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
-import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
-import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskMode;
-import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskType;
-import org.jclouds.googlecomputeengine.parse.ParseInstanceListTest;
-import org.jclouds.googlecomputeengine.parse.ParseInstanceSerialOutputTest;
-import org.jclouds.googlecomputeengine.parse.ParseInstanceTest;
-import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-@Test(groups = "unit")
-public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
-
- public static final HttpRequest GET_INSTANCE_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-
- public static final HttpResponse GET_INSTANCE_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/instance_get.json")).build();
-
- public static final HttpRequest LIST_INSTANCES_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse LIST_INSTANCES_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/instance_list.json")).build();
-
- public static final HttpRequest LIST_CENTRAL1B_INSTANCES_REQUEST = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-b/instances")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- public static final HttpResponse LIST_CENTRAL1B_INSTANCES_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/instance_list_central1b_empty.json")).build();
-
- public static final HttpResponse CREATE_INSTANCE_RESPONSE = HttpResponse.builder().statusCode(200)
- .payload(staticPayloadFromResource("/zone_operation.json")).build();
-
-
- public void testGetInstanceResponseIs2xx() throws Exception {
-
- InstanceApi api = requestsSendResponses(
- requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
- GET_INSTANCE_REQUEST, GET_INSTANCE_RESPONSE).getInstanceApiForProject("myproject");
-
- assertEquals(api.getInZone("us-central1-a", "test-1"), new ParseInstanceTest().expected());
- }
-
- public void testGetInstanceResponseIs4xx() throws Exception {
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_INSTANCE_REQUEST, operationResponse).getInstanceApiForProject("myproject");
-
- assertNull(api.getInZone("us-central1-a", "test-1"));
- }
-
- public void testGetInstanceSerialPortOutput() throws Exception {
- HttpRequest get = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/serialPort")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/instance_serial_port.json")).build();
-
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, get, operationResponse).getInstanceApiForProject("myproject");
-
- assertEquals(api.getSerialPortOutputInZone("us-central1-a", "test-1"), new ParseInstanceSerialOutputTest().expected());
- }
-
- public void testInsertInstanceResponseIs2xxNoOptions() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/instance_insert_simple.json", MediaType.APPLICATION_JSON))
- .build();
-
- InstanceApi api = requestsSendResponses(ImmutableMap.of(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
- requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert,
- CREATE_INSTANCE_RESPONSE)).getInstanceApiForProject("myproject");
-
- InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
- .addNetworkInterface(URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"));
-
- assertEquals(api.createInZone("test-1", "us-central1-a", options), new ParseOperationTest().expected());
- }
-
- public void testInsertInstanceResponseIs2xxAllOptions() {
- HttpRequest insert = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/instance_insert.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse insertInstanceResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- InstanceApi api = requestsSendResponses(ImmutableMap.of(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
- requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, insert, insertInstanceResponse)).getInstanceApiForProject("myproject");
-
- InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
- .addNetworkInterface(URI.create("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/global/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
- .description("desc")
- .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE,
- create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"),
- true)
- .addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build())
- .addMetadata("aKey", "aValue");
-
- assertEquals(api.createInZone("test-0", "us-central1-a", options),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteInstanceResponseIs2xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject");
-
- assertEquals(api.deleteInZone("us-central1-a", "test-1"),
- new ParseOperationTest().expected());
- }
-
- public void testDeleteInstanceResponseIs4xx() {
- HttpRequest delete = HttpRequest
- .builder()
- .method("DELETE")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject");
-
- assertNull(api.deleteInZone("us-central1-a", "test-1"));
- }
-
- public void testListInstancesResponseIs2xx() {
-
- InstanceApi api = requestsSendResponses(
- requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
- LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApiForProject("myproject");
-
- assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
- new ParseInstanceListTest().expected().toString());
- }
-
- public void testListInstancesResponseIs4xx() {
- HttpRequest list = HttpRequest
- .builder()
- .method("GET")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
- TOKEN_RESPONSE, list, operationResponse).getInstanceApiForProject("myproject");
-
- assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
- }
-
- public void testSetInstanceMetadataResponseIs2xx() {
- HttpRequest setMetadata = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/instance_set_metadata.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject");
-
- assertEquals(api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh"),
- new ParseOperationTest().expected());
- }
-
- public void testSetInstanceMetadataResponseIs4xx() {
- HttpRequest setMetadata = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/instance_set_metadata.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject");
-
- assertNull(api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh"));
- }
-
- public void testResetInstanceResponseIs2xx() {
- HttpRequest reset = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/reset")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse resetResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject");
-
- assertEquals(api.resetInZone("us-central1-a", "test-1"),
- new ParseOperationTest().expected());
- }
-
- public void testResetInstanceResponseIs4xx() {
- HttpRequest reset = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/reset")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN).build();
-
- HttpResponse resetResponse = HttpResponse.builder().statusCode(404).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject");
-
- assertNull(api.resetInZone("us-central1-a", "test-1"));
- }
-
- public void testAttachDiskResponseIs2xx() {
- HttpRequest attach = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/instance_attach_disk.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse attachResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject");
-
- assertEquals(api.attachDiskInZone("us-central1-a", "test-1",
- new AttachDiskOptions()
- .mode(DiskMode.READ_ONLY)
- .source(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
- .type(DiskType.PERSISTENT)),
- new ParseOperationTest().expected());
- }
-
- public void testAttachDiskResponseIs4xx() {
- HttpRequest attach = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .payload(payloadFromResourceWithContentType("/instance_attach_disk.json", MediaType.APPLICATION_JSON))
- .build();
-
- HttpResponse attachResponse = HttpResponse.builder().statusCode(404).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject");
-
- assertNull(api.attachDiskInZone("us-central1-a", "test-1",
- new AttachDiskOptions()
- .mode(DiskMode.READ_ONLY)
- .source(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
- .type(DiskType.PERSISTENT)));
-
- }
-
- public void testDetachDiskResponseIs2xx() {
- HttpRequest detach = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
- "?deviceName=test-disk-1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .build();
-
- HttpResponse detachResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/zone_operation.json")).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject");
-
- assertEquals(api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1"),
- new ParseOperationTest().expected());
- }
-
- public void testDetachDiskResponseIs4xx() {
- HttpRequest detach = HttpRequest
- .builder()
- .method("POST")
- .endpoint("https://www.googleapis" +
- ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
- "?deviceName=test-disk-1")
- .addHeader("Accept", "application/json")
- .addHeader("Authorization", "Bearer " + TOKEN)
- .build();
-
- HttpResponse detachResponse = HttpResponse.builder().statusCode(404).build();
-
- InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
- TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject");
-
- assertNull(api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1"));
- }
-
-}