Issue 144: replace WithinThreadExecutorService with com.google.common.util.concurrent.Executors.sameThreadExecutor

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2616 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2010-01-06 22:21:24 +00:00
parent 21014b6c19
commit 6a5a4df606
46 changed files with 173 additions and 421 deletions

View File

@ -92,7 +92,7 @@ public class ${clientName}ContextModuleTest {
super.configure(); super.configure();
} }
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
new ExecutorServiceModule(new WithinThreadExecutorService())); new ExecutorServiceModule(Executors.sameThreadExecutor()));
} }
@Test @Test

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.atmosonline.saas.blobstore.config; package org.jclouds.atmosonline.saas.blobstore.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient; import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
@ -28,7 +29,6 @@ import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
@ -46,7 +46,7 @@ import com.google.inject.TypeLiteral;
public class AtmosBlobStoreModuleTest { public class AtmosBlobStoreModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new JDKLoggingModule(), new AtmosStorageStubClientModule(), new JDKLoggingModule(), new AtmosStorageStubClientModule(),
new AtmosBlobStoreContextModule() { new AtmosBlobStoreContextModule() {
@Override @Override

View File

@ -18,13 +18,13 @@
*/ */
package org.jclouds.atmosonline.saas.config; package org.jclouds.atmosonline.saas.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import org.jclouds.atmosonline.saas.handlers.AtmosStorageClientErrorRetryHandler; import org.jclouds.atmosonline.saas.handlers.AtmosStorageClientErrorRetryHandler;
import org.jclouds.atmosonline.saas.handlers.ParseAtmosStorageErrorFromXmlContent; import org.jclouds.atmosonline.saas.handlers.ParseAtmosStorageErrorFromXmlContent;
import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants; import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.encryption.internal.Base64; import org.jclouds.encryption.internal.Base64;
@ -48,7 +48,7 @@ public class AtmosStorageRestClientModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new AtmosStorageRestClientModule(), new ExecutorServiceModule( return Guice.createInjector(new AtmosStorageRestClientModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { sameThreadExecutor()), new ParserModule(), new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bindConstant().annotatedWith( bindConstant().annotatedWith(

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.atmosonline.saas.filters; package org.jclouds.atmosonline.saas.filters;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.IOException; import java.io.IOException;
@ -30,7 +31,6 @@ import javax.ws.rs.core.MediaType;
import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants; import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants;
import org.jclouds.atmosonline.saas.reference.AtmosStorageHeaders; import org.jclouds.atmosonline.saas.reference.AtmosStorageHeaders;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.date.TimeStamp; import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
@ -79,7 +79,7 @@ public class SignRequestTest {
@BeforeClass @BeforeClass
protected void createFilter() { protected void createFilter() {
injector = Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), injector = Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new AbstractModule() { new AbstractModule() {
protected void configure() { protected void configure() {

View File

@ -18,12 +18,12 @@
*/ */
package org.jclouds.aws.ec2.config; package org.jclouds.aws.ec2.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.aws.ec2.EC2AsyncClient; import org.jclouds.aws.ec2.EC2AsyncClient;
import org.jclouds.aws.ec2.EC2Client; import org.jclouds.aws.ec2.EC2Client;
import org.jclouds.aws.ec2.reference.EC2Constants; import org.jclouds.aws.ec2.reference.EC2Constants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
@ -45,7 +45,7 @@ import com.google.inject.TypeLiteral;
public class EC2ContextModuleTest { public class EC2ContextModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new EC2RestClientModule(), new RestModule(), new EC2RestClientModule(), new RestModule(),
new JavaUrlHttpCommandExecutorServiceModule(), new JDKLoggingModule(), new JavaUrlHttpCommandExecutorServiceModule(), new JDKLoggingModule(),
new EC2ContextModule() { new EC2ContextModule() {

View File

@ -18,13 +18,13 @@
*/ */
package org.jclouds.aws.ec2.config; package org.jclouds.aws.ec2.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.aws.ec2.reference.EC2Constants; import org.jclouds.aws.ec2.reference.EC2Constants;
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler; import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler; import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent; import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingErrorHandler;
@ -44,7 +44,7 @@ public class EC2RestClientModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new EC2RestClientModule(), new ExecutorServiceModule( return Guice.createInjector(new EC2RestClientModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { sameThreadExecutor()), new ParserModule(), new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_AWS_ACCESSKEYID)).to( bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_AWS_ACCESSKEYID)).to(

View File

@ -18,11 +18,11 @@
*/ */
package org.jclouds.aws.ec2.filters; package org.jclouds.aws.ec2.filters;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.aws.ec2.config.EC2RestClientModule; import org.jclouds.aws.ec2.config.EC2RestClientModule;
import org.jclouds.aws.ec2.reference.EC2Constants; import org.jclouds.aws.ec2.reference.EC2Constants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
@ -44,10 +44,10 @@ public class FormSignerTest {
void testBuildCanonicalizedString() { void testBuildCanonicalizedString() {
assertEquals( assertEquals(
filter.buildCanonicalizedString(new ImmutableMultimap.Builder<String, String>().put( filter.buildCanonicalizedString(new ImmutableMultimap.Builder<String, String>().put(
"AWSAccessKeyId", "foo").put( "Action","DescribeImages").put( "AWSAccessKeyId", "foo").put("Action", "DescribeImages").put("Expires",
"Expires","2008-02-10T12:00:00Z").put("ImageId.1", "ami-2bb65342").put( "2008-02-10T12:00:00Z").put("ImageId.1", "ami-2bb65342").put(
"SignatureMethod", "HmacSHA256").put("SignatureVersion", "2").put("Version", "SignatureMethod", "HmacSHA256").put("SignatureVersion", "2").put(
"2009-11-30").build()), "Version", "2009-11-30").build()),
"AWSAccessKeyId=foo&Action=DescribeImages&Expires=2008-02-10T12%3A00%3A00Z&ImageId.1=ami-2bb65342&SignatureMethod=HmacSHA256&SignatureVersion=2&Version=2009-11-30"); "AWSAccessKeyId=foo&Action=DescribeImages&Expires=2008-02-10T12%3A00%3A00Z&ImageId.1=ami-2bb65342&SignatureMethod=HmacSHA256&SignatureVersion=2&Version=2009-11-30");
} }
@ -58,7 +58,7 @@ public class FormSignerTest {
@BeforeClass @BeforeClass
protected void createFilter() { protected void createFilter() {
injector = Guice.createInjector(new EC2RestClientModule(), new ExecutorServiceModule( injector = Guice.createInjector(new EC2RestClientModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { sameThreadExecutor()), new ParserModule(), new AbstractModule() {
protected void configure() { protected void configure() {
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_AWS_ACCESSKEYID)).to( bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_AWS_ACCESSKEYID)).to(

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.aws.s3.blobstore.config; package org.jclouds.aws.s3.blobstore.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.aws.s3.S3AsyncClient; import org.jclouds.aws.s3.S3AsyncClient;
@ -26,7 +27,6 @@ import org.jclouds.aws.s3.config.S3StubClientModule;
import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.aws.s3.reference.S3Constants;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
@ -44,7 +44,7 @@ import com.google.inject.TypeLiteral;
public class S3BlobStoreModuleTest { public class S3BlobStoreModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new JDKLoggingModule(), new S3StubClientModule(), new S3BlobStoreContextModule() { new JDKLoggingModule(), new S3StubClientModule(), new S3BlobStoreContextModule() {
@Override @Override
protected void configure() { protected void configure() {

View File

@ -18,12 +18,12 @@
*/ */
package org.jclouds.aws.s3.config; package org.jclouds.aws.s3.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.aws.s3.S3AsyncClient; import org.jclouds.aws.s3.S3AsyncClient;
import org.jclouds.aws.s3.S3Client; import org.jclouds.aws.s3.S3Client;
import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.aws.s3.reference.S3Constants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
@ -43,7 +43,7 @@ import com.google.inject.TypeLiteral;
public class S3ContextModuleTest { public class S3ContextModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new S3StubClientModule(), new JDKLoggingModule(), new S3ContextModule() { new S3StubClientModule(), new JDKLoggingModule(), new S3ContextModule() {
@Override @Override
protected void configure() { protected void configure() {

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.aws.s3.config; package org.jclouds.aws.s3.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
@ -25,7 +26,6 @@ import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler; import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent; import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.aws.s3.reference.S3Constants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
@ -47,7 +47,7 @@ public class S3RestClientModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule( return Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { sameThreadExecutor()), new ParserModule(), new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to(

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.aws.s3.filters; package org.jclouds.aws.s3.filters;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.net.URI; import java.net.URI;
@ -27,7 +28,6 @@ import javax.ws.rs.core.HttpHeaders;
import org.jclouds.aws.s3.config.S3RestClientModule; import org.jclouds.aws.s3.config.S3RestClientModule;
import org.jclouds.aws.s3.reference.S3Constants; import org.jclouds.aws.s3.reference.S3Constants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
@ -137,7 +137,7 @@ public class RequestAuthorizeSignatureTest {
@BeforeClass @BeforeClass
protected void createFilter() { protected void createFilter() {
injector = Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule( injector = Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { sameThreadExecutor()), new ParserModule(), new AbstractModule() {
protected void configure() { protected void configure() {
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to(

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.azure.storage.blob; package org.jclouds.azure.storage.blob;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.jclouds.azure.storage.blob.options.CreateContainerOptions.Builder.withPublicAcl; import static org.jclouds.azure.storage.blob.options.CreateContainerOptions.Builder.withPublicAcl;
import static org.jclouds.azure.storage.options.ListOptions.Builder.maxResults; import static org.jclouds.azure.storage.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -42,7 +43,6 @@ import org.jclouds.azure.storage.options.ListOptions;
import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.blobstore.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.blobstore.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.blobstore.reference.BlobStoreConstants; import org.jclouds.blobstore.reference.BlobStoreConstants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.encryption.internal.Base64; import org.jclouds.encryption.internal.Base64;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -91,7 +91,9 @@ public class AzureBlobClientTest {
.singletonList("2009-07-17")); .singletonList("2009-07-17"));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testListContainersOptions() throws SecurityException, NoSuchMethodException { public void testListContainersOptions() throws SecurityException, NoSuchMethodException {
@ -112,7 +114,9 @@ public class AzureBlobClientTest {
.singletonList("2009-07-17")); .singletonList("2009-07-17"));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testCreateContainer() throws SecurityException, NoSuchMethodException { public void testCreateContainer() throws SecurityException, NoSuchMethodException {
@ -132,7 +136,8 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnTrueIfContainerAlreadyExists.class); ReturnTrueIfContainerAlreadyExists.class);
} }
@ -151,7 +156,8 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnVoidIf2xx.class); ReturnVoidIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnVoidOnNotFoundOr404.class); ReturnVoidOnNotFoundOr404.class);
} }
@ -176,7 +182,8 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnTrueIfContainerAlreadyExists.class); ReturnTrueIfContainerAlreadyExists.class);
} }
@ -197,7 +204,8 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnTrueIfContainerAlreadyExists.class); ReturnTrueIfContainerAlreadyExists.class);
} }
@ -216,7 +224,8 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnTrueOn404.class); ReturnTrueOn404.class);
} }
@ -240,7 +249,8 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnTrueIfContainerAlreadyExists.class); ReturnTrueIfContainerAlreadyExists.class);
} }
@ -259,7 +269,9 @@ public class AzureBlobClientTest {
.singletonList("2009-07-17")); .singletonList("2009-07-17"));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testListRootBlobs() throws SecurityException, NoSuchMethodException { public void testListRootBlobs() throws SecurityException, NoSuchMethodException {
@ -277,7 +289,9 @@ public class AzureBlobClientTest {
.singletonList("2009-07-17")); .singletonList("2009-07-17"));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testContainerProperties() throws SecurityException, NoSuchMethodException { public void testContainerProperties() throws SecurityException, NoSuchMethodException {
@ -294,7 +308,9 @@ public class AzureBlobClientTest {
.singletonList("2009-07-17")); .singletonList("2009-07-17"));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseContainerPropertiesFromHeaders.class); ParseContainerPropertiesFromHeaders.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testSetResourceMetadata() throws SecurityException, NoSuchMethodException { public void testSetResourceMetadata() throws SecurityException, NoSuchMethodException {
@ -316,7 +332,9 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnVoidIf2xx.class); ReturnVoidIf2xx.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testSetBlobMetadata() throws SecurityException, NoSuchMethodException { public void testSetBlobMetadata() throws SecurityException, NoSuchMethodException {
@ -337,7 +355,9 @@ public class AzureBlobClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnVoidIf2xx.class); ReturnVoidIf2xx.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
@BeforeClass @BeforeClass
@ -369,7 +389,7 @@ public class AzureBlobClientTest {
1l); 1l);
} }
}, new AzureStorageRestClientModule(), new RestModule(), new ExecutorServiceModule( }, new AzureStorageRestClientModule(), new RestModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule());
processor = injector.getInstance(Key processor = injector.getInstance(Key
.get(new TypeLiteral<RestAnnotationProcessor<AzureBlobAsyncClient>>() { .get(new TypeLiteral<RestAnnotationProcessor<AzureBlobAsyncClient>>() {
})); }));

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.azure.storage.blob.blobstore.config; package org.jclouds.azure.storage.blob.blobstore.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.azure.storage.blob.AzureBlobAsyncClient; import org.jclouds.azure.storage.blob.AzureBlobAsyncClient;
@ -29,7 +30,6 @@ import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy; import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.util.Jsr330; import org.jclouds.util.Jsr330;
@ -47,7 +47,7 @@ import com.google.inject.TypeLiteral;
public class AzureBlobStoreModuleTest { public class AzureBlobStoreModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new JDKLoggingModule(), new AzureBlobStubClientModule(), new JDKLoggingModule(), new AzureBlobStubClientModule(),
new AzureBlobStoreContextModule() { new AzureBlobStoreContextModule() {
@Override @Override

View File

@ -18,13 +18,13 @@
*/ */
package org.jclouds.azure.storage.blob.config; package org.jclouds.azure.storage.blob.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.azure.storage.blob.handlers.AzureBlobClientErrorRetryHandler; import org.jclouds.azure.storage.blob.handlers.AzureBlobClientErrorRetryHandler;
import org.jclouds.azure.storage.blob.reference.AzureBlobConstants; import org.jclouds.azure.storage.blob.reference.AzureBlobConstants;
import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent; import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent;
import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.encryption.internal.Base64; import org.jclouds.encryption.internal.Base64;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
@ -46,7 +46,7 @@ public class RestAzureBlobClientModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new AzureBlobRestClientModule(), new ExecutorServiceModule( return Guice.createInjector(new AzureBlobRestClientModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { sameThreadExecutor()), new ParserModule(), new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bindConstant().annotatedWith( bindConstant().annotatedWith(

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.azure.storage.config; package org.jclouds.azure.storage.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT; import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT;
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY; import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY;
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL; import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL;
@ -25,7 +26,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent; import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
@ -49,7 +49,7 @@ public class AzureStorageRestClientModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new AzureStorageRestClientModule(), new ExecutorServiceModule( return Guice.createInjector(new AzureStorageRestClientModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { sameThreadExecutor()), new ParserModule(), new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_ACCOUNT)).to("user"); bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_ACCOUNT)).to("user");

View File

@ -19,6 +19,7 @@
package org.jclouds.azure.storage.filters; package org.jclouds.azure.storage.filters;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.net.URI; import java.net.URI;
@ -31,7 +32,6 @@ import javax.ws.rs.Path;
import org.jclouds.azure.storage.AzureBlob; import org.jclouds.azure.storage.AzureBlob;
import org.jclouds.azure.storage.config.AzureStorageRestClientModule; import org.jclouds.azure.storage.config.AzureStorageRestClientModule;
import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -47,7 +47,6 @@ import org.testng.annotations.Test;
import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Guice; import com.google.inject.Guice;
import com.google.inject.Injector; import com.google.inject.Injector;
/** /**
* Tests behavior of {@code JaxrsAnnotationProcessor} * Tests behavior of {@code JaxrsAnnotationProcessor}
* *
@ -103,7 +102,7 @@ public class SharedKeyAuthenticationLiveTest {
} }
}, new AzureStorageRestClientModule(), new RestModule(), new Log4JLoggingModule(), }, new AzureStorageRestClientModule(), new RestModule(), new Log4JLoggingModule(),
new ExecutorServiceModule(new WithinThreadExecutorService()), new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule()); new JavaUrlHttpCommandExecutorServiceModule());
RestClientFactory factory = injector.getInstance(RestClientFactory.class); RestClientFactory factory = injector.getInstance(RestClientFactory.class);
client = factory.create(IntegrationTestClient.class); client = factory.create(IntegrationTestClient.class);

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.azure.storage.filters; package org.jclouds.azure.storage.filters;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL; import static org.jclouds.azure.storage.reference.AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -28,7 +29,6 @@ import javax.ws.rs.core.HttpHeaders;
import org.jclouds.azure.storage.config.AzureStorageRestClientModule; import org.jclouds.azure.storage.config.AzureStorageRestClientModule;
import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.encryption.internal.Base64; import org.jclouds.encryption.internal.Base64;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
@ -133,21 +133,18 @@ public class SharedKeyAuthenticationTest {
@BeforeClass @BeforeClass
protected void createFilter() { protected void createFilter() {
injector = Guice.createInjector(new ParserModule(), new ExecutorServiceModule( injector = Guice.createInjector(new ParserModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new AzureStorageRestClientModule(), sameThreadExecutor()), new AzureStorageRestClientModule(), new AbstractModule() {
new AbstractModule() {
protected void configure() { protected void configure() {
bindConstant().annotatedWith( bindConstant().annotatedWith(
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)) Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to(ACCOUNT);
.to(ACCOUNT); bindConstant().annotatedWith(
bindConstant().annotatedWith( Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)).to(KEY);
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)) bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to(
.to(KEY); "1");
bindConstant().annotatedWith( }
Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to("1");
}
}); });
filter = injector.getInstance(SharedKeyAuthentication.class); filter = injector.getInstance(SharedKeyAuthentication.class);
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.azure.storage.queue; package org.jclouds.azure.storage.queue;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.jclouds.azure.storage.options.CreateOptions.Builder.withMetadata; import static org.jclouds.azure.storage.options.CreateOptions.Builder.withMetadata;
import static org.jclouds.azure.storage.options.ListOptions.Builder.maxResults; import static org.jclouds.azure.storage.options.ListOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
@ -33,7 +34,6 @@ import org.jclouds.azure.storage.config.AzureStorageRestClientModule;
import org.jclouds.azure.storage.options.CreateOptions; import org.jclouds.azure.storage.options.CreateOptions;
import org.jclouds.azure.storage.options.ListOptions; import org.jclouds.azure.storage.options.ListOptions;
import org.jclouds.azure.storage.reference.AzureStorageConstants; import org.jclouds.azure.storage.reference.AzureStorageConstants;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.encryption.internal.Base64; import org.jclouds.encryption.internal.Base64;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -82,7 +82,9 @@ public class AzureQueueClientTest {
.singletonList("2009-07-17")); .singletonList("2009-07-17"));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testListQueuesOptions() throws SecurityException, NoSuchMethodException { public void testListQueuesOptions() throws SecurityException, NoSuchMethodException {
@ -102,7 +104,9 @@ public class AzureQueueClientTest {
.singletonList("2009-07-17")); .singletonList("2009-07-17"));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class); assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testCreateQueue() throws SecurityException, NoSuchMethodException { public void testCreateQueue() throws SecurityException, NoSuchMethodException {
@ -122,7 +126,9 @@ public class AzureQueueClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testDeleteQueue() throws SecurityException, NoSuchMethodException { public void testDeleteQueue() throws SecurityException, NoSuchMethodException {
@ -140,7 +146,9 @@ public class AzureQueueClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
public void testCreateQueueOptions() throws SecurityException, NoSuchMethodException { public void testCreateQueueOptions() throws SecurityException, NoSuchMethodException {
@ -161,7 +169,9 @@ public class AzureQueueClientTest {
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class); ReturnTrueIf2xx.class);
// TODO check generic type of response parser // TODO check generic type of response parser
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
@BeforeClass @BeforeClass
@ -186,7 +196,7 @@ public class AzureQueueClientTest {
1l); 1l);
} }
}, new AzureStorageRestClientModule(), new RestModule(), new ExecutorServiceModule( }, new AzureStorageRestClientModule(), new RestModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule());
processor = injector.getInstance(Key processor = injector.getInstance(Key
.get(new TypeLiteral<RestAnnotationProcessor<AzureQueueAsyncClient>>() { .get(new TypeLiteral<RestAnnotationProcessor<AzureQueueAsyncClient>>() {
})); }));

View File

@ -18,12 +18,13 @@
*/ */
package org.jclouds.concurrent; package org.jclouds.concurrent;
import static com.google.common.base.Preconditions.*; import static com.google.common.base.Preconditions.checkState;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
@ -36,7 +37,6 @@ import java.util.concurrent.TimeoutException;
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@SingleThreadCompatible
public class RunnableFutureTask<V> implements Future<V> { public class RunnableFutureTask<V> implements Future<V> {
private ExecutionException executionException; private ExecutionException executionException;
private InterruptedException interruptedException; private InterruptedException interruptedException;

View File

@ -1,37 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.concurrent;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* designates that the object does not attempt to spawn threads.
*
* @author Adrian Cole
*
*/
@Retention(RUNTIME)
@Target(TYPE)
public @interface SingleThreadCompatible {
}

View File

@ -1,37 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.concurrent;
import java.util.concurrent.Executor;
/**
* Executor that executes within the current thread. Useful in environments where starting threads
* is prohibited.
*
* @author Adrian Cole
*/
@SingleThreadCompatible
@SingleThreaded
public class WithinThreadExecutor implements Executor {
public void execute(Runnable command) {
command.run();
}
}

View File

@ -1,200 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.concurrent;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* ExecutorService that executes within the current thread. Useful in environments where starting
* threads is prohibited.
*
* @author Adrian Cole
*/
@SingleThreadCompatible
public class WithinThreadExecutorService extends WithinThreadExecutor implements ExecutorService {
private volatile boolean shutdown = false;
/**
* As all calls are blocking, this must alwoys return true;
*/
public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
checkState(!shutdown, "shutdown!");
return true;
}
/**
* {@inheritDoc}
*/
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
throws InterruptedException {
checkState(!shutdown, "shutdown!");
List<Future<T>> results = new ArrayList<Future<T>>(tasks.size());
for (Callable<T> task : tasks) {
checkNotNull(task, "task");
RunnableFutureTask<T> future = new RunnableFutureTask<T>(task);
future.run();
results.add(future);
}
return results;
}
/**
* {@inheritDoc}
*/
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout,
TimeUnit unit) throws InterruptedException {
checkState(!shutdown, "shutdown!");
List<Future<T>> results = new ArrayList<Future<T>>(tasks.size());
long timeUp = System.nanoTime() + unit.toNanos(timeout);
for (Callable<T> task : tasks) {
checkNotNull(task, "task");
RunnableFutureTask<T> future = new RunnableFutureTask<T>(task);
if (System.nanoTime() > timeUp)
future.cancel(false);
else
future.run();
results.add(future);
}
return results;
}
/**
* {@inheritDoc}
*/
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException,
ExecutionException {
checkState(!shutdown, "shutdown!");
checkArgument(tasks.size() > 0, "no tasks");
Exception exception = null;
for (Callable<T> task : tasks) {
checkNotNull(task, "task");
try {
return task.call();
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
exception = e;
}
}
throw new ExecutionException("no tasks completed successfully", exception);
}
/**
* {@inheritDoc}
*/
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
checkState(!shutdown, "shutdown!");
checkArgument(tasks.size() > 0, "no tasks");
long timeUp = System.nanoTime() + unit.toNanos(timeout);
Exception exception = null;
for (Callable<T> task : tasks) {
checkNotNull(task, "task");
try {
return task.call();
} catch (InterruptedException e) {
throw e;
} catch (Exception e) {
exception = e;
}
if (System.nanoTime() > timeUp)
throw new TimeoutException("Time up before we could run a task successfully");
}
throw new ExecutionException("no tasks completed successfully", exception);
}
/**
* {@inheritDoc}
*/
public boolean isShutdown() {
return shutdown;
}
/**
* {@inheritDoc}
*/
public boolean isTerminated() {
return shutdown;
}
/**
* {@inheritDoc}
*/
public void shutdown() {
shutdown = true;
}
/**
* {@inheritDoc}
* <p />
* As every call is sequential, it is impossible for there to be a list remaining.
*/
public List<Runnable> shutdownNow() {
shutdown = true;
return null;
}
/**
* {@inheritDoc}
* <p />
* This will invoke the callable on submit and block for completion.
*/
public <T> Future<T> submit(Callable<T> task) {
RunnableFutureTask<T> future = new RunnableFutureTask<T>(task);
future.run();
return future;
}
/**
* {@inheritDoc}
* <p />
* This will invoke the runnable on submit and block for completion.
*/
public Future<?> submit(Runnable task) {
RunnableFutureTask<Object> future = new RunnableFutureTask<Object>(Executors.callable(task,
null));
future.run();
return future;
}
/**
* {@inheritDoc}
* <p />
* This will invoke the runnable on submit and block for completion.
*/
public <T> Future<T> submit(Runnable task, T result) {
RunnableFutureTask<T> future = new RunnableFutureTask<T>(Executors.callable(task, result));
future.run();
return future;
}
}

View File

@ -19,16 +19,16 @@
package org.jclouds.rest; package org.jclouds.rest;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static java.util.concurrent.Executors.newCachedThreadPool;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.jclouds.concurrent.SingleThreaded; import org.jclouds.concurrent.SingleThreaded;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ConfiguresExecutorService; import org.jclouds.concurrent.config.ConfiguresExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
@ -169,9 +169,9 @@ public abstract class RestContextBuilder<A, S> {
return input.getClass().isAnnotationPresent(SingleThreaded.class); return input.getClass().isAnnotationPresent(SingleThreaded.class);
} }
})) { })) {
modules.add(new ExecutorServiceModule(new WithinThreadExecutorService())); modules.add(new ExecutorServiceModule(sameThreadExecutor()));
} else { } else {
modules.add(new ExecutorServiceModule(Executors.newCachedThreadPool())); modules.add(new ExecutorServiceModule(newCachedThreadPool()));
} }
} }
} }

View File

@ -30,6 +30,7 @@ import java.util.concurrent.TimeoutException;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.util.concurrent.Executors;
/** /**
* Tests behavior of FutureExceptionParser * Tests behavior of FutureExceptionParser
@ -38,7 +39,7 @@ import com.google.common.base.Function;
*/ */
@Test(groups = "unit", testName = "concurrent.FutureExceptionParserTest") @Test(groups = "unit", testName = "concurrent.FutureExceptionParserTest")
public class FutureExceptionParserTest { public class FutureExceptionParserTest {
ExecutorService executorService = new WithinThreadExecutorService(); ExecutorService executorService = Executors.sameThreadExecutor();
@Test @Test
public void testGet() throws InterruptedException, ExecutionException { public void testGet() throws InterruptedException, ExecutionException {

View File

@ -19,6 +19,8 @@
package org.jclouds.http.internal; package org.jclouds.http.internal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static java.util.concurrent.Executors.newCachedThreadPool;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -28,11 +30,9 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.encryption.EncryptionService; import org.jclouds.encryption.EncryptionService;
import org.jclouds.encryption.internal.JCEEncryptionService; import org.jclouds.encryption.internal.JCEEncryptionService;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
@ -62,7 +62,7 @@ public class WireLiveTest {
public Void call() throws Exception { public Void call() throws Exception {
HttpWire wire = setUp(); HttpWire wire = setUp();
InputStream in = wire.input(fromServer); InputStream in = wire.input(fromServer);
ByteArrayOutputStream out = new ByteArrayOutputStream();//TODO ByteArrayOutputStream out = new ByteArrayOutputStream();// TODO
ByteStreams.copy(in, out); ByteStreams.copy(in, out);
byte[] compare = encryptionService.md5(new ByteArrayInputStream(out.toByteArray())); byte[] compare = encryptionService.md5(new ByteArrayInputStream(out.toByteArray()));
Thread.sleep(100); Thread.sleep(100);
@ -125,7 +125,7 @@ public class WireLiveTest {
} }
public static HttpWire setUp() throws Exception { public static HttpWire setUp() throws Exception {
ExecutorService service = Executors.newCachedThreadPool(); ExecutorService service = newCachedThreadPool();
BufferLogger bufferLogger = new BufferLogger(); BufferLogger bufferLogger = new BufferLogger();
HttpWire wire = new HttpWire(service); HttpWire wire = new HttpWire(service);
wire.wireLog = (bufferLogger); wire.wireLog = (bufferLogger);
@ -133,7 +133,7 @@ public class WireLiveTest {
} }
public HttpWire setUpSynch() throws Exception { public HttpWire setUpSynch() throws Exception {
ExecutorService service = new WithinThreadExecutorService(); ExecutorService service = sameThreadExecutor();
BufferLogger bufferLogger = new BufferLogger(); BufferLogger bufferLogger = new BufferLogger();
HttpWire wire = new HttpWire(service); HttpWire wire = new HttpWire(service);
wire.wireLog = (bufferLogger); wire.wireLog = (bufferLogger);
@ -158,7 +158,7 @@ public class WireLiveTest {
URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl")); URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl"));
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
Callable<Void> callable = new ConnectionTester(connection.getInputStream()); Callable<Void> callable = new ConnectionTester(connection.getInputStream());
Future<Void> result = Executors.newCachedThreadPool().submit(callable); Future<Void> result = newCachedThreadPool().submit(callable);
result.get(30, TimeUnit.SECONDS); result.get(30, TimeUnit.SECONDS);
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.http.internal; package org.jclouds.http.internal;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -25,8 +26,6 @@ import java.io.InputStream;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.http.internal.HttpWire;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.util.Utils; import org.jclouds.util.Utils;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -98,7 +97,7 @@ public class WireTest {
} }
public HttpWire setUpSynch() throws Exception { public HttpWire setUpSynch() throws Exception {
ExecutorService service = new WithinThreadExecutorService(); ExecutorService service = sameThreadExecutor();
BufferLogger bufferLogger = new BufferLogger(); BufferLogger bufferLogger = new BufferLogger();
HttpWire wire = new HttpWire(service); HttpWire wire = new HttpWire(service);
wire.wireLog = (bufferLogger); wire.wireLog = (bufferLogger);

View File

@ -18,13 +18,13 @@
*/ */
package org.jclouds.rest; package org.jclouds.rest;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpUtils; import org.jclouds.http.HttpUtils;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -57,7 +57,7 @@ public abstract class RestClientTest<T> {
protected void setupFactory() { protected void setupFactory() {
injector = Guice.createInjector(createModule(), new RestModule(), new ExecutorServiceModule( injector = Guice.createInjector(createModule(), new RestModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule());
processor = injector.getInstance(Key.get(createTypeLiteral())); processor = injector.getInstance(Key.get(createTypeLiteral()));
} }
@ -82,10 +82,11 @@ public abstract class RestClientTest<T> {
protected void assertExceptionParserClassEquals(Method method, @Nullable Class<?> parserClass) { protected void assertExceptionParserClassEquals(Method method, @Nullable Class<?> parserClass) {
if (parserClass == null) if (parserClass == null)
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(
method).getClass(), ThrowResourceNotFoundOn404.class);
else else
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(
parserClass); method).getClass(), parserClass);
} }
protected void assertSaxResponseParserClassEquals(Method method, @Nullable Class<?> parserClass) { protected void assertSaxResponseParserClassEquals(Method method, @Nullable Class<?> parserClass) {

View File

@ -19,6 +19,7 @@
package org.jclouds.rest.internal; package org.jclouds.rest.internal;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
@ -56,7 +57,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.date.internal.SimpleDateFormatDateService;
@ -1664,7 +1664,7 @@ public class RestAnnotationProcessorTest {
} }
}); });
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), }, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule()); new JavaUrlHttpCommandExecutorServiceModule());
} }

View File

@ -18,12 +18,10 @@
*/ */
package org.jclouds.gae.config; package org.jclouds.gae.config;
import java.util.Arrays; import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import java.util.Properties;
import java.util.concurrent.ExecutorService; import java.util.Properties;
import org.jclouds.concurrent.SingleThreadCompatible;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.gae.GaeHttpCommandExecutorService; import org.jclouds.gae.GaeHttpCommandExecutorService;
import org.jclouds.http.HttpCommandExecutorService; import org.jclouds.http.HttpCommandExecutorService;
@ -46,8 +44,7 @@ public class GaeHttpCommandExecutorServiceModuleTest {
public void testConfigureBindsClient() { public void testConfigureBindsClient() {
final Properties properties = new Properties(); final Properties properties = new Properties();
Injector i = Guice.createInjector( Injector i = Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new ExecutorServiceModule(new WithinThreadExecutorService()),
new GaeHttpCommandExecutorServiceModule() { new GaeHttpCommandExecutorServiceModule() {
@Override @Override
protected void configure() { protected void configure() {
@ -62,8 +59,5 @@ public class GaeHttpCommandExecutorServiceModuleTest {
}); });
HttpCommandExecutorService client = i.getInstance(HttpCommandExecutorService.class); HttpCommandExecutorService client = i.getInstance(HttpCommandExecutorService.class);
assert client instanceof GaeHttpCommandExecutorService; assert client instanceof GaeHttpCommandExecutorService;
ExecutorService executorService = i.getInstance(ExecutorService.class);
assert executorService.getClass().isAnnotationPresent(SingleThreadCompatible.class) : Arrays
.asList(executorService.getClass().getAnnotations());
} }
} }

View File

@ -19,6 +19,7 @@
package org.jclouds.mezeo.pcs2; package org.jclouds.mezeo.pcs2;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -27,7 +28,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.encryption.EncryptionService; import org.jclouds.encryption.EncryptionService;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -101,7 +101,7 @@ public class PCSCloudLiveTest {
protected PCSCloud provideCloud(RestClientFactory factory) { protected PCSCloud provideCloud(RestClientFactory factory) {
return factory.create(PCSCloud.class); return factory.create(PCSCloud.class);
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), }, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule()); new JavaUrlHttpCommandExecutorServiceModule());
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.mezeo.pcs2; package org.jclouds.mezeo.pcs2;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@ -26,7 +27,6 @@ import java.net.URI;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.encryption.EncryptionService; import org.jclouds.encryption.EncryptionService;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -67,7 +67,9 @@ public class PCSCloudTest {
CloudXlinkHandler.class); CloudXlinkHandler.class);
assertEquals(httpMethod.getFilters().size(), 1); assertEquals(httpMethod.getFilters().size(), 1);
assertEquals(httpMethod.getFilters().get(0).getClass(), BasicAuthentication.class); assertEquals(httpMethod.getFilters().get(0).getClass(), BasicAuthentication.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class); assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
} }
private RestAnnotationProcessor<PCSCloud> processor; private RestAnnotationProcessor<PCSCloud> processor;
@ -94,7 +96,7 @@ public class PCSCloudTest {
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
return new BasicAuthentication("foo", "bar", encryptionService); return new BasicAuthentication("foo", "bar", encryptionService);
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), }, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule()); new JavaUrlHttpCommandExecutorServiceModule());
processor = injector.getInstance(Key processor = injector.getInstance(Key

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.mezeo.pcs2.config; package org.jclouds.mezeo.pcs2.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.functions.config.ParserModule;
@ -61,7 +61,7 @@ public class PCSContextModuleTest {
super.configure(); super.configure();
} }
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
new ExecutorServiceModule(new WithinThreadExecutorService())); new ExecutorServiceModule(sameThreadExecutor()));
} }
@Test @Test

View File

@ -110,7 +110,7 @@ public class AddMetadataAndReturnIdTest {
// @BeforeClass // @BeforeClass
// protected void createFilter() throws SecurityException, NoSuchMethodException { // protected void createFilter() throws SecurityException, NoSuchMethodException {
// Injector injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule( // Injector injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule(
// new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule(), // Executors.sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule(),
// new AbstractModule() { // new AbstractModule() {
// //
// protected void configure() { // protected void configure() {

View File

@ -19,6 +19,7 @@
package org.jclouds.nirvanix.sdn; package org.jclouds.nirvanix.sdn;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
@ -26,7 +27,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.logging.log4j.config.Log4JLoggingModule;
@ -77,7 +77,8 @@ public class SDNAuthenticationLiveTest {
protected SDNAuthentication provideCloud(RestClientFactory factory) { protected SDNAuthentication provideCloud(RestClientFactory factory) {
return factory.create(SDNAuthentication.class); return factory.create(SDNAuthentication.class);
} }
}, new RestModule(), new Log4JLoggingModule(), new ExecutorServiceModule( }, new RestModule(), new Log4JLoggingModule(),
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule()); new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule());
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.nirvanix.sdn; package org.jclouds.nirvanix.sdn;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -25,7 +26,6 @@ import java.net.URI;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -81,7 +81,7 @@ public class SDNAuthenticationTest {
} }
}); });
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), }, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule()); new JavaUrlHttpCommandExecutorServiceModule());
processor = injector.getInstance(Key processor = injector.getInstance(Key
.get(new TypeLiteral<RestAnnotationProcessor<SDNAuthentication>>() { .get(new TypeLiteral<RestAnnotationProcessor<SDNAuthentication>>() {

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.nirvanix.sdn.filters; package org.jclouds.nirvanix.sdn.filters;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -26,7 +27,6 @@ import java.net.URI;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.ext.RuntimeDelegate; import javax.ws.rs.ext.RuntimeDelegate;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.date.DateService; import org.jclouds.date.DateService;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
@ -101,7 +101,7 @@ public class AddSessionTokenToRequestTest {
@BeforeClass @BeforeClass
protected void createFilter() { protected void createFilter() {
injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule( injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule(), sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule(),
new AbstractModule() { new AbstractModule() {
protected void configure() { protected void configure() {

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.nirvanix.sdn.filters; package org.jclouds.nirvanix.sdn.filters;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.expect;
import static org.easymock.classextension.EasyMock.createMock; import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay; import static org.easymock.classextension.EasyMock.replay;
@ -29,7 +30,6 @@ import java.net.URI;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.ext.RuntimeDelegate; import javax.ws.rs.ext.RuntimeDelegate;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
@ -92,7 +92,7 @@ public class InsertUserContextIntoPathTest {
@BeforeClass @BeforeClass
protected void createFilter() throws SecurityException, NoSuchMethodException { protected void createFilter() throws SecurityException, NoSuchMethodException {
injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule( injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule(
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule(), sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule(),
new AbstractModule() { new AbstractModule() {
protected void configure() { protected void configure() {

View File

@ -19,6 +19,7 @@
package org.jclouds.rackspace; package org.jclouds.rackspace;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
@ -29,7 +30,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.Closer;
@ -131,7 +131,7 @@ public class RackspaceAuthenticationLiveTest {
public void addContextModule(List<Module> modules) { public void addContextModule(List<Module> modules) {
modules.add(new RackspaceAuthenticationContextModule()); modules.add(new RackspaceAuthenticationContextModule());
} }
}.withModules(new Log4JLoggingModule(), }.withModules(new Log4JLoggingModule(), new ExecutorServiceModule(sameThreadExecutor()))
new ExecutorServiceModule(new WithinThreadExecutorService())).buildContext(); .buildContext();
} }
} }

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.rackspace; package org.jclouds.rackspace;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -26,7 +27,6 @@ import java.util.Collections;
import javax.ws.rs.HttpMethod; import javax.ws.rs.HttpMethod;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -85,7 +85,7 @@ public class RackspaceAuthenticationTest {
} }
}); });
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), }, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule()); new JavaUrlHttpCommandExecutorServiceModule());
processor = injector.getInstance(Key processor = injector.getInstance(Key
.get(new TypeLiteral<RestAnnotationProcessor<RackspaceAuthentication>>() { .get(new TypeLiteral<RestAnnotationProcessor<RackspaceAuthentication>>() {

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.rackspace.cloudfiles; package org.jclouds.rackspace.cloudfiles;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rackspace.StubRackspaceAuthenticationModule; import org.jclouds.rackspace.StubRackspaceAuthenticationModule;
@ -44,7 +44,7 @@ import com.google.inject.TypeLiteral;
public class CloudFilesContextModuleTest { public class CloudFilesContextModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new CloudFilesStubClientModule(), new JDKLoggingModule(), new CloudFilesStubClientModule(), new JDKLoggingModule(),
new StubRackspaceAuthenticationModule(), new CloudFilesContextModule() { new StubRackspaceAuthenticationModule(), new CloudFilesContextModule() {
@Override @Override

View File

@ -18,11 +18,11 @@
*/ */
package org.jclouds.rackspace.cloudfiles.blobstore.config; package org.jclouds.rackspace.cloudfiles.blobstore.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BlobStoreContextImpl; import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rackspace.StubRackspaceAuthenticationModule; import org.jclouds.rackspace.StubRackspaceAuthenticationModule;
@ -45,7 +45,7 @@ import com.google.inject.TypeLiteral;
public class CloudFilesBlobStoreModuleTest { public class CloudFilesBlobStoreModuleTest {
Injector createInjector() { Injector createInjector() {
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
new JDKLoggingModule(), new CloudFilesStubClientModule(), new JDKLoggingModule(), new CloudFilesStubClientModule(),
new StubRackspaceAuthenticationModule(), new CloudFilesBlobStoreContextModule() { new StubRackspaceAuthenticationModule(), new CloudFilesBlobStoreContextModule() {
@Override @Override

View File

@ -18,6 +18,7 @@
*/ */
package org.jclouds.rackspace.cloudservers; package org.jclouds.rackspace.cloudservers;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.jclouds.rackspace.cloudservers.options.CreateServerOptions.Builder.withFile; import static org.jclouds.rackspace.cloudservers.options.CreateServerOptions.Builder.withFile;
import static org.jclouds.rackspace.cloudservers.options.CreateServerOptions.Builder.withMetadata; import static org.jclouds.rackspace.cloudservers.options.CreateServerOptions.Builder.withMetadata;
import static org.jclouds.rackspace.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup; import static org.jclouds.rackspace.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup;
@ -39,7 +40,6 @@ import javax.ws.rs.HttpMethod;
import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.http.functions.ReturnFalseOn404; import org.jclouds.http.functions.ReturnFalseOn404;
@ -1010,7 +1010,7 @@ public class CloudServersClientTest {
public String getAuthToken() { public String getAuthToken() {
return "testtoken"; return "testtoken";
} }
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()), }, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
new JavaUrlHttpCommandExecutorServiceModule()); new JavaUrlHttpCommandExecutorServiceModule());
processor = injector.getInstance(Key processor = injector.getInstance(Key
.get(new TypeLiteral<RestAnnotationProcessor<CloudServersAsyncClient>>() { .get(new TypeLiteral<RestAnnotationProcessor<CloudServersAsyncClient>>() {

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.rimuhosting.miro.config; package org.jclouds.rimuhosting.miro.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -65,7 +65,7 @@ public class RimuHostingContextModuleTest {
super.configure(); super.configure();
} }
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
new ExecutorServiceModule(new WithinThreadExecutorService())); new ExecutorServiceModule(sameThreadExecutor()));
} }
@Test @Test

View File

@ -18,9 +18,9 @@
*/ */
package org.jclouds.twitter.config; package org.jclouds.twitter.config;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
@ -64,7 +64,7 @@ public class TwitterContextModuleTest {
super.configure(); super.configure();
} }
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(), }, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
new ExecutorServiceModule(new WithinThreadExecutorService())); new ExecutorServiceModule(sameThreadExecutor()));
} }
@Test @Test

View File

@ -17,8 +17,8 @@
* ==================================================================== * ====================================================================
*/ */
package org.jclouds.vcloud; package org.jclouds.vcloud;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_KEY;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_SESSIONINTERVAL;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_USER;
@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Named; import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.encryption.EncryptionService; import org.jclouds.encryption.EncryptionService;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
@ -58,6 +57,7 @@ import com.google.inject.Module;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
/** /**
* Tests behavior of {@code VCloudLogin} * Tests behavior of {@code VCloudLogin}
* *
@ -130,7 +130,8 @@ public class VCloudLoginLiveTest {
@BeforeClass @BeforeClass
void setupFactory() { void setupFactory() {
final String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"), final String endpoint = checkNotNull(System.getProperty("jclouds.test.endpoint"),
"jclouds.test.endpoint")+"/v0.8/login"; "jclouds.test.endpoint")
+ "/v0.8/login";
final String account = checkNotNull(System.getProperty("jclouds.test.user"), final String account = checkNotNull(System.getProperty("jclouds.test.user"),
"jclouds.test.user"); "jclouds.test.user");
final String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); final String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
@ -156,7 +157,7 @@ public class VCloudLoginLiveTest {
modules.add(new VCloudLoginRestClientModule(endpoint)); modules.add(new VCloudLoginRestClientModule(endpoint));
} }
}.withModules(new Log4JLoggingModule(), }.withModules(new Log4JLoggingModule(), new ExecutorServiceModule(sameThreadExecutor()))
new ExecutorServiceModule(new WithinThreadExecutorService())).buildContext(); .buildContext();
} }
} }

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud; package org.jclouds.vcloud;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
@ -29,7 +30,6 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.concurrent.WithinThreadExecutorService;
import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.Closer;
@ -56,7 +56,7 @@ import com.google.inject.TypeLiteral;
*/ */
@Test(groups = "live", testName = "vcloud.VCloudVersionsLiveTest") @Test(groups = "live", testName = "vcloud.VCloudVersionsLiveTest")
public class VCloudVersionsLiveTest { public class VCloudVersionsLiveTest {
@RequiresHttp @RequiresHttp
@ConfiguresRestClient @ConfiguresRestClient
private static final class VCloudVersionsRestClientModule extends AbstractModule { private static final class VCloudVersionsRestClientModule extends AbstractModule {
@ -78,9 +78,10 @@ public class VCloudVersionsLiveTest {
@SuppressWarnings( { "unused" }) @SuppressWarnings( { "unused" })
@Provides @Provides
@Singleton @Singleton
RestContext<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient> provideContext(Closer closer, VCloudVersionsAsyncClient api, RestContext<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient> provideContext(
@VCloud URI endPoint) { Closer closer, VCloudVersionsAsyncClient api, @VCloud URI endPoint) {
return new RestContextImpl<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient>(closer, api, api, endPoint, ""); return new RestContextImpl<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient>(closer,
api, api, endPoint, "");
} }
@Override @Override
@ -122,7 +123,7 @@ public class VCloudVersionsLiveTest {
modules.add(new VCloudVersionsRestClientModule()); modules.add(new VCloudVersionsRestClientModule());
} }
}.withModules(new Log4JLoggingModule(), }.withModules(new Log4JLoggingModule(), new ExecutorServiceModule(sameThreadExecutor()))
new ExecutorServiceModule(new WithinThreadExecutorService())).buildContext(); .buildContext();
} }
} }