mirror of https://github.com/apache/jclouds.git
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:
parent
21014b6c19
commit
6a5a4df606
|
@ -92,7 +92,7 @@ public class ${clientName}ContextModuleTest {
|
|||
super.configure();
|
||||
}
|
||||
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService()));
|
||||
new ExecutorServiceModule(Executors.sameThreadExecutor()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.atmosonline.saas.blobstore.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
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.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.util.Jsr330;
|
||||
|
@ -46,7 +46,7 @@ import com.google.inject.TypeLiteral;
|
|||
public class AtmosBlobStoreModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JDKLoggingModule(), new AtmosStorageStubClientModule(),
|
||||
new AtmosBlobStoreContextModule() {
|
||||
@Override
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
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.assertFalse;
|
||||
|
||||
import org.jclouds.atmosonline.saas.handlers.AtmosStorageClientErrorRetryHandler;
|
||||
import org.jclouds.atmosonline.saas.handlers.ParseAtmosStorageErrorFromXmlContent;
|
||||
import org.jclouds.atmosonline.saas.reference.AtmosStorageConstants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.encryption.internal.Base64;
|
||||
|
@ -48,7 +48,7 @@ public class AtmosStorageRestClientModuleTest {
|
|||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new AtmosStorageRestClientModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() {
|
||||
sameThreadExecutor()), new ParserModule(), new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.atmosonline.saas.filters;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
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.AtmosStorageHeaders;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.date.TimeStamp;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -79,7 +79,7 @@ public class SignRequestTest {
|
|||
|
||||
@BeforeClass
|
||||
protected void createFilter() {
|
||||
injector = Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
injector = Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new AbstractModule() {
|
||||
|
||||
protected void configure() {
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.aws.ec2.EC2AsyncClient;
|
||||
import org.jclouds.aws.ec2.EC2Client;
|
||||
import org.jclouds.aws.ec2.reference.EC2Constants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
|
@ -45,7 +45,7 @@ import com.google.inject.TypeLiteral;
|
|||
public class EC2ContextModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new EC2RestClientModule(), new RestModule(),
|
||||
new JavaUrlHttpCommandExecutorServiceModule(), new JDKLoggingModule(),
|
||||
new EC2ContextModule() {
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.aws.ec2.reference.EC2Constants;
|
||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
||||
|
@ -44,7 +44,7 @@ public class EC2RestClientModuleTest {
|
|||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new EC2RestClientModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() {
|
||||
sameThreadExecutor()), new ParserModule(), new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.aws.ec2.filters;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.aws.ec2.config.EC2RestClientModule;
|
||||
import org.jclouds.aws.ec2.reference.EC2Constants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.jclouds.util.Jsr330;
|
||||
|
@ -44,10 +44,10 @@ public class FormSignerTest {
|
|||
void testBuildCanonicalizedString() {
|
||||
assertEquals(
|
||||
filter.buildCanonicalizedString(new ImmutableMultimap.Builder<String, String>().put(
|
||||
"AWSAccessKeyId", "foo").put( "Action","DescribeImages").put(
|
||||
"Expires","2008-02-10T12:00:00Z").put("ImageId.1", "ami-2bb65342").put(
|
||||
"SignatureMethod", "HmacSHA256").put("SignatureVersion", "2").put("Version",
|
||||
"2009-11-30").build()),
|
||||
"AWSAccessKeyId", "foo").put("Action", "DescribeImages").put("Expires",
|
||||
"2008-02-10T12:00:00Z").put("ImageId.1", "ami-2bb65342").put(
|
||||
"SignatureMethod", "HmacSHA256").put("SignatureVersion", "2").put(
|
||||
"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");
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class FormSignerTest {
|
|||
@BeforeClass
|
||||
protected void createFilter() {
|
||||
injector = Guice.createInjector(new EC2RestClientModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() {
|
||||
sameThreadExecutor()), new ParserModule(), new AbstractModule() {
|
||||
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(Jsr330.named(EC2Constants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.aws.s3.blobstore.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
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.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.util.Jsr330;
|
||||
|
@ -44,7 +44,7 @@ import com.google.inject.TypeLiteral;
|
|||
public class S3BlobStoreModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JDKLoggingModule(), new S3StubClientModule(), new S3BlobStoreContextModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.aws.s3.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.aws.s3.S3AsyncClient;
|
||||
import org.jclouds.aws.s3.S3Client;
|
||||
import org.jclouds.aws.s3.reference.S3Constants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
|
@ -43,7 +43,7 @@ import com.google.inject.TypeLiteral;
|
|||
public class S3ContextModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new S3StubClientModule(), new JDKLoggingModule(), new S3ContextModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
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.assertFalse;
|
||||
|
||||
|
@ -25,7 +26,6 @@ import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
|||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.aws.handlers.ParseAWSErrorFromXmlContent;
|
||||
import org.jclouds.aws.s3.reference.S3Constants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
|
@ -47,7 +47,7 @@ public class S3RestClientModuleTest {
|
|||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() {
|
||||
sameThreadExecutor()), new ParserModule(), new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.aws.s3.filters;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
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.reference.S3Constants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
|
@ -137,7 +137,7 @@ public class RequestAuthorizeSignatureTest {
|
|||
@BeforeClass
|
||||
protected void createFilter() {
|
||||
injector = Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() {
|
||||
sameThreadExecutor()), new ParserModule(), new AbstractModule() {
|
||||
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to(
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
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.options.ListOptions.Builder.maxResults;
|
||||
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.blobstore.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.blobstore.reference.BlobStoreConstants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.encryption.internal.Base64;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -91,7 +91,9 @@ public class AzureBlobClientTest {
|
|||
.singletonList("2009-07-17"));
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
|
||||
// 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 {
|
||||
|
@ -112,7 +114,9 @@ public class AzureBlobClientTest {
|
|||
.singletonList("2009-07-17"));
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
|
||||
// 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 {
|
||||
|
@ -132,7 +136,8 @@ public class AzureBlobClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// TODO check generic type of response parser
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ReturnTrueIfContainerAlreadyExists.class);
|
||||
}
|
||||
|
||||
|
@ -151,7 +156,8 @@ public class AzureBlobClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnVoidIf2xx.class);
|
||||
// TODO check generic type of response parser
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ReturnVoidOnNotFoundOr404.class);
|
||||
}
|
||||
|
||||
|
@ -176,7 +182,8 @@ public class AzureBlobClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// TODO check generic type of response parser
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ReturnTrueIfContainerAlreadyExists.class);
|
||||
}
|
||||
|
||||
|
@ -197,7 +204,8 @@ public class AzureBlobClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// TODO check generic type of response parser
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ReturnTrueIfContainerAlreadyExists.class);
|
||||
}
|
||||
|
||||
|
@ -216,7 +224,8 @@ public class AzureBlobClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// TODO check generic type of response parser
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ReturnTrueOn404.class);
|
||||
}
|
||||
|
||||
|
@ -240,7 +249,8 @@ public class AzureBlobClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// TODO check generic type of response parser
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ReturnTrueIfContainerAlreadyExists.class);
|
||||
}
|
||||
|
||||
|
@ -259,7 +269,9 @@ public class AzureBlobClientTest {
|
|||
.singletonList("2009-07-17"));
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
|
||||
// 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 {
|
||||
|
@ -277,7 +289,9 @@ public class AzureBlobClientTest {
|
|||
.singletonList("2009-07-17"));
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
|
||||
// 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 {
|
||||
|
@ -294,7 +308,9 @@ public class AzureBlobClientTest {
|
|||
.singletonList("2009-07-17"));
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ParseContainerPropertiesFromHeaders.class);
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ThrowResourceNotFoundOn404.class);
|
||||
}
|
||||
|
||||
public void testSetResourceMetadata() throws SecurityException, NoSuchMethodException {
|
||||
|
@ -316,7 +332,9 @@ public class AzureBlobClientTest {
|
|||
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnVoidIf2xx.class);
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ThrowResourceNotFoundOn404.class);
|
||||
}
|
||||
|
||||
public void testSetBlobMetadata() throws SecurityException, NoSuchMethodException {
|
||||
|
@ -337,7 +355,9 @@ public class AzureBlobClientTest {
|
|||
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnVoidIf2xx.class);
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ThrowResourceNotFoundOn404.class);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -369,7 +389,7 @@ public class AzureBlobClientTest {
|
|||
1l);
|
||||
}
|
||||
}, new AzureStorageRestClientModule(), new RestModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule());
|
||||
sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule());
|
||||
processor = injector.getInstance(Key
|
||||
.get(new TypeLiteral<RestAnnotationProcessor<AzureBlobAsyncClient>>() {
|
||||
}));
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.azure.storage.blob.blobstore.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
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.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.util.Jsr330;
|
||||
|
@ -47,7 +47,7 @@ import com.google.inject.TypeLiteral;
|
|||
public class AzureBlobStoreModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JDKLoggingModule(), new AzureBlobStubClientModule(),
|
||||
new AzureBlobStoreContextModule() {
|
||||
@Override
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.azure.storage.blob.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.azure.storage.blob.handlers.AzureBlobClientErrorRetryHandler;
|
||||
import org.jclouds.azure.storage.blob.reference.AzureBlobConstants;
|
||||
import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent;
|
||||
import org.jclouds.azure.storage.reference.AzureStorageConstants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.encryption.internal.Base64;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
|
@ -46,7 +46,7 @@ public class RestAzureBlobClientModuleTest {
|
|||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new AzureBlobRestClientModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() {
|
||||
sameThreadExecutor()), new ParserModule(), new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
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_KEY;
|
||||
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 org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
|
@ -49,7 +49,7 @@ public class AzureStorageRestClientModuleTest {
|
|||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new AzureStorageRestClientModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() {
|
||||
sameThreadExecutor()), new ParserModule(), new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_ACCOUNT)).to("user");
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.azure.storage.filters;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -31,7 +32,6 @@ import javax.ws.rs.Path;
|
|||
import org.jclouds.azure.storage.AzureBlob;
|
||||
import org.jclouds.azure.storage.config.AzureStorageRestClientModule;
|
||||
import org.jclouds.azure.storage.reference.AzureStorageConstants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
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.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code JaxrsAnnotationProcessor}
|
||||
*
|
||||
|
@ -103,7 +102,7 @@ public class SharedKeyAuthenticationLiveTest {
|
|||
}
|
||||
|
||||
}, new AzureStorageRestClientModule(), new RestModule(), new Log4JLoggingModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JavaUrlHttpCommandExecutorServiceModule());
|
||||
RestClientFactory factory = injector.getInstance(RestClientFactory.class);
|
||||
client = factory.create(IntegrationTestClient.class);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
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.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.reference.AzureStorageConstants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.encryption.internal.Base64;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -133,18 +133,15 @@ public class SharedKeyAuthenticationTest {
|
|||
@BeforeClass
|
||||
protected void createFilter() {
|
||||
injector = Guice.createInjector(new ParserModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new AzureStorageRestClientModule(),
|
||||
new AbstractModule() {
|
||||
sameThreadExecutor()), new AzureStorageRestClientModule(), new AbstractModule() {
|
||||
|
||||
protected void configure() {
|
||||
bindConstant().annotatedWith(
|
||||
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT))
|
||||
.to(ACCOUNT);
|
||||
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to(ACCOUNT);
|
||||
bindConstant().annotatedWith(
|
||||
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY))
|
||||
.to(KEY);
|
||||
bindConstant().annotatedWith(
|
||||
Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to("1");
|
||||
Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_KEY)).to(KEY);
|
||||
bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to(
|
||||
"1");
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
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.ListOptions.Builder.maxResults;
|
||||
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.ListOptions;
|
||||
import org.jclouds.azure.storage.reference.AzureStorageConstants;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.encryption.internal.Base64;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -82,7 +82,9 @@ public class AzureQueueClientTest {
|
|||
.singletonList("2009-07-17"));
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
|
||||
// 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 {
|
||||
|
@ -102,7 +104,9 @@ public class AzureQueueClientTest {
|
|||
.singletonList("2009-07-17"));
|
||||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(), ParseSax.class);
|
||||
// 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 {
|
||||
|
@ -122,7 +126,9 @@ public class AzureQueueClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// 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 {
|
||||
|
@ -140,7 +146,9 @@ public class AzureQueueClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// 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 {
|
||||
|
@ -161,7 +169,9 @@ public class AzureQueueClientTest {
|
|||
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
|
||||
ReturnTrueIf2xx.class);
|
||||
// TODO check generic type of response parser
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
|
||||
assertEquals(processor
|
||||
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
ThrowResourceNotFoundOn404.class);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
@ -186,7 +196,7 @@ public class AzureQueueClientTest {
|
|||
1l);
|
||||
}
|
||||
}, new AzureStorageRestClientModule(), new RestModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule());
|
||||
sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule());
|
||||
processor = injector.getInstance(Key
|
||||
.get(new TypeLiteral<RestAnnotationProcessor<AzureQueueAsyncClient>>() {
|
||||
}));
|
||||
|
|
|
@ -18,12 +18,13 @@
|
|||
*/
|
||||
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.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
|
@ -36,7 +37,6 @@ import java.util.concurrent.TimeoutException;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@SingleThreadCompatible
|
||||
public class RunnableFutureTask<V> implements Future<V> {
|
||||
private ExecutionException executionException;
|
||||
private InterruptedException interruptedException;
|
||||
|
|
|
@ -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 {
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,16 +19,16 @@
|
|||
package org.jclouds.rest;
|
||||
|
||||
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.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jclouds.concurrent.SingleThreaded;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ConfiguresExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
|
@ -169,9 +169,9 @@ public abstract class RestContextBuilder<A, S> {
|
|||
return input.getClass().isAnnotationPresent(SingleThreaded.class);
|
||||
}
|
||||
})) {
|
||||
modules.add(new ExecutorServiceModule(new WithinThreadExecutorService()));
|
||||
modules.add(new ExecutorServiceModule(sameThreadExecutor()));
|
||||
} else {
|
||||
modules.add(new ExecutorServiceModule(Executors.newCachedThreadPool()));
|
||||
modules.add(new ExecutorServiceModule(newCachedThreadPool()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.concurrent.TimeoutException;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.util.concurrent.Executors;
|
||||
|
||||
/**
|
||||
* Tests behavior of FutureExceptionParser
|
||||
|
@ -38,7 +39,7 @@ import com.google.common.base.Function;
|
|||
*/
|
||||
@Test(groups = "unit", testName = "concurrent.FutureExceptionParserTest")
|
||||
public class FutureExceptionParserTest {
|
||||
ExecutorService executorService = new WithinThreadExecutorService();
|
||||
ExecutorService executorService = Executors.sameThreadExecutor();
|
||||
|
||||
@Test
|
||||
public void testGet() throws InterruptedException, ExecutionException {
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
package org.jclouds.http.internal;
|
||||
|
||||
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 java.io.ByteArrayInputStream;
|
||||
|
@ -28,11 +30,9 @@ import java.net.URL;
|
|||
import java.net.URLConnection;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.encryption.internal.JCEEncryptionService;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -125,7 +125,7 @@ public class WireLiveTest {
|
|||
}
|
||||
|
||||
public static HttpWire setUp() throws Exception {
|
||||
ExecutorService service = Executors.newCachedThreadPool();
|
||||
ExecutorService service = newCachedThreadPool();
|
||||
BufferLogger bufferLogger = new BufferLogger();
|
||||
HttpWire wire = new HttpWire(service);
|
||||
wire.wireLog = (bufferLogger);
|
||||
|
@ -133,7 +133,7 @@ public class WireLiveTest {
|
|||
}
|
||||
|
||||
public HttpWire setUpSynch() throws Exception {
|
||||
ExecutorService service = new WithinThreadExecutorService();
|
||||
ExecutorService service = sameThreadExecutor();
|
||||
BufferLogger bufferLogger = new BufferLogger();
|
||||
HttpWire wire = new HttpWire(service);
|
||||
wire.wireLog = (bufferLogger);
|
||||
|
@ -158,7 +158,7 @@ public class WireLiveTest {
|
|||
URL url = new URL(checkNotNull(sysHttpStreamUrl, "sysHttpStreamUrl"));
|
||||
URLConnection connection = url.openConnection();
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.http.internal;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
|
@ -25,8 +26,6 @@ import java.io.InputStream;
|
|||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.http.internal.HttpWire;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -98,7 +97,7 @@ public class WireTest {
|
|||
}
|
||||
|
||||
public HttpWire setUpSynch() throws Exception {
|
||||
ExecutorService service = new WithinThreadExecutorService();
|
||||
ExecutorService service = sameThreadExecutor();
|
||||
BufferLogger bufferLogger = new BufferLogger();
|
||||
HttpWire wire = new HttpWire(service);
|
||||
wire.wireLog = (bufferLogger);
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
*/
|
||||
package org.jclouds.rest;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.HttpUtils;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -57,7 +57,7 @@ public abstract class RestClientTest<T> {
|
|||
protected void setupFactory() {
|
||||
|
||||
injector = Guice.createInjector(createModule(), new RestModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule());
|
||||
sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule());
|
||||
|
||||
processor = injector.getInstance(Key.get(createTypeLiteral()));
|
||||
}
|
||||
|
@ -82,10 +82,11 @@ public abstract class RestClientTest<T> {
|
|||
|
||||
protected void assertExceptionParserClassEquals(Method method, @Nullable Class<?> parserClass) {
|
||||
if (parserClass == null)
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(
|
||||
method).getClass(), ThrowResourceNotFoundOn404.class);
|
||||
else
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
|
||||
parserClass);
|
||||
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(
|
||||
method).getClass(), parserClass);
|
||||
}
|
||||
|
||||
protected void assertSaxResponseParserClassEquals(Method method, @Nullable Class<?> parserClass) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.rest.internal;
|
||||
|
||||
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.assertNull;
|
||||
|
||||
|
@ -56,7 +57,6 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.date.DateService;
|
||||
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());
|
||||
|
||||
}
|
||||
|
|
|
@ -18,12 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.gae.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.concurrent.SingleThreadCompatible;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.gae.GaeHttpCommandExecutorService;
|
||||
import org.jclouds.http.HttpCommandExecutorService;
|
||||
|
@ -46,8 +44,7 @@ public class GaeHttpCommandExecutorServiceModuleTest {
|
|||
public void testConfigureBindsClient() {
|
||||
final Properties properties = new Properties();
|
||||
|
||||
Injector i = Guice.createInjector(
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
Injector i = Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new GaeHttpCommandExecutorServiceModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
|
@ -62,8 +59,5 @@ public class GaeHttpCommandExecutorServiceModuleTest {
|
|||
});
|
||||
HttpCommandExecutorService client = i.getInstance(HttpCommandExecutorService.class);
|
||||
assert client instanceof GaeHttpCommandExecutorService;
|
||||
ExecutorService executorService = i.getInstance(ExecutorService.class);
|
||||
assert executorService.getClass().isAnnotationPresent(SingleThreadCompatible.class) : Arrays
|
||||
.asList(executorService.getClass().getAnnotations());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.mezeo.pcs2;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -27,7 +28,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -101,7 +101,7 @@ public class PCSCloudLiveTest {
|
|||
protected PCSCloud provideCloud(RestClientFactory factory) {
|
||||
return factory.create(PCSCloud.class);
|
||||
}
|
||||
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
}, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JavaUrlHttpCommandExecutorServiceModule());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.mezeo.pcs2;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
@ -26,7 +27,6 @@ import java.net.URI;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -67,7 +67,9 @@ public class PCSCloudTest {
|
|||
CloudXlinkHandler.class);
|
||||
assertEquals(httpMethod.getFilters().size(), 1);
|
||||
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;
|
||||
|
@ -94,7 +96,7 @@ public class PCSCloudTest {
|
|||
throws UnsupportedEncodingException {
|
||||
return new BasicAuthentication("foo", "bar", encryptionService);
|
||||
}
|
||||
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
}, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JavaUrlHttpCommandExecutorServiceModule());
|
||||
|
||||
processor = injector.getInstance(Key
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.mezeo.pcs2.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
|
@ -61,7 +61,7 @@ public class PCSContextModuleTest {
|
|||
super.configure();
|
||||
}
|
||||
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService()));
|
||||
new ExecutorServiceModule(sameThreadExecutor()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -110,7 +110,7 @@ public class AddMetadataAndReturnIdTest {
|
|||
// @BeforeClass
|
||||
// protected void createFilter() throws SecurityException, NoSuchMethodException {
|
||||
// Injector injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule(
|
||||
// new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
// Executors.sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
// new AbstractModule() {
|
||||
//
|
||||
// protected void configure() {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.nirvanix.sdn;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -26,7 +27,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
|
@ -77,7 +77,8 @@ public class SDNAuthenticationLiveTest {
|
|||
protected SDNAuthentication provideCloud(RestClientFactory factory) {
|
||||
return factory.create(SDNAuthentication.class);
|
||||
}
|
||||
}, new RestModule(), new Log4JLoggingModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule());
|
||||
}, new RestModule(), new Log4JLoggingModule(),
|
||||
new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JavaUrlHttpCommandExecutorServiceModule());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.nirvanix.sdn;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -25,7 +26,6 @@ import java.net.URI;
|
|||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
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());
|
||||
processor = injector.getInstance(Key
|
||||
.get(new TypeLiteral<RestAnnotationProcessor<SDNAuthentication>>() {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.nirvanix.sdn.filters;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -26,7 +27,6 @@ import java.net.URI;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.ext.RuntimeDelegate;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -101,7 +101,7 @@ public class AddSessionTokenToRequestTest {
|
|||
@BeforeClass
|
||||
protected void createFilter() {
|
||||
injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
new AbstractModule() {
|
||||
|
||||
protected void configure() {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
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.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
|
@ -29,7 +30,6 @@ import java.net.URI;
|
|||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.ext.RuntimeDelegate;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -92,7 +92,7 @@ public class InsertUserContextIntoPathTest {
|
|||
@BeforeClass
|
||||
protected void createFilter() throws SecurityException, NoSuchMethodException {
|
||||
injector = Guice.createInjector(new RestModule(), new ExecutorServiceModule(
|
||||
new WithinThreadExecutorService()), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
sameThreadExecutor()), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
new AbstractModule() {
|
||||
|
||||
protected void configure() {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.rackspace;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -29,7 +30,6 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
|
@ -131,7 +131,7 @@ public class RackspaceAuthenticationLiveTest {
|
|||
public void addContextModule(List<Module> modules) {
|
||||
modules.add(new RackspaceAuthenticationContextModule());
|
||||
}
|
||||
}.withModules(new Log4JLoggingModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService())).buildContext();
|
||||
}.withModules(new Log4JLoggingModule(), new ExecutorServiceModule(sameThreadExecutor()))
|
||||
.buildContext();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.rackspace;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -26,7 +27,6 @@ import java.util.Collections;
|
|||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
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());
|
||||
processor = injector.getInstance(Key
|
||||
.get(new TypeLiteral<RestAnnotationProcessor<RackspaceAuthentication>>() {
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.rackspace.cloudfiles;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.rackspace.StubRackspaceAuthenticationModule;
|
||||
|
@ -44,7 +44,7 @@ import com.google.inject.TypeLiteral;
|
|||
public class CloudFilesContextModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new CloudFilesStubClientModule(), new JDKLoggingModule(),
|
||||
new StubRackspaceAuthenticationModule(), new CloudFilesContextModule() {
|
||||
@Override
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.rackspace.cloudfiles.blobstore.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.blobstore.BlobStoreContext;
|
||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.logging.jdk.config.JDKLoggingModule;
|
||||
import org.jclouds.rackspace.StubRackspaceAuthenticationModule;
|
||||
|
@ -45,7 +45,7 @@ import com.google.inject.TypeLiteral;
|
|||
public class CloudFilesBlobStoreModuleTest {
|
||||
|
||||
Injector createInjector() {
|
||||
return Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
return Guice.createInjector(new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JDKLoggingModule(), new CloudFilesStubClientModule(),
|
||||
new StubRackspaceAuthenticationModule(), new CloudFilesBlobStoreContextModule() {
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
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.withMetadata;
|
||||
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.MediaType;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
import org.jclouds.http.functions.ReturnFalseOn404;
|
||||
|
@ -1010,7 +1010,7 @@ public class CloudServersClientTest {
|
|||
public String getAuthToken() {
|
||||
return "testtoken";
|
||||
}
|
||||
}, new RestModule(), new ExecutorServiceModule(new WithinThreadExecutorService()),
|
||||
}, new RestModule(), new ExecutorServiceModule(sameThreadExecutor()),
|
||||
new JavaUrlHttpCommandExecutorServiceModule());
|
||||
processor = injector.getInstance(Key
|
||||
.get(new TypeLiteral<RestAnnotationProcessor<CloudServersAsyncClient>>() {
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.rimuhosting.miro.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -65,7 +65,7 @@ public class RimuHostingContextModuleTest {
|
|||
super.configure();
|
||||
}
|
||||
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService()));
|
||||
new ExecutorServiceModule(sameThreadExecutor()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.twitter.config;
|
||||
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.HttpRetryHandler;
|
||||
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
|
||||
|
@ -64,7 +64,7 @@ public class TwitterContextModuleTest {
|
|||
super.configure();
|
||||
}
|
||||
}, new ParserModule(), new JavaUrlHttpCommandExecutorServiceModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService()));
|
||||
new ExecutorServiceModule(sameThreadExecutor()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.vcloud;
|
||||
|
||||
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_SESSIONINTERVAL;
|
||||
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.Singleton;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
|
@ -58,6 +57,7 @@ import com.google.inject.Module;
|
|||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudLogin}
|
||||
*
|
||||
|
@ -130,7 +130,8 @@ public class VCloudLoginLiveTest {
|
|||
@BeforeClass
|
||||
void setupFactory() {
|
||||
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"),
|
||||
"jclouds.test.user");
|
||||
final String key = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||
|
@ -156,7 +157,7 @@ public class VCloudLoginLiveTest {
|
|||
modules.add(new VCloudLoginRestClientModule(endpoint));
|
||||
}
|
||||
|
||||
}.withModules(new Log4JLoggingModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService())).buildContext();
|
||||
}.withModules(new Log4JLoggingModule(), new ExecutorServiceModule(sameThreadExecutor()))
|
||||
.buildContext();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.vcloud;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.util.concurrent.Executors.sameThreadExecutor;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -29,7 +30,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
|
@ -78,9 +78,10 @@ public class VCloudVersionsLiveTest {
|
|||
@SuppressWarnings( { "unused" })
|
||||
@Provides
|
||||
@Singleton
|
||||
RestContext<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient> provideContext(Closer closer, VCloudVersionsAsyncClient api,
|
||||
@VCloud URI endPoint) {
|
||||
return new RestContextImpl<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient>(closer, api, api, endPoint, "");
|
||||
RestContext<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient> provideContext(
|
||||
Closer closer, VCloudVersionsAsyncClient api, @VCloud URI endPoint) {
|
||||
return new RestContextImpl<VCloudVersionsAsyncClient, VCloudVersionsAsyncClient>(closer,
|
||||
api, api, endPoint, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,7 +123,7 @@ public class VCloudVersionsLiveTest {
|
|||
modules.add(new VCloudVersionsRestClientModule());
|
||||
}
|
||||
|
||||
}.withModules(new Log4JLoggingModule(),
|
||||
new ExecutorServiceModule(new WithinThreadExecutorService())).buildContext();
|
||||
}.withModules(new Log4JLoggingModule(), new ExecutorServiceModule(sameThreadExecutor()))
|
||||
.buildContext();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue