From d06e8d26781c9074952c8e426c29986df2f38051 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Wed, 9 Jun 2010 12:46:01 -0700 Subject: [PATCH] Issue 276: revise gogrid api --- .../java/org/jclouds/http/MultipartForm.java | 5 + .../internal/RestAnnotationProcessor.java | 52 +++++- .../services/GridLoadBalancerAsyncClient.java | 131 ++++++++------ .../services/GridLoadBalancerClient.java | 171 ++++++++++-------- .../org/jclouds/gogrid/GoGridLiveTest.java | 2 +- .../GridLoadBalancerAsyncClientTest.java | 41 ++++- ...loperCloudComputeServiceContextModule.java | 17 +- .../IBMDeveloperCloudRestClientModule.java | 2 +- ...MDeveloperCloudComputeServiceLiveTest.java | 11 ++ 9 files changed, 282 insertions(+), 150 deletions(-) diff --git a/core/src/main/java/org/jclouds/http/MultipartForm.java b/core/src/main/java/org/jclouds/http/MultipartForm.java index 765e95486a..cf2e82a1fe 100644 --- a/core/src/main/java/org/jclouds/http/MultipartForm.java +++ b/core/src/main/java/org/jclouds/http/MultipartForm.java @@ -28,6 +28,7 @@ import java.util.Map.Entry; import org.jclouds.util.InputStreamChain; import org.jclouds.util.Utils; +import com.google.common.collect.Lists; import com.google.common.collect.Multimap; /** @@ -42,6 +43,10 @@ public class MultipartForm { private long size; public MultipartForm(String boundary, Part... parts) { + this(boundary, Lists.newArrayList(parts)); + } + + public MultipartForm(String boundary, Iterable parts) { String boundaryrn = boundary + rn; chain = new InputStreamChain(); for (Part part : parts) { diff --git a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java index 775a34e9e5..61c634dcc3 100755 --- a/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestAnnotationProcessor.java @@ -39,6 +39,7 @@ import java.util.Set; import java.util.SortedSet; import java.util.Map.Entry; +import javax.annotation.Nullable; import javax.annotation.Resource; import javax.inject.Named; import javax.inject.Provider; @@ -60,6 +61,8 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpUtils; +import org.jclouds.http.MultipartForm; +import org.jclouds.http.MultipartForm.Part; import org.jclouds.http.functions.CloseContentAndReturn; import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x; @@ -86,6 +89,7 @@ import org.jclouds.rest.annotations.MapPayloadParam; import org.jclouds.rest.annotations.MatrixParams; import org.jclouds.rest.annotations.OverrideRequestFilters; import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.PartParam; import org.jclouds.rest.annotations.QueryParams; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; @@ -98,6 +102,8 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Iterables; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.Lists; @@ -110,7 +116,6 @@ import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.TypeLiteral; -import com.google.inject.internal.Nullable; /** * Creates http methods based on annotations on a class or interface. @@ -142,6 +147,7 @@ public class RestAnnotationProcessor { private final Map>> methodToIndexOfParamToQueryParamAnnotations = createMethodToIndexOfParamToAnnotation(QueryParam.class); private final Map>> methodToIndexOfParamToPathParamAnnotations = createMethodToIndexOfParamToAnnotation(PathParam.class); private final Map>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(MapPayloadParam.class); + private final Map>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class); private final Map>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class); private final Map delegationMap = Maps.newHashMap(); @@ -185,6 +191,16 @@ public class RestAnnotationProcessor { private static final Class optionsVarArgsClass = new HttpRequestOptions[] {} .getClass(); + private static final Function, ? extends Part> ENTRY_TO_PART = new Function, Part>() { + + @Override + public Part apply(Entry from) { + return new Part(ImmutableMultimap.of("Content-Disposition", String.format( + "form-data; name=\"%s\"", from.getKey())), from.getValue()); + } + + }; + private final Map> methodToIndexesOfOptions = new MapMaker() .makeComputingMap(new Function>() { public Set apply(final Method method) { @@ -270,6 +286,7 @@ public class RestAnnotationProcessor { methodToIndexOfParamToPathParamAnnotations.get(method).get(index); methodToIndexOfParamToPostParamAnnotations.get(method).get(index); methodToIndexOfParamToParamParserAnnotations.get(method).get(index); + methodToIndexOfParamToPartParamAnnotations.get(method).get(index); methodToIndexesOfOptions.get(method); } delegationMap.put(new MethodKey(method), method); @@ -401,7 +418,22 @@ public class RestAnnotationProcessor { addHostHeaderIfAnnotatedWithVirtualHost(headers, request.getEndpoint().getHost(), method); addFiltersIfAnnotated(method, request); - if (formParams.size() > 0) { + List parts = getParts(method, args); + if (parts.size() > 0) { + if (formParams.size() > 0) { + parts = Lists.newLinkedList(Iterables.concat(Iterables + ., Part> transform(formParams.entries(), ENTRY_TO_PART), + parts)); + } + MultipartForm form = new MultipartForm(BOUNDARY, parts); + + request.setPayload(form.getData()); + request.getHeaders().put(HttpHeaders.CONTENT_TYPE, + "multipart/form-data; boundary=" + BOUNDARY); + + request.getHeaders().put(HttpHeaders.CONTENT_LENGTH, form.getSize() + ""); + + } else if (formParams.size() > 0) { if (headers.get(HttpHeaders.CONTENT_TYPE) != null) headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); request.setPayload(makeQueryLine(formParams, null, skips)); @@ -419,6 +451,8 @@ public class RestAnnotationProcessor { return request; } + public static final String BOUNDARY = "--JCLOUDS--"; + private String getPath(Class clazz, Method method, Object[] args) { UriBuilder builder = uriBuilderProvider.get(); if (clazz.isAnnotationPresent(Path.class)) @@ -972,6 +1006,20 @@ public class RestAnnotationProcessor { return out; } + List getParts(Method method, Object... args) { + List parts = Lists.newLinkedList(); + Map> indexToPartParam = methodToIndexOfParamToPartParamAnnotations + .get(method); + for (Entry> entry : indexToPartParam.entrySet()) { + for (Annotation key : entry.getValue()) { + PartParam extractor = (PartParam) key; + Part part = injector.getInstance(extractor.value()).apply(args[entry.getKey()]); + parts.add(part); + } + } + return parts; + } + private Multimap getPathParamKeyValues(Method method, Object... args) { Multimap pathParamValues = LinkedHashMultimap.create(); pathParamValues.putAll(constants); diff --git a/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java b/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java index 69e814fdce..b4de1eae31 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClient.java @@ -18,7 +18,17 @@ */ package org.jclouds.gogrid.services; -import com.google.common.util.concurrent.ListenableFuture; +import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION; +import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY; +import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY; + +import java.util.List; +import java.util.Set; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + import org.jclouds.gogrid.GoGrid; import org.jclouds.gogrid.binders.BindIdsToQueryParams; import org.jclouds.gogrid.binders.BindNamesToQueryParams; @@ -30,19 +40,13 @@ import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication; import org.jclouds.gogrid.functions.ParseLoadBalancerFromJsonResponse; import org.jclouds.gogrid.functions.ParseLoadBalancerListFromJsonResponse; import org.jclouds.gogrid.options.AddLoadBalancerOptions; -import org.jclouds.rest.annotations.*; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; -import java.util.List; -import java.util.Set; - -import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION; -import static org.jclouds.gogrid.reference.GoGridQueryParams.ID_KEY; -import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY; -import static org.jclouds.gogrid.reference.GoGridQueryParams.LOAD_BALANCER_KEY; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Endpoint; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import com.google.common.util.concurrent.ListenableFuture; /** * @author Oleksiy Yarmula @@ -52,63 +56,74 @@ import static org.jclouds.gogrid.reference.GoGridQueryParams.LOAD_BALANCER_KEY; @QueryParams(keys = VERSION, values = "1.4") public interface GridLoadBalancerAsyncClient { - /** - * @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...) - */ - @GET - @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) - @Path("/grid/loadbalancer/list") - ListenableFuture> getLoadBalancerList(); + /** + * @see GridJobClient#getJobList(org.jclouds.gogrid.options.GetJobListOptions...) + */ + @GET + @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) + @Path("/grid/loadbalancer/list") + ListenableFuture> getLoadBalancerList(); - /** + /** * @see GridLoadBalancerClient#getLoadBalancersByName */ - @GET - @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) - @Path("/grid/loadbalancer/get") - ListenableFuture> getLoadBalancersByName(@BinderParam(BindNamesToQueryParams.class) String... names); + @GET + @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) + @Path("/grid/loadbalancer/get") + ListenableFuture> getLoadBalancersByName( + @BinderParam(BindNamesToQueryParams.class) String... names); - /** + /** * @see GridLoadBalancerClient#getLoadBalancersById */ - @GET - @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) - @Path("/grid/loadbalancer/get") - ListenableFuture> getLoadBalancersById(@BinderParam(BindIdsToQueryParams.class) Long... ids); + @GET + @ResponseParser(ParseLoadBalancerListFromJsonResponse.class) + @Path("/grid/loadbalancer/get") + ListenableFuture> getLoadBalancersById( + @BinderParam(BindIdsToQueryParams.class) Long... ids); - /** - * @see GridLoadBalancerClient#addLoadBalancer - */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/add") - ListenableFuture addLoadBalancer(@QueryParam(NAME_KEY) String name, - @BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp, - @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps, - AddLoadBalancerOptions... options); + /** + * @see GridLoadBalancerClient#addLoadBalancer + */ + @GET + @ResponseParser(ParseLoadBalancerFromJsonResponse.class) + @Path("/grid/loadbalancer/add") + ListenableFuture addLoadBalancer(@QueryParam(NAME_KEY) String name, + @BinderParam(BindVirtualIpPortPairToQueryParams.class) IpPortPair virtualIp, + @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps, + AddLoadBalancerOptions... options); - /** - * @see GridLoadBalancerClient#editLoadBalancer - */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/edit") - ListenableFuture editLoadBalancer(@QueryParam(LOAD_BALANCER_KEY) String idOrName, - @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps); + /** + * @see GridLoadBalancerClient#editLoadBalancerNamed + */ + @GET + @ResponseParser(ParseLoadBalancerFromJsonResponse.class) + @Path("/grid/loadbalancer/edit") + ListenableFuture editLoadBalancerNamed(@QueryParam(NAME_KEY) String name, + @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps); - /** + /** + * @see GridLoadBalancerClient#editLoadBalancer + */ + @GET + @ResponseParser(ParseLoadBalancerFromJsonResponse.class) + @Path("/grid/loadbalancer/edit") + ListenableFuture editLoadBalancer(@QueryParam(ID_KEY) long id, + @BinderParam(BindRealIpPortPairsToQueryParams.class) List realIps); + + /** * @see GridLoadBalancerClient# */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/delete") - ListenableFuture deleteById(@QueryParam(ID_KEY) Long id); + @GET + @ResponseParser(ParseLoadBalancerFromJsonResponse.class) + @Path("/grid/loadbalancer/delete") + ListenableFuture deleteById(@QueryParam(ID_KEY) Long id); - /** + /** * @see GridLoadBalancerClient# */ - @GET - @ResponseParser(ParseLoadBalancerFromJsonResponse.class) - @Path("/grid/loadbalancer/delete") - ListenableFuture deleteByName(@QueryParam(NAME_KEY) String name); + @GET + @ResponseParser(ParseLoadBalancerFromJsonResponse.class) + @Path("/grid/loadbalancer/delete") + ListenableFuture deleteByName(@QueryParam(NAME_KEY) String name); } diff --git a/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java b/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java index 4aeda5316a..9a5f817af8 100644 --- a/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java +++ b/gogrid/src/main/java/org/jclouds/gogrid/services/GridLoadBalancerClient.java @@ -18,101 +18,112 @@ */ package org.jclouds.gogrid.services; +import java.util.List; +import java.util.Set; +import java.util.concurrent.TimeUnit; + import org.jclouds.concurrent.Timeout; import org.jclouds.gogrid.domain.IpPortPair; import org.jclouds.gogrid.domain.LoadBalancer; import org.jclouds.gogrid.options.AddLoadBalancerOptions; -import java.util.List; -import java.util.Set; -import java.util.concurrent.TimeUnit; - /** * @author Oleksiy Yarmula */ @Timeout(duration = 30, timeUnit = TimeUnit.SECONDS) public interface GridLoadBalancerClient { - /** - * Returns all load balancers found for the current user. - * @return load balancers found - */ - Set getLoadBalancerList(); + /** + * Returns all load balancers found for the current user. + * + * @return load balancers found + */ + Set getLoadBalancerList(); - /** - * Returns the load balancer(s) by unique name(s). - * - * Given a name or a set of names, finds one or - * multiple load balancers. - * @param names to get the load balancers - * @return load balancer(s) matching the name(s) - */ - Set getLoadBalancersByName(String... names); + /** + * Returns the load balancer(s) by unique name(s). + * + * Given a name or a set of names, finds one or multiple load balancers. + * + * @param names + * to get the load balancers + * @return load balancer(s) matching the name(s) + */ + Set getLoadBalancersByName(String... names); - /** - * Returns the load balancer(s) by unique id(s). - * - * Given an id or a set of ids, finds one or - * multiple load balancers. - * @param ids to get the load balancers - * @return load balancer(s) matching the ids - */ - Set getLoadBalancersById(Long... ids); + /** + * Returns the load balancer(s) by unique id(s). + * + * Given an id or a set of ids, finds one or multiple load balancers. + * + * @param ids + * to get the load balancers + * @return load balancer(s) matching the ids + */ + Set getLoadBalancersById(Long... ids); - /** - * Creates a load balancer with given properties. - * - * @param name name of the load balancer - * @param virtualIp virtual IP with IP address set in - * {@link org.jclouds.gogrid.domain.Ip#ip} and - * port set in {@link IpPortPair#port} - * @param realIps real IPs to bind the virtual IP to, with - * IP address set in - * {@link org.jclouds.gogrid.domain.Ip#ip} and - * port set in {@link IpPortPair#port} - * @param options options that specify load balancer's type (round robin, - * least load), persistence strategy, or description. - * @return created load balancer object - */ - LoadBalancer addLoadBalancer(String name, - IpPortPair virtualIp, - List realIps, - AddLoadBalancerOptions... options); + /** + * Creates a load balancer with given properties. + * + * @param name + * name of the load balancer + * @param virtualIp + * virtual IP with IP address set in {@link org.jclouds.gogrid.domain.Ip#ip} and port + * set in {@link IpPortPair#port} + * @param realIps + * real IPs to bind the virtual IP to, with IP address set in + * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port} + * @param options + * options that specify load balancer's type (round robin, least load), persistence + * strategy, or description. + * @return created load balancer object + */ + LoadBalancer addLoadBalancer(String name, IpPortPair virtualIp, List realIps, + AddLoadBalancerOptions... options); - /** - * Edits the existing load balancer to change the real - * IP mapping. - * - * @param idOrName id or name of the existing load balancer - * @param realIps real IPs to bind the virtual IP to, with - * IP address set in - * {@link org.jclouds.gogrid.domain.Ip#ip} and - * port set in {@link IpPortPair#port} - * @return edited object - */ - LoadBalancer editLoadBalancer(String idOrName, - List realIps); + /** + * Edits the existing load balancer to change the real IP mapping. + * + * @param id + * id of the existing load balancer + * @param realIps + * real IPs to bind the virtual IP to, with IP address set in + * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port} + * @return edited object + */ + LoadBalancer editLoadBalancer(long id, List realIps); - /** - * Deletes the load balancer by Id - * - * @param id - * id of the load balancer to delete - * @return load balancer before the command is executed - */ - LoadBalancer deleteById(Long id); + /** + * Edits the existing load balancer to change the real IP mapping. + * + * @param name + * name of the existing load balancer + * @param realIps + * real IPs to bind the virtual IP to, with IP address set in + * {@link org.jclouds.gogrid.domain.Ip#ip} and port set in {@link IpPortPair#port} + * @return edited object + */ + LoadBalancer editLoadBalancerNamed(String name, List realIps); - /** - * Deletes the load balancer by name; - * - * NOTE: Using this parameter may generate an - * error if one or more load balancers share a - * non-unique name. - * - * @param name - * name of the load balancer to be deleted - * - * @return load balancer before the command is executed - */ - LoadBalancer deleteByName(String name); + /** + * Deletes the load balancer by Id + * + * @param id + * id of the load balancer to delete + * @return load balancer before the command is executed + */ + LoadBalancer deleteById(Long id); + + /** + * Deletes the load balancer by name; + * + * NOTE: Using this parameter may generate an error if one or more load balancers share a + * non-unique name. + * + * @param name + * name of the load balancer to be deleted + * + * @return load balancer before the command is executed + */ + LoadBalancer deleteByName(String name); } diff --git a/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTest.java b/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTest.java index df81237225..30d4f11408 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTest.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTest.java @@ -265,7 +265,7 @@ public class GoGridLiveTest { assertNotNull(createdLoadBalancer.getVirtualIp()); assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp()); - LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().editLoadBalancer( + LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().editLoadBalancerNamed( nameOfLoadBalancer, Arrays.asList(new IpPortPair(realIp3, 8181))); assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer); assertNotNull(editedLoadBalancer.getRealIpList()); diff --git a/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java b/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java index 966a11c5f1..053fcb636c 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/services/GridLoadBalancerAsyncClientTest.java @@ -46,7 +46,6 @@ import org.jclouds.logging.Logger; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.RestAnnotationProcessor; -import com.google.inject.name.Names; import org.testng.annotations.Test; import com.google.common.collect.Iterables; @@ -54,6 +53,7 @@ import com.google.inject.AbstractModule; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; /** * @author Oleksiy Yarmula @@ -123,14 +123,42 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest httpRequest = processor.createRequest( + method, 1l, Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080), new IpPortPair( + new Ip("127.0.0.1"), 9090))); + + assertRequestLineEquals( + httpRequest, + "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.4&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"); + assertHeadersEqual(httpRequest, ""); + assertPayloadEquals(httpRequest, null); + + assertResponseParserClassEquals(method, httpRequest, ParseLoadBalancerFromJsonResponse.class); + assertSaxResponseParserClassEquals(method, null); + assertExceptionParserClassEquals(method, null); + + checkFilters(httpRequest); + Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest); + + assertRequestLineEquals( + httpRequest, + "GET https://api.gogrid.com/api/grid/loadbalancer/edit?v=1.4&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=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1"); + assertHeadersEqual(httpRequest, ""); + assertPayloadEquals(httpRequest, null); + } + + @Test + public void testEditLoadBalancerNamed() throws NoSuchMethodException, IOException { + Method method = GridLoadBalancerAsyncClient.class.getMethod("editLoadBalancerNamed", + String.class, List.class); GeneratedHttpRequest httpRequest = processor.createRequest( method, "BalanceIt", Arrays.asList(new IpPortPair(new Ip("127.0.0.1"), 8080), new IpPortPair(new Ip("127.0.0.1"), 9090))); assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/loadbalancer/" - + "edit?v=1.4&loadbalancer=BalanceIt&realiplist.0.ip=127.0.0.1&" + + "edit?v=1.4&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"); assertHeadersEqual(httpRequest, ""); assertPayloadEquals(httpRequest, null); @@ -142,10 +170,9 @@ public class GridLoadBalancerAsyncClientTest extends RestClientTest instanceActive(InstanceActive instanceActive) { - return new RetryablePredicate(instanceActive, 600, 1, TimeUnit.SECONDS); + return new RetryablePredicate(instanceActive, 1200, 3, TimeUnit.SECONDS); } @Provides diff --git a/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTest.java b/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTest.java index 523f302ba3..701318eb72 100644 --- a/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTest.java +++ b/ibmdev/src/test/java/org/jclouds/ibmdev/compute/IBMDeveloperCloudComputeServiceLiveTest.java @@ -25,6 +25,8 @@ import org.jclouds.ibmdev.IBMDeveloperCloudClient; import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.Architecture; +import org.jclouds.compute.domain.ComputeMetadata; +import org.jclouds.compute.domain.ComputeType; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.rest.RestContext; @@ -52,6 +54,15 @@ public class IBMDeveloperCloudComputeServiceLiveTest extends BaseComputeServiceL assertEquals(defaultTemplate.getLocation().getId(), "1"); assertEquals(defaultTemplate.getSize().getCores(), 2.0d); } + + @Override + public void testListNodes() throws Exception { + for (ComputeMetadata node : client.listNodes()) { + assert node.getProviderId() != null; + // assert node.getLocation() != null; + assertEquals(node.getType(), ComputeType.NODE); + } + } @Override protected JschSshClientModule getSshModule() {