44import static com .upplication .s3fs .S3UnitTestBase .S3_GLOBAL_URI ;
55import static org .junit .Assert .assertEquals ;
66import static org .junit .Assert .assertNotNull ;
7+ import static org .junit .Assert .assertSame ;
78import static org .mockito .Matchers .argThat ;
89import static org .mockito .Matchers .eq ;
910import static org .mockito .Mockito .*;
@@ -39,8 +40,6 @@ public void setup() throws IOException {
3940 }
4041 provider = spy (new S3FileSystemProvider ());
4142 doReturn (buildFakeProps ()).when (provider ).loadAmazonProperties ();
42- doReturn (false ).when (provider ).overloadPropertiesWithSystemEnv (any (Properties .class ), anyString ());
43- doReturn (false ).when (provider ).overloadPropertiesWithSystemProps (any (Properties .class ), anyString ());
4443 }
4544
4645 @ Test
@@ -64,7 +63,7 @@ public void createsAuthenticatedByEnvOverridesProps() {
6463 verify (provider ).createFileSystem (eq (S3_GLOBAL_URI ), argThat (new ArgumentMatcher <Properties >() {
6564 @ Override
6665 public boolean matches (Object argument ) {
67- Properties called = (Properties )argument ;
66+ Properties called = (Properties ) argument ;
6867 assertEquals (env .get (ACCESS_KEY ), called .get (ACCESS_KEY ));
6968 assertEquals (env .get (SECRET_KEY ), called .get (SECRET_KEY ));
7069 return true ;
@@ -139,10 +138,22 @@ public boolean matches(Object argument) {
139138
140139 @ Test
141140 public void createsAnonymousNotPossible () {
142- FileSystem fileSystem = provider .newFileSystem (S3_GLOBAL_URI , ImmutableMap .<String , Object > of ());
141+ FileSystem fileSystem = provider .newFileSystem (S3_GLOBAL_URI , ImmutableMap .<String , Object >of ());
143142 assertNotNull (fileSystem );
144143 verify (provider ).createFileSystem (eq (S3_GLOBAL_URI ), eq (buildFakeProps ()));
145144 }
145+
146+ @ Test
147+ public void getFileSystemWithSameEnvReturnSameFileSystem () {
148+ doCallRealMethod ().when (provider ).loadAmazonProperties ();
149+
150+ Map <String , Object > env = ImmutableMap .<String , Object > of ("s3fs_access_key" , "a" , "s3fs_secret_key" , "b" );
151+ FileSystem fileSystem = provider .getFileSystem (S3_GLOBAL_URI , env );
152+ assertNotNull (fileSystem );
153+
154+ FileSystem sameFileSystem = provider .getFileSystem (S3_GLOBAL_URI , env );
155+ assertSame (fileSystem , sameFileSystem );
156+ }
146157
147158 private Map <String , String > buildFakeEnv (){
148159 return ImmutableMap .<String , String > builder ()
@@ -153,7 +164,7 @@ private Map<String, String> buildFakeEnv(){
153164 private Properties buildFakeProps () {
154165 try {
155166 Properties props = new Properties ();
156- props .load (Thread .currentThread ().getContextClassLoader ().getResourceAsStream ("amazon-test-sample .properties" ));
167+ props .load (Thread .currentThread ().getContextClassLoader ().getResourceAsStream ("amazon-test.properties" ));
157168 return props ;
158169 }
159170 catch (IOException e ){
0 commit comments