You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/27 00:28:46 UTC

[3/3] jclouds-labs-google git commit: Converting tests to Mock

Converting tests to Mock


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/f41d49ce
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/f41d49ce
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/f41d49ce

Branch: refs/heads/master
Commit: f41d49ceab60ff017b00348e95e0589a5cb5cc62
Parents: c2fd429
Author: Daniel Broudy <br...@google.com>
Authored: Tue Nov 25 13:43:54 2014 -0800
Committer: Adrian Cole <ac...@twitter.com>
Committed: Wed Nov 26 15:27:44 2014 -0800

----------------------------------------------------------------------
 .../features/AddressApiExpectTest.java          | 149 ---------
 .../features/AddressApiMockTest.java            |  87 +++++
 .../features/BackendServiceApiExpectTest.java   | 146 ---------
 .../features/BackendServiceApiMockTest.java     | 136 ++++++++
 .../features/DiskApiExpectTest.java             | 217 -------------
 .../features/DiskApiMockTest.java               | 128 ++++++++
 .../features/DiskTypeApiExpectTest.java         | 101 ------
 .../features/DiskTypeApiMockTest.java           |  63 ++++
 .../features/FirewallApiExpectTest.java         |  90 ------
 .../features/FirewallApiMockTest.java           |  82 +++++
 .../features/ForwardingRuleApiExpectTest.java   | 177 ----------
 .../features/ForwardingRuleApiMockTest.java     | 104 ++++++
 .../GlobalForwardingRuleApiExpectTest.java      | 177 ----------
 .../GlobalForwardingRuleApiMockTest.java        | 106 ++++++
 .../features/HttpHealthCheckApiExpectTest.java  | 141 +-------
 .../features/HttpHealthCheckApiMockTest.java    | 109 +++++++
 .../features/ImageApiMockTest.java              |  12 +-
 .../features/InstanceApiExpectTest.java         | 321 -------------------
 .../features/InstanceApiMockTest.java           | 162 +++++++++-
 .../features/MachineTypeApiExpectTest.java      | 109 -------
 .../features/MachineTypeApiMockTest.java        |  63 ++++
 .../parse/ParseAddressListTest.java             |  11 +-
 .../parse/ParseAddressTest.java                 |  11 +-
 .../parse/ParseBackendServiceGetHealthTest.java |   8 +-
 .../parse/ParseBackendServiceListTest.java      |  11 +-
 .../parse/ParseBackendServiceTest.java          |  12 +-
 .../parse/ParseDiskListTest.java                |   7 +-
 .../parse/ParseDiskTest.java                    |  11 +-
 .../parse/ParseFirewallListTest.java            |  11 +-
 .../parse/ParseFirewallTest.java                |   9 +-
 .../parse/ParseForwardingRuleListTest.java      |   7 +-
 .../parse/ParseForwardingRuleTest.java          |  10 +-
 .../parse/ParseGlobalOperationTest.java         |   9 +-
 .../parse/ParseHttpHealthCheckListTest.java     |  11 +-
 .../parse/ParseHttpHealthCheckTest.java         |   7 +-
 .../parse/ParseInstanceListTest.java            |   7 +-
 .../parse/ParseInstanceTest.java                |  17 +-
 .../parse/ParseMachineTypeListTest.java         |  11 +-
 .../parse/ParseMachineTypeTest.java             |   7 +-
 .../parse/ParseRegionOperationTest.java         |  11 +-
 .../src/test/resources/address_get.json         |   1 -
 .../resources/machinetype_list_central1b.json   |  41 ---
 .../machinetype_list_central1b_empty.json       |   6 -
 43 files changed, 1175 insertions(+), 1741 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
deleted file mode 100644
index 5feeef1..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java
+++ /dev/null
@@ -1,149 +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.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseAddressListTest;
-import org.jclouds.googlecomputeengine.parse.ParseAddressTest;
-import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "AddressApiExpectTest")
-public class AddressApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   public void testGetAddressResponseIs2xx() throws Exception {
-      HttpRequest get = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/regions/us-central1/addresses/test-ip1")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/address_get.json")).build();
-
-      AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, response).addressesInRegion("us-central1");
-
-      assertEquals(api.get("test-ip1"), new ParseAddressTest().expected());
-   }
-
-   public void testGetAddressResponseIs4xx() throws Exception {
-      HttpRequest get = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/regions/us-central1/addresses/test-ip1")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, response).addressesInRegion("us-central1");
-
-      assertNull(api.get("test-ip1"));
-   }
-
-   public void testInsertAddressResponseIs2xx() {
-      HttpRequest insert = HttpRequest
-              .builder()
-              .method("POST")
-              .endpoint(BASE_URL + "/party/regions/us-central1/addresses")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN)
-              .payload(payloadFromResourceWithContentType("/address_insert.json", MediaType.APPLICATION_JSON))
-              .build();
-
-      HttpResponse insertAddressResponse = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/region_operation.json")).build();
-
-      AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, insert,
-              insertAddressResponse).addressesInRegion("us-central1");
-
-      assertEquals(api.create("test-ip1"), new ParseRegionOperationTest().expected());
-   }
-
-   public void testDeleteAddressResponseIs2xx() {
-      HttpRequest delete = HttpRequest
-              .builder()
-              .method("DELETE")
-              .endpoint(BASE_URL + "/party/regions/us-central1/addresses/test-ip1")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/region_operation.json")).build();
-
-      AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).addressesInRegion("us-central1");
-
-      assertEquals(api.delete("test-ip1"), new ParseRegionOperationTest().expected());
-   }
-
-   public void testDeleteAddressResponseIs4xx() {
-      HttpRequest delete = HttpRequest
-              .builder()
-              .method("DELETE")
-              .endpoint(BASE_URL + "/party/regions/us-central1/addresses/test-ip1")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
-      AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, delete, deleteResponse).addressesInRegion("us-central1");
-
-      assertNull(api.delete("test-ip1"));
-   }
-
-   HttpRequest list = HttpRequest
-         .builder()
-         .method("GET")
-         .endpoint(BASE_URL + "/party/regions/us-central1/addresses")
-         .addHeader("Accept", "application/json")
-         .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public void list() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/address_list.json")).build();
-
-      AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).addressesInRegion("us-central1");
-
-      assertEquals(api.list().next(), new ParseAddressListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).addressesInRegion("us-central1");
-
-      assertFalse(api.list().hasNext());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiMockTest.java
new file mode 100644
index 0000000..3903048
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiMockTest.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.googlecomputeengine.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.parse.ParseAddressListTest;
+import org.jclouds.googlecomputeengine.parse.ParseAddressTest;
+import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "AddressApiExpectTest", singleThreaded = true)
+public class AddressApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception{
+      server.enqueue(jsonResponse("/address_get.json"));
+
+      assertEquals(addressApi().get("test-ip1"), new ParseAddressTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/regions/us-central1/addresses/test-ip1");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(addressApi().get("test-ip1"));
+      assertSent(server, "GET", "/projects/party/regions/us-central1/addresses/test-ip1");
+   }
+
+   public void insert() throws Exception {
+      server.enqueue(jsonResponse("/region_operation.json"));
+
+      assertEquals(addressApi().create("test-ip1"),
+            new ParseRegionOperationTest().expected(url("/projects")));
+      assertSent(server, "POST", "/projects/party/regions/us-central1/addresses",
+            stringFromResource("/address_insert.json"));
+   }
+
+   public void delete() throws Exception {
+      server.enqueue(jsonResponse("/region_operation.json"));
+
+      assertEquals(addressApi().delete("test-ip1"),
+            new ParseRegionOperationTest().expected(url("/projects")));
+      assertSent(server, "DELETE", "/projects/party/regions/us-central1/addresses/test-ip1");
+   }
+
+   public void delete_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(addressApi().delete("test-ip1"));
+      assertSent(server, "DELETE", "/projects/party/regions/us-central1/addresses/test-ip1");
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/address_list.json"));
+
+      assertEquals(addressApi().list().next(), new ParseAddressListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/regions/us-central1/addresses");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(addressApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/regions/us-central1/addresses");
+   }
+
+   AddressApi addressApi(){
+      return api().addressesInRegion("us-central1");
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java
index 2e03495..79fd5f7 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java
@@ -18,8 +18,6 @@ package org.jclouds.googlecomputeengine.features;
 
 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
 import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
 
 import java.io.IOException;
 import java.net.URI;
@@ -28,9 +26,6 @@ import java.util.List;
 import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
 import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
 import org.jclouds.googlecomputeengine.options.BackendServiceOptions;
-import org.jclouds.googlecomputeengine.parse.ParseBackendServiceGetHealthTest;
-import org.jclouds.googlecomputeengine.parse.ParseBackendServiceListTest;
-import org.jclouds.googlecomputeengine.parse.ParseBackendServiceTest;
 import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.http.HttpResponse;
@@ -55,75 +50,6 @@ public class BackendServiceApiExpectTest extends BaseGoogleComputeEngineExpectTe
                                    .build();
    }
 
-   public void testGetBackendServiceResponseIs2xx() throws Exception {
-      HttpRequest request = getBasicRequest().method("GET")
-                                             .endpoint(ENDPOINT_BASE + "/jclouds-test")
-                                             .build();
-      HttpResponse response = createResponse("/backend_service_get.json");
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response)
-              .backendServices();
-
-      assertEquals(api.get("jclouds-test"), new ParseBackendServiceTest().expected());
-   }
-
-   public void testGetBackendServiceResponseIs4xx() throws Exception {
-      HttpRequest request = getBasicRequest().method("GET")
-                                             .endpoint(ENDPOINT_BASE + "/jclouds-test")
-                                             .build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response)
-              .backendServices();
-
-      assertNull(api.get("jclouds-test"));
-   }
-
-   public void testInsertBackendServiceResponseIs2xx() throws IOException {
-      HttpRequest request = getBasicRequest().method("POST")
-               .endpoint(ENDPOINT_BASE)
-               .payload(payloadFromResourceWithContentType("/backend_service_insert.json",
-                                                           APPLICATION_JSON))
-               .build();
-      HttpResponse response = createResponse("/operation.json");
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).backendServices();
-
-      List<URI> healthChecks = ImmutableList.of(URI.create("https://www.googleapis.com/compute/v1/projects/"
-                           + "myproject/global/httpHealthChecks/jclouds-test"));
-      assertEquals(api.create( new BackendServiceOptions().name("jclouds-test")
-                                                                         .protocol("HTTP")
-                                                                         .port(80)
-                                                                         .timeoutSec(30)
-                                                                         .healthChecks(healthChecks)),
-                   new ParseOperationTest().expected());
-
-   }
-
-   public void testUpdateBackendServiceResponseIs2xx() throws IOException {
-      HttpRequest request = getBasicRequest().method("PUT")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .payload(payloadFromResourceWithContentType("/backend_service_insert.json",
-                                                           APPLICATION_JSON))
-               .build();
-      HttpResponse response = createResponse("/operation.json");
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).backendServices();
-
-      List<URI> healthChecks = ImmutableList.of(URI.create("https://www.googleapis.com/compute/v1/projects/"
-                          + "myproject/global/httpHealthChecks/jclouds-test"));
-      assertEquals(api.update("jclouds-test", new BackendServiceOptions().name("jclouds-test")
-                                                                         .protocol("HTTP")
-                                                                         .port(80)
-                                                                         .timeoutSec(30)
-                                                                         .healthChecks(healthChecks)),
-                   new ParseOperationTest().expected());
-   }
-
    public void testPatchBackendServiceResponseIs2xx() throws IOException {
       HttpRequest request = getBasicRequest().method("PATCH")
                .endpoint(ENDPOINT_BASE + "/jclouds-test")
@@ -144,76 +70,4 @@ public class BackendServiceApiExpectTest extends BaseGoogleComputeEngineExpectTe
                                                                          .healthChecks(healthChecks)),
                    new ParseOperationTest().expected());
    }
-
-   public void testDeleteBackendServiceResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("DELETE")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-      HttpResponse response = createResponse("/operation.json");
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).backendServices();
-
-      assertEquals(api.delete("jclouds-test"), new ParseOperationTest().expected());
-   }
-
-   public void testDeleteBackendServiceResponseIs4xx() {
-      HttpRequest request = getBasicRequest().method("DELETE")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).backendServices();
-
-      assertNull(api.delete("jclouds-test"));
-   }
-
-   public void testListBackendServiceResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("GET")
-               .endpoint(ENDPOINT_BASE)
-               .build();
-      HttpResponse response = createResponse("/backend_service_list.json");
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response).backendServices();
-
-      assertEquals(api.list().next(), new ParseBackendServiceListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpRequest list = HttpRequest
-            .builder()
-            .method("GET")
-            .endpoint(BASE_URL + "/party/global/backendServices")
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, list, response).backendServices();
-
-      assertFalse(api.list().hasNext());
-   }
-
-   public void testGetHealthResponseIs2xx() throws IOException {
-      HttpRequest request = getBasicRequest().method("POST")
-                                             .endpoint(ENDPOINT_BASE
-                                                       + "/jclouds-test/getHealth")
-                                             .payload(payloadFromResource("/backend_service_get_health_request.json"))
-                                             .build();
-      HttpResponse response = createResponse("/backend_service_get_health.json");
-
-      BackendServiceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).backendServices();
-
-      URI group = URI.create("https://www.googleapis.com/resourceviews/v1beta1/"
-                             + "projects/myproject/zones/us-central1-a/"
-                             + "resourceViews/jclouds-test");
-      assertEquals(api.getHealth("jclouds-test", group), new ParseBackendServiceGetHealthTest().expected());
-
-   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java
new file mode 100644
index 0000000..0434401
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiMockTest.java
@@ -0,0 +1,136 @@
+/*
+ * 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.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.net.URI;
+import java.util.List;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.options.BackendServiceOptions;
+import org.jclouds.googlecomputeengine.parse.ParseBackendServiceGetHealthTest;
+import org.jclouds.googlecomputeengine.parse.ParseBackendServiceListTest;
+import org.jclouds.googlecomputeengine.parse.ParseBackendServiceTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "BackendServiceApiMockTest", singleThreaded = true)
+public class BackendServiceApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/backend_service_get.json"));
+
+      assertEquals(backendServiceApi().get("jclouds-test"),
+            new ParseBackendServiceTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/global/backendServices/jclouds-test");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(backendServiceApi().get("jclouds-test"));
+      assertSent(server, "GET", "/projects/party/global/backendServices/jclouds-test");
+   }
+
+   public void insert() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      List<URI> healthChecks = ImmutableList.of(URI.create(url("/projects/"
+            + "myproject/global/httpHealthChecks/jclouds-test")));
+
+      assertEquals(backendServiceApi().create( new BackendServiceOptions().name("jclouds-test")
+            .protocol("HTTP")
+            .port(80)
+            .timeoutSec(30)
+            .healthChecks(healthChecks)),
+            new ParseOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/global/backendServices",
+            stringFromResource("/backend_service_insert.json"));
+   }
+
+   public void update() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      List<URI> healthChecks = ImmutableList.of(URI.create(url("/projects/"
+            + "myproject/global/httpHealthChecks/jclouds-test")));
+
+      assertEquals(backendServiceApi().update("jclouds-test",
+            new BackendServiceOptions().name("jclouds-test")
+               .protocol("HTTP")
+               .port(80)
+               .timeoutSec(30)
+               .healthChecks(healthChecks)),
+            new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "PUT", "/projects/party/global/backendServices/jclouds-test",
+            stringFromResource("/backend_service_insert.json"));
+   }
+
+   public void delete() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      assertEquals(backendServiceApi().delete("jclouds-test"),
+            new ParseOperationTest().expected(url("/projects")));
+
+      assertSent(server, "DELETE", "/projects/party/global/backendServices/jclouds-test");
+   }
+
+   public void delete_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(backendServiceApi().delete("jclouds-test"));
+
+      assertSent(server, "DELETE", "/projects/party/global/backendServices/jclouds-test");
+   }
+
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/backend_service_list.json"));
+
+      assertEquals(backendServiceApi().list().next(), new ParseBackendServiceListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/global/backendServices");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(backendServiceApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/global/backendServices");
+   }
+
+   public void getHealth() throws Exception {
+      server.enqueue(jsonResponse("/backend_service_get_health.json"));
+
+      URI group = URI.create("https://www.googleapis.com/resourceviews/v1beta1/"
+            + "projects/myproject/zones/us-central1-a/"
+            + "resourceViews/jclouds-test");
+      assertEquals(backendServiceApi().getHealth("jclouds-test", group),
+            new ParseBackendServiceGetHealthTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/global/backendServices/jclouds-test/getHealth",
+            stringFromResource("/backend_service_get_health_request.json"));
+   }
+
+   public BackendServiceApi backendServiceApi(){
+      return api().backendServices();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
deleted file mode 100644
index e3807bc..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java
+++ /dev/null
@@ -1,217 +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.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.net.URI;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
-import org.jclouds.googlecomputeengine.parse.ParseDiskListTest;
-import org.jclouds.googlecomputeengine.parse.ParseDiskTest;
-import org.jclouds.googlecomputeengine.parse.ParseZoneOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "DiskApiExpectTest")
-public class DiskApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-   public static final String IMAGE_URL = BASE_URL + "/party/zones/us-central1-a/images/foo";
-   public static final String SSD_URL = BASE_URL + "/party/zones/us-central1-a/diskTypes/pd-ssd";
-
-   public void testGetDiskResponseIs2xx() throws Exception {
-      HttpRequest get = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/zones/us-central1-a/disks/testimage1")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/disk_get.json")).build();
-
-      DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, response).disksInZone("us-central1-a");
-
-      assertEquals(api.get("testimage1"), new ParseDiskTest().expected());
-   }
-
-   public void testGetDiskResponseIs4xx() throws Exception {
-      HttpRequest get = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/zones/us-central1-a/disks/testimage1")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, response).disksInZone("us-central1-a");
-
-      assertNull(api.get("testimage1"));
-   }
-
-   public void testInsertDiskResponseIs2xx() {
-      HttpRequest insert = HttpRequest
-              .builder()
-              .method("POST")
-              .endpoint(BASE_URL + "/party/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).disksInZone("us-central1-a");
-
-      assertEquals(api.create("testimage1", 1), new ParseZoneOperationTest().expected());
-   }
-
-   public void testInsertDiskFromImageResponseIs2xx() {
-      HttpRequest insert = HttpRequest
-              .builder()
-              .method("POST")
-              .endpoint(BASE_URL + "/party/zones/us-central1-a/disks")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN)
-              .payload(payloadFromResourceWithContentType("/disk_insert_sourceImage.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).disksInZone("us-central1-a");
-
-      DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(IMAGE_URL));
-      assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected());
-   }
-
-   public void testInsertDiskSSDResponseIs2xx(){
-      HttpRequest insert = HttpRequest
-            .builder()
-            .method("POST")
-            .endpoint(BASE_URL + "/party/zones/us-central1-a/disks")
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN)
-            .payload(payloadFromResourceWithContentType("/disk_insert_ssd.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).disksInZone("us-central1-a");
-
-    DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(URI.create(SSD_URL));
-    assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected());
-   }
-
-   public void testCreateSnapshotResponseIs2xx() {
-      HttpRequest createSnapshotRequest = HttpRequest
-              .builder()
-              .method("POST")
-              .endpoint(BASE_URL + "/party/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).disksInZone("us-central1-a");
-
-      assertEquals(api.createSnapshot("testimage1", "test-snap"), new ParseZoneOperationTest().expected());
-   }
-
-   public void testDeleteDiskResponseIs2xx() {
-      HttpRequest delete = HttpRequest
-              .builder()
-              .method("DELETE")
-              .endpoint(BASE_URL + "/party/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).disksInZone("us-central1-a");
-
-      assertEquals(api.delete("testimage1"),
-              new ParseZoneOperationTest().expected());
-   }
-
-   public void testDeleteDiskResponseIs4xx() {
-      HttpRequest delete = HttpRequest
-              .builder()
-              .method("DELETE")
-              .endpoint(BASE_URL + "/party/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).disksInZone("us-central1-a");
-
-      assertNull(api.delete("testimage1"));
-   }
-
-   HttpRequest list = HttpRequest
-         .builder()
-         .method("GET")
-         .endpoint(BASE_URL + "/party/zones/us-central1-a/disks")
-         .addHeader("Accept", "application/json")
-         .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public void list() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/disk_list.json")).build();
-
-      DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).disksInZone("us-central1-a");
-
-      assertEquals(api.list().next(), new ParseDiskListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-      
-      DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).disksInZone("us-central1-a");
-
-      assertFalse(api.list().hasNext());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiMockTest.java
new file mode 100644
index 0000000..7633a03
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiMockTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.net.URI;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.options.DiskCreationOptions;
+import org.jclouds.googlecomputeengine.parse.ParseDiskListTest;
+import org.jclouds.googlecomputeengine.parse.ParseDiskTest;
+import org.jclouds.googlecomputeengine.parse.ParseZoneOperationTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "DiskApiMockTest", singleThreaded = true)
+public class DiskApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public static final String IMAGE_URL = "/projects/party/zones/us-central1-a/images/foo";
+   public static final String SSD_URL =  "/projects/party/zones/us-central1-a/diskTypes/pd-ssd";
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/disk_get.json"));
+
+      assertEquals(diskApi().get("testimage1"), new ParseDiskTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/disks/testimage1");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(diskApi().get("testimage1"));
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/disks/testimage1");
+   }
+
+   public void insert() throws Exception {
+      server.enqueue(jsonResponse("/zone_operation.json"));
+
+      assertEquals(diskApi().create("testimage1", 1),
+            new ParseZoneOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/zones/us-central1-a/disks",
+            stringFromResource("/disk_insert.json"));
+   }
+
+   public void insertFromImage() throws Exception {
+      server.enqueue(jsonResponse("/zone_operation.json"));
+
+      DiskCreationOptions diskCreationOptions = new DiskCreationOptions()
+         .sourceImage(URI.create(url(IMAGE_URL)));
+      assertEquals(diskApi().create("testimage1", 1, diskCreationOptions),
+            new ParseZoneOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/zones/us-central1-a/disks",
+            stringFromResource("/disk_insert_sourceImage.json"));
+   }
+
+   public void insertFromSSD() throws Exception {
+      server.enqueue(jsonResponse("/zone_operation.json"));
+
+      DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(URI.create(url(SSD_URL)));
+      assertEquals(diskApi().create("testimage1", 1, diskCreationOptions),
+            new ParseZoneOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/zones/us-central1-a/disks",
+            stringFromResource("/disk_insert_ssd.json"));
+   }
+
+   public void creatSnapshot() throws Exception {
+      server.enqueue(jsonResponse("/zone_operation.json"));
+
+      assertEquals(diskApi().createSnapshot("testimage1", "test-snap"),
+            new ParseZoneOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/zones/us-central1-a/disks/testimage1/createSnapshot",
+            stringFromResource("/disk_create_snapshot.json"));
+   }
+
+   public void delete() throws Exception {
+      server.enqueue(jsonResponse("/zone_operation.json"));
+
+      assertEquals(diskApi().delete("testimage1"),
+            new ParseZoneOperationTest().expected(url("/projects")));
+
+      assertSent(server, "DELETE", "/projects/party/zones/us-central1-a/disks/testimage1");
+   }
+
+   public void delete_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(diskApi().delete("testimage1"));
+      assertSent(server, "DELETE", "/projects/party/zones/us-central1-a/disks/testimage1");
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/disk_list.json"));
+
+      assertEquals(diskApi().list().next(), new ParseDiskListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/disks");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(diskApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/disks");
+   }
+
+   public DiskApi diskApi(){
+      return api().disksInZone("us-central1-a");
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
deleted file mode 100644
index 37ece62..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java
+++ /dev/null
@@ -1,101 +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.options.ListOptions.Builder.maxResults;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseDiskTypeListTest;
-import org.jclouds.googlecomputeengine.parse.ParseDiskTypeTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "DiskTypeApiExpectTest")
-public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   public static final HttpRequest LIST_DISK_TYPES_REQUEST = HttpRequest
-           .builder()
-           .method("GET")
-           .endpoint(BASE_URL + "/party/zones/us-central1-a/diskTypes")
-           .addHeader("Accept", "application/json")
-           .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public static final HttpResponse LIST_DISK_TYPES_RESPONSE = HttpResponse.builder()
-           .statusCode(200)
-           .payload(staticPayloadFromResource("/disktype_list.json"))
-           .build();
-
-   public void testGetDiskTypeResponseIs2xx() throws Exception {
-      HttpRequest get = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/zones/us-central1-a/diskTypes/pd-standard")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/disktype.json")).build();
-
-      DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, response).diskTypesInZone("us-central1-a");
-
-      assertEquals(diskTypeApi.get("pd-standard"),
-              new ParseDiskTypeTest().expected());
-   }
-
-   public void testGetDiskTypeResponseIs4xx() throws Exception {
-      HttpRequest get = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/zones/us-central1-a/diskTypes/pd-standard")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, response).diskTypesInZone("us-central1-a");
-
-      assertNull(diskTypeApi.get("pd-standard"));
-   }
-
-   public void list() throws Exception {
-
-      DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).diskTypesInZone("us-central1-a");
-
-      assertEquals(diskTypeApi.list().next(), new ParseDiskTypeListTest().expected());
-   }
-
-   public void listWithOptionsEmpty() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-      
-      HttpRequest listRequestWithOptions = LIST_DISK_TYPES_REQUEST.toBuilder()
-            .endpoint(LIST_DISK_TYPES_REQUEST.getEndpoint() + "?maxResults=1").build();
-
-      DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, listRequestWithOptions, response).diskTypesInZone("us-central1-a");
-
-      assertFalse(diskTypeApi.list(maxResults(1)).hasNext());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiMockTest.java
new file mode 100644
index 0000000..07b8cf2
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiMockTest.java
@@ -0,0 +1,63 @@
+/*
+ * 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.assertFalse;
+import static org.testng.Assert.assertNull;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.parse.ParseDiskTypeListTest;
+import org.jclouds.googlecomputeengine.parse.ParseDiskTypeTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "DiskTypeApiMockTest", singleThreaded = true)
+public class DiskTypeApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/disktype.json"));
+
+      assertEquals(diskTypeApi().get("pd-standard"),
+            new ParseDiskTypeTest().expected());
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/diskTypes/pd-standard");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(diskTypeApi().get("pd-standard"));
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/diskTypes/pd-standard");
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/disktype_list.json"));
+
+      assertEquals(diskTypeApi().list().next(), new ParseDiskTypeListTest().expected());
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/diskTypes");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(diskTypeApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a/diskTypes");
+   }
+
+   public DiskTypeApi diskTypeApi() {
+      return api().diskTypesInZone("us-central1-a");
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
index 96dd7b2..cc92e23 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
@@ -22,8 +22,6 @@ import static java.lang.String.format;
 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.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
 
 import java.io.IOException;
 import java.net.URI;
@@ -35,8 +33,6 @@ import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
 import org.jclouds.googlecomputeengine.domain.Firewall;
 import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
 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;
@@ -59,14 +55,6 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
    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).firewalls();
-
-      assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected());
-   }
-
    public static Payload firewallPayloadFirewallOfName(String firewallName,
                                                        String networkName,
                                                        List<String> sourceRanges,
@@ -95,23 +83,6 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
       return payload;
    }
 
-
-   public void testGetFirewallResponseIs4xx() throws Exception {
-      HttpRequest get = HttpRequest
-              .builder()
-              .method("GET")
-              .endpoint(BASE_URL + "/party/global/firewalls/jclouds-test")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, get, response).firewalls();
-
-      assertNull(api.get("jclouds-test"));
-   }
-
    public void testInsertFirewallResponseIs2xx() throws IOException {
 
       HttpRequest request = HttpRequest
@@ -209,65 +180,4 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
                       .addSourceRange("10.0.1.0/32")
                       .addTargetTag("tag2")), new ParseOperationTest().expected());
    }
-
-   public void testDeleteFirewallResponseIs2xx() {
-      HttpRequest delete = HttpRequest
-              .builder()
-              .method("DELETE")
-              .endpoint(BASE_URL + "/party/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).firewalls();
-
-      assertEquals(api.delete("default-allow-internal"),
-              new ParseOperationTest().expected());
-   }
-
-   public void testDeleteFirewallResponseIs4xx() {
-      HttpRequest delete = HttpRequest
-              .builder()
-              .method("DELETE")
-              .endpoint(BASE_URL + "/party/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).firewalls();
-
-      assertNull(api.delete("default-allow-internal"));
-   }
-
-   HttpRequest list = HttpRequest
-         .builder()
-         .method("GET")
-         .endpoint(BASE_URL + "/party/global/firewalls")
-         .addHeader("Accept", "application/json")
-         .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public void testListFirewallsResponseIs2xx() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/firewall_list.json")).build();
-
-      FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).firewalls();
-
-      assertEquals(api.list().next(), new ParseFirewallListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).firewalls();
-
-      assertFalse(api.list().hasNext());
-   }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiMockTest.java
new file mode 100644
index 0000000..bf7ce5d
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiMockTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.parse.ParseFirewallListTest;
+import org.jclouds.googlecomputeengine.parse.ParseFirewallTest;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "FirewallApiMockTest", singleThreaded = true)
+public class FirewallApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/firewall_get.json"));
+
+      assertEquals(firewallApi().get("jclouds-test"),
+            new ParseFirewallTest().expected(url("/projects")));
+
+      assertSent(server, "GET", "/projects/party/global/firewalls/jclouds-test");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(firewallApi().get("jclouds-test"));
+
+      assertSent(server, "GET", "/projects/party/global/firewalls/jclouds-test");
+   }
+
+   public void delete() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      assertEquals(firewallApi().delete("default-allow-internal"),
+            new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "DELETE", "/projects/party/global/firewalls/default-allow-internal");
+   }
+
+   public void delete_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(firewallApi().delete("default-allow-internal"));
+      assertSent(server, "DELETE", "/projects/party/global/firewalls/default-allow-internal");
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/firewall_list.json"));
+
+      assertEquals(firewallApi().list().next(), new ParseFirewallListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/global/firewalls");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(firewallApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/global/firewalls");
+   }
+
+   FirewallApi firewallApi(){
+      return api().firewalls();
+   }
+
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java
deleted file mode 100644
index d3c5402..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java
+++ /dev/null
@@ -1,177 +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.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.net.URI;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions;
-import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleListTest;
-import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleTest;
-import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "ForwardingRuleApiExpectTest")
-public class ForwardingRuleApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   public void testGetForwardingRuleResponseIs2xx() throws Exception {
-      HttpRequest get = HttpRequest
-            .builder()
-            .method("GET")
-            .endpoint(BASE_URL + "/party/regions/us-central1/forwardingRules/test-forwarding-rule")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/forwardingrule_get.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, get, response).forwardingRulesInRegion("us-central1");
-
-      assertEquals(api.get("test-forwarding-rule"), new ParseForwardingRuleTest().expected());
-   }
-
-   public void testGetForwardingRuleResponseIs4xx() throws Exception {
-      HttpRequest get = HttpRequest
-            .builder()
-            .method("GET")
-            .endpoint(BASE_URL + "/party/regions/us-central1/forwardingRules/test-forwarding-rule")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, get, response).forwardingRulesInRegion("us-central1");
-
-      assertNull(api.get("test-forwarding-rule"));
-   }
-
-   public void testInsertForwardingRuleResponseIs2xx() {
-      HttpRequest insert = HttpRequest
-            .builder()
-            .method("POST")
-            .endpoint(BASE_URL + "/party/regions/us-central1/forwardingRules")
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN)
-            .payload(payloadFromResourceWithContentType("/forwardingrule_insert.json", MediaType.APPLICATION_JSON))
-            .build();
-
-      HttpResponse insertForwardingRuleResponse = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/region_operation.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, insert,
-            insertForwardingRuleResponse).forwardingRulesInRegion("us-central1");
-
-      ForwardingRuleCreationOptions forwardingRuleCreationOptions = new ForwardingRuleCreationOptions()
-      .target(URI.create(BASE_URL + "/party/regions/europe-west1/targetPools/test-target-pool"));
-      assertEquals(api.create("test-forwarding-rule", forwardingRuleCreationOptions),
-            new ParseRegionOperationTest().expected());
-   }
-
-   public void testDeleteForwardingRuleResponseIs2xx() {
-      HttpRequest delete = HttpRequest
-            .builder()
-            .method("DELETE")
-            .endpoint(BASE_URL + "/party/regions/us-central1/forwardingRules/test-forwarding-rule")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/region_operation.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, delete, deleteResponse).forwardingRulesInRegion("us-central1");
-
-      assertEquals(api.delete("test-forwarding-rule"), new ParseRegionOperationTest().expected());
-   }
-
-   public void testDeleteForwardingRuleResponseIs4xx() {
-      HttpRequest delete = HttpRequest
-            .builder()
-            .method("DELETE")
-            .endpoint(BASE_URL + "/party/regions/us-central1/forwardingRules/test-targetPool")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, delete, deleteResponse).forwardingRulesInRegion("us-central1");
-
-      assertNull(api.delete("test-targetPool"));
-   }
-
-   HttpRequest list = HttpRequest
-         .builder()
-         .method("GET")
-         .endpoint(BASE_URL + "/party/regions/us-central1/forwardingRules")
-         .addHeader("Accept", "application/json")
-         .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public void list() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/forwardingrule_list.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, list, response).forwardingRulesInRegion("us-central1");
-
-      assertEquals(api.list().next(), new ParseForwardingRuleListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, list, response).forwardingRulesInRegion("us-central1");
-
-      assertFalse(api.list().hasNext());
-   }
-
-   public void testSetTargetForwardingRuleResponseIs2xx(){
-      String ruleName = "testForwardingRule";
-      HttpRequest setTarget = HttpRequest
-            .builder()
-            .method("POST")
-            .endpoint(BASE_URL + "/party/regions/us-central1/forwardingRules/" + ruleName + "/setTarget")
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN)
-            .payload(payloadFromResourceWithContentType("/forwardingrule_set_target.json", MediaType.APPLICATION_JSON))
-            .build();
-
-      HttpResponse setTargetResponse = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/region_operation.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, setTarget, setTargetResponse).forwardingRulesInRegion("us-central1");
-
-      URI newTarget = URI.create(BASE_URL + "/party/regions/europe-west1/targetPools/test-target-pool");
-      assertEquals(api.setTarget(ruleName, newTarget), new ParseRegionOperationTest().expected());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiMockTest.java
new file mode 100644
index 0000000..f66a141
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiMockTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.assertFalse;
+import static org.testng.AssertJUnit.assertNull;
+
+import java.net.URI;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions;
+import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleListTest;
+import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleTest;
+import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "ForwardingRuleApiMockTest", singleThreaded = true)
+public class ForwardingRuleApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/forwardingrule_get.json"));
+
+      assertEquals(forwardingRuleApi().get("test-forwarding-rule"),
+            new ParseForwardingRuleTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/regions/us-central1/forwardingRules/test-forwarding-rule");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(forwardingRuleApi().get("test-forwarding-rule"));
+      assertSent(server, "GET", "/projects/party/regions/us-central1/forwardingRules/test-forwarding-rule");
+   }
+
+   public void insert() throws Exception {
+      server.enqueue(jsonResponse("/region_operation.json"));
+
+      ForwardingRuleCreationOptions forwardingRuleCreationOptions = new ForwardingRuleCreationOptions()
+      .target(URI.create(url("/projects/party/regions/europe-west1/targetPools/test-target-pool")));
+      assertEquals(forwardingRuleApi().create("test-forwarding-rule", forwardingRuleCreationOptions),
+            new ParseRegionOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/regions/us-central1/forwardingRules",
+            stringFromResource("/forwardingrule_insert.json"));
+   }
+
+   public void delete() throws Exception {
+      server.enqueue(jsonResponse("/region_operation.json"));
+
+      assertEquals(forwardingRuleApi().delete("test-forwarding-rule"),
+            new ParseRegionOperationTest().expected(url("/projects")));
+      assertSent(server, "DELETE", "/projects/party/regions/us-central1/forwardingRules/test-forwarding-rule");
+   }
+
+   public void delete_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(forwardingRuleApi().delete("test-forwarding-rule"));
+      assertSent(server, "DELETE", "/projects/party/regions/us-central1/forwardingRules/test-forwarding-rule");
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/forwardingrule_list.json"));
+
+      assertEquals(forwardingRuleApi().list().next(), new ParseForwardingRuleListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/regions/us-central1/forwardingRules");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(forwardingRuleApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/regions/us-central1/forwardingRules");
+   }
+
+   public void setTarget() throws Exception {
+      server.enqueue(jsonResponse("/region_operation.json"));
+
+      URI newTarget = URI.create(url("/projects/party/regions/europe-west1/targetPools/test-target-pool"));
+      assertEquals(forwardingRuleApi().setTarget("testForwardingRule", newTarget), new ParseRegionOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/regions/us-central1/forwardingRules/testForwardingRule/setTarget",
+            stringFromResource("/forwardingrule_set_target.json"));
+   }
+
+   ForwardingRuleApi forwardingRuleApi() {
+      return api().forwardingRulesInRegion("us-central1");
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/f41d49ce/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiExpectTest.java
deleted file mode 100644
index 1adcd5e..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalForwardingRuleApiExpectTest.java
+++ /dev/null
@@ -1,177 +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.assertFalse;
-import static org.testng.AssertJUnit.assertNull;
-
-import java.net.URI;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions;
-import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleListTest;
-import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleTest;
-import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "ForwardingRuleApiExpectTest")
-public class GlobalForwardingRuleApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   public void testGetForwardingRuleResponseIs2xx() throws Exception {
-      HttpRequest get = HttpRequest
-            .builder()
-            .method("GET")
-            .endpoint(BASE_URL + "/party/global/forwardingRules/test-forwarding-rule")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/forwardingrule_get.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, get, response).globalForwardingRules();
-
-      assertEquals(api.get("test-forwarding-rule"), new ParseForwardingRuleTest().expected());
-   }
-
-   public void testGetForwardingRuleResponseIs4xx() throws Exception {
-      HttpRequest get = HttpRequest
-            .builder()
-            .method("GET")
-            .endpoint(BASE_URL + "/party/global/forwardingRules/test-forwarding-rule")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, get, response).globalForwardingRules();
-
-      assertNull(api.get("test-forwarding-rule"));
-   }
-
-   public void testInsertForwardingRuleResponseIs2xx() {
-      HttpRequest insert = HttpRequest
-            .builder()
-            .method("POST")
-            .endpoint(BASE_URL + "/party/global/forwardingRules")
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN)
-            .payload(payloadFromResourceWithContentType("/forwardingrule_insert.json", MediaType.APPLICATION_JSON))
-            .build();
-
-      HttpResponse insertForwardingRuleResponse = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/region_operation.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, insert,
-            insertForwardingRuleResponse).globalForwardingRules();
-
-      ForwardingRuleCreationOptions forwardingRuleCreationOptions = new ForwardingRuleCreationOptions()
-      .target(URI.create(BASE_URL + "/party/regions/europe-west1/targetPools/test-target-pool"));
-      assertEquals(api.create("test-forwarding-rule", forwardingRuleCreationOptions),
-            new ParseRegionOperationTest().expected());
-   }
-
-   public void testDeleteForwardingRuleResponseIs2xx() {
-      HttpRequest delete = HttpRequest
-            .builder()
-            .method("DELETE")
-            .endpoint(BASE_URL + "/party/global/forwardingRules/test-forwarding-rule")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/region_operation.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, delete, deleteResponse).globalForwardingRules();
-
-      assertEquals(api.delete("test-forwarding-rule"), new ParseRegionOperationTest().expected());
-   }
-
-   public void testDeleteForwardingRuleResponseIs4xx() {
-      HttpRequest delete = HttpRequest
-            .builder()
-            .method("DELETE")
-            .endpoint(BASE_URL + "/party/global/forwardingRules/test-targetPool")
-                  .addHeader("Accept", "application/json")
-                  .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, delete, deleteResponse).globalForwardingRules();
-
-      assertNull(api.delete("test-targetPool"));
-   }
-
-   HttpRequest list = HttpRequest
-         .builder()
-         .method("GET")
-         .endpoint(BASE_URL + "/party/global/forwardingRules")
-         .addHeader("Accept", "application/json")
-         .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public void list() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/forwardingrule_list.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, list, response).globalForwardingRules();
-
-      assertEquals(api.list().next(), new ParseForwardingRuleListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, list, response).globalForwardingRules();
-
-      assertFalse(api.list().hasNext());
-   }
-
-   public void testSetTargetForwardingRuleResponseIs2xx(){
-      String ruleName = "testForwardingRule";
-      HttpRequest setTarget = HttpRequest
-            .builder()
-            .method("POST")
-            .endpoint(BASE_URL + "/party/global/forwardingRules/" + ruleName + "/setTarget")
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN)
-            .payload(payloadFromResourceWithContentType("/forwardingrule_set_target.json", MediaType.APPLICATION_JSON))
-            .build();
-
-      HttpResponse setTargetResponse = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/region_operation.json")).build();
-
-      ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-            TOKEN_RESPONSE, setTarget, setTargetResponse).globalForwardingRules();
-
-      URI newTarget = URI.create(BASE_URL + "/party/regions/europe-west1/targetPools/test-target-pool");
-      assertEquals(api.setTarget(ruleName, newTarget), new ParseRegionOperationTest().expected());
-   }
-
-}