diff --git a/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/GetJobManagement_Test.java b/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/GetJobManagement_Test.java index 752535cae..b78cf835f 100644 --- a/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/GetJobManagement_Test.java +++ b/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/GetJobManagement_Test.java @@ -18,6 +18,7 @@ import com.google.common.collect.Lists; import com.spectralogic.ds3client.Ds3Client; import com.spectralogic.ds3client.Ds3ClientImpl; +import com.spectralogic.ds3client.commands.DeleteObjectRequest; import com.spectralogic.ds3client.commands.GetObjectRequest; import com.spectralogic.ds3client.commands.GetObjectResponse; import com.spectralogic.ds3client.commands.PutObjectRequest; @@ -32,6 +33,7 @@ import com.spectralogic.ds3client.integration.test.helpers.TempStorageIds; import com.spectralogic.ds3client.integration.test.helpers.TempStorageUtil; import com.spectralogic.ds3client.models.ChecksumType; +import com.spectralogic.ds3client.models.Contents; import com.spectralogic.ds3client.models.Priority; import com.spectralogic.ds3client.models.bulk.Ds3Object; import com.spectralogic.ds3client.models.bulk.PartialDs3Object; @@ -178,6 +180,7 @@ public void createReadJobWithBigFile() throws IOException, URISyntaxException, N } finally { FileUtils.deleteDirectory(tempDirectory.toFile()); + deleteBigFile(); } } @@ -208,6 +211,16 @@ private void putBigFile() throws IOException, URISyntaxException { writeJob.transfer(new FileObjectPutter(dirPath)); } + private void deleteBigFile() throws IOException { + final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client); + + final Iterable objects = helpers.listObjects(BUCKET_NAME); + for (final Contents contents : objects) { + if (contents.getKey().equals("lesmis-copies.txt")) { + client.deleteObject(new DeleteObjectRequest(BUCKET_NAME, contents.getKey())); + } + } + } @Test public void createReadJobWithPriorityOption() throws IOException, @@ -293,6 +306,7 @@ public void testPartialRetriesWithInjectedFailures() throws NoSuchMethodExceptio } } finally { FileUtils.deleteDirectory(tempDirectory.toFile()); + deleteBigFile(); } } } diff --git a/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/Smoke_Test.java b/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/Smoke_Test.java index 7ed2e7b7d..1b658ec5a 100644 --- a/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/Smoke_Test.java +++ b/ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/Smoke_Test.java @@ -931,24 +931,30 @@ public SeekableByteChannel buildChannel(final String key) throws IOException { @Test public void partialGetWithBookOverChunkBoundry() throws IOException, URISyntaxException { + final String DIR_NAME = "largeFiles/"; + final String FILE_NAME = "lesmis-copies.txt"; + + final Path objPath = ResourceUtils.loadFileResource(DIR_NAME + FILE_NAME); + final long bookSize = Files.size(objPath); + final String bucketName = "partialGetOnBook"; - final Path filePath = Files.createTempFile("ds3", "lesmis-copies.txt"); + final Path filePath = Files.createTempFile("ds3", FILE_NAME); LOG.info("TempFile for partial get of book: " + filePath.toAbsolutePath().toString()); try { HELPERS.ensureBucketExists(bucketName, envDataPolicyId); - final List putObjects = Lists.newArrayList(new Ds3Object("lesmis-copies.txt", 13290604)); + final List putObjects = Lists.newArrayList(new Ds3Object(FILE_NAME, bookSize)); final Ds3ClientHelpers.Job putJob = HELPERS .startWriteJob(bucketName, putObjects, WriteJobOptions.create() .withMaxUploadSize(PutBulkJobSpectraS3Request.MIN_UPLOAD_SIZE_IN_BYTES)); - putJob.transfer(new ResourceObjectPutter("largeFiles/")); + putJob.transfer(new ResourceObjectPutter(DIR_NAME)); final List getObjects = Lists.newArrayList(); - getObjects.add(new PartialDs3Object("lesmis-copies.txt", Range.byLength(1048476, 200))); + getObjects.add(new PartialDs3Object(FILE_NAME, Range.byLength(1048476, 200))); final Ds3ClientHelpers.Job getJob = HELPERS.startReadJob(bucketName, getObjects); @@ -964,7 +970,7 @@ public SeekableByteChannel buildChannel(final String key) throws IOException { assertThat(Files.size(filePath), is(200L)); final String partialFile = new String(Files.readAllBytes(filePath), Charset.forName("UTF-8")); final String expectedResult = new String(Files.readAllBytes(expectedResultPath), Charset.forName("UTF-8")); - assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length() - 1))); // need the trim to remove a newline that is added by the os + assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length()))); } finally { deleteAllContents(client, bucketName); Files.delete(filePath); diff --git a/ds3-sdk-integration/src/test/resources/largeFiles/output b/ds3-sdk-integration/src/test/resources/largeFiles/output index b4a25469e..f05440f83 100644 --- a/ds3-sdk-integration/src/test/resources/largeFiles/output +++ b/ds3-sdk-integration/src/test/resources/largeFiles/output @@ -1,5 +1,6 @@ -antern, on the dark side of the street. One of the three entered the -alley leading to the commissary's house. The one who marched at their -head struck him as decidedly suspicious. - -"Come, child," \ No newline at end of file +lantern-post of the +blind alley Genrot. + +At that epoch there were no gas-jets in the streets of Paris. At +nightfall lanterns placed at regular distances were lighted; they were +ascended and descended \ No newline at end of file