freshen ning

This commit is contained in:
Adrian Cole 2012-05-07 13:34:55 -07:00
parent d99c18140e
commit 51e5e4c4bb
3 changed files with 8 additions and 14 deletions

View File

@ -60,7 +60,7 @@
<dependency> <dependency>
<groupId>com.ning</groupId> <groupId>com.ning</groupId>
<artifactId>async-http-client</artifactId> <artifactId>async-http-client</artifactId>
<version>1.6.3</version> <version>1.7.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jetty</groupId> <groupId>org.eclipse.jetty</groupId>

View File

@ -31,6 +31,7 @@ import java.util.concurrent.Future;
import javax.inject.Singleton; import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import org.jclouds.JcloudsVersion;
import org.jclouds.crypto.CryptoStreams; import org.jclouds.crypto.CryptoStreams;
import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpCommandExecutorService; 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.LinkedHashMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.google.common.io.Closeables; 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.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -68,7 +68,8 @@ import com.ning.http.client.generators.InputStreamBodyGenerator;
*/ */
public class NingHttpCommandExecutorService implements HttpCommandExecutorService { 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 AsyncHttpClient client;
private final ConvertToNingRequest convertToNingRequest; private final ConvertToNingRequest convertToNingRequest;
@ -99,10 +100,10 @@ public class NingHttpCommandExecutorService implements HttpCommandExecutorServic
continue; continue;
} else { } else {
errorHandler.handleError(command, httpResponse); errorHandler.handleError(command, httpResponse);
return wrapAsFuture(httpResponse); return Futures.immediateFuture(httpResponse);
} }
} else { } else {
return wrapAsFuture(httpResponse); return Futures.immediateFuture(httpResponse);
} }
} }
@ -115,15 +116,6 @@ public class NingHttpCommandExecutorService implements HttpCommandExecutorServic
} }
} }
private ListenableFuture<HttpResponse> wrapAsFuture(final HttpResponse httpResponse) {
return Futures.makeListenable(new AbstractFuture<HttpResponse>() {
@Override
public HttpResponse get() throws InterruptedException, ExecutionException {
return httpResponse;
}
});
}
@Singleton @Singleton
public static class ConvertToNingRequest implements Function<HttpRequest, Request> { public static class ConvertToNingRequest implements Function<HttpRequest, Request> {

View File

@ -29,6 +29,7 @@ import java.util.Properties;
import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest; import org.jclouds.http.BaseHttpCommandExecutorServiceIntegrationTest;
import org.jclouds.http.ning.config.NingHttpCommandExecutorServiceModule; import org.jclouds.http.ning.config.NingHttpCommandExecutorServiceModule;
import org.testng.annotations.Test;
import com.google.inject.Module; import com.google.inject.Module;
@ -37,6 +38,7 @@ import com.google.inject.Module;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(testName = "NingHttpCommandExecutorServiceTest")
public class NingHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorServiceIntegrationTest { public class NingHttpCommandExecutorServiceTest extends BaseHttpCommandExecutorServiceIntegrationTest {
static { static {
System.setProperty("http.conn-manager.timeout", 1000 + ""); System.setProperty("http.conn-manager.timeout", 1000 + "");