Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 519195e

Browse files
committed
🐛 Fix case sensitive test name
1 parent 83890c0 commit 519195e

File tree

6 files changed

+40
-10
lines changed

6 files changed

+40
-10
lines changed

src/main/java/com/upplication/s3fs/S3FileSystemProvider.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ public boolean overloadPropertiesWithSystemProps(Properties props, String key) {
229229
}
230230

231231
/**
232+
* The system envs have preference over the properties files.
233+
* So we overload it
234+
* @param props Properties
235+
* @param key String
232236
* @return true if the key are overloaded by a system property
233237
*/
234238
public boolean overloadPropertiesWithSystemEnv(Properties props, String key) {
@@ -239,6 +243,11 @@ public boolean overloadPropertiesWithSystemEnv(Properties props, String key) {
239243
return false;
240244
}
241245

246+
/**
247+
* Get the system env with the key param
248+
* @param key String
249+
* @return String or null
250+
*/
242251
public String systemGetEnv(String key) {
243252
return System.getenv(key);
244253
}

src/main/java/com/upplication/s3fs/S3Path.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public S3FileStore getFileStore() {
116116
/**
117117
* key for amazon without final slash.
118118
* <b>note:</b> the final slash need to be added to save a directory (Amazon s3 spec)
119+
*
120+
* @return the key for AmazonS3Client
119121
*/
120122
public String getKey() {
121123

@@ -125,12 +127,6 @@ public String getKey() {
125127
key = key.substring(1, key.length());
126128
}
127129

128-
// TODO: review this... :S
129-
/*
130-
if (key.endsWith("/")) {
131-
key = key.substring(0, key.length()-1);
132-
}
133-
*/
134130
return key;
135131
}
136132

src/test/java/com/upplication/s3fs/FileSystemProvider/CreateDirectoryTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
import java.nio.file.*;
1515
import java.util.Properties;
1616

17-
import static org.junit.Assert.assertArrayEquals;
18-
import static org.junit.Assert.assertEquals;
19-
import static org.junit.Assert.assertTrue;
17+
import static org.junit.Assert.*;
2018
import static org.mockito.Mockito.*;
2119

2220
public class CreateDirectoryTest extends S3UnitTestBase {
@@ -51,6 +49,7 @@ public void createDirectoryInNewBucket() throws IOException {
5149
S3Path root = createNewS3FileSystem().getPath("/newer-bucket");
5250
Path resolve = root.resolve("folder");
5351
Path path = Files.createDirectories(resolve);
52+
5453
assertEquals("s3://s3.test.amazonaws.com/newer-bucket/folder", path.toAbsolutePath().toString());
5554
// assert
5655
assertTrue(Files.exists(root));
@@ -89,7 +88,7 @@ private S3FileSystem createNewS3FileSystem() throws IOException {
8988
try {
9089
return s3fsProvider.getFileSystem(S3EndpointConstant.S3_GLOBAL_URI_TEST);
9190
} catch (FileSystemNotFoundException e) {
92-
return (S3FileSystem) FileSystems.newFileSystem(S3EndpointConstant.S3_GLOBAL_URI_TEST, null);
91+
return (S3FileSystem) s3fsProvider.newFileSystem(S3EndpointConstant.S3_GLOBAL_URI_TEST, null);
9392
}
9493

9594
}

src/test/java/com/upplication/s3fs/Path/ToUriTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.nio.file.FileSystem;
1515
import java.nio.file.FileSystems;
1616
import java.nio.file.Path;
17+
import java.util.HashMap;
1718
import java.util.Map;
1819

1920
import static com.upplication.s3fs.AmazonS3Factory.ACCESS_KEY;
@@ -92,6 +93,23 @@ public void toUriWithCredentials() {
9293
assertEquals(URI.create("s3://access@s3.test.amazonaws.com/bla/file"), path.toUri());
9394
}
9495

96+
@Test
97+
public void toUriWithCredentialBySystemenv() {
98+
99+
System.setProperty(ACCESS_KEY, "accessKeywii");
100+
System.setProperty(SECRET_KEY, "secretKey");
101+
102+
FileSystem fileSystem = new S3FileSystemProvider()
103+
.newFileSystem(S3_GLOBAL_URI_TEST, new HashMap<String, Object>());
104+
105+
Path path = fileSystem.getPath("/bla/file");
106+
107+
assertEquals(URI.create("s3://accessKeywii@s3.test.amazonaws.com/bla/file"), path.toUri());
108+
109+
System.clearProperty(ACCESS_KEY);
110+
System.clearProperty(SECRET_KEY);
111+
}
112+
95113
@Test
96114
public void toUriWithEndpoint() throws IOException {
97115
try (FileSystem fs = FileSystems.newFileSystem(URI.create("s3://endpoint/"), null)) {

src/test/java/com/upplication/s3fs/S3UnitTestBase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.upplication.s3fs;
22

3+
import static com.upplication.s3fs.AmazonS3Factory.ACCESS_KEY;
4+
import static com.upplication.s3fs.AmazonS3Factory.SECRET_KEY;
35
import static com.upplication.s3fs.S3FileSystemProvider.AMAZON_S3_FACTORY_CLASS;
46

57
import org.junit.After;
@@ -12,7 +14,13 @@ public class S3UnitTestBase {
1214

1315
@BeforeClass
1416
public static void setProperties() {
17+
18+
System.clearProperty(S3FileSystemProvider.AMAZON_S3_FACTORY_CLASS);
19+
System.clearProperty(ACCESS_KEY);
20+
System.clearProperty(SECRET_KEY);
21+
1522
System.setProperty(AMAZON_S3_FACTORY_CLASS, "com.upplication.s3fs.util.AmazonS3MockFactory");
23+
1624
}
1725

1826
@After

0 commit comments

Comments
 (0)