Skip to content

Commit f7151ba

Browse files
committed
Fixing tests that refer to a resource file that used to have Windoze line endings.
1 parent cf58378 commit f7151ba

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/GetJobManagement_Test.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
import com.google.common.collect.Lists;
1919
import com.spectralogic.ds3client.Ds3Client;
2020
import com.spectralogic.ds3client.Ds3ClientImpl;
21-
import com.spectralogic.ds3client.commands.GetObjectRequest;
22-
import com.spectralogic.ds3client.commands.GetObjectResponse;
23-
import com.spectralogic.ds3client.commands.PutObjectRequest;
21+
import com.spectralogic.ds3client.commands.*;
2422
import com.spectralogic.ds3client.commands.spectrads3.GetJobSpectraS3Request;
2523
import com.spectralogic.ds3client.commands.spectrads3.GetJobSpectraS3Response;
2624
import com.spectralogic.ds3client.helpers.Ds3ClientHelpers;
@@ -32,6 +30,7 @@
3230
import com.spectralogic.ds3client.integration.test.helpers.TempStorageIds;
3331
import com.spectralogic.ds3client.integration.test.helpers.TempStorageUtil;
3432
import com.spectralogic.ds3client.models.ChecksumType;
33+
import com.spectralogic.ds3client.models.Contents;
3534
import com.spectralogic.ds3client.models.Priority;
3635
import com.spectralogic.ds3client.models.bulk.Ds3Object;
3736
import com.spectralogic.ds3client.models.bulk.PartialDs3Object;
@@ -178,6 +177,7 @@ public void createReadJobWithBigFile() throws IOException, URISyntaxException, N
178177

179178
} finally {
180179
FileUtils.deleteDirectory(tempDirectory.toFile());
180+
deleteBigFile();
181181
}
182182
}
183183

@@ -208,6 +208,16 @@ private void putBigFile() throws IOException, URISyntaxException {
208208
writeJob.transfer(new FileObjectPutter(dirPath));
209209
}
210210

211+
private void deleteBigFile() throws IOException {
212+
final Ds3ClientHelpers helpers = Ds3ClientHelpers.wrap(client);
213+
214+
final Iterable<Contents> objects = helpers.listObjects(BUCKET_NAME);
215+
for (final Contents contents : objects) {
216+
if (contents.getKey().equals("lesmis-copies.txt")) {
217+
client.deleteObject(new DeleteObjectRequest(BUCKET_NAME, contents.getKey()));
218+
}
219+
}
220+
}
211221

212222
@Test
213223
public void createReadJobWithPriorityOption() throws IOException,
@@ -293,6 +303,7 @@ public void testPartialRetriesWithInjectedFailures() throws NoSuchMethodExceptio
293303
}
294304
} finally {
295305
FileUtils.deleteDirectory(tempDirectory.toFile());
306+
deleteBigFile();
296307
}
297308
}
298309
}

ds3-sdk-integration/src/test/java/com/spectralogic/ds3client/integration/Smoke_Test.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -931,24 +931,30 @@ public SeekableByteChannel buildChannel(final String key) throws IOException {
931931

932932
@Test
933933
public void partialGetWithBookOverChunkBoundry() throws IOException, URISyntaxException {
934+
final String DIR_NAME = "largeFiles/";
935+
final String FILE_NAME = "lesmis-copies.txt";
936+
937+
final Path objPath = ResourceUtils.loadFileResource(DIR_NAME + FILE_NAME);
938+
final long bookSize = Files.size(objPath);
939+
934940
final String bucketName = "partialGetOnBook";
935-
final Path filePath = Files.createTempFile("ds3", "lesmis-copies.txt");
941+
final Path filePath = Files.createTempFile("ds3", FILE_NAME);
936942
LOG.info("TempFile for partial get of book: " + filePath.toAbsolutePath().toString());
937943

938944
try {
939945

940946
HELPERS.ensureBucketExists(bucketName, envDataPolicyId);
941947

942-
final List<Ds3Object> putObjects = Lists.newArrayList(new Ds3Object("lesmis-copies.txt", 13290604));
948+
final List<Ds3Object> putObjects = Lists.newArrayList(new Ds3Object(FILE_NAME, bookSize));
943949

944950
final Ds3ClientHelpers.Job putJob = HELPERS
945951
.startWriteJob(bucketName, putObjects, WriteJobOptions.create()
946952
.withMaxUploadSize(PutBulkJobSpectraS3Request.MIN_UPLOAD_SIZE_IN_BYTES));
947953

948-
putJob.transfer(new ResourceObjectPutter("largeFiles/"));
954+
putJob.transfer(new ResourceObjectPutter(DIR_NAME));
949955

950956
final List<Ds3Object> getObjects = Lists.newArrayList();
951-
getObjects.add(new PartialDs3Object("lesmis-copies.txt", Range.byLength(1048476, 200)));
957+
getObjects.add(new PartialDs3Object(FILE_NAME, Range.byLength(1048476, 200)));
952958

953959
final Ds3ClientHelpers.Job getJob = HELPERS.startReadJob(bucketName, getObjects);
954960

@@ -964,7 +970,7 @@ public SeekableByteChannel buildChannel(final String key) throws IOException {
964970
assertThat(Files.size(filePath), is(200L));
965971
final String partialFile = new String(Files.readAllBytes(filePath), Charset.forName("UTF-8"));
966972
final String expectedResult = new String(Files.readAllBytes(expectedResultPath), Charset.forName("UTF-8"));
967-
assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length() - 1))); // need the trim to remove a newline that is added by the os
973+
assertThat(partialFile, is(expectedResult.substring(0, expectedResult.length())));
968974
} finally {
969975
deleteAllContents(client, bucketName);
970976
Files.delete(filePath);
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
antern, on the dark side of the street. One of the three entered the
2-
alley leading to the commissary's house. The one who marched at their
3-
head struck him as decidedly suspicious.
4-
5-
"Come, child,"
1+
lantern-post of the
2+
blind alley Genrot.
3+
4+
At that epoch there were no gas-jets in the streets of Paris. At
5+
nightfall lanterns placed at regular distances were lighted; they were
6+
ascended and descended

0 commit comments

Comments
 (0)