From 51e5e4c4bbb4409ff7e60b7140d147cd2e9166c6 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 7 May 2012 13:34:55 -0700 Subject: [PATCH] freshen ning --- sandbox-drivers/asynchttpclient/pom.xml | 2 +- .../ning/NingHttpCommandExecutorService.java | 18 +++++------------- .../NingHttpCommandExecutorServiceTest.java | 2 ++ 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/sandbox-drivers/asynchttpclient/pom.xml b/sandbox-drivers/asynchttpclient/pom.xml index ee0d487922..d4b7492d6c 100644 --- a/sandbox-drivers/asynchttpclient/pom.xml +++ b/sandbox-drivers/asynchttpclient/pom.xml @@ -60,7 +60,7 @@ com.ning async-http-client - 1.6.3 + 1.7.4 org.eclipse.jetty diff --git a/sandbox-drivers/asynchttpclient/src/main/java/org/jclouds/http/ning/NingHttpCommandExecutorService.java b/sandbox-drivers/asynchttpclient/src/main/java/org/jclouds/http/ning/NingHttpCommandExecutorService.java index ef2a647701..de50d577aa 100644 --- a/sandbox-drivers/asynchttpclient/src/main/java/org/jclouds/http/ning/NingHttpCommandExecutorService.java +++ b/sandbox-drivers/asynchttpclient/src/main/java/org/jclouds/http/ning/NingHttpCommandExecutorService.java @@ -31,6 +31,7 @@ import java.util.concurrent.Future; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; +import org.jclouds.JcloudsVersion; import org.jclouds.crypto.CryptoStreams; import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpCommandExecutorService; @@ -50,7 +51,6 @@ import com.google.common.base.Throwables; import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; import com.google.common.io.Closeables; -import com.google.common.util.concurrent.AbstractFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.inject.Inject; @@ -68,7 +68,8 @@ import com.ning.http.client.generators.InputStreamBodyGenerator; */ public class NingHttpCommandExecutorService implements HttpCommandExecutorService { - public static final String USER_AGENT = "jclouds/1.0 ning http/1.0.0"; + //TODO: get async version from maven or something + public static final String USER_AGENT = String.format("jclouds/%s async-http-client/%s", JcloudsVersion.get(), "1.7.4"); private final AsyncHttpClient client; private final ConvertToNingRequest convertToNingRequest; @@ -99,10 +100,10 @@ public class NingHttpCommandExecutorService implements HttpCommandExecutorServic continue; } else { errorHandler.handleError(command, httpResponse); - return wrapAsFuture(httpResponse); + return Futures.immediateFuture(httpResponse); } } else { - return wrapAsFuture(httpResponse); + return Futures.immediateFuture(httpResponse); } } @@ -115,15 +116,6 @@ public class NingHttpCommandExecutorService implements HttpCommandExecutorServic } } - private ListenableFuture wrapAsFuture(final HttpResponse httpResponse) { - return Futures.makeListenable(new AbstractFuture() { - @Override - public HttpResponse get() throws InterruptedException, ExecutionException { - return httpResponse; - } - }); - } - @Singleton public static class ConvertToNingRequest implements Function { diff --git a/sandbox-drivers/asynchttpclient/src/test/java/org/jclouds/http/ning/NingHttpCommandExecutorServiceTest.java b/sandbox-drivers/asynchttpclient/src/test/java/org/jclouds/http/ning/NingHttpCommandExecutorServiceTest.java index 64fca3328a..51d9be9ef6 100644 --- a/sandbox-drivers/asynchttpclient/src/test/java/org/jclouds/http/ning/NingHttpCommandExecutorServiceTest.java +++ b/sandbox-drivers/asynchttpclient/src/test/java/org/jclouds/http/ning/NingHttpCommandExecutorServiceTest.java @@ -29,6 +29,7 @@ import java.util.Properties; import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest; import org.jclouds.http.ning.config.NingHttpCommandExecutorServiceModule; +import org.testng.annotations.Test; import com.google.inject.Module; @@ -37,6 +38,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ +@Test(testName = "NingHttpCommandExecutorServiceTest") public class NingHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorServiceIntegrationTest { static { System.setProperty("http.conn-manager.timeout", 1000 + "");