formatting

git-svn-id: http://jclouds.googlecode.com/svn/trunk@68 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
ferncam1 2009-04-28 18:58:08 +00:00
parent 090a909be3
commit 86a2e33f7e
2 changed files with 68 additions and 66 deletions

View File

@ -111,7 +111,6 @@ public abstract class BaseHttpFutureCommandClientTest {
injector = Guice.createInjector(new AbstractModule() { injector = Guice.createInjector(new AbstractModule() {
@Override @Override
protected void configure() { protected void configure() {
Names.bindProperties(binder(), properties); Names.bindProperties(binder(), properties);
} }
}, new HttpCommandsModule(), createClientModule(), }, new HttpCommandsModule(), createClientModule(),

View File

@ -51,7 +51,7 @@ import org.testng.annotations.Test;
import com.google.inject.Injector; import com.google.inject.Injector;
import com.google.inject.Module; import com.google.inject.Module;
@Test(sequential=true) @Test(sequential = true)
public class S3IntegrationTest { public class S3IntegrationTest {
private static final Handler HANDLER = new ConsoleHandler() { private static final Handler HANDLER = new ConsoleHandler() {
@ -78,90 +78,93 @@ public class S3IntegrationTest {
guiceLogger.setLevel(Level.ALL); guiceLogger.setLevel(Level.ALL);
} }
protected String bucketPrefix = System.getProperty("user.name")
+ "." + this.getClass().getName();
String badRequestWhenSourceIsDestBucketOnCopy400 = "<Error><Code>InvalidRequest</Code><Message>The Source and Destination may not be the same when the MetadataDirective is Copy.</Message><RequestId>54C77CAF4D42474B</RequestId><HostId>SJecknEUUUx88/65VAKbCdKSOCkpuVTeu7ZG9in9x9NTNglGnoxdbALCfS4k/DUZ</HostId></Error>"; String badRequestWhenSourceIsDestBucketOnCopy400 = "<Error><Code>InvalidRequest</Code><Message>The Source and Destination may not be the same when the MetadataDirective is Copy.</Message><RequestId>54C77CAF4D42474B</RequestId><HostId>SJecknEUUUx88/65VAKbCdKSOCkpuVTeu7ZG9in9x9NTNglGnoxdbALCfS4k/DUZ</HostId></Error>";
String noSuchSourceKeyOrBucketOnCopy404 = "<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>null</Key><RequestId>9CCDF1DACA78B36F</RequestId><HostId>63cqk9YsTFBVfBfks840JVGsepPEdQM42mU+r7HN35sF4Nk5xAcWDEUPaQpK2eFU</HostId></Error>"; String noSuchSourceKeyOrBucketOnCopy404 = "<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>null</Key><RequestId>9CCDF1DACA78B36F</RequestId><HostId>63cqk9YsTFBVfBfks840JVGsepPEdQM42mU+r7HN35sF4Nk5xAcWDEUPaQpK2eFU</HostId></Error>";
String noSuchDestinationBucketOnCopy404 = "<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><BucketName>copydestination</BucketName><RequestId>4F0CF319C5535975</RequestId><HostId>hdZyHOm7VK+JI2UCdye3d6TVkKhRBIoWflldXVDTKbgipYlamy8HgPBzHrUAVQNJ</HostId></Error>"; String noSuchDestinationBucketOnCopy404 = "<Error><Code>NoSuchBucket</Code><Message>The specified bucket does not exist</Message><BucketName>copydestination</BucketName><RequestId>4F0CF319C5535975</RequestId><HostId>hdZyHOm7VK+JI2UCdye3d6TVkKhRBIoWflldXVDTKbgipYlamy8HgPBzHrUAVQNJ</HostId></Error>";
String successfulCopyObject200 = "<CopyObjectResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><LastModified>2009-03-19T13:23:27.000Z</LastModified><ETag>\"92836a3ea45a6984d1b4d23a747d46bb\"</ETag></CopyObjectResult>"; String successfulCopyObject200 = "<CopyObjectResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"><LastModified>2009-03-19T13:23:27.000Z</LastModified><ETag>\"92836a3ea45a6984d1b4d23a747d46bb\"</ETag></CopyObjectResult>";
String badSign403 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" String badSign403 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<Error><Code>SignatureDoesNotMatch</Code><Message>The operation signature we calculated does not match the signature you provided. Check your key and signing method.</Message><StringToSignBytes>47 45 54 0a 0a 0a 54 68 75 2c 20 31 39 20 4d 61 72 20 32 30 30 39 20 31 37 3a 34 38 3a 30 31 20 47 4d 54 0a 2f 61 64 72 69 61 6e 63 6f 6c 65 2e 73 33 2e 61 6d 61 7a 6f 6e 73 33 74 65 73 74 2e 66 69 6c 65 74 65 73 74 73 66 6f 72 61 64 72 69 61 6e 2f 66 69 6c 65</StringToSignBytes><RequestId>514AA22EB75A6E42</RequestId><HostId>H5nqnZkGjuKvB+seutvx5hnp1P+WAuC9c3Y7MdQCcYDr1TGwNX/mt+FHstK0pVld</HostId><SignatureProvided>Qm6Wss7e5e/eNXV50AxChH+xkLI=</SignatureProvided><StringToSign>GET\n" + "<Error><Code>SignatureDoesNotMatch</Code><Message>The operation signature we calculated does not match the signature you provided. Check your key and signing method.</Message><StringToSignBytes>47 45 54 0a 0a 0a 54 68 75 2c 20 31 39 20 4d 61 72 20 32 30 30 39 20 31 37 3a 34 38 3a 30 31 20 47 4d 54 0a 2f 61 64 72 69 61 6e 63 6f 6c 65 2e 73 33 2e 61 6d 61 7a 6f 6e 73 33 74 65 73 74 2e 66 69 6c 65 74 65 73 74 73 66 6f 72 61 64 72 69 61 6e 2f 66 69 6c 65</StringToSignBytes><RequestId>514AA22EB75A6E42</RequestId><HostId>H5nqnZkGjuKvB+seutvx5hnp1P+WAuC9c3Y7MdQCcYDr1TGwNX/mt+FHstK0pVld</HostId><SignatureProvided>Qm6Wss7e5e/eNXV50AxChH+xkLI=</SignatureProvided><StringToSign>GET\n"
+ "\n" + "\n"
+ "\n" + "\n"
+ "Thu, 19 Mar 2009 17:48:01 GMT\n" + "Thu, 19 Mar 2009 17:48:01 GMT\n"
+ "/adriancole.s3.amazons3test.filetestsforadrian/file</StringToSign><AWSAccessKeyId>0101100101001001</AWSAccessKeyId></Error>"; + "/adriancole.s3.amazons3test.filetestsforadrian/file</StringToSign><AWSAccessKeyId>0101100101001001</AWSAccessKeyId></Error>";
String amazonHadAnError = "<Error><Code>InternalError</Code><Message>We encountered an internal error. Please try again.</Message><RequestId>EF6FA7A639CAFF15</RequestId><HostId>tBkX23mIeq2riHsNw2YShupMlZ9+iy3V/uN+lRhqCR4qHTE07ujFeyAUPTowvuH/</HostId></Error>"; String amazonHadAnError = "<Error><Code>InternalError</Code><Message>We encountered an internal error. Please try again.</Message><RequestId>EF6FA7A639CAFF15</RequestId><HostId>tBkX23mIeq2riHsNw2YShupMlZ9+iy3V/uN+lRhqCR4qHTE07ujFeyAUPTowvuH/</HostId></Error>";
protected S3Connection client; protected S3Connection client;
Injector i = null; Injector i = null;
protected String bucketPrefix = System.getProperty("user.name") + "."
+ this.getClass().getName();
private static final String sysAWSAccessKeyId = System private static final String sysAWSAccessKeyId = System
.getProperty("jclouds.aws.accesskeyid"); .getProperty("jclouds.aws.accesskeyid");
protected Injector createInject(String AWSAccessKeyId, String AWSSecretAccessKey) {
return S3ConnectionFactory.getInjector(buildS3Properties(
AWSAccessKeyId, AWSSecretAccessKey), createHttpModule());
}
protected Properties buildS3Properties(String AWSAccessKeyId, String AWSSecretAccessKey) {
Properties properties = new Properties(
S3ConnectionFactory.DEFAULT_PROPERTIES);
properties.setProperty("jclouds.aws.accesskeyid", checkNotNull(
AWSAccessKeyId, "AWSAccessKeyId"));
properties.setProperty("jclouds.aws.secretaccesskey", checkNotNull(
AWSSecretAccessKey, "AWSSecretAccessKey"));
properties.setProperty("jclouds.http.secure", "false");
properties.setProperty("jclouds.http.port", "80");
return properties;
}
protected Module createHttpModule() {
return new JavaUrlHttpFutureCommandClientModule();
}
private static final String sysAWSSecretAccessKey = System private static final String sysAWSSecretAccessKey = System
.getProperty("jclouds.aws.secretaccesskey"); .getProperty("jclouds.aws.secretaccesskey");
@BeforeTest @BeforeTest
@Parameters( { "jclouds.aws.accesskeyid", "jclouds.aws.secretaccesskey" }) @Parameters( { "jclouds.aws.accesskeyid", "jclouds.aws.secretaccesskey" })
protected void setUpClient(@Optional String AWSAccessKeyId, @Optional String AWSSecretAccessKey) throws Exception { protected void setUpClient(@Optional String AWSAccessKeyId,
i = createInject(AWSAccessKeyId != null ? AWSAccessKeyId @Optional String AWSSecretAccessKey) throws Exception {
: sysAWSAccessKeyId, i = createInject(AWSAccessKeyId != null ? AWSAccessKeyId
AWSSecretAccessKey != null ? AWSSecretAccessKey : sysAWSAccessKeyId,
: sysAWSSecretAccessKey); AWSSecretAccessKey != null ? AWSSecretAccessKey
client = i.getInstance(LiveS3Connection.class); : sysAWSSecretAccessKey);
deleteEverything(); client = i.getInstance(LiveS3Connection.class);
deleteEverything();
}
protected Injector createInject(String AWSAccessKeyId,
String AWSSecretAccessKey) {
return S3ConnectionFactory.getInjector(buildS3Properties(
AWSAccessKeyId, AWSSecretAccessKey), createHttpModule());
}
protected Properties buildS3Properties(String AWSAccessKeyId,
String AWSSecretAccessKey) {
Properties properties = new Properties(
S3ConnectionFactory.DEFAULT_PROPERTIES);
properties.setProperty("jclouds.aws.accesskeyid", checkNotNull(
AWSAccessKeyId, "AWSAccessKeyId"));
properties.setProperty("jclouds.aws.secretaccesskey", checkNotNull(
AWSSecretAccessKey, "AWSSecretAccessKey"));
properties.setProperty("jclouds.http.secure", "false");
properties.setProperty("jclouds.http.port", "80");
return properties;
}
protected Module createHttpModule() {
return new JavaUrlHttpFutureCommandClientModule();
} }
protected void deleteEverything() throws Exception { protected void deleteEverything() throws Exception {
try { try {
List<S3Bucket> buckets = client.getBuckets().get(); List<S3Bucket> buckets = client.getBuckets().get();
List<Future<Boolean>> results = new ArrayList<Future<Boolean>>(); List<Future<Boolean>> results = new ArrayList<Future<Boolean>>();
for (S3Bucket bucket : buckets) { for (S3Bucket bucket : buckets) {
if (bucket.getName().startsWith(bucketPrefix.toLowerCase())) { if (bucket.getName().startsWith(bucketPrefix.toLowerCase())) {
bucket = client.getBucket(bucket).get(); bucket = client.getBucket(bucket).get();
for (S3Object object : bucket.getContents()) { for (S3Object object : bucket.getContents()) {
results.add(client results.add(client
.deleteObject(bucket, object.getKey())); .deleteObject(bucket, object.getKey()));
} }
Iterator<Future<Boolean>> iterator = results.iterator(); Iterator<Future<Boolean>> iterator = results.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
iterator.next().get(); iterator.next().get();
iterator.remove(); iterator.remove();
} }
client.deleteBucket(bucket).get(); client.deleteBucket(bucket).get();
} }
} }
} catch (CancellationException e) { } catch (CancellationException e) {
throw e; throw e;
} }
} }
@AfterTest @AfterTest
protected void tearDownClient() throws Exception { protected void tearDownClient() throws Exception {
deleteEverything(); deleteEverything();
client.close(); client.close();
i = null; i = null;
} }
} }