You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2014/12/16 00:47:06 UTC

[1/2] jclouds-labs-google git commit: New MockTests: TargetHttpProxyApi, UrlMap, ZoneApi, FirewallApi

Repository: jclouds-labs-google
Updated Branches:
  refs/heads/master d73562a66 -> 5f1069b92


New MockTests: TargetHttpProxyApi, UrlMap, ZoneApi, FirewallApi


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/a9dcca87
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/a9dcca87
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/a9dcca87

Branch: refs/heads/master
Commit: a9dcca878e77554ccf6cec62673c5dcdf6ea7ff7
Parents: d73562a
Author: Daniel Broudy <br...@google.com>
Authored: Tue Dec 9 10:15:43 2014 -0800
Committer: Ignasi Barrera <na...@apache.org>
Committed: Tue Dec 16 00:44:31 2014 +0100

----------------------------------------------------------------------
 .../features/FirewallApiExpectTest.java         | 122 +------------
 .../features/FirewallApiMockTest.java           |  40 +++++
 .../features/TargetHttpProxyApiExpectTest.java  | 171 -------------------
 .../features/TargetHttpProxyApiMockTest.java    |  99 +++++++++++
 .../features/UrlMapApiExpectTest.java           | 159 ++---------------
 .../features/UrlMapApiMockTest.java             | 140 +++++++++++++++
 .../features/ZoneApiExpectTest.java             |  95 -----------
 .../features/ZoneApiMockTest.java               |  63 +++++++
 .../parse/ParseTargetHttpProxyListTest.java     |  15 +-
 .../parse/ParseTargetHttpProxyTest.java         |  12 +-
 .../parse/ParseUrlMapListTest.java              |  13 +-
 .../parse/ParseUrlMapTest.java                  |   9 +-
 .../parse/ParseUrlMapValidateTest.java          |   9 +-
 .../parse/ParseZoneListTest.java                |   9 +-
 .../parse/ParseZoneTest.java                    |   7 +-
 .../src/test/resources/firewall_insert.json     |  23 ++-
 16 files changed, 429 insertions(+), 557 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/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 b1ec4da..b5ed9a1 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
@@ -16,18 +16,10 @@
  */
 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.io.Payloads.newStringPayload;
-import static org.jclouds.util.Strings2.toStringAndClose;
 import static org.testng.Assert.assertEquals;
 
 import java.io.IOException;
 import java.net.URI;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
 
 import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
 import org.jclouds.googlecomputeengine.domain.Firewall;
@@ -36,119 +28,13 @@ import org.jclouds.googlecomputeengine.options.FirewallOptions;
 import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.http.HttpResponse;
-import org.jclouds.io.Payload;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
 
 @Test(groups = "unit", testName = "FirewallApiExpectTest")
 public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
 
-   public static final HttpRequest GET_FIREWALL_REQUEST = HttpRequest
-           .builder()
-           .method("GET")
-           .endpoint(BASE_URL + "/party/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 static Payload firewallPayloadFirewallOfName(String firewallName,
-                                                       String networkName,
-                                                       List<String> sourceRanges,
-                                                       List<String> sourceTags,
-                                                       List<String> targetTags,
-                                                       List<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;
-   }
-
-   //TODO (broudy): convert to mock test and add description to test.
-   public void testInsertFirewallResponseIs2xx() throws IOException {
-
-      HttpRequest request = HttpRequest
-              .builder()
-              .method("POST")
-              .endpoint(BASE_URL + "/party/global/firewalls")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN)
-              .payload(firewallPayloadFirewallOfName(
-                      "myfw",
-                      "default",
-                      ImmutableList.of("10.0.1.0/32"),
-                      ImmutableList.of("tag1"),
-                      ImmutableList.of("tag2"),
-                      ImmutableList.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).firewalls();
-
-      assertEquals(api.createInNetwork("myfw", URI.create(BASE_URL + "/party/global/networks/default"),
-              new FirewallOptions()
-                      .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24")))
-                      .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(BASE_URL + "/party/global/firewalls/myfw")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN)
-              .payload(firewallPayloadFirewallOfName(
-                      "myfw",
-                      "default",
-                      ImmutableList.of("10.0.1.0/32"),
-                      ImmutableList.of("tag1"),
-                      ImmutableList.of("tag2"),
-                      ImmutableList.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).firewalls();
-
-      assertEquals(api.update("myfw",
-              new FirewallOptions()
-                      .name("myfw")
-                      .network(URI.create(BASE_URL + "/party/global/networks/default"))
-                      .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24")))
-                      .addSourceTag("tag1")
-                      .addSourceRange("10.0.1.0/32")
-                      .addTargetTag("tag2")), new ParseOperationTest().expected());
-   }
-
    public void testPatchFirewallResponseIs2xx() throws IOException {
       HttpRequest update = HttpRequest
               .builder()
@@ -156,13 +42,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<Goo
               .endpoint(BASE_URL + "/party/global/firewalls/myfw")
               .addHeader("Accept", "application/json")
               .addHeader("Authorization", "Bearer " + TOKEN)
-              .payload(firewallPayloadFirewallOfName(
-                      "myfw",
-                      "default",
-                      ImmutableList.of("10.0.1.0/32"),
-                      ImmutableList.of("tag1"),
-                      ImmutableList.of("tag2"),
-                      ImmutableList.of("22", "23-24")))
+              .payload(payloadFromResource("/firewall_insert.json"))
               .build();
 
       HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/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
index bf7ce5d..ba8afef 100644
--- 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
@@ -20,12 +20,18 @@ 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.domain.Firewall;
 import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+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.testng.annotations.Test;
 
+import com.google.common.collect.ImmutableList;
+
 @Test(groups = "unit", testName = "FirewallApiMockTest", singleThreaded = true)
 public class FirewallApiMockTest extends BaseGoogleComputeEngineApiMockTest {
 
@@ -75,6 +81,40 @@ public class FirewallApiMockTest extends BaseGoogleComputeEngineApiMockTest {
       assertSent(server, "GET", "/projects/party/global/firewalls");
    }
 
+   public void insert() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      FirewallOptions options = new FirewallOptions()
+         .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24")))
+         .addSourceTag("tag1")
+         .addSourceRange("10.0.1.0/32")
+         .addTargetTag("tag2");
+
+      assertEquals(firewallApi().createInNetwork("myfw", URI.create(url("/projects/party/global/networks/default")), options),
+            new ParseOperationTest().expected(url("/projects")));
+
+      assertSent(server, "POST", "/projects/party/global/firewalls",
+            stringFromResource("/firewall_insert.json"));
+   }
+
+   public void update() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      FirewallOptions options = new FirewallOptions()
+         .name("myfw")
+         .network(URI.create(url("/projects/party/global/networks/default")))
+         .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24")))
+         .addSourceTag("tag1")
+         .addSourceRange("10.0.1.0/32")
+         .addTargetTag("tag2");
+
+      assertEquals(firewallApi().update("myfw", options),
+            new ParseOperationTest().expected(url("/projects")));
+
+      assertSent(server, "PUT", "/projects/party/global/firewalls/myfw",
+            stringFromResource("/firewall_insert.json"));
+   }
+
    FirewallApi firewallApi(){
       return api().firewalls();
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java
deleted file mode 100644
index 9984b20..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java
+++ /dev/null
@@ -1,171 +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.parse.ParseOperationTest;
-import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyListTest;
-import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit")
-public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   private static final String ENDPOINT_BASE = "https://www.googleapis.com/"
-            + "compute/v1/projects/party/global/targetHttpProxies";
-
-   private org.jclouds.http.HttpRequest.Builder<? extends HttpRequest.Builder<?>> getBasicRequest() {
-      return HttpRequest.builder().addHeader("Accept", "application/json")
-                                  .addHeader("Authorization", "Bearer " + TOKEN);
-   }
-
-   private HttpResponse createResponse(String payloadFile) {
-      return HttpResponse.builder().statusCode(200)
-                                   .payload(payloadFromResource(payloadFile))
-                                   .build();
-   }
-
-   public void testGetTargetHttpProxyResponseIs2xx() throws Exception {
-      HttpRequest request = getBasicRequest().method("GET")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test").build();
-
-      HttpResponse response = createResponse("/target_http_proxy_get.json");
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response).targetHttpProxies();
-
-      assertEquals(api.get("jclouds-test"),
-                   new ParseTargetHttpProxyTest().expected());
-   }
-
-   public void testGetTargetHttpProxyResponseIs4xx() throws Exception {
-      HttpRequest request = getBasicRequest().method("GET")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test").build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response).targetHttpProxies();
-
-      assertNull(api.get("jclouds-test"));
-   }
-
-
-
-   public void testInsertTargetHttpProxyResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("POST")
-               .endpoint(ENDPOINT_BASE)
-               .payload(payloadFromResourceWithContentType("/target_http_proxy_insert.json",
-                                                           MediaType.APPLICATION_JSON))
-               .build();
-
-      HttpResponse response = createResponse("/operation.json");
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).targetHttpProxies();
-
-      URI urlMap = URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test");
-      assertEquals(api.create("jclouds-test", urlMap), new ParseOperationTest().expected());
-   }
-
-   public void testDeleteTargetHttpProxyResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("DELETE")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-
-      HttpResponse response = createResponse("/operation.json");
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).targetHttpProxies();
-
-      assertEquals(api.delete("jclouds-test"),
-              new ParseOperationTest().expected());
-   }
-
-   public void testDeleteTargetHttpProxyResponseIs4xx() {
-      HttpRequest request = getBasicRequest().method("DELETE")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).targetHttpProxies();
-
-      assertNull(api.delete("jclouds-test"));
-   }
-
-   public void testSetUrlMapTargetHttpProxyResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("POST")
-               // setUrlMap uses a non-standard url pattern
-               .endpoint("https://www.googleapis.com/compute/v1/projects/party/targetHttpProxies"
-                         + "/jclouds-test/setUrlMap")
-               .payload(payloadFromResourceWithContentType("/target_http_proxy_set_url_map.json",
-                                                           MediaType.APPLICATION_JSON))
-               .build();
-
-      HttpResponse response = createResponse("/operation.json");
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).targetHttpProxies();
-
-      URI urlMap = URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test");
-      assertEquals(api.setUrlMap("jclouds-test", urlMap), new ParseOperationTest().expected());
-   }
-
-   public void testListTargetHttpProxiesResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("GET")
-               .endpoint(ENDPOINT_BASE)
-               .build();
-
-      HttpResponse response = createResponse("/target_http_proxy_list.json");
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response).targetHttpProxies();
-
-      assertEquals(api.list().next(),
-              new ParseTargetHttpProxyListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpRequest list = HttpRequest
-            .builder()
-            .method("GET")
-            .endpoint(BASE_URL + "/party/global/targetHttpProxies")
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-            TOKEN_RESPONSE, list, response).targetHttpProxies();
-
-      assertFalse(api.list().hasNext());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java
new file mode 100644
index 0000000..08d3e85
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiMockTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.parse.ParseOperationTest;
+import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyListTest;
+import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "TargetHttpProxyApiMockTest", singleThreaded = true)
+public class TargetHttpProxyApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/target_http_proxy_get.json"));
+
+      assertEquals(targetHttpProxyApi().get("jclouds-test"),
+            new ParseTargetHttpProxyTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/global/targetHttpProxies/jclouds-test");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(targetHttpProxyApi().get("jclouds-test"));
+      assertSent(server, "GET", "/projects/party/global/targetHttpProxies/jclouds-test");
+   }
+
+   public void insert() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      URI urlMap = URI.create(url("/projects/myproject/global/urlMaps/jclouds-test"));
+      assertEquals(targetHttpProxyApi().create("jclouds-test", urlMap), new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "POST", "/projects/party/global/targetHttpProxies",
+            stringFromResource("/target_http_proxy_insert.json"));
+   }
+
+   public void delete() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      assertEquals(targetHttpProxyApi().delete("jclouds-test"),
+            new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "DELETE", "/projects/party/global/targetHttpProxies/jclouds-test");
+   }
+
+   public void delete_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(targetHttpProxyApi().delete("jclouds-test"));
+      assertSent(server, "DELETE", "/projects/party/global/targetHttpProxies/jclouds-test");
+   }
+
+   public void setUrlMap() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      URI urlMap = URI.create(url("/projects/myproject/global/urlMaps/jclouds-test"));
+      assertEquals(targetHttpProxyApi().setUrlMap("jclouds-test", urlMap), new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "POST", "/projects/party/targetHttpProxies/jclouds-test/setUrlMap",
+            stringFromResource("/target_http_proxy_set_url_map.json"));
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/target_http_proxy_list.json"));
+
+      assertEquals(targetHttpProxyApi().list().next(), new ParseTargetHttpProxyListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/global/targetHttpProxies");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(targetHttpProxyApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/global/targetHttpProxies");
+   }
+
+   TargetHttpProxyApi targetHttpProxyApi() {
+      return api().targetHttpProxies();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java
index e13dbf3..885ab88 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java
@@ -17,8 +17,6 @@
 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.io.IOException;
 import java.net.URI;
@@ -33,9 +31,6 @@ import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher.PathRule;
 import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
 import org.jclouds.googlecomputeengine.options.UrlMapOptions;
 import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
-import org.jclouds.googlecomputeengine.parse.ParseUrlMapListTest;
-import org.jclouds.googlecomputeengine.parse.ParseUrlMapTest;
-import org.jclouds.googlecomputeengine.parse.ParseUrlMapValidateTest;
 import org.jclouds.http.HttpRequest;
 import org.jclouds.http.HttpResponse;
 import org.testng.annotations.Test;
@@ -45,155 +40,25 @@ import com.google.common.collect.ImmutableList;
 @Test(groups = "unit")
 public class UrlMapApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
 
-   private static final String ENDPOINT_BASE = "https://www.googleapis.com/"
-            + "compute/v1/projects/party/global/urlMaps";
 
-   private org.jclouds.http.HttpRequest.Builder<? extends HttpRequest.Builder<?>> getBasicRequest() {
-      return HttpRequest.builder().addHeader("Accept", "application/json")
-                                  .addHeader("Authorization", "Bearer " + TOKEN);
-   }
-
-   private HttpResponse createResponse(String payloadFile) {
-      return HttpResponse.builder().statusCode(200)
-                                   .payload(payloadFromResource(payloadFile))
-                                   .build();
-   }
-
-   public void testGetUrlMapResponseIs2xx() throws Exception {
-      HttpRequest request = getBasicRequest().method("GET")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-
-      HttpResponse response = createResponse("/url_map_get.json");
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertEquals(api.get("jclouds-test"), new ParseUrlMapTest().expected());
-   }
-
-   public void testGetUrlMapResponseIs4xx() throws Exception {
-      HttpRequest request = getBasicRequest().method("GET")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertNull(api.get("jclouds-test"));
-   }
-
-   public void testInsertUrlMapResponseIs2xx() throws IOException {
-      HttpRequest request = getBasicRequest().method("POST")
-               .endpoint(ENDPOINT_BASE)
-               .payload(payloadFromResourceWithContentType("/url_map_insert.json", MediaType.APPLICATION_JSON))
-               .build();
-
-      HttpResponse response = createResponse("/operation.json");
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertEquals(api.create(createBasicMap()), new ParseOperationTest().expected());
-
-   }
-
-   public void testUpdateUrlMapResponseIs2xx() throws IOException {
-      HttpRequest request = getBasicRequest().method("PUT")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .payload(payloadFromResourceWithContentType("/url_map_insert.json", MediaType.APPLICATION_JSON))
-               .build();
-
-      HttpResponse response = createResponse("/operation.json");
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertEquals(api.update("jclouds-test", createBasicMap()), new ParseOperationTest().expected());
-   }
-
-   public void testPatchUrlMapResponseIs2xx() throws IOException {
-      HttpRequest request = getBasicRequest().method("PATCH")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .payload(payloadFromResourceWithContentType("/url_map_insert.json", MediaType.APPLICATION_JSON))
-               .build();
-
-      HttpResponse response = createResponse("/operation.json");
+   public void patch() throws IOException {
+      HttpRequest request = HttpRequest.builder()
+            .addHeader("Accept", "application/json")
+            .addHeader("Authorization", "Bearer " + TOKEN)
+            .method("PATCH")
+            .endpoint("https://www.googleapis.com/compute/v1/projects"
+                     + "/party/global/urlMaps/jclouds-test")
+            .payload(payloadFromResourceWithContentType("/url_map_insert.json", MediaType.APPLICATION_JSON))
+            .build();
 
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertEquals(api.patch("jclouds-test", createBasicMap()), new ParseOperationTest().expected());
-   }
-
-   public void testDeleteUrlMapResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("DELETE")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-
-      HttpResponse response = createResponse("/operation.json");
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertEquals(api.delete("jclouds-test"), new ParseOperationTest().expected());
-   }
-
-   public void testDeleteUrlMapResponseIs4xx() {
-      HttpRequest request = getBasicRequest().method("DELETE")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test")
-               .build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertNull(api.delete("jclouds-test"));
-   }
-
-   HttpRequest list = HttpRequest
-         .builder()
-         .method("GET")
-         .endpoint(ENDPOINT_BASE)
-         .addHeader("Accept", "application/json")
-         .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public void list() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/url_map_list.json")).build();
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).urlMaps();
-
-      assertEquals(api.list().next(), new ParseUrlMapListTest().expected());
-   }
-
-   public void listEmpty() {
       HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, list, response).urlMaps();
-
-      assertFalse(api.list().hasNext());
-   }
-
-   public void testValidateUrlMapsResponseIs2xx() {
-      HttpRequest request = getBasicRequest().method("POST")
-               .endpoint(ENDPOINT_BASE + "/jclouds-test/validate")
-               .payload(payloadFromResourceWithContentType("/url_map_validate_request.json",
-                                                           MediaType.APPLICATION_JSON))
-               .build();
-
-      HttpResponse response = createResponse("/url_map_validate.json");
+            .payload(payloadFromResource("/operation.json"))
+            .build();
 
       UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
               TOKEN_RESPONSE, request, response).urlMaps();
 
-      assertEquals(api.validate("jclouds-test", createBasicMap()), new ParseUrlMapValidateTest().expected());
+      assertEquals(api.patch("jclouds-test", createBasicMap()), new ParseOperationTest().expected());
    }
 
    private UrlMapOptions createBasicMap() {

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
new file mode 100644
index 0000000..b0de3d8
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
@@ -0,0 +1,140 @@
+/*
+ * 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.domain.UrlMap;
+import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule;
+import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher;
+import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher.PathRule;
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.options.UrlMapOptions;
+import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
+import org.jclouds.googlecomputeengine.parse.ParseUrlMapListTest;
+import org.jclouds.googlecomputeengine.parse.ParseUrlMapTest;
+import org.jclouds.googlecomputeengine.parse.ParseUrlMapValidateTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = "unit", testName = "UrlMapApiMockTest", singleThreaded = true)
+public class UrlMapApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/url_map_get.json"));
+
+      assertEquals(urlMapApi().get("jclouds-test"), new ParseUrlMapTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/global/urlMaps/jclouds-test");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(urlMapApi().get("jclouds-test"));
+      assertSent(server, "GET", "/projects/party/global/urlMaps/jclouds-test");
+   }
+
+   public void insert() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      assertEquals(urlMapApi().create(createBasicMap()), new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "POST", "/projects/party/global/urlMaps",
+            stringFromResource("/url_map_insert.json"));
+   }
+
+   public void update() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      assertEquals(urlMapApi().update("jclouds-test", createBasicMap()),
+            new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "PUT", "/projects/party/global/urlMaps/jclouds-test",
+            stringFromResource("/url_map_insert.json"));
+   }
+
+/*
+   public void patch() throws Exception {
+      // PATCH not yet supported
+      server.enqueue(jsonResponse("/operation.json"));
+
+      assertEquals(urlMapApi().patch("jclouds-test", createBasicMap()),
+            new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "PATCH", "/projects/party/global/urlMaps/jclouds-test",
+            stringFromResource("/url_map_insert.json"));
+   }
+*/
+   public void delete() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      assertEquals(urlMapApi().delete("jclouds-test"),
+            new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "DELETE", "/projects/party/global/urlMaps/jclouds-test");
+   }
+
+   public void delete_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(urlMapApi().delete("jclouds-test"));
+      assertSent(server, "DELETE", "/projects/party/global/urlMaps/jclouds-test");
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/url_map_list.json"));
+
+      assertEquals(urlMapApi().list().next(),
+            new ParseUrlMapListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/global/urlMaps");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(urlMapApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/global/urlMaps");
+   }
+
+   public void validate() throws Exception {
+      server.enqueue(jsonResponse("/url_map_validate.json"));
+
+      assertEquals(urlMapApi().validate("jclouds-test", createBasicMap()),
+            new ParseUrlMapValidateTest().expected(url("/projects")));
+      assertSent(server, "POST", "/projects/party/global/urlMaps/jclouds-test/validate");
+   }
+
+   private UrlMapOptions createBasicMap() {
+      URI service = URI.create(url("/projects/myproject/global/backendServices/jclouds-test"));
+      return new UrlMapOptions().name("jclouds-test")
+                                .description("Sample url map")
+                                .hostRule(HostRule.create(null, ImmutableList.of("jclouds-test"), "path"))
+                                .pathMatcher(PathMatcher.create("path",
+                                                                null,
+                                                                service,
+                                                                ImmutableList.of(
+                                                                      PathRule.create(ImmutableList.of("/"),
+                                                                                      service))))
+                                .test(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service))
+                                .defaultService(service);
+   }
+
+   UrlMapApi urlMapApi() {
+      return api().urlMaps();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
deleted file mode 100644
index 43f1b00..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java
+++ /dev/null
@@ -1,95 +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.Assert.assertNull;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.parse.ParseZoneListTest;
-import org.jclouds.googlecomputeengine.parse.ParseZoneTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "ZoneApiExpectTest")
-public class ZoneApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   public static final String ZONES_URL_PREFIX = BASE_URL + "/party/zones";
-
-   public static final HttpRequest GET_ZONE_REQ = HttpRequest
-           .builder()
-           .method("GET")
-           .endpoint(ZONES_URL_PREFIX + "/us-central1-a")
-           .addHeader("Accept", "application/json")
-           .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public static final HttpRequest LIST_ZONES_REQ = HttpRequest
-           .builder()
-           .method("GET")
-           .endpoint(ZONES_URL_PREFIX)
-           .addHeader("Accept", "application/json")
-           .addHeader("Authorization", "Bearer " + TOKEN).build();
-
-   public static final HttpResponse LIST_ZONES_SHORT_RESPONSE = HttpResponse.builder().statusCode(200)
-           .payload(staticPayloadFromResource("/zone_list_short.json")).build();
-
-   public static final HttpResponse LIST_ZONES_RESPONSE = HttpResponse.builder().statusCode(200)
-           .payload(staticPayloadFromResource("/zone_list.json")).build();
-
-   public void testGetZoneResponseIs2xx() throws Exception {
-
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/zone_get.json")).build();
-
-      ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, GET_ZONE_REQ, response).zones();
-
-      assertEquals(api.get("us-central1-a"),
-              new ParseZoneTest().expected());
-   }
-
-   public void testGetZoneResponseIs4xx() throws Exception {
-
-      HttpResponse response = HttpResponse.builder().statusCode(404).build();
-
-      ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, GET_ZONE_REQ, response).zones();
-
-      assertNull(api.get("us-central1-a"));
-   }
-
-   public void list() throws Exception {
-      ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, LIST_ZONES_REQ, LIST_ZONES_RESPONSE).zones();
-
-      assertEquals(api.list().next(), new ParseZoneListTest().expected());
-   }
-
-   public void listEmpty() {
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/list_empty.json")).build();
-
-      ZoneApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
-              TOKEN_RESPONSE, LIST_ZONES_REQ, response).zones();
-
-      assertFalse(api.list().hasNext());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiMockTest.java
new file mode 100644
index 0000000..cefecf4
--- /dev/null
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiMockTest.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.AssertJUnit.assertNull;
+
+import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
+import org.jclouds.googlecomputeengine.parse.ParseZoneListTest;
+import org.jclouds.googlecomputeengine.parse.ParseZoneTest;
+import org.testng.annotations.Test;
+
+@Test(groups = "unit", testName = "ZoneApiMockTest", singleThreaded = true)
+public class ZoneApiMockTest extends BaseGoogleComputeEngineApiMockTest {
+
+   public void get() throws Exception {
+      server.enqueue(jsonResponse("/zone_get.json"));
+
+      assertEquals(zoneApi().get("us-central1-a"),
+            new ParseZoneTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a");
+   }
+
+   public void get_4xx() throws Exception {
+      server.enqueue(response404());
+
+      assertNull(zoneApi().get("us-central1-a"));
+      assertSent(server, "GET", "/projects/party/zones/us-central1-a");
+   }
+
+   public void list() throws Exception {
+      server.enqueue(jsonResponse("/zone_list.json"));
+
+      assertEquals(zoneApi().list().next(), new ParseZoneListTest().expected(url("/projects")));
+      assertSent(server, "GET", "/projects/party/zones");
+   }
+
+   public void list_empty() throws Exception {
+      server.enqueue(jsonResponse("/list_empty.json"));
+
+      assertFalse(zoneApi().list().hasNext());
+      assertSent(server, "GET", "/projects/party/zones");
+   }
+
+   ZoneApi zoneApi() {
+      return api().zones();
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java
index d4abfca..4c0a3d2 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java
@@ -38,19 +38,22 @@ public class ParseTargetHttpProxyListTest extends BaseGoogleComputeEngineParseTe
       return "/target_http_proxy_list.json";
    }
 
-   @Override
-   @Consumes(MediaType.APPLICATION_JSON)
+   @Override @Consumes(MediaType.APPLICATION_JSON)
    public ListPage<TargetHttpProxy> expected() {
+      return expected(BASE_URL);
+   }
+
+   @Consumes(MediaType.APPLICATION_JSON)
+   public ListPage<TargetHttpProxy> expected(String baseUrl) {
       return ForwardingListPage.create(
             ImmutableList.of(
-                  new ParseTargetHttpProxyTest().expected(),
+                  new ParseTargetHttpProxyTest().expected(baseUrl),
                   TargetHttpProxy.create("13050421646334304116", // id
                         new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"), // creationTimestamp
-                        URI.create("https://www.googleapis" +
-                              ".com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test-2"), // selfLink
+                        URI.create(baseUrl + "/myproject/global/targetHttpProxies/jclouds-test-2"), // selfLink
                         "jclouds-test-2", // name
                         "Simple proxy", // description
-                        URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test-2"))), // urlMap
+                        URI.create(baseUrl + "/myproject/global/urlMaps/jclouds-test-2"))), // urlMap
                   null // nextPageToken d
             );
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java
index 802ad46..47ce80b 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java
@@ -34,14 +34,18 @@ public class ParseTargetHttpProxyTest extends BaseGoogleComputeEngineParseTest<T
       return "/target_http_proxy_get.json";
    }
 
-   @Override
-   @Consumes(MediaType.APPLICATION_JSON)
+   @Override @Consumes(MediaType.APPLICATION_JSON)
    public TargetHttpProxy expected() {
+      return expected(BASE_URL);
+   }
+
+   @Consumes(MediaType.APPLICATION_JSON)
+   public TargetHttpProxy expected(String baseUrl) {
       return TargetHttpProxy.create("13050421646334304115", // id
             new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"), // creationTimestamp
-            URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test"), // selfLink
+            URI.create(baseUrl + "/myproject/global/targetHttpProxies/jclouds-test"), // selfLink
             "jclouds-test", // name
             null,
-            URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test")); // urlMap
+            URI.create(baseUrl + "/myproject/global/urlMaps/jclouds-test")); // urlMap
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapListTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapListTest.java
index 5c7f945..a5b30c4 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapListTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapListTest.java
@@ -41,19 +41,22 @@ public class ParseUrlMapListTest extends BaseGoogleComputeEngineParseTest<ListPa
    @Override
    @Consumes(MediaType.APPLICATION_JSON)
    public ListPage<UrlMap> expected() {
+      return expected(BASE_URL);
+   }
+
+   @Consumes(MediaType.APPLICATION_JSON)
+   public ListPage<UrlMap> expected(String baseUrl) {
       return ForwardingListPage.create(
-            ImmutableList.of(new ParseUrlMapTest().expected(),
+            ImmutableList.of(new ParseUrlMapTest().expected(baseUrl),
                   UrlMap.create("13741966667737398120", // id
                         new SimpleDateFormatDateService().iso8601DateParse("2014-07-23T12:39:50.022-07:00"), // creationTimestamp
-                        URI.create("https://www.googleapis" +
-                              ".com/compute/v1/projects/myproject/global/urlMaps/jclouds-test-2"), // selfLink
+                        URI.create(baseUrl + "/myproject/global/urlMaps/jclouds-test-2"), // selfLink
                         "jclouds-test-2", // name
                         "Basic url map", // description
                         null, // hostRules
                         null, // pathMatchers
                         null, // urlMapTests
-                        URI.create("https://www.googleapis.com/compute/v1/projects/"
-                              + "myproject/global/backendServices/jclouds-test"), // defaultService
+                        URI.create(baseUrl + "/myproject/global/backendServices/jclouds-test"), // defaultService
                         "EDqhvJucpz4=")), // fingerprint
             null);
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapTest.java
index e29b8dd..f266f6d 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapTest.java
@@ -44,7 +44,12 @@ public class ParseUrlMapTest extends BaseGoogleComputeEngineParseTest<UrlMap> {
    @Override
    @Consumes(MediaType.APPLICATION_JSON)
    public UrlMap expected() {
-      URI service = URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/backendServices/jclouds-test");
+      return expected(BASE_URL);
+   }
+
+   @Consumes(MediaType.APPLICATION_JSON)
+   public UrlMap expected(String baseUrl) {
+      URI service = URI.create(baseUrl + "/myproject/global/backendServices/jclouds-test");
 
       List<HostRule> hostRules = ImmutableList.of(HostRule.create(null, // description
             ImmutableList.of("jclouds-test"), // hosts
@@ -64,7 +69,7 @@ public class ParseUrlMapTest extends BaseGoogleComputeEngineParseTest<UrlMap> {
 
       return UrlMap.create("13741966667737398119", // id
             new SimpleDateFormatDateService().iso8601DateParse("2014-07-23T12:39:50.022-07:00"), // creationTimestamp
-            URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test"), // selfLink
+            URI.create(baseUrl + "/myproject/global/urlMaps/jclouds-test"), // selfLink
             "jclouds-test", // name
             "Sample url map", // description
             hostRules, // hostRules

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapValidateTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapValidateTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapValidateTest.java
index 20380c0..06fdc6b 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapValidateTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseUrlMapValidateTest.java
@@ -39,13 +39,18 @@ public class ParseUrlMapValidateTest extends BaseGoogleComputeEngineParseTest<Ur
    @Override
    @Consumes(APPLICATION_JSON)
    public UrlMapValidateResult expected() {
+      return expected(BASE_URL);
+   }
+
+   @Consumes(APPLICATION_JSON)
+   public UrlMapValidateResult expected(String baseUrl) {
       return UrlMapValidateResult.create(false, // loadSucceded
             ImmutableList.of("jclouds-test"), // loadError
             false, // testPassed
             ImmutableList.of(TestFailure.create("jclouds-test", // host
                   "/test/path", // path
-                  URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/backendServices/jclouds-test"), // expectedService
-                  URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/backendServices/jclouds-test-2") //actualService
+                  URI.create(baseUrl + "/myproject/global/backendServices/jclouds-test"), // expectedService
+                  URI.create(baseUrl + "/myproject/global/backendServices/jclouds-test-2") //actualService
                   ))); //testFailures)
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java
index 05f610d..9bd0930 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneListTest.java
@@ -40,11 +40,16 @@ public class ParseZoneListTest extends BaseGoogleComputeEngineParseTest<ListPage
 
    @Override @Consumes(APPLICATION_JSON)
    public ListPage<Zone> expected() {
-      Zone zone1 = new ParseZoneTest().expected();
+      return expected(BASE_URL);
+   }
+
+   @Consumes(APPLICATION_JSON)
+   public ListPage<Zone> expected(String baseUrl) {
+      Zone zone1 = new ParseZoneTest().expected(baseUrl);
       Zone zone2 = Zone.create( //
             "13024414164050619686", // id
             parse("2012-10-24T20:13:19.271"), // creationTimestamp
-            URI.create(BASE_URL + "/party/zones/us-central1-b"), // selfLink
+            URI.create(baseUrl + "/party/zones/us-central1-b"), // selfLink
             "us-central1-b", // name
             "us-central1-b", // description
             Zone.Status.UP, // status

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java
index 2a472c9..7bfd66c 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseZoneTest.java
@@ -38,10 +38,15 @@ public class ParseZoneTest extends BaseGoogleComputeEngineParseTest<Zone> {
 
    @Override @Consumes(APPLICATION_JSON)
    public Zone expected() {
+      return expected(BASE_URL);
+   }
+
+   @Consumes(APPLICATION_JSON)
+   public Zone expected(String baseUrl) {
       return Zone.create( //
             "13020128040171887099", // id
             parse("2012-10-19T16:42:54.131"), // creationTimestamp
-            URI.create(BASE_URL + "/party/zones/us-central1-a"), // selfLink
+            URI.create(baseUrl + "/party/zones/us-central1-a"), // selfLink
             "us-central1-a", // name
             "us-central1-a", // description
             Zone.Status.DOWN, // status

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/a9dcca87/google-compute-engine/src/test/resources/firewall_insert.json
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/resources/firewall_insert.json b/google-compute-engine/src/test/resources/firewall_insert.json
index 8742a10..6d29ef8 100644
--- a/google-compute-engine/src/test/resources/firewall_insert.json
+++ b/google-compute-engine/src/test/resources/firewall_insert.json
@@ -1 +1,22 @@
-{"name":"%s","network":"https://www.googleapis.com/compute/v1/projects/party/global/networks/%s","sourceRanges":[%s],"sourceTags":[%s],"targetTags":[%s],"allowed":[{"IPProtocol":"tcp","ports":[%s]}]}
\ No newline at end of file
+{
+  "name": "myfw",
+  "network": "https://www.googleapis.com/compute/v1/projects/party/global/networks/default",
+  "sourceRanges": [
+    "10.0.1.0/32"
+  ],
+  "sourceTags": [
+    "tag1"
+  ],
+  "targetTags": [
+    "tag2"
+  ],
+  "allowed": [
+    {
+      "IPProtocol": "tcp",
+      "ports": [
+        "22",
+        "23-24"
+      ]
+    }
+  ]
+}
\ No newline at end of file


[2/2] jclouds-labs-google git commit: MockTests now support PATCH semantics

Posted by na...@apache.org.
MockTests now support PATCH semantics


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/5f1069b9
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/5f1069b9
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/5f1069b9

Branch: refs/heads/master
Commit: 5f1069b9241d235f8373e1bfddd2b04b914c1c48
Parents: a9dcca8
Author: Daniel Broudy <br...@google.com>
Authored: Mon Dec 15 14:59:50 2014 -0800
Committer: Ignasi Barrera <na...@apache.org>
Committed: Tue Dec 16 00:44:33 2014 +0100

----------------------------------------------------------------------
 google-compute-engine/pom.xml                   |  6 ++
 .../features/BackendServiceApiExpectTest.java   | 73 ------------------
 .../features/BackendServiceApiMockTest.java     | 18 ++++-
 .../features/FirewallApiExpectTest.java         | 64 ----------------
 .../features/FirewallApiMockTest.java           | 18 +++++
 .../features/HttpHealthCheckApiExpectTest.java  | 55 --------------
 .../features/HttpHealthCheckApiMockTest.java    | 12 +++
 .../features/UrlMapApiExpectTest.java           | 79 --------------------
 .../features/UrlMapApiMockTest.java             |  4 +-
 .../BaseGoogleComputeEngineApiMockTest.java     |  5 +-
 10 files changed, 57 insertions(+), 277 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/google-compute-engine/pom.xml
----------------------------------------------------------------------
diff --git a/google-compute-engine/pom.xml b/google-compute-engine/pom.xml
index 4c01bbc..c5837ff 100644
--- a/google-compute-engine/pom.xml
+++ b/google-compute-engine/pom.xml
@@ -99,6 +99,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.jclouds.driver</groupId>
+            <artifactId>jclouds-okhttp</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/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
deleted file mode 100644
index 79fd5f7..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/BackendServiceApiExpectTest.java
+++ /dev/null
@@ -1,73 +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 javax.ws.rs.core.MediaType.APPLICATION_JSON;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URI;
-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.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit")
-public class BackendServiceApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   private static final String ENDPOINT_BASE = "https://www.googleapis.com/"
-            + "compute/v1/projects/party/global/backendServices";
-
-   private org.jclouds.http.HttpRequest.Builder<? extends HttpRequest.Builder<?>> getBasicRequest() {
-      return HttpRequest.builder().addHeader("Accept", "application/json")
-                                  .addHeader("Authorization", "Bearer " + TOKEN);
-   }
-
-   private HttpResponse createResponse(String payloadFile) {
-      return HttpResponse.builder().statusCode(200)
-                                   .payload(payloadFromResource(payloadFile))
-                                   .build();
-   }
-
-   public void testPatchBackendServiceResponseIs2xx() throws IOException {
-      HttpRequest request = getBasicRequest().method("PATCH")
-               .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.patch("jclouds-test", new BackendServiceOptions().name("jclouds-test")
-                                                                         .protocol("HTTP")
-                                                                         .port(80)
-                                                                         .timeoutSec(30)
-                                                                         .healthChecks(healthChecks)),
-                   new ParseOperationTest().expected());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/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
index ba5bfe0..1cc8400 100644
--- 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
@@ -85,6 +85,23 @@ public class BackendServiceApiMockTest extends BaseGoogleComputeEngineApiMockTes
             stringFromResource("/backend_service_insert.json"));
    }
 
+   public void patch() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      List<URI> healthChecks = ImmutableList.of(URI.create(url("/projects/"
+            + "myproject/global/httpHealthChecks/jclouds-test")));
+
+      assertEquals(backendServiceApi().patch("jclouds-test",
+            new BackendServiceOptions().name("jclouds-test")
+               .protocol("HTTP")
+               .port(80)
+               .timeoutSec(30)
+               .healthChecks(healthChecks)),
+            new ParseOperationTest().expected(url("/projects")));
+      assertSent(server, "PATCH", "/projects/party/global/backendServices/jclouds-test",
+            stringFromResource("/backend_service_insert.json"));
+   }
+
    public void delete() throws Exception {
       server.enqueue(jsonResponse("/operation.json"));
 
@@ -102,7 +119,6 @@ public class BackendServiceApiMockTest extends BaseGoogleComputeEngineApiMockTes
       assertSent(server, "DELETE", "/projects/party/global/backendServices/jclouds-test");
    }
 
-
    public void list() throws Exception {
       server.enqueue(jsonResponse("/backend_service_list.json"));
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/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
deleted file mode 100644
index b5ed9a1..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java
+++ /dev/null
@@ -1,64 +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 java.io.IOException;
-import java.net.URI;
-
-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.ParseOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = "unit", testName = "FirewallApiExpectTest")
-public class FirewallApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   public void testPatchFirewallResponseIs2xx() throws IOException {
-      HttpRequest update = HttpRequest
-              .builder()
-              .method("PATCH")
-              .endpoint(BASE_URL + "/party/global/firewalls/myfw")
-              .addHeader("Accept", "application/json")
-              .addHeader("Authorization", "Bearer " + TOKEN)
-              .payload(payloadFromResource("/firewall_insert.json"))
-              .build();
-
-      HttpResponse updateFirewallResponse = HttpResponse.builder().statusCode(200)
-              .payload(payloadFromResource("/operation.json")).build();
-
-      FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, update,
-              updateFirewallResponse).firewalls();
-
-      assertEquals(api.patch("myfw",
-              new FirewallOptions()
-                      .name("myfw")
-                      .network(URI.create(BASE_URL + "/party/global/networks/default"))
-                      .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24")))
-                      .addSourceTag("tag1")
-                      .addSourceRange("10.0.1.0/32")
-                      .addTargetTag("tag2")), new ParseOperationTest().expected());
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/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
index ba8afef..bae4f72 100644
--- 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
@@ -115,6 +115,24 @@ public class FirewallApiMockTest extends BaseGoogleComputeEngineApiMockTest {
             stringFromResource("/firewall_insert.json"));
    }
 
+   public void patch() throws Exception {
+      server.enqueue(jsonResponse("/operation.json"));
+
+      FirewallOptions options = new FirewallOptions()
+         .name("myfw")
+         .network(URI.create(url("/projects/party/global/networks/default")))
+         .addAllowedRule(Firewall.Rule.create("tcp", ImmutableList.of("22", "23-24")))
+         .addSourceTag("tag1")
+         .addSourceRange("10.0.1.0/32")
+         .addTargetTag("tag2");
+
+      assertEquals(firewallApi().patch("myfw", options),
+            new ParseOperationTest().expected(url("/projects")));
+
+      assertSent(server, "PATCH", "/projects/party/global/firewalls/myfw",
+            stringFromResource("/firewall_insert.json"));
+   }
+
    FirewallApi firewallApi(){
       return api().firewalls();
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
deleted file mode 100644
index 2b50537..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java
+++ /dev/null
@@ -1,55 +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 javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions;
-import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "HttpHealthCheckApiExpectTest")
-public class HttpHealthCheckApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-   public void testPatchHttpHealthChecksResponseIs2xx() {
-      String healthCheckName = "http-health-check";
-      HttpRequest patch = HttpRequest
-            .builder()
-            .method("PATCH")
-            .endpoint(BASE_URL + "/party/global/httpHealthChecks/" + healthCheckName)
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN)
-            .payload(payloadFromResourceWithContentType("/httphealthcheck_patch.json", MediaType.APPLICATION_JSON))
-            .build();
-
-       HttpResponse insertHttpHealthCheckResponse = HttpResponse.builder().statusCode(200)
-               .payload(payloadFromResource("/global_operation.json")).build();
-
-       HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-               TOKEN_RESPONSE, patch,
-               insertHttpHealthCheckResponse).httpHeathChecks();
-       HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder().timeoutSec(0).unhealthyThreshold(0).buildNoDefaults();
-       assertEquals(api.patch(healthCheckName, options), new ParseGlobalOperationTest().expected());
-   }
-
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
index 2943a33..ebc86fe 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiMockTest.java
@@ -87,6 +87,18 @@ public class HttpHealthCheckApiMockTest extends BaseGoogleComputeEngineApiMockTe
             stringFromResource("/httphealthcheck_insert.json"));
    }
 
+   public void patch() throws Exception {
+      server.enqueue(jsonResponse("/global_operation.json"));
+
+      HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
+         .timeoutSec(0).unhealthyThreshold(0).buildNoDefaults();
+      assertEquals(httpHealthCheckApi().patch("http-health-check", options),
+            new ParseGlobalOperationTest().expected(url("/projects")));
+
+      assertSent(server, "PATCH", "/projects/party/global/httpHealthChecks/http-health-check",
+            stringFromResource("/httphealthcheck_patch.json"));
+   }
+
    public void list() throws Exception {
       server.enqueue(jsonResponse("/httphealthcheck_list.json"));
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java
deleted file mode 100644
index 885ab88..0000000
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java
+++ /dev/null
@@ -1,79 +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 java.io.IOException;
-import java.net.URI;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
-import org.jclouds.googlecomputeengine.domain.UrlMap;
-import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule;
-import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher;
-import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher.PathRule;
-import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
-import org.jclouds.googlecomputeengine.options.UrlMapOptions;
-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.ImmutableList;
-
-@Test(groups = "unit")
-public class UrlMapApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> {
-
-
-   public void patch() throws IOException {
-      HttpRequest request = HttpRequest.builder()
-            .addHeader("Accept", "application/json")
-            .addHeader("Authorization", "Bearer " + TOKEN)
-            .method("PATCH")
-            .endpoint("https://www.googleapis.com/compute/v1/projects"
-                     + "/party/global/urlMaps/jclouds-test")
-            .payload(payloadFromResourceWithContentType("/url_map_insert.json", MediaType.APPLICATION_JSON))
-            .build();
-
-      HttpResponse response = HttpResponse.builder().statusCode(200)
-            .payload(payloadFromResource("/operation.json"))
-            .build();
-
-      UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
-              TOKEN_RESPONSE, request, response).urlMaps();
-
-      assertEquals(api.patch("jclouds-test", createBasicMap()), new ParseOperationTest().expected());
-   }
-
-   private UrlMapOptions createBasicMap() {
-      URI service = URI.create("https://www.googleapis.com/compute/v1/projects/"
-               + "myproject/global/backendServices/jclouds-test");
-      return new UrlMapOptions().name("jclouds-test")
-                                .description("Sample url map")
-                                .hostRule(HostRule.create(null, ImmutableList.of("jclouds-test"), "path"))
-                                .pathMatcher(PathMatcher.create("path",
-                                                                null,
-                                                                service,
-                                                                ImmutableList.of(
-                                                                      PathRule.create(ImmutableList.of("/"),
-                                                                                      service))))
-                                .test(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service))
-                                .defaultService(service);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
index b0de3d8..1107557 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiMockTest.java
@@ -70,9 +70,7 @@ public class UrlMapApiMockTest extends BaseGoogleComputeEngineApiMockTest {
             stringFromResource("/url_map_insert.json"));
    }
 
-/*
    public void patch() throws Exception {
-      // PATCH not yet supported
       server.enqueue(jsonResponse("/operation.json"));
 
       assertEquals(urlMapApi().patch("jclouds-test", createBasicMap()),
@@ -80,7 +78,7 @@ public class UrlMapApiMockTest extends BaseGoogleComputeEngineApiMockTest {
       assertSent(server, "PATCH", "/projects/party/global/urlMaps/jclouds-test",
             stringFromResource("/url_map_insert.json"));
    }
-*/
+
    public void delete() throws Exception {
       server.enqueue(jsonResponse("/operation.json"));
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/5f1069b9/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java
index a9f4483..8907be9 100644
--- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java
+++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiMockTest.java
@@ -36,6 +36,7 @@ import org.jclouds.ContextBuilder;
 import org.jclouds.compute.ComputeService;
 import org.jclouds.compute.ComputeServiceContext;
 import org.jclouds.concurrent.config.ExecutorServiceModule;
+import org.jclouds.http.okhttp.config.OkHttpCommandExecutorServiceModule;
 import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
 import org.jclouds.googlecomputeengine.GoogleComputeEngineProviderMetadata;
 import org.testng.annotations.AfterMethod;
@@ -49,7 +50,7 @@ import com.squareup.okhttp.mockwebserver.MockWebServer;
 import com.squareup.okhttp.mockwebserver.RecordedRequest;
 
 /**
- * Tests need to run {@code singleThreaded = true) as otherwise tests will clash on the server field.
+ * Tests need to run {@code singleThreaded = true} as otherwise tests will clash on the server field.
  * Sharing the server field means less code to write.
  */
 public class BaseGoogleComputeEngineApiMockTest {
@@ -80,7 +81,7 @@ public class BaseGoogleComputeEngineApiMockTest {
    }
 
    private final Set<Module> modules = ImmutableSet
-         .of(new ExecutorServiceModule(sameThreadExecutor()), GoogleComputeEngineTestModule.INSTANCE);
+         .of(new ExecutorServiceModule(sameThreadExecutor()), GoogleComputeEngineTestModule.INSTANCE, new OkHttpCommandExecutorServiceModule());
 
    final AtomicInteger suffix = new AtomicInteger();