From 3bd0be2c24bb61560a42307cca211deabe0ef80a Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 22 Oct 2011 22:34:45 +0200 Subject: [PATCH] backfilled tests for org.jclouds.rest.binders --- .../rest/binders/BindAsHostPrefix.java | 2 +- .../rest/binders/BindMapToMatrixParams.java | 12 +-- .../rest/binders/BindMapToStringPayload.java | 16 +++- .../org/jclouds/rest/BaseRestClientTest.java | 13 ++- .../BindAsHostPrefixIfConfiguredTest.java | 61 ++++++++++++ .../binders/BindMapToMatrixParamsTest.java | 17 +--- .../binders/BindMapToStringPayloadTest.java | 94 +++++++++++++++++++ .../rest/binders/BindToJsonPayloadTest.java | 71 ++++++++++++++ .../rest/binders/BindToStringPayloadTest.java | 66 +++++++++++++ .../internal/RestAnnotationProcessorTest.java | 9 +- 10 files changed, 326 insertions(+), 35 deletions(-) create mode 100644 core/src/test/java/org/jclouds/rest/binders/BindAsHostPrefixIfConfiguredTest.java create mode 100644 core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java create mode 100644 core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java create mode 100644 core/src/test/java/org/jclouds/rest/binders/BindToStringPayloadTest.java diff --git a/core/src/main/java/org/jclouds/rest/binders/BindAsHostPrefix.java b/core/src/main/java/org/jclouds/rest/binders/BindAsHostPrefix.java index 3a06daee15..b8a38e3793 100644 --- a/core/src/main/java/org/jclouds/rest/binders/BindAsHostPrefix.java +++ b/core/src/main/java/org/jclouds/rest/binders/BindAsHostPrefix.java @@ -44,7 +44,7 @@ public class BindAsHostPrefix implements Binder { @Inject public BindAsHostPrefix(Provider uriBuilderProvider) { - this.uriBuilderProvider = uriBuilderProvider; + this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider"); } @Override diff --git a/core/src/main/java/org/jclouds/rest/binders/BindMapToMatrixParams.java b/core/src/main/java/org/jclouds/rest/binders/BindMapToMatrixParams.java index f0edfad047..f242eb0259 100644 --- a/core/src/main/java/org/jclouds/rest/binders/BindMapToMatrixParams.java +++ b/core/src/main/java/org/jclouds/rest/binders/BindMapToMatrixParams.java @@ -20,6 +20,7 @@ package org.jclouds.rest.binders; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.http.utils.ModifyRequest.replaceMatrixParam; import java.util.Map; import java.util.Map.Entry; @@ -29,7 +30,6 @@ import javax.inject.Provider; import javax.ws.rs.core.UriBuilder; import org.jclouds.http.HttpRequest; -import org.jclouds.http.utils.ModifyRequest; import org.jclouds.rest.Binder; /** @@ -42,16 +42,16 @@ public class BindMapToMatrixParams implements Binder { @Inject BindMapToMatrixParams(Provider builder) { - this.builder = builder; + this.builder = checkNotNull(builder, "builder"); } - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") + @Override public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof Map, - "this binder is only valid for Maps!"); + checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Maps!"); Map map = (Map) input; for (Entry entry : map.entrySet()) { - request = ModifyRequest.replaceMatrixParam(request, entry.getKey(), entry.getValue(), builder.get()); + request = replaceMatrixParam(request, entry.getKey(), entry.getValue(), builder.get()); } return request; } diff --git a/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java b/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java index e3486d2947..4ce7bb6c65 100644 --- a/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java +++ b/core/src/main/java/org/jclouds/rest/binders/BindMapToStringPayload.java @@ -18,6 +18,10 @@ */ package org.jclouds.rest.binders; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.jclouds.io.Payloads.newStringPayload; + import java.net.URI; import java.util.Map; @@ -27,7 +31,6 @@ import javax.inject.Singleton; import javax.ws.rs.core.UriBuilder; import org.jclouds.http.HttpRequest; -import org.jclouds.io.Payloads; import org.jclouds.rest.MapBinder; import org.jclouds.rest.annotations.Payload; import org.jclouds.rest.internal.GeneratedHttpRequest; @@ -42,22 +45,25 @@ public class BindMapToStringPayload implements MapBinder { @Inject public BindMapToStringPayload(Provider uriBuilders) { - this.uriBuilders = uriBuilders; + this.uriBuilders = checkNotNull(uriBuilders, "uriBuilders"); } @SuppressWarnings("unchecked") @Override public R bindToRequest(R request, Map postParams) { - GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(request); + checkNotNull(postParams, "postParams"); + GeneratedHttpRequest r = GeneratedHttpRequest.class.cast(checkNotNull(request, "request")); + checkArgument(r.getJavaMethod().isAnnotationPresent(Payload.class), + "method %s must have @Payload annotation to use this binder", r.getJavaMethod()); String payload = r.getJavaMethod().getAnnotation(Payload.class).value(); if (postParams.size() > 0) { UriBuilder builder = uriBuilders.get(); - builder.uri(URI.create("http://test/")); + builder.uri(URI.create("http://fake/")); builder.path(payload); URI fake = builder.buildFromMap(postParams); payload = fake.getPath().substring(1); } - return (R) request.toBuilder().payload(Payloads.newStringPayload(payload)).build(); + return (R) request.toBuilder().payload(newStringPayload(payload)).build(); } @Override diff --git a/core/src/test/java/org/jclouds/rest/BaseRestClientTest.java b/core/src/test/java/org/jclouds/rest/BaseRestClientTest.java index f2a53bb0bf..b307a22108 100644 --- a/core/src/test/java/org/jclouds/rest/BaseRestClientTest.java +++ b/core/src/test/java/org/jclouds/rest/BaseRestClientTest.java @@ -19,9 +19,10 @@ package org.jclouds.rest; import static com.google.common.base.Throwables.propagate; +import static com.google.inject.util.Types.newParameterizedType; import static org.easymock.classextension.EasyMock.createMock; -import static org.jclouds.http.HttpUtils.sortAndConcatHeadersIntoString; import static org.eclipse.jetty.http.HttpHeaders.TRANSFER_ENCODING; +import static org.jclouds.http.HttpUtils.sortAndConcatHeadersIntoString; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; @@ -29,8 +30,6 @@ import java.io.IOException; import java.lang.reflect.Method; import java.util.concurrent.ExecutorService; -import org.jclouds.javax.annotation.Nullable; - import org.jclouds.Constants; import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.config.ConfiguresExecutorService; @@ -41,6 +40,7 @@ import org.jclouds.http.TransformingHttpCommandExecutorService; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.functions.ParseSax; import org.jclouds.io.MutableContentMetadata; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.util.Strings2; @@ -48,6 +48,7 @@ import org.testng.annotations.Test; import com.google.inject.AbstractModule; import com.google.inject.Injector; +import com.google.inject.Key; import com.google.inject.name.Names; /** @@ -157,4 +158,10 @@ public abstract class BaseRestClientTest { parserClass); } + @SuppressWarnings("unchecked") + protected RestAnnotationProcessor factory(Class clazz) { + return ((RestAnnotationProcessor) injector.getInstance(Key.get(newParameterizedType( + RestAnnotationProcessor.class, clazz)))); + } + } \ No newline at end of file diff --git a/core/src/test/java/org/jclouds/rest/binders/BindAsHostPrefixIfConfiguredTest.java b/core/src/test/java/org/jclouds/rest/binders/BindAsHostPrefixIfConfiguredTest.java new file mode 100644 index 0000000000..a9ec908102 --- /dev/null +++ b/core/src/test/java/org/jclouds/rest/binders/BindAsHostPrefixIfConfiguredTest.java @@ -0,0 +1,61 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.rest.binders; + +import static org.testng.Assert.assertEquals; + +import java.net.URI; + +import javax.ws.rs.core.UriBuilder; + +import org.jclouds.http.HttpRequest; +import org.testng.annotations.Test; + +import com.google.inject.util.Providers; +import com.sun.jersey.api.uri.UriBuilderImpl; + +/** + * Tests behavior of {@code BindAsHostPrefix} + * + * @author Adrian Cole + */ +// NOTE:without testName, this will not call @Before* and fail w/NPE during +// surefire +@Test(groups = "unit", testName = "BindAsHostPrefixTest") +public class BindAsHostPrefixIfConfiguredTest { + + public void testPrefixValid() { + + BindAsHostPrefix binder = new BindAsHostPrefix(Providers. of(new UriBuilderImpl())); + + HttpRequest request = binder.bindToRequest(new HttpRequest("GET", URI.create("https://s3.amazonaws.com")), + "bucket"); + assertEquals(request.getRequestLine(), "GET https://bucket.s3.amazonaws.com HTTP/1.1"); + + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testPrefixInvalidHostname() { + + BindAsHostPrefix binder = new BindAsHostPrefix(Providers. of(new UriBuilderImpl())); + + binder.bindToRequest(new HttpRequest("GET", URI.create("https://s3.amazonaws.com")), "b_ucket"); + + } +} diff --git a/core/src/test/java/org/jclouds/rest/binders/BindMapToMatrixParamsTest.java b/core/src/test/java/org/jclouds/rest/binders/BindMapToMatrixParamsTest.java index 0d4646cc9c..11688155cd 100644 --- a/core/src/test/java/org/jclouds/rest/binders/BindMapToMatrixParamsTest.java +++ b/core/src/test/java/org/jclouds/rest/binders/BindMapToMatrixParamsTest.java @@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals; import java.io.File; import java.net.URI; -import javax.inject.Provider; import javax.ws.rs.HttpMethod; import javax.ws.rs.core.UriBuilder; @@ -31,6 +30,7 @@ import org.jclouds.http.HttpRequest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; +import com.google.inject.util.Providers; import com.sun.jersey.api.uri.UriBuilderImpl; /** @@ -45,14 +45,7 @@ public class BindMapToMatrixParamsTest { public void testCorrect() throws SecurityException, NoSuchMethodException { HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(); - BindMapToMatrixParams binder = new BindMapToMatrixParams(new Provider() { - - @Override - public UriBuilder get() { - return new UriBuilderImpl(); - } - - }); + BindMapToMatrixParams binder = new BindMapToMatrixParams(Providers. of(new UriBuilderImpl())); assertEquals(binder.bindToRequest(request, ImmutableMap.of("imageName", "foo", "serverId", "2")), HttpRequest .builder().method("GET").endpoint(URI.create("http://momma/;imageName=foo;serverId=2")).build()); @@ -61,14 +54,14 @@ public class BindMapToMatrixParamsTest { @Test(expectedExceptions = IllegalArgumentException.class) public void testMustBeMap() { - BindMapToMatrixParams binder = new BindMapToMatrixParams(null); + BindMapToMatrixParams binder = new BindMapToMatrixParams(Providers. of(new UriBuilderImpl())); HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost")); binder.bindToRequest(request, new File("foo")); } - @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class }) + @Test(expectedExceptions = NullPointerException.class) public void testNullIsBad() { - BindMapToMatrixParams binder = new BindMapToMatrixParams(null); + BindMapToMatrixParams binder = new BindMapToMatrixParams(Providers. of(new UriBuilderImpl())); HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(); binder.bindToRequest(request, null); } diff --git a/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java new file mode 100644 index 0000000000..ae64498c48 --- /dev/null +++ b/core/src/test/java/org/jclouds/rest/binders/BindMapToStringPayloadTest.java @@ -0,0 +1,94 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.rest.binders; + +import static org.testng.Assert.assertEquals; + +import java.io.File; +import java.lang.reflect.Method; +import java.net.URI; + +import javax.ws.rs.HttpMethod; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.UriBuilder; + +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.ImmutableMap; +import com.google.inject.util.Providers; +import com.sun.jersey.api.uri.UriBuilderImpl; + +/** + * Tests behavior of {@code BindMapToStringPayload} + * + * @author Adrian Cole + */ +@Test(groups = "unit") +public class BindMapToStringPayloadTest { + static interface TestPayload { + @org.jclouds.rest.annotations.Payload("name {fooble}") + void testPayload(@PathParam("foo") String path); + + void noPayload(String path); + } + + @Test + public void testCorrect() throws SecurityException, NoSuchMethodException { + Method testPayload = TestPayload.class.getMethod("testPayload", String.class); + GeneratedHttpRequest request = GeneratedHttpRequest. builder() + .declaring(TestPayload.class).javaMethod(testPayload).args(ImmutableList. of("robot")) + .method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build(); + + GeneratedHttpRequest newRequest = binder() + .bindToRequest(request, ImmutableMap.of("fooble", "robot")); + + assertEquals(newRequest.getRequestLine(), request.getRequestLine()); + assertEquals(newRequest.getPayload().getRawContent(), "name robot"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMustHavePayloadAnnotation() throws SecurityException, NoSuchMethodException { + Method noPayload = TestPayload.class.getMethod("noPayload", String.class); + GeneratedHttpRequest request = GeneratedHttpRequest. builder() + .declaring(TestPayload.class).javaMethod(noPayload).args(ImmutableList. of("robot")) + .method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build(); + binder().bindToRequest(request, ImmutableMap.of("fooble", "robot")); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMustBeMap() { + BindMapToStringPayload binder = binder(); + HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost")); + binder.bindToRequest(request, new File("foo")); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullIsBad() { + BindMapToStringPayload binder = binder(); + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(); + binder.bindToRequest(request, null); + } + + public BindMapToStringPayload binder() { + return new BindMapToStringPayload(Providers. of(new UriBuilderImpl())); + } +} diff --git a/core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java b/core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java new file mode 100644 index 0000000000..8d8e38df1f --- /dev/null +++ b/core/src/test/java/org/jclouds/rest/binders/BindToJsonPayloadTest.java @@ -0,0 +1,71 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.rest.binders; + +import static org.testng.Assert.assertEquals; + +import java.io.File; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.jclouds.json.Json; +import org.jclouds.json.internal.GsonWrapper; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; +import com.google.gson.Gson; + +/** + * Tests behavior of {@code BindToJsonPayload} + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BindToJsonPayloadTest") +public class BindToJsonPayloadTest { + + Json json = new GsonWrapper(new Gson()); + + @Test + public void testMap() throws SecurityException, NoSuchMethodException { + BindToJsonPayload binder = new BindToJsonPayload(json); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(); + request = binder.bindToRequest(request, ImmutableMap.of("imageName", "foo", "serverId", "2")); + assertEquals(request.getPayload().getRawContent(), "{\"imageName\":\"foo\",\"serverId\":\"2\"}"); + assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json"); + + } + + @Test + public void testSomethingNotAMap() throws SecurityException, NoSuchMethodException { + BindToJsonPayload binder = new BindToJsonPayload(json); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(); + request = binder.bindToRequest(request, new File("foo")); + assertEquals(request.getPayload().getRawContent(), "{\"path\":\"foo\"}"); + assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json"); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullIsBad() { + BindToJsonPayload binder = new BindToJsonPayload(json); + binder.bindToRequest(HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(), null); + } +} diff --git a/core/src/test/java/org/jclouds/rest/binders/BindToStringPayloadTest.java b/core/src/test/java/org/jclouds/rest/binders/BindToStringPayloadTest.java new file mode 100644 index 0000000000..f4eef07bed --- /dev/null +++ b/core/src/test/java/org/jclouds/rest/binders/BindToStringPayloadTest.java @@ -0,0 +1,66 @@ +/** + * Licensed to jclouds, Inc. (jclouds) under one or more + * contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. jclouds 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.rest.binders; + +import static org.testng.Assert.assertEquals; + +import java.io.File; +import java.net.URI; + +import org.jclouds.http.HttpRequest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableMap; + +/** + * Tests behavior of {@code BindToStringPayload} + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BindToStringPayloadTest") +public class BindToStringPayloadTest { + + @Test + public void testMap() throws SecurityException, NoSuchMethodException { + BindToStringPayload binder = new BindToStringPayload(); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(); + request = binder.bindToRequest(request, ImmutableMap.of("imageName", "foo", "serverId", "2")); + assertEquals(request.getPayload().getRawContent(), "{imageName=foo, serverId=2}"); + assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/unknown"); + + } + + @Test + public void testSomethingNotAMap() throws SecurityException, NoSuchMethodException { + BindToStringPayload binder = new BindToStringPayload(); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(); + request = binder.bindToRequest(request, new File("foo")); + assertEquals(request.getPayload().getRawContent(), "foo"); + assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/unknown"); + + } + + @Test(expectedExceptions = NullPointerException.class) + public void testNullIsBad() { + BindToStringPayload binder = new BindToStringPayload(); + binder.bindToRequest(HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build(), null); + } +} diff --git a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java index ced959e11b..c1a19b59e9 100644 --- a/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java +++ b/core/src/test/java/org/jclouds/rest/internal/RestAnnotationProcessorTest.java @@ -20,7 +20,6 @@ package org.jclouds.rest.internal; import static com.google.common.base.Charsets.UTF_8; import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.inject.util.Types.newParameterizedType; import static org.easymock.EasyMock.eq; import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.reportMatcher; @@ -55,7 +54,6 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import org.jclouds.javax.annotation.Nullable; import javax.inject.Named; import javax.inject.Provider; import javax.inject.Qualifier; @@ -108,6 +106,7 @@ import org.jclouds.http.options.HttpRequestOptions; import org.jclouds.io.Payload; import org.jclouds.io.PayloadEnclosing; import org.jclouds.io.Payloads; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.rest.AsyncClientFactory; import org.jclouds.rest.AuthorizationException; @@ -161,7 +160,6 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.AbstractModule; import com.google.inject.ConfigurationException; import com.google.inject.Injector; -import com.google.inject.Key; import com.google.inject.Module; import com.google.inject.Provides; import com.google.inject.TypeLiteral; @@ -2457,11 +2455,6 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest { assertEquals(form, "x-amz-copy-source=/eggs/robot"); } - @SuppressWarnings("unchecked") - private RestAnnotationProcessor factory(Class clazz) { - return ((RestAnnotationProcessor) injector.getInstance(Key.get(newParameterizedType( - RestAnnotationProcessor.class, clazz)))); - } DateService dateService = new SimpleDateFormatDateService();