From aa6bb89d75320d7f8431f63817dd01513402a316 Mon Sep 17 00:00:00 2001 From: "adrian.f.cole" Date: Fri, 30 Oct 2009 20:46:58 +0000 Subject: [PATCH] Issue 113: signature logger git-svn-id: http://jclouds.googlecode.com/svn/trunk@2008 3d8758e0-26b5-11de-8745-db77d3ebf521 --- .../saas/filters/SignRequestTest.java | 31 ++++++++-------- .../aws/s3/config/S3RestClientModuleTest.java | 30 ++++++++-------- .../RequestAuthorizeSignatureTest.java | 28 ++++++++------- .../config/RestAzureBlobClientModuleTest.java | 35 ++++++++++--------- .../AzureStorageRestClientModuleTest.java | 27 +++++++------- .../filters/SharedKeyAuthenticationTest.java | 5 ++- 6 files changed, 83 insertions(+), 73 deletions(-) diff --git a/atmosonline/saas/core/src/test/java/org/jclouds/atmosonline/saas/filters/SignRequestTest.java b/atmosonline/saas/core/src/test/java/org/jclouds/atmosonline/saas/filters/SignRequestTest.java index 75eea61470..407fe2776c 100644 --- a/atmosonline/saas/core/src/test/java/org/jclouds/atmosonline/saas/filters/SignRequestTest.java +++ b/atmosonline/saas/core/src/test/java/org/jclouds/atmosonline/saas/filters/SignRequestTest.java @@ -35,6 +35,8 @@ 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.http.HttpRequest; import org.jclouds.util.Jsr330; import org.jclouds.util.TimeStamp; @@ -82,22 +84,23 @@ public class SignRequestTest { @BeforeClass protected void createFilter() { - injector = Guice.createInjector(new AbstractModule() { + injector = Guice.createInjector(new ExecutorServiceModule(new WithinThreadExecutorService()), + new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith(Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID)) - .to("user"); - bindConstant().annotatedWith(Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_KEY)) - .to(KEY); - } + protected void configure() { + bindConstant().annotatedWith( + Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_UID)).to("user"); + bindConstant().annotatedWith( + Jsr330.named(AtmosStorageConstants.PROPERTY_EMCSAAS_KEY)).to(KEY); + } - @SuppressWarnings("unused") - @Provides - @TimeStamp - String getDate() { - return "Thu, 05 Jun 2008 16:38:19 GMT"; - } - }); + @SuppressWarnings("unused") + @Provides + @TimeStamp + String getDate() { + return "Thu, 05 Jun 2008 16:38:19 GMT"; + } + }); filter = injector.getInstance(SignRequest.class); } diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java index 8c9906c413..523715684a 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/config/S3RestClientModuleTest.java @@ -32,6 +32,8 @@ import org.jclouds.aws.s3.handlers.AWSClientErrorRetryHandler; import org.jclouds.aws.s3.handlers.AWSRedirectionRetryHandler; import org.jclouds.aws.s3.handlers.ParseAWSErrorFromXmlContent; import org.jclouds.aws.s3.reference.S3Constants; +import org.jclouds.concurrent.WithinThreadExecutorService; +import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; import org.jclouds.http.handlers.DelegatingRetryHandler; @@ -50,20 +52,20 @@ import com.google.inject.Injector; public class S3RestClientModuleTest { Injector createInjector() { - return Guice.createInjector(new S3RestClientModule(), new ParserModule(), - new AbstractModule() { - @Override - protected void configure() { - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("user"); - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("key"); - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)) - .to("http://localhost"); - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to("2"); - } - }); + return Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( + "user"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)) + .to("key"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)).to( + "http://localhost"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to( + "2"); + } + }); } @Test diff --git a/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java b/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java index 2431679b75..e6745b0803 100644 --- a/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java +++ b/aws/s3/core/src/test/java/org/jclouds/aws/s3/filters/RequestAuthorizeSignatureTest.java @@ -32,6 +32,8 @@ 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; import org.jclouds.util.Jsr330; @@ -139,20 +141,20 @@ public class RequestAuthorizeSignatureTest { */ @BeforeClass protected void createFilter() { - injector = Guice.createInjector(new S3RestClientModule(), new ParserModule(), - new AbstractModule() { + injector = Guice.createInjector(new S3RestClientModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to("foo"); - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)).to("bar"); - bindConstant().annotatedWith( - Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to("2"); - bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)) - .to("https://s3.amazonaws.com"); - } - }); + protected void configure() { + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_ACCESSKEYID)).to( + "foo"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_AWS_SECRETACCESSKEY)) + .to("bar"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_SESSIONINTERVAL)).to( + "2"); + bindConstant().annotatedWith(Jsr330.named(S3Constants.PROPERTY_S3_ENDPOINT)).to( + "https://s3.amazonaws.com"); + } + }); filter = injector.getInstance(RequestAuthorizeSignature.class); } diff --git a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobClientModuleTest.java b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobClientModuleTest.java index f5ce9725cd..04f71f4b86 100644 --- a/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobClientModuleTest.java +++ b/azure/storage/blob/core/src/test/java/org/jclouds/azure/storage/blob/config/RestAzureBlobClientModuleTest.java @@ -29,6 +29,8 @@ 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.http.HttpUtils; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; @@ -48,24 +50,23 @@ import com.google.inject.Injector; public class RestAzureBlobClientModuleTest { Injector createInjector() { - return Guice.createInjector(new AzureBlobRestClientModule(), new ParserModule(), - new AbstractModule() { - @Override - protected void configure() { - bindConstant().annotatedWith( - Jsr330.named(AzureBlobConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to( - "user"); - bindConstant().annotatedWith( - Jsr330.named(AzureBlobConstants.PROPERTY_AZURESTORAGE_KEY)).to( + return Guice.createInjector(new AzureBlobRestClientModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { + @Override + protected void configure() { + bindConstant().annotatedWith( + Jsr330.named(AzureBlobConstants.PROPERTY_AZURESTORAGE_ACCOUNT)).to("user"); + bindConstant() + .annotatedWith(Jsr330.named(AzureBlobConstants.PROPERTY_AZURESTORAGE_KEY)).to( HttpUtils.toBase64String("secret".getBytes())); - bindConstant().annotatedWith( - Jsr330.named(AzureBlobConstants.PROPERTY_AZUREBLOB_ENDPOINT)).to( - "http://localhost"); - bindConstant().annotatedWith( - Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to( - 1l); - } - }); + bindConstant().annotatedWith( + Jsr330.named(AzureBlobConstants.PROPERTY_AZUREBLOB_ENDPOINT)).to( + "http://localhost"); + bindConstant().annotatedWith( + Jsr330.named(AzureStorageConstants.PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to( + 1l); + } + }); } @Test diff --git a/azure/storage/core/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java b/azure/storage/core/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java index ff223514ad..2376e8c8da 100644 --- a/azure/storage/core/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java +++ b/azure/storage/core/src/test/java/org/jclouds/azure/storage/config/AzureStorageRestClientModuleTest.java @@ -32,6 +32,8 @@ import static org.testng.Assert.assertFalse; import java.util.concurrent.ConcurrentMap; import org.jclouds.azure.storage.handlers.ParseAzureStorageErrorFromXmlContent; +import org.jclouds.concurrent.WithinThreadExecutorService; +import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.http.HttpRetryHandler; import org.jclouds.http.functions.config.ParserModule; import org.jclouds.http.handlers.DelegatingErrorHandler; @@ -52,18 +54,16 @@ import com.google.inject.Injector; public class AzureStorageRestClientModuleTest { Injector createInjector() { - return Guice.createInjector(new AzureStorageRestClientModule(), new ParserModule(), - new AbstractModule() { - @Override - protected void configure() { - bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_ACCOUNT)).to( - "user"); - bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_KEY)).to( - "secret"); - bindConstant().annotatedWith( - Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to("2"); - } - }); + return Guice.createInjector(new AzureStorageRestClientModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new ParserModule(), new AbstractModule() { + @Override + protected void configure() { + bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_ACCOUNT)).to("user"); + bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_KEY)).to("secret"); + bindConstant().annotatedWith(Jsr330.named(PROPERTY_AZURESTORAGE_SESSIONINTERVAL)).to( + "2"); + } + }); } @Test @@ -102,8 +102,7 @@ public class AzureStorageRestClientModuleTest { @Test void testRedirectionRetryHandler() { DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class); - assertEquals(handler.getRedirectionRetryHandler().getClass(), - RedirectionRetryHandler.class); + assertEquals(handler.getRedirectionRetryHandler().getClass(), RedirectionRetryHandler.class); } } \ No newline at end of file diff --git a/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java b/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java index e159c0e074..d9e30a312b 100755 --- a/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java +++ b/azure/storage/core/src/test/java/org/jclouds/azure/storage/filters/SharedKeyAuthenticationTest.java @@ -33,6 +33,8 @@ 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.http.HttpRequest; import org.jclouds.http.HttpUtils; import org.jclouds.http.functions.config.ParserModule; @@ -135,7 +137,8 @@ public class SharedKeyAuthenticationTest { */ @BeforeClass protected void createFilter() { - injector = Guice.createInjector(new ParserModule(), new AzureStorageRestClientModule(), + injector = Guice.createInjector(new ParserModule(), new ExecutorServiceModule( + new WithinThreadExecutorService()), new AzureStorageRestClientModule(), new AbstractModule() { protected void configure() {