You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/08/02 16:57:59 UTC
[06/10] Remove async from gogrid
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java
new file mode 100644
index 0000000..be06c8d
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerApiTest.java
@@ -0,0 +1,273 @@
+/*
+ * 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.gogrid.features;
+
+import static org.jclouds.reflect.Reflection2.method;
+
+import java.io.IOException;
+
+import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.gogrid.domain.PowerCommand;
+import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
+import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
+import org.jclouds.gogrid.options.GetServerListOptions;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+import com.google.common.reflect.Invokable;
+/**
+ * Tests behavior of {@code GridServerApi}
+ *
+ * @author Oleksiy Yarmula, Adrian Cole
+ */
+// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
+@Test(groups = "unit", testName = "GridServerApiTest")
+public class GridServerApiTest extends BaseGoGridApiTest<GridServerApi> {
+
+ @Test
+ public void testGetServerListWithOptions() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServerList", GetServerListOptions[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
+ new GetServerListOptions.Builder().onlySandboxServers()));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/grid/server/list?v=1.6&isSandbox=true HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?"
+ + "v=1.6&isSandbox=true&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetServersByName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServersByName", String[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("server1"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&name=server1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&name=server1&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetServersById() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServersById", long[].class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?v=1.6&id=123 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?" + "v=1.6&id=123&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+
+ @Test
+ public void testPowerServer() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "power", String.class, PowerCommand.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer",
+ PowerCommand.RESTART));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
+ + "server=PowerServer&power=restart " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/power?v=1.6&"
+ + "server=PowerServer&power=restart&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testDeleteByName() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "deleteByName", String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("PowerServer"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
+ + "name=PowerServer " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/delete?v=1.6&"
+ + "name=PowerServer&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testGetRamSizes() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getRamSizes");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram "
+ + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.ram&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testServerCredentials() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getServerCredentials", long.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1));
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/support/grid/password/get?v=1.6&id=1 HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseCredentialsFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+ }
+
+ @Test
+ public void testTypes() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "getTypes");
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
+
+ assertRequestLineEquals(httpRequest,
+ "GET https://api.gogrid.com/api/common/lookup/list?v=1.6&lookup=server.type HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+ }
+
+ @Test
+ public void testEditServerDescription() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "editServerDescription", long.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "newDesc"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&description=newDesc HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&description=newDesc&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testEditServerRam() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "editServerRam", long.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "1GB"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.ram=1GB HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.ram=1GB&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+
+ @Test
+ public void testEditServerType() throws NoSuchMethodException, IOException {
+ Invokable<?, ?> method = method(GridServerApi.class, "editServerType", long.class, String.class);
+ GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(2, "web"));
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.type=web HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+
+ assertSaxResponseParserClassEquals(method, null);
+ assertFallbackClassEquals(method, null);
+
+ checkFilters(httpRequest);
+ httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
+
+ assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/edit?v=1.6&"
+ + "id=2&server.type=web&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
+ assertNonPayloadHeadersEqual(httpRequest, "");
+ assertPayloadEquals(httpRequest, null, null, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java
new file mode 100644
index 0000000..bdcf3e6
--- /dev/null
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/features/GridServerClientExpectTest.java
@@ -0,0 +1,143 @@
+/*
+ * 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.gogrid.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.net.URI;
+
+import org.jclouds.gogrid.GoGridApi;
+import org.jclouds.gogrid.options.AddServerOptions;
+import org.jclouds.gogrid.options.GetServerListOptions;
+import org.jclouds.gogrid.parse.ParseServerListTest;
+import org.jclouds.gogrid.parse.ParseServerTest;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @author Adrian Cole
+ */
+@Test(groups = "unit", testName = "GridServerClientExpectTest")
+public class GridServerClientExpectTest extends BaseGoGridHttpApiExpectTest {
+
+ HttpRequest addServer = HttpRequest.builder().method("GET")
+ .endpoint("https://api.gogrid.com/api/grid/server/add")
+ .addQueryParam("v", "1.6")
+ .addQueryParam("name", "serverName")
+ .addQueryParam("image", "img55")
+ .addQueryParam("server.ram", "memory")
+ .addQueryParam("ip", "127.0.0.1")
+ .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
+ .addQueryParam("api_key", "identity").build();
+
+ public void testAddServerWhenResponseIs2xx() throws Exception {
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi addServerWorked = requestSendsResponse(addServer, listGridServersResponse);
+
+ assertEquals(addServerWorked.getServerServices().addServer("serverName", "img55", "memory", "127.0.0.1")
+ .toString(), new ParseServerTest().expected().toString());
+ }
+
+ HttpRequest addServerOptions = HttpRequest.builder().method("GET")
+ .endpoint("https://api.gogrid.com/api/grid/server/add")
+ .addQueryParam("v", "1.6")
+ .addQueryParam("name", "serverName")
+ .addQueryParam("image", "img55")
+ .addQueryParam("server.ram", "memory")
+ .addQueryParam("ip", "127.0.0.1")
+ .addQueryParam("isSandbox", "true")
+ .addQueryParam("description", "fooy")
+ .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
+ .addQueryParam("api_key", "identity").build();
+
+ public void testAddServerWithOptionsWhenResponseIs2xx() throws Exception {
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi addServerWithOptionsWorked = requestSendsResponse(addServerOptions, listGridServersResponse);
+
+ assertEquals(addServerWithOptionsWorked.getServerServices().addServer("serverName", "img55", "memory",
+ "127.0.0.1", new AddServerOptions().asSandboxType().withDescription("fooy")).toString(),
+ new ParseServerTest().expected().toString());
+ }
+
+ public void testGetServerListWhenResponseIs2xx() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
+
+ assertEquals(clientWhenGridServersExist.getServerServices().getServerList().toString(), new ParseServerListTest()
+ .expected().toString());
+ }
+
+ public void testGetServerListWhenReponseIs404IsEmpty() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(404).payload(
+ payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
+
+ GoGridApi clientWhenNoGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
+
+ assertTrue(clientWhenNoGridServersExist.getServerServices().getServerList().isEmpty());
+ }
+
+ public void testGetServerListWithOptionsWhenResponseIs2xx() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/grid/server/list?" + "v=1.6&isSandbox=true&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(200).payload(
+ payloadFromResourceWithContentType("/test_get_server_list.json", "application/json")).build();
+
+ GoGridApi clientWhenGridServersExist = requestSendsResponse(listGridServers, listGridServersResponse);
+
+ assertEquals(clientWhenGridServersExist.getServerServices().getServerList(
+ new GetServerListOptions.Builder().onlySandboxServers()).toString(), new ParseServerListTest()
+ .expected().toString());
+ }
+
+ public void testGetServerCredentialsWhenNotFoundThrowsResourceNotFoundExceptionWithNiceMessage() throws Exception {
+ HttpRequest listGridServers = HttpRequest.builder().method("GET").endpoint(
+ URI.create("https://api.gogrid.com/api/support/grid/password/get?" + "v=1.6&id=11&"
+ + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity")).build();
+
+ HttpResponse listGridServersResponse = HttpResponse.builder().statusCode(400).payload(
+ payloadFromResourceWithContentType("/test_error_handler.json", "application/json")).build();
+
+ GoGridApi clientWhenGridServersNotFound = requestSendsResponse(listGridServers, listGridServersResponse);
+ try {
+ clientWhenGridServersNotFound.getServerServices().getServerCredentials(11);
+ fail("should have failed");
+ } catch (ResourceNotFoundException e) {
+ assertEquals(e.getMessage(), "No object found that matches your input criteria.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
index 44f2479..1f5f03b 100644
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
+++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/predicates/ServerLatestJobCompletedTest.java
@@ -25,7 +25,7 @@ import static org.testng.Assert.assertTrue;
import org.jclouds.gogrid.domain.Job;
import org.jclouds.gogrid.domain.JobState;
import org.jclouds.gogrid.domain.Server;
-import org.jclouds.gogrid.services.GridJobClient;
+import org.jclouds.gogrid.features.GridJobApi;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@@ -46,7 +46,7 @@ public class ServerLatestJobCompletedTest {
Job job = createMock(Job.class);
expect(job.getCurrentState()).andReturn(JobState.SUCCEEDED);
- GridJobClient client = createMock(GridJobClient.class);
+ GridJobApi client = createMock(GridJobApi.class);
expect(client.getJobList(latestJobForObjectByName(serverName))).andReturn(ImmutableSet.<Job> of(job));
replay(job);
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java
deleted file mode 100644
index f498fd5..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridAsyncClientTest.java
+++ /dev/null
@@ -1,69 +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.gogrid.services;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.date.TimeStamp;
-import org.jclouds.gogrid.GoGridProviderMetadata;
-import org.jclouds.gogrid.config.GoGridRestClientModule;
-import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.internal.BaseAsyncClientTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Module;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public abstract class BaseGoGridAsyncClientTest<T> extends BaseAsyncClientTest<T> {
- @Override
- protected void checkFilters(HttpRequest request) {
- assertEquals(request.getFilters().size(), 1);
- assertEquals(request.getFilters().get(0).getClass(), SharedKeyLiteAuthentication.class);
- }
-
- @ConfiguresRestClient
- protected static final class TestGoGridRestClientModule extends GoGridRestClientModule {
- @Override
- protected void configure() {
- super.configure();
- }
-
- @Override
- protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
- return 1267243795L;
- }
- }
-
- @Override
- protected Module createModule() {
- return new TestGoGridRestClientModule();
- }
-
- @Override
- public ProviderMetadata createProviderMetadata() {
- return new GoGridProviderMetadata();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java
deleted file mode 100644
index a92b3f0..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java
+++ /dev/null
@@ -1,33 +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.gogrid.services;
-
-import org.jclouds.apis.BaseApiLiveTest;
-import org.jclouds.gogrid.GoGridClient;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code GoGridClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "BaseGoGridClientLiveTest")
-public class BaseGoGridClientLiveTest extends BaseApiLiveTest<GoGridClient> {
- public BaseGoGridClientLiveTest() {
- provider = "gogrid";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java
deleted file mode 100644
index 8135e44..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridRestClientExpectTest.java
+++ /dev/null
@@ -1,51 +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.gogrid.services;
-
-import org.jclouds.date.TimeStamp;
-import org.jclouds.gogrid.GoGridClient;
-import org.jclouds.gogrid.config.GoGridRestClientModule;
-import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.internal.BaseRestClientExpectTest;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Module;
-
-/**
- *
- * @author Adrian Cole
- */
-public class BaseGoGridRestClientExpectTest extends BaseRestClientExpectTest<GoGridClient> {
-
- public BaseGoGridRestClientExpectTest() {
- provider = "gogrid";
- }
-
- @ConfiguresRestClient
- protected static final class TestGoGridRestClientModule extends GoGridRestClientModule {
-
- @Override
- protected Long provideTimeStamp(@TimeStamp Supplier<Long> cache) {
- return 1267243795L;
- }
- }
-
- @Override
- protected Module createModule() {
- return new TestGoGridRestClientModule();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java
deleted file mode 100644
index a52b8c8..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageAsyncClientTest.java
+++ /dev/null
@@ -1,192 +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.gogrid.services;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.gogrid.domain.ServerImageState;
-import org.jclouds.gogrid.domain.ServerImageType;
-import org.jclouds.gogrid.functions.ParseImageFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse;
-import org.jclouds.gogrid.options.GetImageListOptions;
-import org.jclouds.gogrid.options.SaveImageOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridImageAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "GridImageAsyncClientTest")
-public class GridImageAsyncClientTest extends BaseGoGridAsyncClientTest<GridImageAsyncClient> {
-
- @Test
- public void testGetImageListWithOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "getImageList", GetImageListOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(
- method, ImmutableList.<Object> of(
- new GetImageListOptions().onlyPublic().setState(ServerImageState.AVAILABLE)
- .setType(ServerImageType.WEB_APPLICATION_SERVER)));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?v=1.5&"
- + "isPublic=true&image.state=Available&" + "image.type=Web%20Server HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/list?"
- + "v=1.5&isPublic=true&image.state=Available&" + "image.type=Web%20Server&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetImagesByName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "getImagesByName", String[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("name1", "name2"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&"
- + "name=name1&name=name2 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/get?v=1.5&"
- + "name=name1&name=name2&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditImageDescription() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "editImageDescription", String.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newDesc"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&description=newDesc HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&description=newDesc&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditImageFriendlyName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "editImageFriendlyName", String.class, String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("imageName", "newFriendlyName"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&friendlyName=newFriendlyName HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/edit?v=1.5&"
- + "image=imageName&friendlyName=newFriendlyName&" + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity "
- + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testDeleteById() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "deleteById", long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(11l));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/image/delete?v=1.5&id=11 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
- }
-
- @Test
- public void testSaveImageFromServerNoOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class,
- SaveImageOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName"));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/image/save?v=1.5&friendlyName=friendly&server=serverName HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- }
-
- @Test
- public void testSaveImageOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridImageAsyncClient.class, "saveImageFromServer", String.class, String.class,
- SaveImageOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("friendly", "serverName",
- new SaveImageOptions().withDescription("fooy")));
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/image/save?v=1.5&friendlyName=friendly&server=serverName&description=fooy HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseImageFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java
deleted file mode 100644
index 188a2ba..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridImageClientLiveTest.java
+++ /dev/null
@@ -1,138 +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.gogrid.services;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.jclouds.gogrid.domain.Ip;
-import org.jclouds.gogrid.domain.Server;
-import org.jclouds.gogrid.domain.ServerImage;
-import org.jclouds.gogrid.domain.ServerImageState;
-import org.jclouds.gogrid.options.SaveImageOptions;
-import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "GridImageClientLiveTest")
-public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
-
- public void testListImages() throws Exception {
- Set<ServerImage> response = api.getImageServices().getImageList();
- assert null != response;
- for (ServerImage image : response) {
- assert image.getId() >= 0 : image;
- checkImage(image);
-
- ServerImage query = Iterables.getOnlyElement(api.getImageServices()
- .getImagesById(image.getId()));
- assertEquals(query.getId(), image.getId());
-
- checkImage(query);
- }
- }
-
- private void checkImage(ServerImage image) {
- assert image.getArchitecture() != null : image;
- assert image.getBillingTokens() != null : image;
- if (image.getCreatedTime() == null)
- Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the createdTime field");
- assert image.getDescription() != null : image;
- assert image.getFriendlyName() != null : image;
- assert image.getId() >= 0 : image;
- assert image.getLocation() != null : image;
- assert image.getName() != null : image;
- assert image.getOs() != null : image;
- assert image.getOwner() != null : image;
- assert image.getPrice() >= 0 : image;
- assert image.getState() != null : image;
- assert image.getType() != null : image;
- if (image.getUpdatedTime() == null)
- Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the updatedTime field");
- }
-
- @Test
- public void testSaveServerToImage() throws IOException {
- Predicate<Server> serverLatestJobCompleted = retry(new ServerLatestJobCompleted(api
- .getJobServices()), 800, 20, SECONDS);
-
- final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
- ServerImage image = null;
- try {
- Set<Ip> availableIps = api.getIpServices().getUnassignedPublicIpList();
- Ip availableIp = Iterables.getLast(availableIps);
-
- Server createdServer = api.getServerServices()
- .addServer(nameOfServer, "5489", "1", availableIp.getIp());
- assertNotNull(createdServer);
- assert serverLatestJobCompleted.apply(createdServer);
- image = api
- .getImageServices()
- .saveImageFromServer("friendlyName", createdServer.getName(),
- SaveImageOptions.Builder.withDescription("description"));
-
- assertEquals(image.getFriendlyName(), "friendlyName");
- assertEquals(image.getDescription(), "description");
- assertFalse(image.isPublic());
-
- assertEventuallyImageStateEquals(image, ServerImageState.AVAILABLE);
-
- api.getImageServices().deleteById(image.getId());
-
- assertEventuallyImageStateEquals(image, ServerImageState.TRASH);
-
- image = null;
- } finally {
- if (image != null)
- try {
- api.getImageServices().deleteById(image.getId());
- } catch (Exception e) {
- // not failing so that we can ensure server below deletes
- e.printStackTrace();
- }
- // delete the server
- api.getServerServices().deleteByName(nameOfServer);
- }
-
- }
-
- protected void assertEventuallyImageStateEquals(ServerImage image, final ServerImageState state) {
- assertTrue(retry(new Predicate<ServerImage>() {
- public boolean apply(ServerImage input) {
- return Iterables.getOnlyElement(api.getImageServices().getImagesById(input.getId()))
- .getState() == state;
- }
- }, 600, 1, SECONDS).apply(image));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java
deleted file mode 100644
index 1fa2ba8..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridIpAsyncClientTest.java
+++ /dev/null
@@ -1,87 +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.gogrid.services;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.gogrid.domain.IpType;
-import org.jclouds.gogrid.functions.ParseIpListFromJsonResponse;
-import org.jclouds.gogrid.options.GetIpListOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridIpAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridIpAsyncClientTest")
-public class GridIpAsyncClientTest extends BaseGoGridAsyncClientTest<GridIpAsyncClient> {
-
- @Test
- public void testGetIpListWithOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridIpAsyncClient.class, "getIpList", GetIpListOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(new GetIpListOptions()
- .onlyUnassigned().onlyWithType(IpType.PUBLIC)));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Unassigned&"
- + "ip.type=Public HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseIpListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Unassigned&"
- + "ip.type=Public&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetAssignedIpList() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridIpAsyncClient.class, "getAssignedIpList");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Assigned HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseIpListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/ip/list?v=1.5&ip.state=Assigned&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java
deleted file mode 100644
index 3a6973f..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobAsyncClientTest.java
+++ /dev/null
@@ -1,127 +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.gogrid.services;
-
-import static org.jclouds.gogrid.options.GetJobListOptions.Builder.startDate;
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.util.Date;
-
-import org.jclouds.gogrid.domain.JobState;
-import org.jclouds.gogrid.domain.ObjectType;
-import org.jclouds.gogrid.functions.ParseJobListFromJsonResponse;
-import org.jclouds.gogrid.options.GetJobListOptions;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridJobAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridJobAsyncClientTest")
-public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsyncClient> {
-
- @Test
- public void testGetJobListWithOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class);
- GeneratedHttpRequest httpRequest = processor
- .createRequest(method, ImmutableList.<Object> of(startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L))
- .onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING)));
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/job/list?v=1.5&startdate=1267385381770&"
- + "enddate=1267385382770&job.objecttype=VirtualServer&" + "job.state=Processing HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest,
- "GET https://api.gogrid.com/api/grid/job/list?v=1.5&startdate=1267385381770&"
- + "enddate=1267385382770&job.objecttype=VirtualServer&" + "job.state=Processing&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetJobListNoOptions() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobList", GetJobListOptions[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetJobsForServerName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobsForObjectName", String.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("MyServer"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&"
- + "object=MyServer HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/list?v=1.5&"
- + "object=MyServer&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetJobsById() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridJobAsyncClient.class, "getJobsById", long[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(123L, 456L));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&"
- + "id=123&id=456 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseJobListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/job/get?v=1.5&"
- + "id=123&id=456&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.java
deleted file mode 100644
index 4397611..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridJobClientLiveTest.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.gogrid.services;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Set;
-
-import org.jclouds.gogrid.domain.Job;
-import org.jclouds.gogrid.options.GetJobListOptions;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-
-/**
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridJobClientLiveTest")
-public class GridJobClientLiveTest extends BaseGoGridClientLiveTest {
-
- public void testListJobs() throws Exception {
- Set<Job> response = api.getJobServices().getJobList(GetJobListOptions.Builder.maxItems(10));
- assert null != response;
- assert response.size() <= 10 : response;
- for (Job job : response) {
- assert job.getId() >= 0 : job;
- checkJob(job);
-
- Job query = Iterables.getOnlyElement(api.getJobServices().getJobsById(job.getId()));
- assertEquals(query.getId(), job.getId());
-
- checkJob(query);
- }
- }
-
- private void checkJob(Job job) {
- assert job.getAttempts() >= 0 : job;
- assert job.getCommand() != null : job;
- assert job.getCreatedOn() != null : job;
- assert job.getCreatedOn() != null : job;
- assert job.getDetails() != null : job;
- assert job.getHistory() != null : job;
- assert job.getId() >= 0 : job;
- assert job.getLastUpdatedOn() != null : job;
- assert job.getObjectType() != null : job;
- assert job.getOwner() != null : job;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/d4bf5112/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java
deleted file mode 100644
index 911ee0c..0000000
--- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java
+++ /dev/null
@@ -1,209 +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.gogrid.services;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.jclouds.gogrid.domain.Ip;
-import org.jclouds.gogrid.domain.IpPortPair;
-import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
-import org.jclouds.gogrid.domain.LoadBalancerType;
-import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse;
-import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse;
-import org.jclouds.gogrid.options.AddLoadBalancerOptions;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code GridLoadBalancerAsyncClient}
- *
- * @author Oleksiy Yarmula
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
-@Test(groups = "unit", testName = "GridLoadBalancerAsyncClientTest")
-public class GridLoadBalancerAsyncClientTest extends BaseGoGridAsyncClientTest<GridLoadBalancerAsyncClient> {
-
- @Test
- public void testGetLoadBalancerList() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancerList");
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.of());
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/list?v=1.5&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- HttpRequest addLoadBalancer = HttpRequest.builder().method("GET")
- .endpoint("https://api.gogrid.com/api/grid/loadbalancer/add")
- .addQueryParam("v", "1.5")
- .addQueryParam("name", "BalanceIt")
- .addQueryParam("loadbalancer.type", "Least Connect")
- .addQueryParam("loadbalancer.persistence", "SSL Sticky")
- .addQueryParam("virtualip.ip", "127.0.0.1")
- .addQueryParam("virtualip.port", "80")
- .addQueryParam("realiplist.0.ip", "127.0.0.1")
- .addQueryParam("realiplist.0.port", "8080")
- .addQueryParam("realiplist.1.ip", "127.0.0.1")
- .addQueryParam("realiplist.1.port", "9090")
- .addQueryParam("sig", "e9aafd0a5d4c69bb24536be4bce8a528")
- .addQueryParam("api_key", "identity").build();
-
- @Test
- public void testAddLoadBalancer() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "addLoadBalancer", String.class, IpPortPair.class,
- List.class, AddLoadBalancerOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt",
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(80).build(),
- ImmutableList.of(IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build()),
- new AddLoadBalancerOptions.Builder().create(
- LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SSL_STICKY)));
-
- request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request);
-
- assertRequestLineEquals(request, addLoadBalancer.getRequestLine());
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @Test
- public void testEditLoadBalancer() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancer", long.class, List.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(1l, ImmutableList.of(
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&id=1&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&id=1&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "editLoadBalancerNamed", String.class, List.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of("BalanceIt", ImmutableList.of(
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(8080).build(),
- IpPortPair.builder().ip(Ip.builder().ip("127.0.0.1").build()).port(9090).build())));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "edit?v=1.5&name=BalanceIt&realiplist.0.ip=127.0.0.1&"
- + "realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(
- httpRequest,
- "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.5&name=BalanceIt&realiplist.0.ip=127.0.0.1&realiplist.0.port=8080&realiplist.1.ip=127.0.0.1&realiplist.1.port=9090&sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testGetLoadBalancersByName() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "getLoadBalancersByName", String[].class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(
- "My Load Balancer", "My Load Balancer 2"));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "get?v=1.5&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerListFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "get?v=1.5&name=My%20Load%20Balancer&name=My%20Load%20Balancer%202&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-
- @Test
- public void testDeleteLoadBalancerById() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(GridLoadBalancerAsyncClient.class, "deleteById", Long.class);
- GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableList.<Object> of(55L));
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/"
- + "delete?v=1.5&id=55 HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
-
- assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(httpRequest);
- httpRequest = (GeneratedHttpRequest) Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
-
- assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" + "delete?v=1.5&id=55&"
- + "sig=e9aafd0a5d4c69bb24536be4bce8a528&api_key=identity " + "HTTP/1.1");
- assertNonPayloadHeadersEqual(httpRequest, "");
- assertPayloadEquals(httpRequest, null, null, false);
- }
-}