MD5 tests for JetS3t putObject impl

git-svn-id: http://jclouds.googlecode.com/svn/trunk@880 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
jamurty 2009-05-30 05:29:58 +00:00
parent 7ac032015d
commit 58e5b51c59
2 changed files with 14 additions and 1 deletions

View File

@ -311,6 +311,7 @@ public class JCloudsS3Service extends S3Service {
org.jclouds.aws.s3.domain.S3Object jcObject = Util.convertObject(jsObject);
byte md5[] = connection.putObject(bucketName, jcObject, options)
.get(requestTimeoutMilliseconds, TimeUnit.MILLISECONDS);
jsObject.setMd5Hash(md5);
return jsObject;
} catch (Exception e) {
Utils.<S3ServiceException> rethrowIfRuntimeOrSameType(e);

View File

@ -30,6 +30,7 @@ import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
@ -42,6 +43,7 @@ import org.apache.commons.io.IOUtils;
import org.jclouds.aws.s3.S3IntegrationTest;
import org.jclouds.aws.s3.config.StubS3ConnectionModule;
import org.jclouds.aws.s3.reference.S3Constants;
import org.jclouds.aws.s3.util.S3Utils;
import org.jclouds.http.ContentTypes;
import org.jets3t.service.S3ObjectsChunk;
import org.jets3t.service.S3Service;
@ -400,7 +402,17 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
// URL publicUrl = new URL(
// "http://" + commonTestingBucketName + ".s3.amazonaws.com:80/" + requestObject.getKey());
// assertEquals(((HttpURLConnection) publicUrl.openConnection()).getResponseCode(), 200);
// Upload object and check MD5
requestObject = new S3Object(objectKey);
data = "Here is some d‡tˆ for you";
requestObject.setDataInputStream(new ByteArrayInputStream(data.getBytes("UTF-8")));
jsResultObject = service.putObject(new S3Bucket(commonTestingBucketName), requestObject);
jcObject = client.getObject(commonTestingBucketName, objectKey).get(10, TimeUnit.SECONDS);
assertTrue(jsResultObject.verifyData(data.getBytes("UTF-8")));
assertEquals(jsResultObject.getMd5HashAsHex(),
S3Utils.toHexString(jcObject.getMetadata().getMd5()));
emptyBucket(commonTestingBucketName);
}