mirror of https://github.com/apache/jclouds.git
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:
parent
7ac032015d
commit
58e5b51c59
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
@ -401,6 +403,16 @@ public class JCloudsS3ServiceIntegrationTest extends S3IntegrationTest {
|
|||
// "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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue