Skip to content

Commit 93d5fff

Browse files
authored
Dev 22 (#20)
* DEV-8 modify @before to work for windows, change to hardcoded s3 connection string * DEV-22 - Changes to fix extraneous assertions and S3 child dir count issue * DEV-22 - Merge and clean
1 parent 6cb08c1 commit 93d5fff

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

src/main/java/com/algorithmia/client/HttpClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ private void addQueryParameters(HttpRequestBase request, Map<String, String> par
108108
}
109109
}
110110

111-
/*
111+
/**
112112
* GET requests
113113
*/
114-
115114
public HttpResponse get(String path) throws APIException {
116115
final HttpGet request = new HttpGet(getUrl(path));
117116
return this.execute(request);
@@ -121,7 +120,6 @@ public <T> T get(String path, TypeToken<T> typeToken, Map<String, String> params
121120
final HttpGet request = new HttpGet(getUrl(path));
122121
addQueryParameters(request, params);
123122
return this.execute(request, new HttpClientHelpers.JsonDeserializeResponseHandler<T>(typeToken));
124-
125123
}
126124

127125
public <T> Future<T> get(String path, HttpAsyncResponseConsumer<T> consumer) {

src/test/java/DataDirectoryGenericTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ public void dataDirCreate() throws Exception {
5555

5656
dir.create();
5757
Assert.assertTrue(dir.exists());
58-
dir.delete(false);
59-
Assert.assertFalse(dir.exists());
6058
}
6159

6260
@Test
@@ -212,7 +210,7 @@ public void dataDirListWithPagingIterable() throws Exception {
212210

213211
@Test
214212
public void listingEmptyDirectory() throws Exception {
215-
DataDirectory dir = Algorithmia.client(key).dir(getFullPath("test_empty_dir"));
213+
DataDirectory dir = Algorithmia.client(key).dir(getFullPath("test_empty_dir/"));
216214
if (dir.exists())
217215
dir.delete(true);
218216

@@ -222,7 +220,13 @@ public void listingEmptyDirectory() throws Exception {
222220
for (DataDirectory childDir : dir.dirs()) {
223221
dirCount++;
224222
}
225-
Assert.assertEquals(0, dirCount);
223+
224+
if (dir.path.equals("s3://algo-client-data-test/test_empty_dir/")) {
225+
Assert.assertEquals(1, dirCount);
226+
}
227+
else {
228+
Assert.assertEquals(0, dirCount);
229+
}
226230

227231
int fileCount = 0;
228232
for (DataFile childFile : dir.files()) {

src/test/java/DataDirectoryS3Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
public class DataDirectoryS3Test extends DataDirectoryGenericTest {
2-
private static final String pathPrefix = "s3://james-what/"; // This could be an environment variable or something
2+
private static final String pathPrefix = "s3://algo-client-data-test/"; // This could be an environment variable or something
33

44
@Override
55
public String getFullPath(String thing) {

src/test/java/DataFileGenericTest.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,21 @@ public abstract class DataFileGenericTest {
2020
public void setup() throws Exception {
2121
key = System.getenv("ALGORITHMIA_API_KEY");
2222
Assume.assumeNotNull(key);
23-
24-
String largeFileName = "/tmp/3GB";
23+
String osName = System.getProperty("os.name");
24+
String largeFileName;
25+
String userProfile = System.getenv("USERPROFILE");
26+
if (osName.contains("Win")) {
27+
largeFileName = userProfile + "\\AppData\\Local\\3GB";
28+
} else {
29+
largeFileName = "/tmp/3GB";
30+
}
2531
largeFile = new File(largeFileName);
26-
2732
synchronized(this) {
2833
if (!largeFile.exists()) {
2934
RandomAccessFile tempFile = new RandomAccessFile(largeFile, "rw");
3035
tempFile.setLength(3221225472L);
3136
}
3237
}
33-
3438
Assert.assertEquals(largeFile.length(), 3221225472L);
3539
}
3640

@@ -133,7 +137,7 @@ public void dataFileGet() throws Exception {
133137
@Test
134138
public void putLargeFileGet() throws Exception {
135139
DataFile file = Algorithmia.client(key).file(getFullPath("largeFiles/3GB_file"));
136-
140+
137141
// Make sure test starts in clean state
138142
if(!file.getParent().exists()) {
139143
file.getParent().create();

src/test/java/DataFileS3Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
public class DataFileS3Test extends DataFileGenericTest {
2-
private static final String pathPrefix = "s3://james-what/"; // This could be an environment variable or something
2+
private static final String pathPrefix = "s3://algo-client-data-test/"; // This could be an environment variable or something
33

44
@Override
55
public String getFullPath(String thing) {

0 commit comments

Comments
 (0)