-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support enumeration of filesystems when credentials are not available #1189
Changes from 5 commits
4711cd5
189cd05
3ebee20
44cd268
356da96
ed02398
32e779b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2016 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.storage.contrib.nio; | ||
|
||
import com.google.cloud.storage.Storage; | ||
import com.google.cloud.storage.StorageOptions; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong. |
||
|
||
import java.net.URI; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.times; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* Unit tests for {@link CloudStorageFileSystemProvider} late initialization. | ||
*/ | ||
@RunWith(JUnit4.class) | ||
public class CloudStorageLateInitializationTest { | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong. |
||
|
||
@Rule public final ExpectedException thrown = ExpectedException.none(); | ||
|
||
private StorageOptions mockOptions; | ||
|
||
@Before | ||
public void before() { | ||
mockOptions = mock(StorageOptions.class); | ||
Storage mockStorage = mock(Storage.class); | ||
when(mockOptions.service()).thenReturn(mockStorage); | ||
CloudStorageFileSystemProvider.setStorageOptions(mockOptions); | ||
} | ||
|
||
@Test | ||
public void ctorDoesNotCreateStorage() { | ||
new CloudStorageFileSystemProvider(); | ||
verify(mockOptions, never()).service(); | ||
} | ||
|
||
@Test | ||
public void getPathCreatesStorageOnce() { | ||
CloudStorageFileSystemProvider provider = new CloudStorageFileSystemProvider(); | ||
provider.getPath(URI.create("gs://bucket1/wat")); | ||
provider.getPath(URI.create("gs://bucket2/wat")); | ||
verify(mockOptions, times(1)).service(); | ||
} | ||
|
||
@Test | ||
public void getFileSystemCreatesStorageOnce() { | ||
CloudStorageFileSystemProvider provider = new CloudStorageFileSystemProvider(); | ||
provider.getFileSystem(URI.create("gs://bucket1")); | ||
provider.getFileSystem(URI.create("gs://bucket2")); | ||
verify(mockOptions, times(1)).service(); | ||
} | ||
|
||
This comment was marked as spam.
Sorry, something went wrong. |
||
} |
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.