Issue 113: signature logger

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2008 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-10-30 20:46:58 +00:00
parent 243ec0d2aa
commit aa6bb89d75
6 changed files with 83 additions and 73 deletions

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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() {