Format Jimfs with google-java-format.
Made a bunch of manual fixes, but mostly pretty good.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=94692335
diff --git a/jimfs/src/main/java/com/google/common/jimfs/AbstractWatchService.java b/jimfs/src/main/java/com/google/common/jimfs/AbstractWatchService.java
index ac3556f..0cb9afd 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/AbstractWatchService.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/AbstractWatchService.java
@@ -91,8 +91,7 @@
/**
* Called when the given key is cancelled. Does nothing by default.
*/
- public void cancelled(Key key) {
- }
+ public void cancelled(Key key) {}
@VisibleForTesting
ImmutableList<WatchKey> queuedKeys() {
@@ -157,8 +156,7 @@
private final Kind<T> kind;
private final int count;
- @Nullable
- private final T context;
+ @Nullable private final T context;
public Event(Kind<T> kind, int count, @Nullable T context) {
this.kind = checkNotNull(kind);
@@ -214,8 +212,7 @@
*/
static final class Key implements WatchKey {
- @VisibleForTesting
- static final int MAX_QUEUE_SIZE = 256;
+ @VisibleForTesting static final int MAX_QUEUE_SIZE = 256;
private static WatchEvent<Object> overflowEvent(int count) {
return new Event<>(OVERFLOW, count, null);
@@ -231,7 +228,9 @@
private final BlockingQueue<WatchEvent<?>> events = new ArrayBlockingQueue<>(MAX_QUEUE_SIZE);
- public Key(AbstractWatchService watcher, @Nullable Watchable watchable,
+ public Key(
+ AbstractWatchService watcher,
+ @Nullable Watchable watchable,
Iterable<? extends WatchEvent.Kind<?>> subscribedTypes) {
this.watcher = checkNotNull(watcher);
this.watchable = watchable; // nullable for Watcher poison
diff --git a/jimfs/src/main/java/com/google/common/jimfs/AclAttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/AclAttributeProvider.java
index 6a52a70..f02b6c8 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/AclAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/AclAttributeProvider.java
@@ -84,8 +84,7 @@
}
@Override
- public void set(
- File file, String view, String attribute, Object value, boolean create) {
+ public void set(File file, String view, String attribute, Object value, boolean create) {
if (attribute.equals("acl")) {
checkNotCreate(view, attribute, create);
file.setAttribute("acl", "acl", toAcl(checkType(view, attribute, value, List.class)));
@@ -97,8 +96,9 @@
ImmutableList<?> copy = ImmutableList.copyOf(list);
for (Object obj : copy) {
if (!(obj instanceof AclEntry)) {
- throw new IllegalArgumentException("invalid element for attribute 'acl:acl': "
- + "should be List<AclEntry>, found element of type " + obj.getClass());
+ throw new IllegalArgumentException(
+ "invalid element for attribute 'acl:acl': should be List<AclEntry>, "
+ + "found element of type " + obj.getClass());
}
}
@@ -111,8 +111,8 @@
}
@Override
- public AclFileAttributeView view(FileLookup lookup,
- ImmutableMap<String, FileAttributeView> inheritedViews) {
+ public AclFileAttributeView view(
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup, (FileOwnerAttributeView) inheritedViews.get("owner"));
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/AttributeCopyOption.java b/jimfs/src/main/java/com/google/common/jimfs/AttributeCopyOption.java
index 7d10e31..d9ce761 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/AttributeCopyOption.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/AttributeCopyOption.java
@@ -29,4 +29,3 @@
/** Do not copy any of the file's attributes. */
NONE
}
-
diff --git a/jimfs/src/main/java/com/google/common/jimfs/AttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/AttributeProvider.java
index 82ceba1..c509467 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/AttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/AttributeProvider.java
@@ -112,8 +112,7 @@
* @throws UnsupportedOperationException if the given attribute is one supported by this provider
* and is allowed to be set by the user, but not on file creation and {@code create} is true
*/
- public abstract void set(
- File file, String view, String attribute, Object value, boolean create);
+ public abstract void set(File file, String view, String attribute, Object value, boolean create);
// optional
@@ -175,9 +174,11 @@
*/
protected static IllegalArgumentException invalidType(
String view, String attribute, Object value, Class<?>... expectedTypes) {
- Object expected = expectedTypes.length == 1 ?
- expectedTypes[0] : "one of " + Arrays.toString(expectedTypes);
- throw new IllegalArgumentException("invalid type " + value.getClass() + " for attribute '"
- + view + ":" + attribute + "': expected " + expected);
+ Object expected =
+ expectedTypes.length == 1 ? expectedTypes[0] : "one of " + Arrays.toString(expectedTypes);
+ throw new IllegalArgumentException(
+ "invalid type " + value.getClass()
+ + " for attribute '" + view + ":" + attribute
+ + "': expected " + expected);
}
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java b/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java
index 6ad1420..636066e 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/AttributeService.java
@@ -69,10 +69,8 @@
*/
public AttributeService(
Iterable<? extends AttributeProvider> providers, Map<String, ?> userProvidedDefaults) {
- ImmutableMap.Builder<String, AttributeProvider> byViewNameBuilder =
- ImmutableMap.builder();
- ImmutableMap.Builder<Class<?>, AttributeProvider> byViewTypeBuilder =
- ImmutableMap.builder();
+ ImmutableMap.Builder<String, AttributeProvider> byViewNameBuilder = ImmutableMap.builder();
+ ImmutableMap.Builder<Class<?>, AttributeProvider> byViewTypeBuilder = ImmutableMap.builder();
ImmutableMap.Builder<Class<?>, AttributeProvider> byAttributesTypeBuilder =
ImmutableMap.builder();
@@ -213,8 +211,7 @@
public Object getAttribute(File file, String view, String attribute) {
Object value = getAttributeInternal(file, view, attribute);
if (value == null) {
- throw new IllegalArgumentException(
- "invalid attribute for view '" + view + "': " + attribute);
+ throw new IllegalArgumentException("invalid attribute for view '" + view + "': " + attribute);
}
return value;
}
@@ -276,8 +273,7 @@
*/
@SuppressWarnings("unchecked")
@Nullable
- public <V extends FileAttributeView> V getFileAttributeView(
- FileLookup lookup, Class<V> type) {
+ public <V extends FileAttributeView> V getFileAttributeView(FileLookup lookup, Class<V> type) {
AttributeProvider provider = providersByViewType.get(type);
if (provider != null) {
@@ -298,22 +294,26 @@
return ImmutableMap.copyOf(inheritedViews);
}
- private void createInheritedViews(FileLookup lookup, AttributeProvider provider,
+ private void createInheritedViews(
+ FileLookup lookup,
+ AttributeProvider provider,
Map<String, FileAttributeView> inheritedViews) {
for (String inherited : provider.inherits()) {
if (!inheritedViews.containsKey(inherited)) {
AttributeProvider inheritedProvider = providersByName.get(inherited);
- FileAttributeView inheritedView = getFileAttributeView(
- lookup, inheritedProvider.viewType(), inheritedViews);
+ FileAttributeView inheritedView =
+ getFileAttributeView(lookup, inheritedProvider.viewType(), inheritedViews);
inheritedViews.put(inherited, inheritedView);
}
}
}
- private FileAttributeView getFileAttributeView(FileLookup lookup,
- Class<? extends FileAttributeView> viewType, Map<String, FileAttributeView> inheritedViews) {
+ private FileAttributeView getFileAttributeView(
+ FileLookup lookup,
+ Class<? extends FileAttributeView> viewType,
+ Map<String, FileAttributeView> inheritedViews) {
AttributeProvider provider = providersByViewType.get(viewType);
createInheritedViews(lookup, provider, inheritedViews);
return provider.view(lookup, ImmutableMap.copyOf(inheritedViews));
diff --git a/jimfs/src/main/java/com/google/common/jimfs/BasicAttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/BasicAttributeProvider.java
index 72cbcdc..b1e110c 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/BasicAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/BasicAttributeProvider.java
@@ -36,16 +36,17 @@
*/
final class BasicAttributeProvider extends AttributeProvider {
- private static final ImmutableSet<String> ATTRIBUTES = ImmutableSet.of(
- "size",
- "fileKey",
- "isDirectory",
- "isRegularFile",
- "isSymbolicLink",
- "isOther",
- "creationTime",
- "lastAccessTime",
- "lastModifiedTime");
+ private static final ImmutableSet<String> ATTRIBUTES =
+ ImmutableSet.of(
+ "size",
+ "fileKey",
+ "isDirectory",
+ "isRegularFile",
+ "isSymbolicLink",
+ "isOther",
+ "creationTime",
+ "lastAccessTime",
+ "lastModifiedTime");
@Override
public String name() {
@@ -84,13 +85,11 @@
}
@Override
- public void set(File file,
- String view, String attribute, Object value, boolean create) {
+ public void set(File file, String view, String attribute, Object value, boolean create) {
switch (attribute) {
case "creationTime":
checkNotCreate(view, attribute, create);
- file.setCreationTime(
- checkType(view, attribute, value, FileTime.class).toMillis());
+ file.setCreationTime(checkType(view, attribute, value, FileTime.class).toMillis());
break;
case "lastAccessTime":
checkNotCreate(view, attribute, create);
@@ -117,8 +116,8 @@
}
@Override
- public BasicFileAttributeView view(FileLookup lookup,
- ImmutableMap<String, FileAttributeView> inheritedViews) {
+ public BasicFileAttributeView view(
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup);
}
@@ -155,7 +154,8 @@
public void setTimes(
@Nullable FileTime lastModifiedTime,
@Nullable FileTime lastAccessTime,
- @Nullable FileTime createTime) throws IOException {
+ @Nullable FileTime createTime)
+ throws IOException {
File file = lookupFile();
if (lastModifiedTime != null) {
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Configuration.java b/jimfs/src/main/java/com/google/common/jimfs/Configuration.java
index d9d14fd..a687009 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/Configuration.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/Configuration.java
@@ -86,12 +86,13 @@
}
private static final class UnixHolder {
- private static final Configuration UNIX = Configuration.builder(PathType.unix())
- .setRoots("/")
- .setWorkingDirectory("/work")
- .setAttributeViews("basic")
- .setSupportedFeatures(LINKS, SYMBOLIC_LINKS, SECURE_DIRECTORY_STREAM, FILE_CHANNEL)
- .build();
+ private static final Configuration UNIX =
+ Configuration.builder(PathType.unix())
+ .setRoots("/")
+ .setWorkingDirectory("/work")
+ .setAttributeViews("basic")
+ .setSupportedFeatures(LINKS, SYMBOLIC_LINKS, SECURE_DIRECTORY_STREAM, FILE_CHANNEL)
+ .build();
}
/**
@@ -132,11 +133,12 @@
}
private static final class OsxHolder {
- private static final Configuration OS_X = unix().toBuilder()
- .setNameDisplayNormalization(NFC) // matches JDK 1.7u40+ behavior
- .setNameCanonicalNormalization(NFD, CASE_FOLD_ASCII) // NFD is default in HFS+
- .setSupportedFeatures(LINKS, SYMBOLIC_LINKS, FILE_CHANNEL)
- .build();
+ private static final Configuration OS_X =
+ unix().toBuilder()
+ .setNameDisplayNormalization(NFC) // matches JDK 1.7u40+ behavior
+ .setNameCanonicalNormalization(NFD, CASE_FOLD_ASCII) // NFD is default in HFS+
+ .setSupportedFeatures(LINKS, SYMBOLIC_LINKS, FILE_CHANNEL)
+ .build();
}
/**
@@ -173,14 +175,15 @@
}
private static final class WindowsHolder {
- private static final Configuration WINDOWS = Configuration.builder(PathType.windows())
- .setRoots("C:\\")
- .setWorkingDirectory("C:\\work")
- .setNameCanonicalNormalization(CASE_FOLD_ASCII)
- .setPathEqualityUsesCanonicalForm(true) // matches real behavior of WindowsPath
- .setAttributeViews("basic")
- .setSupportedFeatures(LINKS, SYMBOLIC_LINKS, FILE_CHANNEL)
- .build();
+ private static final Configuration WINDOWS =
+ Configuration.builder(PathType.windows())
+ .setRoots("C:\\")
+ .setWorkingDirectory("C:\\work")
+ .setNameCanonicalNormalization(CASE_FOLD_ASCII)
+ .setPathEqualityUsesCanonicalForm(true) // matches real behavior of WindowsPath
+ .setAttributeViews("basic")
+ .setSupportedFeatures(LINKS, SYMBOLIC_LINKS, FILE_CHANNEL)
+ .build();
}
/**
@@ -223,12 +226,14 @@
this.maxSize = builder.maxSize;
this.maxCacheSize = builder.maxCacheSize;
this.attributeViews = builder.attributeViews;
- this.attributeProviders = builder.attributeProviders == null
- ? ImmutableSet.<AttributeProvider>of()
- : ImmutableSet.copyOf(builder.attributeProviders);
- this.defaultAttributeValues = builder.defaultAttributeValues == null
- ? ImmutableMap.<String, Object>of()
- : ImmutableMap.copyOf(builder.defaultAttributeValues);
+ this.attributeProviders =
+ builder.attributeProviders == null
+ ? ImmutableSet.<AttributeProvider>of()
+ : ImmutableSet.copyOf(builder.attributeProviders);
+ this.defaultAttributeValues =
+ builder.defaultAttributeValues == null
+ ? ImmutableMap.<String, Object>of()
+ : ImmutableMap.copyOf(builder.defaultAttributeValues);
this.roots = builder.roots;
this.workingDirectory = builder.workingDirectory;
this.supportedFeatures = builder.supportedFeatures;
@@ -289,12 +294,14 @@
this.maxSize = configuration.maxSize;
this.maxCacheSize = configuration.maxCacheSize;
this.attributeViews = configuration.attributeViews;
- this.attributeProviders = configuration.attributeProviders.isEmpty()
- ? null
- : new HashSet<>(configuration.attributeProviders);
- this.defaultAttributeValues = configuration.defaultAttributeValues.isEmpty()
- ? null
- : new HashMap<>(configuration.defaultAttributeValues);
+ this.attributeProviders =
+ configuration.attributeProviders.isEmpty()
+ ? null
+ : new HashSet<>(configuration.attributeProviders);
+ this.defaultAttributeValues =
+ configuration.defaultAttributeValues.isEmpty()
+ ? null
+ : new HashMap<>(configuration.defaultAttributeValues);
this.roots = configuration.roots;
this.workingDirectory = configuration.workingDirectory;
this.supportedFeatures = configuration.supportedFeatures;
@@ -304,8 +311,7 @@
* Sets the normalizations that will be applied to the display form of filenames. The display
* form is used in the {@code toString()} of {@code Path} objects.
*/
- public Builder setNameDisplayNormalization(
- PathNormalization first, PathNormalization... more) {
+ public Builder setNameDisplayNormalization(PathNormalization first, PathNormalization... more) {
this.nameDisplayNormalization = checkNormalizations(Lists.asList(first, more));
return this;
}
@@ -358,8 +364,8 @@
private static void checkNormalizationNotSet(
PathNormalization n, @Nullable PathNormalization set) {
if (set != null) {
- throw new IllegalArgumentException("can't set normalization " + n
- + ": normalization " + set + " already set");
+ throw new IllegalArgumentException(
+ "can't set normalization " + n + ": normalization " + set + " already set");
}
}
@@ -539,8 +545,10 @@
* </table>
*/
public Builder setDefaultAttributeValue(String attribute, Object value) {
- checkArgument(ATTRIBUTE_PATTERN.matcher(attribute).matches(),
- "attribute (%s) must be of the form \"view:attribute\"", attribute);
+ checkArgument(
+ ATTRIBUTE_PATTERN.matcher(attribute).matches(),
+ "attribute (%s) must be of the form \"view:attribute\"",
+ attribute);
checkNotNull(value);
if (defaultAttributeValues == null) {
@@ -581,8 +589,10 @@
*/
public Builder setWorkingDirectory(String workingDirectory) {
PathType.ParseResult parseResult = pathType.parsePath(workingDirectory);
- checkArgument(parseResult.isAbsolute(),
- "working directory must be an absolute path: %s", workingDirectory);
+ checkArgument(
+ parseResult.isAbsolute(),
+ "working directory must be an absolute path: %s",
+ workingDirectory);
this.workingDirectory = checkNotNull(workingDirectory);
return this;
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Directory.java b/jimfs/src/main/java/com/google/common/jimfs/Directory.java
index 454c873..7b41ec9 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/Directory.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/Directory.java
@@ -352,8 +352,7 @@
public Iterator<DirectoryEntry> iterator() {
return new AbstractIterator<DirectoryEntry>() {
int index;
- @Nullable
- DirectoryEntry entry;
+ @Nullable DirectoryEntry entry;
@Override
protected DirectoryEntry computeNext() {
diff --git a/jimfs/src/main/java/com/google/common/jimfs/DirectoryEntry.java b/jimfs/src/main/java/com/google/common/jimfs/DirectoryEntry.java
index f7d4d80..4514162 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/DirectoryEntry.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/DirectoryEntry.java
@@ -42,11 +42,9 @@
private final Directory directory;
private final Name name;
- @Nullable
- private final File file;
+ @Nullable private final File file;
- @Nullable
- DirectoryEntry next; // for use in Directory
+ @Nullable DirectoryEntry next; // for use in Directory
DirectoryEntry(Directory directory, Name name, @Nullable File file) {
this.directory = checkNotNull(directory);
@@ -80,8 +78,8 @@
* @return this
* @throws FileAlreadyExistsException if this entry does not exist
*/
- public DirectoryEntry requireDoesNotExist(
- Path pathForException) throws FileAlreadyExistsException {
+ public DirectoryEntry requireDoesNotExist(Path pathForException)
+ throws FileAlreadyExistsException {
if (exists()) {
throw new FileAlreadyExistsException(pathForException.toString());
}
@@ -95,8 +93,8 @@
* @throws NoSuchFileException if this entry does not exist
* @throws NotDirectoryException if this entry does not link to a directory
*/
- public DirectoryEntry requireDirectory(
- Path pathForException) throws NoSuchFileException, NotDirectoryException {
+ public DirectoryEntry requireDirectory(Path pathForException)
+ throws NoSuchFileException, NotDirectoryException {
requireExists(pathForException);
if (!file().isDirectory()) {
throw new NotDirectoryException(pathForException.toString());
@@ -111,8 +109,8 @@
* @throws NoSuchFileException if this entry does not exist
* @throws NotLinkException if this entry does not link to a symbolic link
*/
- public DirectoryEntry requireSymbolicLink(
- Path pathForException) throws NoSuchFileException, NotLinkException {
+ public DirectoryEntry requireSymbolicLink(Path pathForException)
+ throws NoSuchFileException, NotLinkException {
requireExists(pathForException);
if (!file().isSymbolicLink()) {
throw new NotLinkException(pathForException.toString());
diff --git a/jimfs/src/main/java/com/google/common/jimfs/DosAttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/DosAttributeProvider.java
index c7d4a67..e62cb63 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/DosAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/DosAttributeProvider.java
@@ -39,11 +39,8 @@
*/
final class DosAttributeProvider extends AttributeProvider {
- private static final ImmutableSet<String> ATTRIBUTES = ImmutableSet.of(
- "readonly",
- "hidden",
- "archive",
- "system");
+ private static final ImmutableSet<String> ATTRIBUTES =
+ ImmutableSet.of("readonly", "hidden", "archive", "system");
private static final ImmutableSet<String> INHERITED_VIEWS = ImmutableSet.of("basic", "owner");
@@ -71,8 +68,7 @@
"dos:system", getDefaultValue("dos:system", userProvidedDefaults));
}
- private static Boolean getDefaultValue(
- String attribute, Map<String, ?> userProvidedDefaults) {
+ private static Boolean getDefaultValue(String attribute, Map<String, ?> userProvidedDefaults) {
Object userProvidedValue = userProvidedDefaults.get(attribute);
if (userProvidedValue != null) {
return checkType("dos", attribute, userProvidedValue, Boolean.class);
@@ -92,8 +88,7 @@
}
@Override
- public void set(File file, String view, String attribute, Object value,
- boolean create) {
+ public void set(File file, String view, String attribute, Object value, boolean create) {
if (supports(attribute)) {
checkNotCreate(view, attribute, create);
file.setAttribute("dos", attribute, checkType(view, attribute, value, Boolean.class));
@@ -106,8 +101,8 @@
}
@Override
- public DosFileAttributeView view(FileLookup lookup,
- ImmutableMap<String, FileAttributeView> inheritedViews) {
+ public DosFileAttributeView view(
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup, (BasicFileAttributeView) inheritedViews.get("basic"));
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/File.java b/jimfs/src/main/java/com/google/common/jimfs/File.java
index d47248f..99a4f59 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/File.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/File.java
@@ -160,8 +160,7 @@
/**
* Called when this file has been unlinked from a directory, either for a move or delete.
*/
- void unlinked() {
- }
+ void unlinked() {}
/**
* Increments the link count for this file.
diff --git a/jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java b/jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java
index b7ab122..bd668a6 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/FileSystemView.java
@@ -73,8 +73,8 @@
/**
* Creates a new file system view.
*/
- public FileSystemView(JimfsFileStore store,
- Directory workingDirectory, JimfsPath workingDirectoryPath) {
+ public FileSystemView(
+ JimfsFileStore store, Directory workingDirectory, JimfsPath workingDirectoryPath) {
this.store = checkNotNull(store);
this.workingDirectory = checkNotNull(workingDirectory);
this.workingDirectoryPath = checkNotNull(workingDirectoryPath);
@@ -105,8 +105,8 @@
/**
* Attempt to look up the file at the given path.
*/
- DirectoryEntry lookUpWithLock(
- JimfsPath path, Set<? super LinkOption> options) throws IOException {
+ DirectoryEntry lookUpWithLock(JimfsPath path, Set<? super LinkOption> options)
+ throws IOException {
store.readLock().lock();
try {
return lookUp(path, options);
@@ -118,8 +118,8 @@
/**
* Looks up the file at the given path without locking.
*/
- private DirectoryEntry lookUp(
- JimfsPath path, Set<? super LinkOption> options) throws IOException {
+ private DirectoryEntry lookUp(JimfsPath path, Set<? super LinkOption> options)
+ throws IOException {
return store.lookUp(workingDirectory, path, options);
}
@@ -132,7 +132,8 @@
JimfsPath dir,
DirectoryStream.Filter<? super Path> filter,
Set<? super LinkOption> options,
- JimfsPath basePathForStream) throws IOException {
+ JimfsPath basePathForStream)
+ throws IOException {
Directory file = (Directory) lookUpWithLock(dir, options)
.requireDirectory(dir)
.file();
@@ -189,8 +190,8 @@
* Returns whether or not the two given paths locate the same file. The second path is located
* using the given view rather than this file view.
*/
- public boolean isSameFile(
- JimfsPath path, FileSystemView view2, JimfsPath path2) throws IOException {
+ public boolean isSameFile(JimfsPath path, FileSystemView view2, JimfsPath path2)
+ throws IOException {
if (!isSameFileSystem(view2)) {
return false;
}
@@ -216,8 +217,7 @@
store.readLock().lock();
try {
- DirectoryEntry entry = lookUp(path, options)
- .requireExists(path);
+ DirectoryEntry entry = lookUp(path, options).requireExists(path);
List<Name> names = new ArrayList<>();
names.add(entry.name());
@@ -260,8 +260,12 @@
* Returns the new file. If {@code allowExisting} is {@code true} and a file already exists at
* the given path, returns that file. Otherwise, throws {@link FileAlreadyExistsException}.
*/
- private File createFile(JimfsPath path, Supplier<? extends File> fileCreator,
- boolean failIfExists, FileAttribute<?>... attrs) throws IOException {
+ private File createFile(
+ JimfsPath path,
+ Supplier<? extends File> fileCreator,
+ boolean failIfExists,
+ FileAttribute<?>... attrs)
+ throws IOException {
checkNotNull(path);
checkNotNull(fileCreator);
@@ -320,8 +324,8 @@
* file. Returns null if the file did not exist.
*/
@Nullable
- private RegularFile lookUpRegularFile(
- JimfsPath path, Set<OpenOption> options) throws IOException {
+ private RegularFile lookUpRegularFile(JimfsPath path, Set<OpenOption> options)
+ throws IOException {
store.readLock().lock();
try {
DirectoryEntry entry = lookUp(path, options);
@@ -386,9 +390,10 @@
throw new UnsupportedOperationException();
}
- SymbolicLink symbolicLink = (SymbolicLink) lookUpWithLock(path, Options.NOFOLLOW_LINKS)
- .requireSymbolicLink(path)
- .file();
+ SymbolicLink symbolicLink =
+ (SymbolicLink) lookUpWithLock(path, Options.NOFOLLOW_LINKS)
+ .requireSymbolicLink(path)
+ .file();
return symbolicLink.target();
}
@@ -407,8 +412,8 @@
* file must exist and must be a regular file. The given file system view must belong to the same
* file system as this view.
*/
- public void link(
- JimfsPath link, FileSystemView existingView, JimfsPath existing) throws IOException {
+ public void link(JimfsPath link, FileSystemView existingView, JimfsPath existing)
+ throws IOException {
checkNotNull(link);
checkNotNull(existingView);
checkNotNull(existing);
@@ -418,7 +423,9 @@
}
if (!isSameFileSystem(existingView)) {
- throw new FileSystemException(link.toString(), existing.toString(),
+ throw new FileSystemException(
+ link.toString(),
+ existing.toString(),
"can't link: source and target are in different file system instances");
}
@@ -428,17 +435,18 @@
store.writeLock().lock();
try {
// we do want to follow links when finding the existing file
- File existingFile = existingView.lookUp(existing, Options.FOLLOW_LINKS)
- .requireExists(existing)
- .file();
+ File existingFile =
+ existingView
+ .lookUp(existing, Options.FOLLOW_LINKS)
+ .requireExists(existing)
+ .file();
if (!existingFile.isRegularFile()) {
- throw new FileSystemException(link.toString(), existing.toString(),
- "can't link: not a regular file");
+ throw new FileSystemException(
+ link.toString(), existing.toString(), "can't link: not a regular file");
}
- Directory linkParent = lookUp(link, Options.NOFOLLOW_LINKS)
- .requireDoesNotExist(link)
- .directory();
+ Directory linkParent =
+ lookUp(link, Options.NOFOLLOW_LINKS).requireDoesNotExist(link).directory();
linkParent.link(linkName, existingFile);
linkParent.updateModifiedTime();
@@ -453,8 +461,7 @@
public void deleteFile(JimfsPath path, DeleteMode deleteMode) throws IOException {
store.writeLock().lock();
try {
- DirectoryEntry entry = lookUp(path, Options.NOFOLLOW_LINKS)
- .requireExists(path);
+ DirectoryEntry entry = lookUp(path, Options.NOFOLLOW_LINKS).requireExists(path);
delete(entry, deleteMode, path);
} finally {
store.writeLock().unlock();
@@ -464,8 +471,8 @@
/**
* Deletes the given directory entry from its parent directory.
*/
- private void delete(DirectoryEntry entry,
- DeleteMode deleteMode, JimfsPath pathForException) throws IOException {
+ private void delete(DirectoryEntry entry, DeleteMode deleteMode, JimfsPath pathForException)
+ throws IOException {
Directory parent = entry.directory();
File file = entry.file();
@@ -497,23 +504,19 @@
/**
* Checks that the given file can be deleted, throwing an exception if it can't.
*/
- private void checkDeletable(
- File file, DeleteMode mode, Path path) throws IOException {
+ private void checkDeletable(File file, DeleteMode mode, Path path) throws IOException {
if (file.isRootDirectory()) {
- throw new FileSystemException(
- path.toString(), null, "can't delete root directory");
+ throw new FileSystemException(path.toString(), null, "can't delete root directory");
}
if (file.isDirectory()) {
if (mode == DeleteMode.NON_DIRECTORY_ONLY) {
- throw new FileSystemException(
- path.toString(), null, "can't delete: is a directory");
+ throw new FileSystemException(path.toString(), null, "can't delete: is a directory");
}
checkEmpty(((Directory) file), path);
} else if (mode == DeleteMode.DIRECTORY_ONLY) {
- throw new FileSystemException(
- path.toString(), null, "can't delete: is not a directory");
+ throw new FileSystemException(path.toString(), null, "can't delete: is not a directory");
}
if (file == workingDirectory && !path.isAbsolute()) {
@@ -536,8 +539,13 @@
/**
* Copies or moves the file at the given source path to the given dest path.
*/
- public void copy(JimfsPath source, FileSystemView destView, JimfsPath dest,
- Set<CopyOption> options, boolean move) throws IOException {
+ public void copy(
+ JimfsPath source,
+ FileSystemView destView,
+ JimfsPath dest,
+ Set<CopyOption> options,
+ boolean move)
+ throws IOException {
checkNotNull(source);
checkNotNull(destView);
checkNotNull(dest);
@@ -549,8 +557,7 @@
File copyFile = null; // non-null after block completes iff source file was copied
lockBoth(store.writeLock(), destView.store.writeLock());
try {
- DirectoryEntry sourceEntry = lookUp(source, options)
- .requireExists(source);
+ DirectoryEntry sourceEntry = lookUp(source, options).requireExists(source);
DirectoryEntry destEntry = destView.lookUp(dest, Options.NOFOLLOW_LINKS);
Directory sourceParent = sourceEntry.directory();
@@ -601,9 +608,8 @@
} else if (options.contains(COPY_ATTRIBUTES)) {
// As with move, if we're copying the file to a different file system, only copy its
// basic attributes.
- attributeCopyOption = sameFileSystem
- ? AttributeCopyOption.ALL
- : AttributeCopyOption.BASIC;
+ attributeCopyOption =
+ sameFileSystem ? AttributeCopyOption.ALL : AttributeCopyOption.BASIC;
}
// Copy the file, but don't copy its content while we're holding the file store locks.
@@ -677,8 +683,8 @@
/**
* Checks that source is not an ancestor of dest, throwing an exception if it is.
*/
- private void checkNotAncestor(
- File source, Directory destParent, FileSystemView destView) throws IOException {
+ private void checkNotAncestor(File source, Directory destParent, FileSystemView destView)
+ throws IOException {
// if dest is not in the same file system, it couldn't be in source's subdirectories
if (!isSameFileSystem(destView)) {
return;
@@ -745,14 +751,16 @@
@Nullable
public <V extends FileAttributeView> V getFileAttributeView(
final JimfsPath path, Class<V> type, final Set<? super LinkOption> options) {
- return store.getFileAttributeView(new FileLookup() {
- @Override
- public File lookup() throws IOException {
- return lookUpWithLock(path, options)
- .requireExists(path)
- .file();
- }
- }, type);
+ return store.getFileAttributeView(
+ new FileLookup() {
+ @Override
+ public File lookup() throws IOException {
+ return lookUpWithLock(path, options)
+ .requireExists(path)
+ .file();
+ }
+ },
+ type);
}
/**
@@ -781,8 +789,9 @@
* Sets the given attribute to the given value on the file located by the given path in this
* view.
*/
- public void setAttribute(JimfsPath path, String attribute, Object value,
- Set<? super LinkOption> options) throws IOException {
+ public void setAttribute(
+ JimfsPath path, String attribute, Object value, Set<? super LinkOption> options)
+ throws IOException {
File file = lookUpWithLock(path, options)
.requireExists(path)
.file();
diff --git a/jimfs/src/main/java/com/google/common/jimfs/FileTree.java b/jimfs/src/main/java/com/google/common/jimfs/FileTree.java
index bbd6b96..57e155b 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/FileTree.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/FileTree.java
@@ -80,8 +80,8 @@
/**
* Returns the result of the file lookup for the given path.
*/
- public DirectoryEntry lookUp(File workingDirectory,
- JimfsPath path, Set<? super LinkOption> options) throws IOException {
+ public DirectoryEntry lookUp(
+ File workingDirectory, JimfsPath path, Set<? super LinkOption> options) throws IOException {
checkNotNull(path);
checkNotNull(options);
@@ -94,8 +94,8 @@
}
@Nullable
- private DirectoryEntry lookUp(File dir,
- JimfsPath path, Set<? super LinkOption> options, int linkDepth) throws IOException {
+ private DirectoryEntry lookUp(
+ File dir, JimfsPath path, Set<? super LinkOption> options, int linkDepth) throws IOException {
ImmutableList<Name> names = path.names();
if (path.isAbsolute()) {
@@ -125,8 +125,9 @@
* lookup fails.
*/
@Nullable
- private DirectoryEntry lookUp(File dir, Iterable<Name> names,
- Set<? super LinkOption> options, int linkDepth) throws IOException {
+ private DirectoryEntry lookUp(
+ File dir, Iterable<Name> names, Set<? super LinkOption> options, int linkDepth)
+ throws IOException {
Iterator<Name> nameIterator = names.iterator();
Name name = nameIterator.next();
while (nameIterator.hasNext()) {
@@ -163,8 +164,9 @@
* Looks up the last element of a path.
*/
@Nullable
- private DirectoryEntry lookUpLast(@Nullable File dir,
- Name name, Set<? super LinkOption> options, int linkDepth) throws IOException {
+ private DirectoryEntry lookUpLast(
+ @Nullable File dir, Name name, Set<? super LinkOption> options, int linkDepth)
+ throws IOException {
Directory directory = toDirectory(dir);
if (directory == null) {
return null;
@@ -188,8 +190,8 @@
* relative to the given directory.
*/
@Nullable
- private DirectoryEntry followSymbolicLink(
- File dir, SymbolicLink link, int linkDepth) throws IOException {
+ private DirectoryEntry followSymbolicLink(File dir, SymbolicLink link, int linkDepth)
+ throws IOException {
if (linkDepth >= MAX_SYMBOLIC_LINK_DEPTH) {
throw new IOException("too many levels of symbolic links");
}
@@ -226,6 +228,7 @@
private static boolean isEmpty(ImmutableList<Name> names) {
// the empty path (created by FileSystem.getPath("")), has no root and a single name, ""
- return names.isEmpty() || names.size() == 1 && names.get(0).toString().isEmpty();
+ return names.isEmpty()
+ || names.size() == 1 && names.get(0).toString().isEmpty();
}
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/GlobToRegex.java b/jimfs/src/main/java/com/google/common/jimfs/GlobToRegex.java
index 5a7cc2c..5d16ddb 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/GlobToRegex.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/GlobToRegex.java
@@ -49,8 +49,8 @@
return new GlobToRegex(glob, separators).convert();
}
- private static final InternalCharMatcher REGEX_RESERVED
- = InternalCharMatcher.anyOf("^$.?+*\\[]{}()");
+ private static final InternalCharMatcher REGEX_RESERVED =
+ InternalCharMatcher.anyOf("^$.?+*\\[]{}()");
private final String glob;
private final String separators;
@@ -248,200 +248,205 @@
/**
* Called after all characters have been read.
*/
- void finish(GlobToRegex converter) {
- }
+ void finish(GlobToRegex converter) {}
}
/**
* Normal state.
*/
- private static final State NORMAL = new State() {
- @Override
- void process(GlobToRegex converter, char c) {
- switch (c) {
- case '?':
- converter.appendQuestionMark();
- return;
- case '[':
- converter.appendBracketStart();
- converter.pushState(BRACKET_FIRST_CHAR);
- return;
- case '{':
- converter.appendCurlyBraceStart();
- converter.pushState(CURLY_BRACE);
- return;
- case '*':
- converter.pushState(STAR);
- return;
- case '\\':
- converter.pushState(ESCAPE);
- return;
- default:
- converter.append(c);
- }
- }
+ private static final State NORMAL =
+ new State() {
+ @Override
+ void process(GlobToRegex converter, char c) {
+ switch (c) {
+ case '?':
+ converter.appendQuestionMark();
+ return;
+ case '[':
+ converter.appendBracketStart();
+ converter.pushState(BRACKET_FIRST_CHAR);
+ return;
+ case '{':
+ converter.appendCurlyBraceStart();
+ converter.pushState(CURLY_BRACE);
+ return;
+ case '*':
+ converter.pushState(STAR);
+ return;
+ case '\\':
+ converter.pushState(ESCAPE);
+ return;
+ default:
+ converter.append(c);
+ }
+ }
- @Override
- public String toString() {
- return "NORMAL";
- }
- };
+ @Override
+ public String toString() {
+ return "NORMAL";
+ }
+ };
/**
* State following the reading of a single \.
*/
- private static final State ESCAPE = new State() {
- @Override
- void process(GlobToRegex converter, char c) {
- converter.append(c);
- converter.popState();
- }
+ private static final State ESCAPE =
+ new State() {
+ @Override
+ void process(GlobToRegex converter, char c) {
+ converter.append(c);
+ converter.popState();
+ }
- @Override
- void finish(GlobToRegex converter) {
- throw converter.syntaxError("Hanging escape (\\) at end of pattern");
- }
+ @Override
+ void finish(GlobToRegex converter) {
+ throw converter.syntaxError("Hanging escape (\\) at end of pattern");
+ }
- @Override
- public String toString() {
- return "ESCAPE";
- }
- };
+ @Override
+ public String toString() {
+ return "ESCAPE";
+ }
+ };
/**
* State following the reading of a single *.
*/
- private static final State STAR = new State() {
- @Override
- void process(GlobToRegex converter, char c) {
- if (c == '*') {
- converter.appendStarStar();
- converter.popState();
- } else {
- converter.appendStar();
- converter.popState();
- converter.currentState().process(converter, c);
- }
- }
+ private static final State STAR =
+ new State() {
+ @Override
+ void process(GlobToRegex converter, char c) {
+ if (c == '*') {
+ converter.appendStarStar();
+ converter.popState();
+ } else {
+ converter.appendStar();
+ converter.popState();
+ converter.currentState().process(converter, c);
+ }
+ }
- @Override
- void finish(GlobToRegex converter) {
- converter.appendStar();
- }
+ @Override
+ void finish(GlobToRegex converter) {
+ converter.appendStar();
+ }
- @Override
- public String toString() {
- return "STAR";
- }
- };
+ @Override
+ public String toString() {
+ return "STAR";
+ }
+ };
/**
* State immediately following the reading of a [.
*/
- private static final State BRACKET_FIRST_CHAR = new State() {
- @Override
- void process(GlobToRegex converter, char c) {
- if (c == ']') {
- // A glob like "[]]" or "[]q]" is apparently fine in Unix (when used with ls for example)
- // but doesn't work for the default java.nio.file implementations. In the cases of "[]]" it
- // produces:
- // java.util.regex.PatternSyntaxException: Unclosed character class near index 13
- // ^[[^/]&&[]]\]$
- // ^
- // The error here is slightly different, but trying to make this work would require some
- // kind of lookahead and break the simplicity of char-by-char conversion here. Also, if
- // someone wants to include a ']' inside a character class, they should escape it.
- throw converter.syntaxError("Empty []");
- }
- if (c == '!') {
- converter.appendExact('^');
- } else if (c == '-') {
- converter.appendExact(c);
- } else {
- converter.appendInBracket(c);
- }
- converter.popState();
- converter.pushState(BRACKET);
- }
+ private static final State BRACKET_FIRST_CHAR =
+ new State() {
+ @Override
+ void process(GlobToRegex converter, char c) {
+ if (c == ']') {
+ // A glob like "[]]" or "[]q]" is apparently fine in Unix (when used with ls for example)
+ // but doesn't work for the default java.nio.file implementations. In the cases of "[]]" it
+ // produces:
+ // java.util.regex.PatternSyntaxException: Unclosed character class near index 13
+ // ^[[^/]&&[]]\]$
+ // ^
+ // The error here is slightly different, but trying to make this work would require some
+ // kind of lookahead and break the simplicity of char-by-char conversion here. Also, if
+ // someone wants to include a ']' inside a character class, they should escape it.
+ throw converter.syntaxError("Empty []");
+ }
+ if (c == '!') {
+ converter.appendExact('^');
+ } else if (c == '-') {
+ converter.appendExact(c);
+ } else {
+ converter.appendInBracket(c);
+ }
+ converter.popState();
+ converter.pushState(BRACKET);
+ }
- @Override
- void finish(GlobToRegex converter) {
- throw converter.syntaxError("Unclosed [");
- }
+ @Override
+ void finish(GlobToRegex converter) {
+ throw converter.syntaxError("Unclosed [");
+ }
- @Override
- public String toString() {
- return "BRACKET_FIRST_CHAR";
- }
- };
+ @Override
+ public String toString() {
+ return "BRACKET_FIRST_CHAR";
+ }
+ };
/**
* State inside [brackets], but not at the first character inside the brackets.
*/
- private static final State BRACKET = new State() {
- @Override
- void process(GlobToRegex converter, char c) {
- if (c == ']') {
- converter.appendBracketEnd();
- converter.popState();
- } else {
- converter.appendInBracket(c);
- }
- }
+ private static final State BRACKET =
+ new State() {
+ @Override
+ void process(GlobToRegex converter, char c) {
+ if (c == ']') {
+ converter.appendBracketEnd();
+ converter.popState();
+ } else {
+ converter.appendInBracket(c);
+ }
+ }
- @Override
- void finish(GlobToRegex converter) {
- throw converter.syntaxError("Unclosed [");
- }
+ @Override
+ void finish(GlobToRegex converter) {
+ throw converter.syntaxError("Unclosed [");
+ }
- @Override
- public String toString() {
- return "BRACKET";
- }
- };
+ @Override
+ public String toString() {
+ return "BRACKET";
+ }
+ };
/**
* State inside {curly braces}.
*/
- private static final State CURLY_BRACE = new State() {
- @Override
- void process(GlobToRegex converter, char c) {
- switch (c) {
- case '?':
- converter.appendQuestionMark();
- break;
- case '[':
- converter.appendBracketStart();
- converter.pushState(BRACKET_FIRST_CHAR);
- break;
- case '{':
- throw converter.syntaxError("{ not allowed in subpattern group");
- case '*':
- converter.pushState(STAR);
- break;
- case '\\':
- converter.pushState(ESCAPE);
- break;
- case '}':
- converter.appendCurlyBraceEnd();
- converter.popState();
- break;
- case ',':
- converter.appendSubpatternSeparator();
- break;
- default:
- converter.append(c);
- }
- }
+ private static final State CURLY_BRACE =
+ new State() {
+ @Override
+ void process(GlobToRegex converter, char c) {
+ switch (c) {
+ case '?':
+ converter.appendQuestionMark();
+ break;
+ case '[':
+ converter.appendBracketStart();
+ converter.pushState(BRACKET_FIRST_CHAR);
+ break;
+ case '{':
+ throw converter.syntaxError("{ not allowed in subpattern group");
+ case '*':
+ converter.pushState(STAR);
+ break;
+ case '\\':
+ converter.pushState(ESCAPE);
+ break;
+ case '}':
+ converter.appendCurlyBraceEnd();
+ converter.popState();
+ break;
+ case ',':
+ converter.appendSubpatternSeparator();
+ break;
+ default:
+ converter.append(c);
+ }
+ }
- @Override
- void finish(GlobToRegex converter) {
- throw converter.syntaxError("Unclosed {");
- }
+ @Override
+ void finish(GlobToRegex converter) {
+ throw converter.syntaxError("Unclosed {");
+ }
- @Override
- public String toString() {
- return "CURLY_BRACE";
- }
- };
+ @Override
+ public String toString() {
+ return "CURLY_BRACE";
+ }
+ };
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/HeapDisk.java b/jimfs/src/main/java/com/google/common/jimfs/HeapDisk.java
index 3fd4652..14d6618 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/HeapDisk.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/HeapDisk.java
@@ -59,9 +59,8 @@
public HeapDisk(Configuration config) {
this.blockSize = config.blockSize;
this.maxBlockCount = toBlockCount(config.maxSize, blockSize);
- this.maxCachedBlockCount = config.maxCacheSize == -1
- ? maxBlockCount
- : toBlockCount(config.maxCacheSize, blockSize);
+ this.maxCachedBlockCount =
+ config.maxCacheSize == -1 ? maxBlockCount : toBlockCount(config.maxCacheSize, blockSize);
this.blockCache = createBlockCache(maxCachedBlockCount);
}
@@ -77,8 +76,8 @@
public HeapDisk(int blockSize, int maxBlockCount, int maxCachedBlockCount) {
checkArgument(blockSize > 0, "blockSize (%s) must be positive", blockSize);
checkArgument(maxBlockCount > 0, "maxBlockCount (%s) must be positive", maxBlockCount);
- checkArgument(maxCachedBlockCount >= 0,
- "maxCachedBlockCount must be non-negative", maxCachedBlockCount);
+ checkArgument(
+ maxCachedBlockCount >= 0, "maxCachedBlockCount must be non-negative", maxCachedBlockCount);
this.blockSize = blockSize;
this.maxBlockCount = maxBlockCount;
this.maxCachedBlockCount = maxCachedBlockCount;
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java b/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java
index f6a65bd..f7fced7 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/Jimfs.java
@@ -147,14 +147,14 @@
@VisibleForTesting
static FileSystem newFileSystem(URI uri, Configuration config) {
- checkArgument(URI_SCHEME.equals(uri.getScheme()),
- "uri (%s) must have scheme %s", uri, URI_SCHEME);
+ checkArgument(
+ URI_SCHEME.equals(uri.getScheme()), "uri (%s) must have scheme %s", uri, URI_SCHEME);
try {
// Create the FileSystem. It uses JimfsFileSystemProvider as its provider, as that is
// the provider that actually implements the operations needed for Files methods to work.
- JimfsFileSystem fileSystem = JimfsFileSystems.newFileSystem(
- JimfsFileSystemProvider.instance(), uri, config);
+ JimfsFileSystem fileSystem =
+ JimfsFileSystems.newFileSystem(JimfsFileSystemProvider.instance(), uri, config);
// Now, call FileSystems.newFileSystem, passing it the FileSystem we just created. This
// allows the system-loaded SystemJimfsFileSystemProvider instance to cache the FileSystem
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsAsynchronousFileChannel.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsAsynchronousFileChannel.java
index 0026660..a65fd96 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsAsynchronousFileChannel.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsAsynchronousFileChannel.java
@@ -56,8 +56,8 @@
return channel.size();
}
- private <R, A> void addCallback(ListenableFuture<R> future,
- CompletionHandler<R, ? super A> handler, @Nullable A attachment) {
+ private <R, A> void addCallback(
+ ListenableFuture<R> future, CompletionHandler<R, ? super A> handler, @Nullable A attachment) {
future.addListener(new CompletionHandlerCallback<>(future, handler, attachment), executor);
}
@@ -73,7 +73,11 @@
}
@Override
- public <A> void lock(long position, long size, boolean shared, @Nullable A attachment,
+ public <A> void lock(
+ long position,
+ long size,
+ boolean shared,
+ @Nullable A attachment,
CompletionHandler<FileLock, ? super A> handler) {
checkNotNull(handler);
addCallback(lock(position, size, shared), handler, attachment);
@@ -92,12 +96,13 @@
} else {
channel.checkWritable();
}
- return executor.submit(new Callable<FileLock>() {
- @Override
- public FileLock call() throws IOException {
- return tryLock(position, size, shared);
- }
- });
+ return executor.submit(
+ new Callable<FileLock>() {
+ @Override
+ public FileLock call() throws IOException {
+ return tryLock(position, size, shared);
+ }
+ });
}
@Override
@@ -114,7 +119,10 @@
}
@Override
- public <A> void read(ByteBuffer dst, long position, @Nullable A attachment,
+ public <A> void read(
+ ByteBuffer dst,
+ long position,
+ @Nullable A attachment,
CompletionHandler<Integer, ? super A> handler) {
addCallback(read(dst, position), handler, attachment);
}
@@ -127,16 +135,20 @@
return closedChannelFuture();
}
channel.checkReadable();
- return executor.submit(new Callable<Integer>() {
- @Override
- public Integer call() throws IOException {
- return channel.read(dst, position);
- }
- });
+ return executor.submit(
+ new Callable<Integer>() {
+ @Override
+ public Integer call() throws IOException {
+ return channel.read(dst, position);
+ }
+ });
}
@Override
- public <A> void write(ByteBuffer src, long position, @Nullable A attachment,
+ public <A> void write(
+ ByteBuffer src,
+ long position,
+ @Nullable A attachment,
CompletionHandler<Integer, ? super A> handler) {
addCallback(write(src, position), handler, attachment);
}
@@ -148,12 +160,13 @@
return closedChannelFuture();
}
channel.checkWritable();
- return executor.submit(new Callable<Integer>() {
- @Override
- public Integer call() throws IOException {
- return channel.write(src, position);
- }
- });
+ return executor.submit(
+ new Callable<Integer>() {
+ @Override
+ public Integer call() throws IOException {
+ return channel.write(src, position);
+ }
+ });
}
@Override
@@ -182,11 +195,12 @@
private final ListenableFuture<R> future;
private final CompletionHandler<R, ? super A> completionHandler;
- @Nullable
- private final A attachment;
+ @Nullable private final A attachment;
- private CompletionHandlerCallback(ListenableFuture<R> future,
- CompletionHandler<R, ? super A> completionHandler, @Nullable A attachment) {
+ private CompletionHandlerCallback(
+ ListenableFuture<R> future,
+ CompletionHandler<R, ? super A> completionHandler,
+ @Nullable A attachment) {
this.future = checkNotNull(future);
this.completionHandler = checkNotNull(completionHandler);
this.attachment = attachment;
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileChannel.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileChannel.java
index 7d8e12d..b7a4662 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileChannel.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileChannel.java
@@ -296,7 +296,7 @@
synchronized (this) {
boolean completed = false;
try {
- begin(); // don't call beginBlocking() because this method doesn't block
+ begin(); // don't call beginBlocking() because this method doesn't block
if (!isOpen()) {
return 0; // AsynchronousCloseException will be thrown
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileStore.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileStore.java
index cfdeafd..4cae30a 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileStore.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileStore.java
@@ -61,8 +61,12 @@
private final Lock readLock;
private final Lock writeLock;
- public JimfsFileStore(FileTree tree, FileFactory factory, HeapDisk disk,
- AttributeService attributes, ImmutableSet<Feature> supportedFeatures,
+ public JimfsFileStore(
+ FileTree tree,
+ FileFactory factory,
+ HeapDisk disk,
+ AttributeService attributes,
+ ImmutableSet<Feature> supportedFeatures,
FileSystemState state) {
this.tree = checkNotNull(tree);
this.factory = checkNotNull(factory);
@@ -132,8 +136,8 @@
* @throws IOException if a symbolic link cycle is detected or the depth of symbolic link
* recursion otherwise exceeds a threshold
*/
- DirectoryEntry lookUp(File workingDirectory,
- JimfsPath path, Set<? super LinkOption> options) throws IOException {
+ DirectoryEntry lookUp(File workingDirectory, JimfsPath path, Set<? super LinkOption> options)
+ throws IOException {
state.checkOpen();
return tree.lookUp(workingDirectory, path, options);
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystem.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystem.java
index d687a8b..4632bbd 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystem.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystem.java
@@ -180,8 +180,12 @@
private final FileSystemView defaultView;
- JimfsFileSystem(JimfsFileSystemProvider provider, URI uri, JimfsFileStore fileStore,
- PathService pathService, FileSystemView defaultView) {
+ JimfsFileSystem(
+ JimfsFileSystemProvider provider,
+ URI uri,
+ JimfsFileStore fileStore,
+ PathService pathService,
+ FileSystemView defaultView) {
this.provider = checkNotNull(provider);
this.uri = checkNotNull(uri);
this.fileStore = checkNotNull(fileStore);
@@ -295,8 +299,7 @@
return new PollingWatchService(defaultView, pathService, fileStore.state());
}
- @Nullable
- private ExecutorService defaultThreadPool;
+ @Nullable private ExecutorService defaultThreadPool;
/**
* Returns a default thread pool to use for asynchronous file channels when users do not provide
@@ -305,18 +308,23 @@
*/
public synchronized ExecutorService getDefaultThreadPool() {
if (defaultThreadPool == null) {
- defaultThreadPool = Executors.newCachedThreadPool(new ThreadFactoryBuilder()
- .setDaemon(true)
- .setNameFormat("JimfsFileSystem-" + uri.getHost() + "-defaultThreadPool-%s")
- .build());
+ defaultThreadPool =
+ Executors.newCachedThreadPool(
+ new ThreadFactoryBuilder()
+ .setDaemon(true)
+ .setNameFormat("JimfsFileSystem-" + uri.getHost() + "-defaultThreadPool-%s")
+ .build());
// ensure thread pool is closed when file system is closed
- fileStore.state().register(new Closeable() {
- @Override
- public void close() {
- defaultThreadPool.shutdown();
- }
- });
+ fileStore
+ .state()
+ .register(
+ new Closeable() {
+ @Override
+ public void close() {
+ defaultThreadPool.shutdown();
+ }
+ });
}
return defaultThreadPool;
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystemProvider.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystemProvider.java
index ae1f15d..1f23701 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystemProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystemProvider.java
@@ -87,14 +87,16 @@
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
- throw new UnsupportedOperationException("This method should not be called directly;"
- + "use an overload of Jimfs.newFileSystem() to create a FileSystem.");
+ throw new UnsupportedOperationException(
+ "This method should not be called directly;"
+ + "use an overload of Jimfs.newFileSystem() to create a FileSystem.");
}
@Override
public FileSystem getFileSystem(URI uri) {
- throw new UnsupportedOperationException("This method should not be called directly; "
- + "use FileSystems.getFileSystem(URI) instead.");
+ throw new UnsupportedOperationException(
+ "This method should not be called directly; "
+ + "use FileSystems.getFileSystem(URI) instead.");
}
@Override
@@ -117,8 +119,8 @@
@Override
public Path getPath(URI uri) {
- throw new UnsupportedOperationException("This method should not be called directly; "
- + "use Paths.get(URI) instead.");
+ throw new UnsupportedOperationException(
+ "This method should not be called directly; " + "use Paths.get(URI) instead.");
}
private static JimfsPath checkPath(Path path) {
@@ -154,7 +156,8 @@
}
private JimfsFileChannel newJimfsFileChannel(
- JimfsPath path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
+ JimfsPath path, Set<? extends OpenOption> options, FileAttribute<?>... attrs)
+ throws IOException {
ImmutableSet<OpenOption> opts = Options.getOptionsForChannel(options);
FileSystemView view = getDefaultView(path);
RegularFile file = view.getOrCreateRegularFile(path, opts, attrs);
@@ -173,8 +176,11 @@
@Override
public AsynchronousFileChannel newAsynchronousFileChannel(
- Path path, Set<? extends OpenOption> options, @Nullable ExecutorService executor,
- FileAttribute<?>... attrs) throws IOException {
+ Path path,
+ Set<? extends OpenOption> options,
+ @Nullable ExecutorService executor,
+ FileAttribute<?>... attrs)
+ throws IOException {
// call newFileChannel and cast so that FileChannel support is checked there
JimfsFileChannel channel = (JimfsFileChannel) newFileChannel(path, options, attrs);
if (executor == null) {
@@ -205,8 +211,8 @@
}
@Override
- public DirectoryStream<Path> newDirectoryStream(Path dir,
- DirectoryStream.Filter<? super Path> filter) throws IOException {
+ public DirectoryStream<Path> newDirectoryStream(
+ Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException {
JimfsPath checkedPath = checkPath(dir);
return getDefaultView(checkedPath)
.newDirectoryStream(checkedPath, filter, Options.FOLLOW_LINKS, checkedPath);
@@ -223,7 +229,8 @@
public void createLink(Path link, Path existing) throws IOException {
JimfsPath linkPath = checkPath(link);
JimfsPath existingPath = checkPath(existing);
- checkArgument(linkPath.getFileSystem().equals(existingPath.getFileSystem()),
+ checkArgument(
+ linkPath.getFileSystem().equals(existingPath.getFileSystem()),
"link and existing paths must belong to the same file system instance");
FileSystemView view = getDefaultView(linkPath);
view.link(linkPath, getDefaultView(existingPath), existingPath);
@@ -234,7 +241,8 @@
throws IOException {
JimfsPath linkPath = checkPath(link);
JimfsPath targetPath = checkPath(target);
- checkArgument(linkPath.getFileSystem().equals(targetPath.getFileSystem()),
+ checkArgument(
+ linkPath.getFileSystem().equals(targetPath.getFileSystem()),
"link and target paths must belong to the same file system instance");
FileSystemView view = getDefaultView(linkPath);
view.createSymbolicLink(linkPath, targetPath, attrs);
@@ -263,8 +271,8 @@
copy(source, target, Options.getMoveOptions(options), true);
}
- private void copy(Path source, Path target,
- ImmutableSet<CopyOption> options, boolean move) throws IOException {
+ private void copy(Path source, Path target, ImmutableSet<CopyOption> options, boolean move)
+ throws IOException {
JimfsPath sourcePath = checkPath(source);
JimfsPath targetPath = checkPath(target);
@@ -303,10 +311,12 @@
JimfsPath checkedPath = checkPath(path);
FileSystemView view = getDefaultView(checkedPath);
if (getFileStore(path).supportsFileAttributeView("dos")) {
- return view.readAttributes(checkedPath, DosFileAttributes.class, Options.NOFOLLOW_LINKS)
+ return view
+ .readAttributes(checkedPath, DosFileAttributes.class, Options.NOFOLLOW_LINKS)
.isHidden();
}
- return path.getNameCount() > 0 && path.getFileName().toString().startsWith(".");
+ return path.getNameCount() > 0
+ && path.getFileName().toString().startsWith(".");
}
@Override
@@ -322,16 +332,16 @@
@Nullable
@Override
- public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type,
- LinkOption... options) {
+ public <V extends FileAttributeView> V getFileAttributeView(
+ Path path, Class<V> type, LinkOption... options) {
JimfsPath checkedPath = checkPath(path);
return getDefaultView(checkedPath)
.getFileAttributeView(checkedPath, type, Options.getLinkOptions(options));
}
@Override
- public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type,
- LinkOption... options) throws IOException {
+ public <A extends BasicFileAttributes> A readAttributes(
+ Path path, Class<A> type, LinkOption... options) throws IOException {
JimfsPath checkedPath = checkPath(path);
return getDefaultView(checkedPath)
.readAttributes(checkedPath, type, Options.getLinkOptions(options));
@@ -353,4 +363,3 @@
.setAttribute(checkedPath, attribute, value, Options.getLinkOptions(options));
}
}
-
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystems.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystems.java
index fe23b58..7b3bbf6 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystems.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsFileSystems.java
@@ -49,11 +49,12 @@
}
return null;
}
-
- private static final Runnable DO_NOTHING = new Runnable() {
- @Override
- public void run() {}
- };
+
+ private static final Runnable DO_NOTHING =
+ new Runnable() {
+ @Override
+ public void run() {}
+ };
/**
* Returns a {@code Runnable} that will remove the file system with the given {@code URI} from
@@ -69,8 +70,8 @@
// method reflectively since the system-loaded instance of it may be a different class
// than the one we'd get if we tried to cast it and call it like normal here.
try {
- Method method = systemJimfsProvider.getClass()
- .getDeclaredMethod("removeFileSystemRunnable", URI.class);
+ Method method =
+ systemJimfsProvider.getClass().getDeclaredMethod("removeFileSystemRunnable", URI.class);
return (Runnable) method.invoke(systemJimfsProvider, uri);
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException(
@@ -90,8 +91,8 @@
JimfsFileStore fileStore = createFileStore(config, pathService, state);
FileSystemView defaultView = createDefaultView(config, fileStore, pathService);
- JimfsFileSystem fileSystem = new JimfsFileSystem(
- provider, uri, fileStore, pathService, defaultView);
+ JimfsFileSystem fileSystem =
+ new JimfsFileSystem(provider, uri, fileStore, pathService, defaultView);
pathService.setFileSystem(fileSystem);
return fileSystem;
@@ -131,8 +132,8 @@
/**
* Creates the default view of the file system using the given working directory.
*/
- private static FileSystemView createDefaultView(Configuration config,
- JimfsFileStore fileStore, PathService pathService) throws IOException {
+ private static FileSystemView createDefaultView(
+ Configuration config, JimfsFileStore fileStore, PathService pathService) throws IOException {
JimfsPath workingDirPath = pathService.parsePath(config.workingDirectory);
Directory dir = fileStore.getRoot(workingDirPath.root());
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsInputStream.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsInputStream.java
index d1146b9..c0c3a0c 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsInputStream.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsInputStream.java
@@ -25,6 +25,8 @@
import java.io.IOException;
import java.io.InputStream;
+import javax.annotation.concurrent.GuardedBy;
+
/**
* {@link InputStream} for reading from a file's {@link RegularFile}.
*
@@ -32,9 +34,14 @@
*/
final class JimfsInputStream extends InputStream {
- // these fields are guarded by synchronization on "this"
- @VisibleForTesting RegularFile file;
+ @GuardedBy("this")
+ @VisibleForTesting
+ RegularFile file;
+
+ @GuardedBy("this")
private long pos;
+
+ @GuardedBy("this")
private boolean finished;
private final FileSystemState fileSystemState;
@@ -129,6 +136,7 @@
return Ints.saturatedCast(available);
}
+ @GuardedBy("this")
private void checkNotClosed() throws IOException {
if (file == null) {
throw new IOException("stream is closed");
@@ -146,6 +154,7 @@
}
}
+ @GuardedBy("this")
private boolean isOpen() {
return file != null;
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java
index a79809c..94aa7cd 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsOutputStream.java
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.OutputStream;
+import javax.annotation.concurrent.GuardedBy;
+
/**
* {@link OutputStream} for writing to a {@link RegularFile}.
*
@@ -31,8 +33,11 @@
*/
final class JimfsOutputStream extends OutputStream {
- // these fields are guarded by synchronization on "this"
- @VisibleForTesting RegularFile file;
+ @GuardedBy("this")
+ @VisibleForTesting
+ RegularFile file;
+
+ @GuardedBy("this")
private long pos;
private final boolean append;
@@ -89,6 +94,7 @@
}
}
+ @GuardedBy("this")
private void checkNotClosed() throws IOException {
if (file == null) {
throw new IOException("stream is closed");
@@ -106,6 +112,7 @@
}
}
+ @GuardedBy("this")
private boolean isOpen() {
return file != null;
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsPath.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsPath.java
index 868a95e..691073b 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsPath.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsPath.java
@@ -53,8 +53,7 @@
*/
final class JimfsPath implements Path {
- @Nullable
- private final Name root;
+ @Nullable private final Name root;
private final ImmutableList<Name> names;
private final PathService pathService;
@@ -95,7 +94,9 @@
* Returns whether or not this is the empty path, with no root and a single, empty string, name.
*/
public boolean isEmptyPath() {
- return root == null && names.size() == 1 && names.get(0).toString().isEmpty();
+ return root == null
+ && names.size() == 1
+ && names.get(0).toString().isEmpty();
}
@Override
@@ -147,16 +148,22 @@
@Override
public JimfsPath getName(int index) {
- checkArgument(index >= 0 && index < names.size(),
- "index (%s) must be >= 0 and < name count (%s)", index, names.size());
+ checkArgument(
+ index >= 0 && index < names.size(),
+ "index (%s) must be >= 0 and < name count (%s)",
+ index,
+ names.size());
return pathService.createFileName(names.get(index));
}
@Override
public JimfsPath subpath(int beginIndex, int endIndex) {
- checkArgument(beginIndex >= 0 && endIndex <= names.size() && endIndex > beginIndex,
+ checkArgument(
+ beginIndex >= 0 && endIndex <= names.size() && endIndex > beginIndex,
"beginIndex (%s) must be >= 0; endIndex (%s) must be <= name count (%s) and > beginIndex",
- beginIndex, endIndex, names.size());
+ beginIndex,
+ endIndex,
+ names.size());
return pathService.createRelativePath(names.subList(beginIndex, endIndex));
}
@@ -259,10 +266,12 @@
if (name.toString().isEmpty()) {
return this;
}
- return pathService.createPathInternal(root, ImmutableList.<Name>builder()
- .addAll(names)
- .add(name)
- .build());
+ return pathService.createPathInternal(
+ root,
+ ImmutableList.<Name>builder()
+ .addAll(names)
+ .add(name)
+ .build());
}
@Override
@@ -278,10 +287,12 @@
if (otherPath.isEmptyPath()) {
return this;
}
- return pathService.createPath(root, ImmutableList.<Name>builder()
- .addAll(names)
- .addAll(otherPath.names)
- .build());
+ return pathService.createPath(
+ root,
+ ImmutableList.<Name>builder()
+ .addAll(names)
+ .addAll(otherPath.names)
+ .build());
}
@Override
@@ -318,8 +329,8 @@
throw new ProviderMismatchException(other.toString());
}
- checkArgument(Objects.equals(root, otherPath.root),
- "Paths have different roots: %s, %s", this, other);
+ checkArgument(
+ Objects.equals(root, otherPath.root), "Paths have different roots: %s, %s", this, other);
if (equals(other)) {
return pathService.emptyPath();
@@ -341,9 +352,10 @@
int extraNamesInThis = Math.max(0, getNameCount() - sharedSubsequenceLength);
- ImmutableList<Name> extraNamesInOther = (otherNames.size() <= sharedSubsequenceLength)
- ? ImmutableList.<Name>of()
- : otherNames.subList(sharedSubsequenceLength, otherNames.size());
+ ImmutableList<Name> extraNamesInOther =
+ (otherNames.size() <= sharedSubsequenceLength)
+ ? ImmutableList.<Name>of()
+ : otherNames.subList(sharedSubsequenceLength, otherNames.size());
List<Name> parts = new ArrayList<>(extraNamesInThis + extraNamesInOther.size());
@@ -362,13 +374,15 @@
@Override
public JimfsPath toRealPath(LinkOption... options) throws IOException {
- return getJimfsFileSystem().getDefaultView()
+ return getJimfsFileSystem()
+ .getDefaultView()
.toRealPath(this, pathService, Options.getLinkOptions(options));
}
@Override
- public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events,
- WatchEvent.Modifier... modifiers) throws IOException {
+ public WatchKey register(
+ WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)
+ throws IOException {
checkNotNull(modifiers);
return register(watcher, events);
}
@@ -443,8 +457,7 @@
@Nullable
private JimfsPath checkPath(Path other) {
- if (checkNotNull(other) instanceof JimfsPath
- && other.getFileSystem().equals(getFileSystem())) {
+ if (checkNotNull(other) instanceof JimfsPath && other.getFileSystem().equals(getFileSystem())) {
return (JimfsPath) other;
}
return null;
diff --git a/jimfs/src/main/java/com/google/common/jimfs/JimfsSecureDirectoryStream.java b/jimfs/src/main/java/com/google/common/jimfs/JimfsSecureDirectoryStream.java
index a4ee9e3..8c19887 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/JimfsSecureDirectoryStream.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/JimfsSecureDirectoryStream.java
@@ -89,8 +89,7 @@
private final class DirectoryIterator extends AbstractIterator<Path> {
- @Nullable
- private Iterator<Name> fileNames;
+ @Nullable private Iterator<Name> fileNames;
@Override
protected synchronized Path computeNext() {
@@ -120,12 +119,13 @@
/**
* A stream filter that always returns true.
*/
- public static final Filter<Object> ALWAYS_TRUE_FILTER = new Filter<Object>() {
- @Override
- public boolean accept(Object entry) throws IOException {
- return true;
- }
- };
+ public static final Filter<Object> ALWAYS_TRUE_FILTER =
+ new Filter<Object>() {
+ @Override
+ public boolean accept(Object entry) throws IOException {
+ return true;
+ }
+ };
@Override
public SecureDirectoryStream<Path> newDirectoryStream(Path path, LinkOption... options)
@@ -135,14 +135,17 @@
// safe cast because a file system that supports SecureDirectoryStream always creates
// SecureDirectoryStreams
- return (SecureDirectoryStream<Path>) view.newDirectoryStream(
- checkedPath, ALWAYS_TRUE_FILTER, Options.getLinkOptions(options),
- path().resolve(checkedPath));
+ return (SecureDirectoryStream<Path>)
+ view.newDirectoryStream(
+ checkedPath,
+ ALWAYS_TRUE_FILTER,
+ Options.getLinkOptions(options),
+ path().resolve(checkedPath));
}
@Override
- public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options,
- FileAttribute<?>... attrs) throws IOException {
+ public SeekableByteChannel newByteChannel(
+ Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
checkOpen();
JimfsPath checkedPath = checkPath(path);
ImmutableSet<OpenOption> opts = Options.getOptionsForChannel(options);
@@ -178,8 +181,12 @@
JimfsSecureDirectoryStream checkedTargetDir = (JimfsSecureDirectoryStream) targetDir;
- view.copy(checkedSrcPath, checkedTargetDir.view, checkedTargetPath,
- ImmutableSet.<CopyOption>of(), true);
+ view.copy(
+ checkedSrcPath,
+ checkedTargetDir.view,
+ checkedTargetPath,
+ ImmutableSet.<CopyOption>of(),
+ true);
}
@Override
@@ -188,20 +195,23 @@
}
@Override
- public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type,
- LinkOption... options) {
+ public <V extends FileAttributeView> V getFileAttributeView(
+ Path path, Class<V> type, LinkOption... options) {
checkOpen();
final JimfsPath checkedPath = checkPath(path);
final ImmutableSet<LinkOption> optionsSet = Options.getLinkOptions(options);
- return view.getFileAttributeView(new FileLookup() {
- @Override
- public File lookup() throws IOException {
- checkOpen(); // per the spec, must check that the stream is open for each view operation
- return view.lookUpWithLock(checkedPath, optionsSet)
- .requireExists(checkedPath)
- .file();
- }
- }, type);
+ return view.getFileAttributeView(
+ new FileLookup() {
+ @Override
+ public File lookup() throws IOException {
+ checkOpen(); // per the spec, must check that the stream is open for each view operation
+ return view
+ .lookUpWithLock(checkedPath, optionsSet)
+ .requireExists(checkedPath)
+ .file();
+ }
+ },
+ type);
}
private static JimfsPath checkPath(Path path) {
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Name.java b/jimfs/src/main/java/com/google/common/jimfs/Name.java
index c48da89..0d6e62e 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/Name.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/Name.java
@@ -112,19 +112,23 @@
return CANONICAL_ORDERING;
}
- private static final Ordering<Name> DISPLAY_ORDERING = Ordering.natural()
- .onResultOf(new Function<Name, String>() {
- @Override
- public String apply(Name name) {
- return name.display;
- }
- });
+ private static final Ordering<Name> DISPLAY_ORDERING =
+ Ordering.natural()
+ .onResultOf(
+ new Function<Name, String>() {
+ @Override
+ public String apply(Name name) {
+ return name.display;
+ }
+ });
- private static final Ordering<Name> CANONICAL_ORDERING = Ordering.natural()
- .onResultOf(new Function<Name, String>() {
- @Override
- public String apply(Name name) {
- return name.canonical;
- }
- });
+ private static final Ordering<Name> CANONICAL_ORDERING =
+ Ordering.natural()
+ .onResultOf(
+ new Function<Name, String>() {
+ @Override
+ public String apply(Name name) {
+ return name.canonical;
+ }
+ });
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/Options.java b/jimfs/src/main/java/com/google/common/jimfs/Options.java
index 0c50821..03a5b94 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/Options.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/Options.java
@@ -123,8 +123,8 @@
}
// just return the link options for finding the file, nothing else is needed
- return (ImmutableSet<OpenOption>) (ImmutableSet<?>)
- (nofollowLinks ? NOFOLLOW_LINKS : FOLLOW_LINKS);
+ return (ImmutableSet<OpenOption>)
+ (ImmutableSet<?>) (nofollowLinks ? NOFOLLOW_LINKS : FOLLOW_LINKS);
}
/**
diff --git a/jimfs/src/main/java/com/google/common/jimfs/OwnerAttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/OwnerAttributeProvider.java
index c78cf93..1c89468 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/OwnerAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/OwnerAttributeProvider.java
@@ -94,8 +94,8 @@
}
@Override
- public FileOwnerAttributeView view(FileLookup lookup,
- ImmutableMap<String, FileAttributeView> inheritedViews) {
+ public FileOwnerAttributeView view(
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup);
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/PathMatchers.java b/jimfs/src/main/java/com/google/common/jimfs/PathMatchers.java
index 49dc57f..35f97e3 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/PathMatchers.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/PathMatchers.java
@@ -50,8 +50,8 @@
public static PathMatcher getPathMatcher(
String syntaxAndPattern, String separators, ImmutableSet<PathNormalization> normalizations) {
int syntaxSeparator = syntaxAndPattern.indexOf(':');
- checkArgument(syntaxSeparator > 0, "Must be of the form 'syntax:pattern': %s",
- syntaxAndPattern);
+ checkArgument(
+ syntaxSeparator > 0, "Must be of the form 'syntax:pattern': %s", syntaxAndPattern);
String syntax = Ascii.toLowerCase(syntaxAndPattern.substring(0, syntaxSeparator));
String pattern = syntaxAndPattern.substring(syntaxSeparator + 1);
diff --git a/jimfs/src/main/java/com/google/common/jimfs/PathNormalization.java b/jimfs/src/main/java/com/google/common/jimfs/PathNormalization.java
index 38c34c8..624cd97 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/PathNormalization.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/PathNormalization.java
@@ -75,9 +75,10 @@
try {
return UCharacter.foldCase(string, true);
} catch (NoClassDefFoundError e) {
- NoClassDefFoundError error = new NoClassDefFoundError(
- "PathNormalization.CASE_FOLD_UNICODE requires ICU4J. " +
- "Did you forget to include it on your classpath?");
+ NoClassDefFoundError error =
+ new NoClassDefFoundError(
+ "PathNormalization.CASE_FOLD_UNICODE requires ICU4J. "
+ + "Did you forget to include it on your classpath?");
error.initCause(e);
throw error;
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/PathService.java b/jimfs/src/main/java/com/google/common/jimfs/PathService.java
index 41b0cba..e5ccadc 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/PathService.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/PathService.java
@@ -49,8 +49,7 @@
*/
final class PathService implements Comparator<JimfsPath> {
- private static final Ordering<Name> DISPLAY_ROOT_ORDERING =
- Name.displayOrdering().nullsLast();
+ private static final Ordering<Name> DISPLAY_ROOT_ORDERING = Name.displayOrdering().nullsLast();
private static final Ordering<Iterable<Name>> DISPLAY_NAMES_ORDERING =
Name.displayOrdering().lexicographical();
@@ -72,13 +71,15 @@
private volatile JimfsPath emptyPath;
PathService(Configuration config) {
- this(config.pathType,
+ this(
+ config.pathType,
config.nameDisplayNormalization,
config.nameCanonicalNormalization,
config.pathEqualityUsesCanonicalForm);
}
- PathService(PathType type,
+ PathService(
+ PathType type,
Iterable<PathNormalization> displayNormalizations,
Iterable<PathNormalization> canonicalNormalizations,
boolean equalityUsesCanonicalForm) {
@@ -87,12 +88,9 @@
this.canonicalNormalizations = ImmutableSet.copyOf(canonicalNormalizations);
this.equalityUsesCanonicalForm = equalityUsesCanonicalForm;
- this.rootOrdering = equalityUsesCanonicalForm
- ? CANONICAL_ROOT_ORDERING
- : DISPLAY_ROOT_ORDERING;
- this.namesOrdering = equalityUsesCanonicalForm
- ? CANONICAL_NAMES_ORDERING
- : DISPLAY_NAMES_ORDERING;
+ this.rootOrdering = equalityUsesCanonicalForm ? CANONICAL_ROOT_ORDERING : DISPLAY_ROOT_ORDERING;
+ this.namesOrdering =
+ equalityUsesCanonicalForm ? CANONICAL_NAMES_ORDERING : DISPLAY_NAMES_ORDERING;
}
/**
@@ -207,8 +205,7 @@
* Parses the given strings as a path.
*/
public JimfsPath parsePath(String first, String... more) {
- String joined = type.joiner()
- .join(Iterables.filter(Lists.asList(first, more), NOT_EMPTY));
+ String joined = type.joiner().join(Iterables.filter(Lists.asList(first, more), NOT_EMPTY));
return toPath(type.parsePath(joined));
}
@@ -289,10 +286,11 @@
syntaxAndPattern, type.getSeparator() + type.getOtherSeparators(), displayNormalizations);
}
- private static final Predicate<Object> NOT_EMPTY = new Predicate<Object>() {
- @Override
- public boolean apply(Object input) {
- return !input.toString().isEmpty();
- }
- };
+ private static final Predicate<Object> NOT_EMPTY =
+ new Predicate<Object>() {
+ @Override
+ public boolean apply(Object input) {
+ return !input.toString().isEmpty();
+ }
+ };
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/PathType.java b/jimfs/src/main/java/com/google/common/jimfs/PathType.java
index 7a4b567..47b1b16 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/PathType.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/PathType.java
@@ -85,6 +85,7 @@
}
private static final char[] regexReservedChars = "^$.?+*\\[]{}()".toCharArray();
+
static {
Arrays.sort(regexReservedChars);
}
@@ -221,8 +222,7 @@
*/
public static final class ParseResult {
- @Nullable
- private final String root;
+ @Nullable private final String root;
private final Iterable<String> names;
public ParseResult(@Nullable String root, Iterable<String> names) {
diff --git a/jimfs/src/main/java/com/google/common/jimfs/PathURLConnection.java b/jimfs/src/main/java/com/google/common/jimfs/PathURLConnection.java
index 3fc315f..d791b07 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/PathURLConnection.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/PathURLConnection.java
@@ -94,8 +94,8 @@
}
FileTime lastModified = Files.getLastModifiedTime(path);
- String contentType = MoreObjects.firstNonNull(
- Files.probeContentType(path), DEFAULT_CONTENT_TYPE);
+ String contentType =
+ MoreObjects.firstNonNull(Files.probeContentType(path), DEFAULT_CONTENT_TYPE);
ImmutableListMultimap.Builder<String, String> builder = ImmutableListMultimap.builder();
builder.put("content-length", "" + length);
diff --git a/jimfs/src/main/java/com/google/common/jimfs/PollingWatchService.java b/jimfs/src/main/java/com/google/common/jimfs/PollingWatchService.java
index eb6e417..757241e 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/PollingWatchService.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/PollingWatchService.java
@@ -55,13 +55,14 @@
* Thread factory for polling threads, which should be daemon threads so as not to keep the VM
* running if the user doesn't close the watch service or the file system.
*/
- private static final ThreadFactory THREAD_FACTORY = new ThreadFactoryBuilder()
- .setNameFormat("com.google.common.jimfs.PollingWatchService-thread-%d")
- .setDaemon(true)
- .build();
+ private static final ThreadFactory THREAD_FACTORY =
+ new ThreadFactoryBuilder()
+ .setNameFormat("com.google.common.jimfs.PollingWatchService-thread-%d")
+ .setDaemon(true)
+ .build();
- private final ScheduledExecutorService pollingService
- = Executors.newSingleThreadScheduledExecutor(THREAD_FACTORY);
+ private final ScheduledExecutorService pollingService =
+ Executors.newSingleThreadScheduledExecutor(THREAD_FACTORY);
/**
* Map of keys to the most recent directory snapshot for each key.
@@ -85,8 +86,11 @@
// TODO(cgdecker): make user configurable somehow? meh
@VisibleForTesting
PollingWatchService(
- FileSystemView view, PathService pathService, FileSystemState fileSystemState,
- long pollingTime, TimeUnit timeUnit) {
+ FileSystemView view,
+ PathService pathService,
+ FileSystemState fileSystemState,
+ long pollingTime,
+ TimeUnit timeUnit) {
this.view = checkNotNull(view);
this.pathService = checkNotNull(pathService);
this.fileSystemState = checkNotNull(fileSystemState);
@@ -99,8 +103,8 @@
}
@Override
- public Key register(Watchable watchable,
- Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException {
+ public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes)
+ throws IOException {
JimfsPath path = checkWatchable(watchable);
Key key = super.register(path, eventTypes);
@@ -123,8 +127,11 @@
private JimfsPath checkWatchable(Watchable watchable) {
if (!(watchable instanceof JimfsPath) || !isSameFileSystem((Path) watchable)) {
- throw new IllegalArgumentException("watchable (" + watchable + ") must be a Path "
- + "associated with the same file system as this watch service");
+ throw new IllegalArgumentException(
+ "watchable ("
+ + watchable
+ + ") must be a Path "
+ + "associated with the same file system as this watch service");
}
return (JimfsPath) watchable;
@@ -164,8 +171,8 @@
}
private void startPolling() {
- pollingFuture = pollingService
- .scheduleAtFixedRate(pollingTask, pollingTime, pollingTime, timeUnit);
+ pollingFuture =
+ pollingService.scheduleAtFixedRate(pollingTask, pollingTime, pollingTime, timeUnit);
}
private void stopPolling() {
@@ -173,31 +180,32 @@
pollingFuture = null;
}
- private final Runnable pollingTask = new Runnable() {
- @Override
- public void run() {
- synchronized (PollingWatchService.this) {
- for (Map.Entry<Key, Snapshot> entry : snapshots.entrySet()) {
- Key key = entry.getKey();
- Snapshot previousSnapshot = entry.getValue();
+ private final Runnable pollingTask =
+ new Runnable() {
+ @Override
+ public void run() {
+ synchronized (PollingWatchService.this) {
+ for (Map.Entry<Key, Snapshot> entry : snapshots.entrySet()) {
+ Key key = entry.getKey();
+ Snapshot previousSnapshot = entry.getValue();
- JimfsPath path = (JimfsPath) key.watchable();
- try {
- Snapshot newSnapshot = takeSnapshot(path);
- boolean posted = previousSnapshot.postChanges(newSnapshot, key);
- entry.setValue(newSnapshot);
- if (posted) {
- key.signal();
+ JimfsPath path = (JimfsPath) key.watchable();
+ try {
+ Snapshot newSnapshot = takeSnapshot(path);
+ boolean posted = previousSnapshot.postChanges(newSnapshot, key);
+ entry.setValue(newSnapshot);
+ if (posted) {
+ key.signal();
+ }
+ } catch (IOException e) {
+ // snapshot failed; assume file does not exist or isn't a directory
+ // and cancel the key
+ key.cancel();
+ }
}
- } catch (IOException e) {
- // snapshot failed; assume file does not exist or isn't a directory and cancel the key
- key.cancel();
}
-
}
- }
- }
- };
+ };
private Snapshot takeSnapshot(JimfsPath path) throws IOException {
return new Snapshot(view.snapshotModifiedTimes(path));
@@ -225,9 +233,8 @@
boolean changesPosted = false;
if (key.subscribesTo(ENTRY_CREATE)) {
- Set<Name> created = Sets.difference(
- newState.modifiedTimes.keySet(),
- modifiedTimes.keySet());
+ Set<Name> created =
+ Sets.difference(newState.modifiedTimes.keySet(), modifiedTimes.keySet());
for (Name name : created) {
key.post(new Event<>(ENTRY_CREATE, 1, pathService.createFileName(name)));
@@ -236,9 +243,8 @@
}
if (key.subscribesTo(ENTRY_DELETE)) {
- Set<Name> deleted = Sets.difference(
- modifiedTimes.keySet(),
- newState.modifiedTimes.keySet());
+ Set<Name> deleted =
+ Sets.difference(modifiedTimes.keySet(), newState.modifiedTimes.keySet());
for (Name name : deleted) {
key.post(new Event<>(ENTRY_DELETE, 1, pathService.createFileName(name)));
diff --git a/jimfs/src/main/java/com/google/common/jimfs/PosixAttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/PosixAttributeProvider.java
index 29f1a20..d278ee6 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/PosixAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/PosixAttributeProvider.java
@@ -47,9 +47,7 @@
*/
final class PosixAttributeProvider extends AttributeProvider {
- private static final ImmutableSet<String> ATTRIBUTES = ImmutableSet.of(
- "group",
- "permissions");
+ private static final ImmutableSet<String> ATTRIBUTES = ImmutableSet.of("group", "permissions");
private static final ImmutableSet<String> INHERITED_VIEWS = ImmutableSet.of("basic", "owner");
@@ -82,9 +80,10 @@
if (userProvidedGroup instanceof String) {
group = createGroupPrincipal((String) userProvidedGroup);
} else {
- throw new IllegalArgumentException("invalid type " + userProvidedGroup.getClass()
- + " for attribute 'posix:group': should be one of " + String.class + " or "
- + GroupPrincipal.class);
+ throw new IllegalArgumentException(
+ "invalid type " + userProvidedGroup.getClass().getName()
+ + " for attribute 'posix:group': should be one of "
+ + String.class + " or " + GroupPrincipal.class);
}
}
@@ -93,14 +92,16 @@
Set<PosixFilePermission> permissions = DEFAULT_PERMISSIONS;
if (userProvidedPermissions != null) {
if (userProvidedPermissions instanceof String) {
- permissions = Sets.immutableEnumSet(
- PosixFilePermissions.fromString((String) userProvidedPermissions));
+ permissions =
+ Sets.immutableEnumSet(
+ PosixFilePermissions.fromString((String) userProvidedPermissions));
} else if (userProvidedPermissions instanceof Set) {
permissions = toPermissions((Set<?>) userProvidedPermissions);
} else {
- throw new IllegalArgumentException("invalid type " + userProvidedPermissions.getClass()
- + " for attribute 'posix:permissions': should be one of " + String.class + " or "
- + Set.class);
+ throw new IllegalArgumentException(
+ "invalid type " + userProvidedPermissions.getClass().getName()
+ + " for attribute 'posix:permissions': should be one of "
+ + String.class + " or " + Set.class);
}
}
@@ -135,8 +136,8 @@
file.setAttribute("posix", "group", group);
break;
case "permissions":
- file.setAttribute("posix", "permissions",
- toPermissions(checkType(view, attribute, value, Set.class)));
+ file.setAttribute(
+ "posix", "permissions", toPermissions(checkType(view, attribute, value, Set.class)));
break;
default:
}
@@ -147,8 +148,10 @@
ImmutableSet<?> copy = ImmutableSet.copyOf(set);
for (Object obj : copy) {
if (!(obj instanceof PosixFilePermission)) {
- throw new IllegalArgumentException("invalid element for attribute 'posix:permissions': "
- + "should be Set<PosixFilePermission>, found element of type " + obj.getClass());
+ throw new IllegalArgumentException(
+ "invalid element for attribute 'posix:permissions': "
+ + "should be Set<PosixFilePermission>, found element of type "
+ + obj.getClass());
}
}
@@ -161,9 +164,10 @@
}
@Override
- public PosixFileAttributeView view(FileLookup lookup,
- ImmutableMap<String, FileAttributeView> inheritedViews) {
- return new View(lookup,
+ public PosixFileAttributeView view(
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
+ return new View(
+ lookup,
(BasicFileAttributeView) inheritedViews.get("basic"),
(FileOwnerAttributeView) inheritedViews.get("owner"));
}
@@ -186,8 +190,8 @@
private final BasicFileAttributeView basicView;
private final FileOwnerAttributeView ownerView;
- protected View(FileLookup lookup,
- BasicFileAttributeView basicView, FileOwnerAttributeView ownerView) {
+ protected View(
+ FileLookup lookup, BasicFileAttributeView basicView, FileOwnerAttributeView ownerView) {
super(lookup);
this.basicView = checkNotNull(basicView);
this.ownerView = checkNotNull(ownerView);
diff --git a/jimfs/src/main/java/com/google/common/jimfs/RegularFile.java b/jimfs/src/main/java/com/google/common/jimfs/RegularFile.java
index 04b8751..21ce9d6 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/RegularFile.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/RegularFile.java
@@ -411,8 +411,7 @@
* @throws IOException if the file needs more blocks but the disk is full or if reading from src
* throws an exception
*/
- public long transferFrom(
- ReadableByteChannel src, long pos, long count) throws IOException {
+ public long transferFrom(ReadableByteChannel src, long pos, long count) throws IOException {
prepareForWrite(pos, 0); // don't assume the full count bytes will be written
if (count == 0) {
@@ -445,7 +444,8 @@
}
if (read != -1) {
- outer: while (remaining > 0) {
+ outer:
+ while (remaining > 0) {
block = blockForWrite(++blockIndex);
buf = ByteBuffer.wrap(block, 0, length(remaining));
@@ -577,8 +577,7 @@
* equal to the current size. This for consistency with {@link FileChannel#transferTo}, which
* this method is primarily intended as an implementation of.
*/
- public long transferTo(
- long pos, long count, WritableByteChannel dest) throws IOException {
+ public long transferTo(long pos, long count, WritableByteChannel dest) throws IOException {
long bytesToRead = bytesToRead(pos, count);
if (bytesToRead > 0) {
diff --git a/jimfs/src/main/java/com/google/common/jimfs/SystemJimfsFileSystemProvider.java b/jimfs/src/main/java/com/google/common/jimfs/SystemJimfsFileSystemProvider.java
index 1d1f2a0..c89fa76 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/SystemJimfsFileSystemProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/SystemJimfsFileSystemProvider.java
@@ -86,9 +86,8 @@
* garbage collected just need to ensure they hold a reference to it somewhere for as long as they
* need it to stick around.
*/
- private static final ConcurrentMap<URI, FileSystem> fileSystems = new MapMaker()
- .weakValues()
- .makeMap();
+ private static final ConcurrentMap<URI, FileSystem> fileSystems =
+ new MapMaker().weakValues().makeMap();
@Override
public String getScheme() {
@@ -97,11 +96,15 @@
@Override
public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
- checkArgument(uri.getScheme().equalsIgnoreCase(URI_SCHEME),
- "uri (%s) scheme must be '%s'", uri, URI_SCHEME);
- checkArgument(isValidFileSystemUri(uri),
- "uri (%s) may not have a path, query or fragment", uri);
- checkArgument(env.get(FILE_SYSTEM_KEY) instanceof FileSystem,
+ checkArgument(
+ uri.getScheme().equalsIgnoreCase(URI_SCHEME),
+ "uri (%s) scheme must be '%s'",
+ uri,
+ URI_SCHEME);
+ checkArgument(
+ isValidFileSystemUri(uri), "uri (%s) may not have a path, query or fragment", uri);
+ checkArgument(
+ env.get(FILE_SYSTEM_KEY) instanceof FileSystem,
"env map (%s) must contain key '%s' mapped to an instance of %s",
env, FILE_SYSTEM_KEY, FileSystem.class);
@@ -123,8 +126,10 @@
@Override
public Path getPath(URI uri) {
- checkArgument(URI_SCHEME.equalsIgnoreCase(uri.getScheme()),
- "uri scheme does not match this provider: %s", uri);
+ checkArgument(
+ URI_SCHEME.equalsIgnoreCase(uri.getScheme()),
+ "uri scheme does not match this provider: %s",
+ uri);
String path = uri.getPath();
checkArgument(!isNullOrEmpty(path), "uri must have a path: %s", uri);
@@ -149,8 +154,7 @@
private static URI toFileSystemUri(URI uri) {
try {
return new URI(
- uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(),
- null, null, null);
+ uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), null, null, null);
} catch (URISyntaxException e) {
throw new AssertionError(e);
}
@@ -194,14 +198,14 @@
}
@Override
- public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options,
- FileAttribute<?>... attrs) throws IOException {
+ public SeekableByteChannel newByteChannel(
+ Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
throw new UnsupportedOperationException();
}
@Override
- public DirectoryStream<Path> newDirectoryStream(Path dir,
- DirectoryStream.Filter<? super Path> filter) throws IOException {
+ public DirectoryStream<Path> newDirectoryStream(
+ Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException {
throw new UnsupportedOperationException();
}
@@ -246,14 +250,14 @@
}
@Override
- public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type,
- LinkOption... options) {
+ public <V extends FileAttributeView> V getFileAttributeView(
+ Path path, Class<V> type, LinkOption... options) {
throw new UnsupportedOperationException();
}
@Override
- public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type,
- LinkOption... options) throws IOException {
+ public <A extends BasicFileAttributes> A readAttributes(
+ Path path, Class<A> type, LinkOption... options) throws IOException {
throw new UnsupportedOperationException();
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/UnixAttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/UnixAttributeProvider.java
index b3bf055..552b161 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/UnixAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/UnixAttributeProvider.java
@@ -38,15 +38,8 @@
*/
final class UnixAttributeProvider extends AttributeProvider {
- private static final ImmutableSet<String> ATTRIBUTES = ImmutableSet.of(
- "uid",
- "ino",
- "dev",
- "nlink",
- "rdev",
- "ctime",
- "mode",
- "gid");
+ private static final ImmutableSet<String> ATTRIBUTES =
+ ImmutableSet.of("uid", "ino", "dev", "nlink", "rdev", "ctime", "mode", "gid");
private static final ImmutableSet<String> INHERITED_VIEWS =
ImmutableSet.of("basic", "owner", "posix");
@@ -75,8 +68,8 @@
}
@Override
- public UnixFileAttributeView view(FileLookup lookup,
- ImmutableMap<String, FileAttributeView> inheritedViews) {
+ public UnixFileAttributeView view(
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
// This method should not be called... and it cannot be called through the public APIs in
// java.nio.file since there is no public UnixFileAttributeView type.
throw new UnsupportedOperationException();
@@ -134,8 +127,7 @@
}
@Override
- public void set(
- File file, String view, String attribute, Object value, boolean create) {
+ public void set(File file, String view, String attribute, Object value, boolean create) {
throw unsettable(view, attribute);
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/UnixFileAttributeView.java b/jimfs/src/main/java/com/google/common/jimfs/UnixFileAttributeView.java
index cc326ff..9a51f72 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/UnixFileAttributeView.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/UnixFileAttributeView.java
@@ -23,5 +23,4 @@
*
* @author Colin Decker
*/
-interface UnixFileAttributeView extends FileAttributeView {
-}
+interface UnixFileAttributeView extends FileAttributeView {}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/UserDefinedAttributeProvider.java b/jimfs/src/main/java/com/google/common/jimfs/UserDefinedAttributeProvider.java
index ed3e006..2e8c3ae 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/UserDefinedAttributeProvider.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/UserDefinedAttributeProvider.java
@@ -80,8 +80,7 @@
}
@Override
- public void set(File file, String view, String attribute, Object value,
- boolean create) {
+ public void set(File file, String view, String attribute, Object value, boolean create) {
checkNotNull(value);
checkNotCreate(view, attribute, create);
@@ -106,8 +105,8 @@
}
@Override
- public UserDefinedFileAttributeView view(FileLookup lookup,
- ImmutableMap<String, FileAttributeView> inheritedViews) {
+ public UserDefinedFileAttributeView view(
+ FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) {
return new View(lookup);
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/UserLookupService.java b/jimfs/src/main/java/com/google/common/jimfs/UserLookupService.java
index 0bcb488..8ebec26 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/UserLookupService.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/UserLookupService.java
@@ -102,8 +102,8 @@
@Override
public boolean equals(Object obj) {
- return obj instanceof JimfsUserPrincipal &&
- getName().equals(((JimfsUserPrincipal) obj).getName());
+ return obj instanceof JimfsUserPrincipal
+ && getName().equals(((JimfsUserPrincipal) obj).getName());
}
}
@@ -118,8 +118,7 @@
@Override
public boolean equals(Object obj) {
- return obj instanceof JimfsGroupPrincipal &&
- ((JimfsGroupPrincipal) obj).name.equals(name);
+ return obj instanceof JimfsGroupPrincipal && ((JimfsGroupPrincipal) obj).name.equals(name);
}
}
}
diff --git a/jimfs/src/main/java/com/google/common/jimfs/WindowsPathType.java b/jimfs/src/main/java/com/google/common/jimfs/WindowsPathType.java
index dc28c8a..4600f8b 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/WindowsPathType.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/WindowsPathType.java
@@ -49,8 +49,7 @@
// root directory and then determine the working directory from there. The file system would
// still have one working directory; for the root that working directory is under, it is the
// working directory. For every other root, the root itself is the working directory.
- private static final Pattern WORKING_DIR_WITH_DRIVE = Pattern.compile(
- "^[a-zA-Z]:([^\\\\].*)?$");
+ private static final Pattern WORKING_DIR_WITH_DRIVE = Pattern.compile("^[a-zA-Z]:([^\\\\].*)?$");
/**
* Pattern for matching trailing spaces in file names.
@@ -67,16 +66,20 @@
path = path.replace('/', '\\');
if (WORKING_DIR_WITH_DRIVE.matcher(path).matches()) {
- throw new InvalidPathException(original, "Jimfs does not currently support the Windows "
- + "syntax for a relative path on a specific drive (e.g. \"C:foo\\bar\"");
+ throw new InvalidPathException(
+ original,
+ "Jimfs does not currently support the Windows syntax for a relative path "
+ + "on a specific drive (e.g. \"C:foo\\bar\"");
}
String root;
if (path.startsWith("\\\\")) {
root = parseUncRoot(path, original);
} else if (path.startsWith("\\")) {
- throw new InvalidPathException(original, "Jimfs does not currently support the Windows "
- + "syntax for an absolute path on the current drive (e.g. \"\\foo\\bar\"");
+ throw new InvalidPathException(
+ original,
+ "Jimfs does not currently support the Windows syntax for an absolute path "
+ + "on the current drive (e.g. \"\\foo\\bar\"");
} else {
root = parseDriveRoot(path);
}
@@ -109,8 +112,7 @@
/**
* Pattern for matching UNC \\host\share root syntax.
*/
- private static final Pattern UNC_ROOT = Pattern.compile(
- "^(\\\\\\\\)([^\\\\]+)?(\\\\[^\\\\]+)?");
+ private static final Pattern UNC_ROOT = Pattern.compile("^(\\\\\\\\)([^\\\\]+)?(\\\\[^\\\\]+)?");
/**
* Parse the root of a UNC-style path, throwing an exception if the path does not start with
diff --git a/jimfs/src/main/java/com/google/common/jimfs/package-info.java b/jimfs/src/main/java/com/google/common/jimfs/package-info.java
index 8d9d6f4..1c191eb 100644
--- a/jimfs/src/main/java/com/google/common/jimfs/package-info.java
+++ b/jimfs/src/main/java/com/google/common/jimfs/package-info.java
@@ -22,4 +22,4 @@
@ParametersAreNonnullByDefault
package com.google.common.jimfs;
-import javax.annotation.ParametersAreNonnullByDefault;
\ No newline at end of file
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/jimfs/src/test/java/com/google/common/jimfs/AbstractAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/AbstractAttributeProviderTest.java
index ab68ab4..efca1a2 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AbstractAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AbstractAttributeProviderTest.java
@@ -97,8 +97,7 @@
}
}
- protected void assertContainsAll(
- File file, ImmutableMap<String, Object> expectedAttributes) {
+ protected void assertContainsAll(File file, ImmutableMap<String, Object> expectedAttributes) {
for (Map.Entry<String, Object> entry : expectedAttributes.entrySet()) {
String attribute = entry.getKey();
Object value = entry.getValue();
diff --git a/jimfs/src/test/java/com/google/common/jimfs/AbstractPathMatcherTest.java b/jimfs/src/test/java/com/google/common/jimfs/AbstractPathMatcherTest.java
index 2995b04..9748ece 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AbstractPathMatcherTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AbstractPathMatcherTest.java
@@ -60,14 +60,16 @@
try {
matcher(pattern);
fail();
- } catch (PatternSyntaxException expected) {}
+ } catch (PatternSyntaxException expected) {
+ }
try {
PathMatcher real = realMatcher(pattern);
if (real != null) {
fail();
}
- } catch (PatternSyntaxException expected) {}
+ } catch (PatternSyntaxException expected) {
+ }
}
protected final PatternAsserter assertThat(String pattern) {
@@ -78,8 +80,7 @@
private final PathMatcher matcher;
- @Nullable
- private final PathMatcher realMatcher;
+ @Nullable private final PathMatcher realMatcher;
PatternAsserter(String pattern) {
this.matcher = matcher(pattern);
@@ -88,11 +89,12 @@
PatternAsserter matches(String... paths) {
for (String path : paths) {
- assertTrue("matcher '" + matcher + "' did not match '" + path + "'",
- matcher.matches(fake(path)));
+ assertTrue(
+ "matcher '" + matcher + "' did not match '" + path + "'", matcher.matches(fake(path)));
if (realMatcher != null) {
Path realPath = Paths.get(path);
- assertTrue("real matcher '" + realMatcher + "' did not match '" + realPath + "'",
+ assertTrue(
+ "real matcher '" + realMatcher + "' did not match '" + realPath + "'",
realMatcher.matches(realPath));
}
}
@@ -101,11 +103,13 @@
PatternAsserter doesNotMatch(String... paths) {
for (String path : paths) {
- assertFalse("glob '" + matcher + "' should not have matched '" + path + "'",
+ assertFalse(
+ "glob '" + matcher + "' should not have matched '" + path + "'",
matcher.matches(fake(path)));
if (realMatcher != null) {
Path realPath = Paths.get(path);
- assertFalse("real matcher '" + realMatcher + "' matched '" + realPath + "'",
+ assertFalse(
+ "real matcher '" + realMatcher + "' matched '" + realPath + "'",
realMatcher.matches(realPath));
}
}
@@ -229,8 +233,9 @@
}
@Override
- public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events,
- WatchEvent.Modifier... modifiers) throws IOException {
+ public WatchKey register(
+ WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)
+ throws IOException {
return null;
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/AbstractWatchServiceTest.java b/jimfs/src/test/java/com/google/common/jimfs/AbstractWatchServiceTest.java
index c21596e..b6cba55 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AbstractWatchServiceTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AbstractWatchServiceTest.java
@@ -82,8 +82,8 @@
@Test
public void testPostEvent() throws IOException {
- AbstractWatchService.Key key = watcher.register(
- new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
+ AbstractWatchService.Key key =
+ watcher.register(new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
AbstractWatchService.Event<Path> event =
new AbstractWatchService.Event<>(ENTRY_CREATE, 1, null);
@@ -105,8 +105,8 @@
@Test
public void testKeyStates() throws IOException {
- AbstractWatchService.Key key = watcher.register(
- new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
+ AbstractWatchService.Key key =
+ watcher.register(new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
AbstractWatchService.Event<Path> event =
new AbstractWatchService.Event<>(ENTRY_CREATE, 1, null);
@@ -144,8 +144,8 @@
@Test
public void testKeyRequeuedOnResetIfEventsArePending() throws IOException {
- AbstractWatchService.Key key = watcher.register(
- new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
+ AbstractWatchService.Key key =
+ watcher.register(new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
key.post(new AbstractWatchService.Event<>(ENTRY_CREATE, 1, null));
key.signal();
@@ -164,8 +164,8 @@
@Test
public void testOverflow() throws IOException {
- AbstractWatchService.Key key = watcher.register(
- new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
+ AbstractWatchService.Key key =
+ watcher.register(new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
for (int i = 0; i < AbstractWatchService.Key.MAX_QUEUE_SIZE + 10; i++) {
key.post(new AbstractWatchService.Event<>(ENTRY_CREATE, 1, null));
}
@@ -185,8 +185,8 @@
@Test
public void testResetAfterCancelReturnsFalse() throws IOException {
- AbstractWatchService.Key key = watcher.register(
- new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
+ AbstractWatchService.Key key =
+ watcher.register(new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
key.signal();
key.cancel();
assertThat(key.reset()).isFalse();
@@ -194,10 +194,10 @@
@Test
public void testClosedWatcher() throws IOException, InterruptedException {
- AbstractWatchService.Key key1 = watcher.register(
- new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
- AbstractWatchService.Key key2 = watcher.register(
- new StubWatchable(), ImmutableSet.of(ENTRY_MODIFY));
+ AbstractWatchService.Key key1 =
+ watcher.register(new StubWatchable(), ImmutableSet.of(ENTRY_CREATE));
+ AbstractWatchService.Key key2 =
+ watcher.register(new StubWatchable(), ImmutableSet.of(ENTRY_MODIFY));
assertThat(key1.isValid()).isTrue();
assertThat(key2.isValid()).isTrue();
@@ -212,22 +212,26 @@
try {
watcher.poll();
fail();
- } catch (ClosedWatchServiceException expected) {}
+ } catch (ClosedWatchServiceException expected) {
+ }
try {
watcher.poll(10, SECONDS);
fail();
- } catch (ClosedWatchServiceException expected) {}
+ } catch (ClosedWatchServiceException expected) {
+ }
try {
watcher.take();
fail();
- } catch (ClosedWatchServiceException expected) {}
+ } catch (ClosedWatchServiceException expected) {
+ }
try {
watcher.register(new StubWatchable(), ImmutableList.<WatchEvent.Kind<?>>of());
fail();
- } catch (ClosedWatchServiceException expected) {}
+ } catch (ClosedWatchServiceException expected) {
+ }
}
// TODO(cgdecker): Test concurrent use of Watcher
@@ -238,8 +242,9 @@
private static final class StubWatchable implements Watchable {
@Override
- public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events,
- WatchEvent.Modifier... modifiers) throws IOException {
+ public WatchKey register(
+ WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)
+ throws IOException {
return register(watcher, events);
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/AclAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/AclAttributeProviderTest.java
index f675c52..989fa9a 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AclAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AclAttributeProviderTest.java
@@ -51,20 +51,23 @@
private static final UserPrincipal USER = createUserPrincipal("user");
private static final UserPrincipal FOO = createUserPrincipal("foo");
- private static final ImmutableList<AclEntry> defaultAcl = new ImmutableList.Builder<AclEntry>()
- .add(AclEntry.newBuilder()
- .setType(ALLOW)
- .setFlags(DIRECTORY_INHERIT)
- .setPermissions(DELETE, APPEND_DATA)
- .setPrincipal(USER)
- .build())
- .add(AclEntry.newBuilder()
- .setType(ALLOW)
- .setFlags(DIRECTORY_INHERIT)
- .setPermissions(DELETE, APPEND_DATA)
- .setPrincipal(FOO)
- .build())
- .build();
+ private static final ImmutableList<AclEntry> defaultAcl =
+ new ImmutableList.Builder<AclEntry>()
+ .add(
+ AclEntry.newBuilder()
+ .setType(ALLOW)
+ .setFlags(DIRECTORY_INHERIT)
+ .setPermissions(DELETE, APPEND_DATA)
+ .setPrincipal(USER)
+ .build())
+ .add(
+ AclEntry.newBuilder()
+ .setType(ALLOW)
+ .setFlags(DIRECTORY_INHERIT)
+ .setPermissions(DELETE, APPEND_DATA)
+ .setPrincipal(FOO)
+ .build())
+ .build();
@Override
protected AclAttributeProvider createProvider() {
@@ -96,9 +99,11 @@
@Test
public void testView() throws IOException {
- AclFileAttributeView view = provider.view(fileLookup(),
- ImmutableMap.<String, FileAttributeView>of(
- "owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
+ AclFileAttributeView view =
+ provider.view(
+ fileLookup(),
+ ImmutableMap.<String, FileAttributeView>of(
+ "owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
assertNotNull(view);
assertThat(view.name()).isEqualTo("acl");
diff --git a/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java b/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java
index 18aef89..8977eda 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java
@@ -47,17 +47,18 @@
@Before
public void setUp() {
- ImmutableSet<AttributeProvider> providers = ImmutableSet.of(
- StandardAttributeProviders.get("basic"),
- StandardAttributeProviders.get("owner"),
- new TestAttributeProvider());
+ ImmutableSet<AttributeProvider> providers =
+ ImmutableSet.of(
+ StandardAttributeProviders.get("basic"),
+ StandardAttributeProviders.get("owner"),
+ new TestAttributeProvider());
service = new AttributeService(providers, ImmutableMap.<String, Object>of());
}
@Test
public void testSupportedFileAttributeViews() {
- assertThat(service.supportedFileAttributeViews()).isEqualTo(
- ImmutableSet.of("basic", "test", "owner"));
+ assertThat(service.supportedFileAttributeViews())
+ .isEqualTo(ImmutableSet.of("basic", "test", "owner"));
}
@Test
@@ -132,8 +133,8 @@
File file = Directory.create(0);
service.setAttribute(file, "test:lastModifiedTime", FileTime.fromMillis(0), false);
assertThat(file.getAttribute("test", "lastModifiedTime")).isNull();
- assertThat(service.getAttribute(file, "basic:lastModifiedTime")).isEqualTo(
- FileTime.fromMillis(0));
+ assertThat(service.getAttribute(file, "basic:lastModifiedTime"))
+ .isEqualTo(FileTime.fromMillis(0));
}
@Test
@@ -235,20 +236,19 @@
final File file = Directory.create(0);
service.setInitialAttributes(file);
- FileLookup fileLookup = new FileLookup() {
- @Override
- public File lookup() throws IOException {
- return file;
- }
- };
+ FileLookup fileLookup =
+ new FileLookup() {
+ @Override
+ public File lookup() throws IOException {
+ return file;
+ }
+ };
- assertThat(service.getFileAttributeView(fileLookup, TestAttributeView.class))
- .isNotNull();
- assertThat(service.getFileAttributeView(fileLookup, BasicFileAttributeView.class))
- .isNotNull();
+ assertThat(service.getFileAttributeView(fileLookup, TestAttributeView.class)).isNotNull();
+ assertThat(service.getFileAttributeView(fileLookup, BasicFileAttributeView.class)).isNotNull();
- TestAttributes attrs
- = service.getFileAttributeView(fileLookup, TestAttributeView.class).readAttributes();
+ TestAttributes attrs =
+ service.getFileAttributeView(fileLookup, TestAttributeView.class).readAttributes();
assertThat(attrs.foo()).isEqualTo("hello");
assertThat(attrs.bar()).isEqualTo(0);
assertThat(attrs.baz()).isEqualTo(1);
@@ -257,14 +257,14 @@
@Test
public void testGetFileAttributeView_isNullForUnsupportedView() {
final File file = Directory.create(0);
- FileLookup fileLookup = new FileLookup() {
- @Override
- public File lookup() throws IOException {
- return file;
- }
- };
- assertThat(service.getFileAttributeView(fileLookup, PosixFileAttributeView.class))
- .isNull();
+ FileLookup fileLookup =
+ new FileLookup() {
+ @Override
+ public File lookup() throws IOException {
+ return file;
+ }
+ };
+ assertThat(service.getFileAttributeView(fileLookup, PosixFileAttributeView.class)).isNull();
}
@Test
@@ -273,44 +273,47 @@
service.setInitialAttributes(file);
ImmutableMap<String, Object> map = service.readAttributes(file, "test:foo,bar,baz");
- assertThat(map).isEqualTo(
- ImmutableMap.of(
- "foo", "hello",
- "bar", 0L,
- "baz", 1));
+ assertThat(map)
+ .isEqualTo(
+ ImmutableMap.of(
+ "foo", "hello",
+ "bar", 0L,
+ "baz", 1));
FileTime time = (FileTime) service.getAttribute(file, "basic:creationTime");
map = service.readAttributes(file, "test:*");
- assertThat(map).isEqualTo(
- ImmutableMap.<String, Object>builder()
- .put("foo", "hello")
- .put("bar", 0L)
- .put("baz", 1)
- .put("fileKey", 0)
- .put("isDirectory", true)
- .put("isRegularFile", false)
- .put("isSymbolicLink", false)
- .put("isOther", false)
- .put("size", 0L)
- .put("lastModifiedTime", time)
- .put("lastAccessTime", time)
- .put("creationTime", time)
- .build());
+ assertThat(map)
+ .isEqualTo(
+ ImmutableMap.<String, Object>builder()
+ .put("foo", "hello")
+ .put("bar", 0L)
+ .put("baz", 1)
+ .put("fileKey", 0)
+ .put("isDirectory", true)
+ .put("isRegularFile", false)
+ .put("isSymbolicLink", false)
+ .put("isOther", false)
+ .put("size", 0L)
+ .put("lastModifiedTime", time)
+ .put("lastAccessTime", time)
+ .put("creationTime", time)
+ .build());
map = service.readAttributes(file, "basic:*");
- assertThat(map).isEqualTo(
- ImmutableMap.<String, Object>builder()
- .put("fileKey", 0)
- .put("isDirectory", true)
- .put("isRegularFile", false)
- .put("isSymbolicLink", false)
- .put("isOther", false)
- .put("size", 0L)
- .put("lastModifiedTime", time)
- .put("lastAccessTime", time)
- .put("creationTime", time)
- .build());
+ assertThat(map)
+ .isEqualTo(
+ ImmutableMap.<String, Object>builder()
+ .put("fileKey", 0)
+ .put("isDirectory", true)
+ .put("isRegularFile", false)
+ .put("isSymbolicLink", false)
+ .put("isOther", false)
+ .put("size", 0L)
+ .put("lastModifiedTime", time)
+ .put("lastAccessTime", time)
+ .put("creationTime", time)
+ .build());
}
@Test
diff --git a/jimfs/src/test/java/com/google/common/jimfs/BasicAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/BasicAttributeProviderTest.java
index b32213e..38c3fdd 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/BasicAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/BasicAttributeProviderTest.java
@@ -37,8 +37,8 @@
* @author Colin Decker
*/
@RunWith(JUnit4.class)
-public class BasicAttributeProviderTest extends
- AbstractAttributeProviderTest<BasicAttributeProvider> {
+public class BasicAttributeProviderTest
+ extends AbstractAttributeProviderTest<BasicAttributeProvider> {
@Override
protected BasicAttributeProvider createProvider() {
@@ -52,8 +52,16 @@
@Test
public void testSupportedAttributes() {
- assertSupportsAll("fileKey", "size", "isDirectory", "isRegularFile", "isSymbolicLink",
- "isOther", "creationTime", "lastModifiedTime", "lastAccessTime");
+ assertSupportsAll(
+ "fileKey",
+ "size",
+ "isDirectory",
+ "isRegularFile",
+ "isSymbolicLink",
+ "isOther",
+ "creationTime",
+ "lastModifiedTime",
+ "lastAccessTime");
}
@Test
@@ -63,7 +71,8 @@
assertThat(time).isEqualTo(file.getLastAccessTime());
assertThat(time).isEqualTo(file.getLastModifiedTime());
- assertContainsAll(file,
+ assertContainsAll(
+ file,
ImmutableMap.<String, Object>builder()
.put("fileKey", 0)
.put("size", 0L)
diff --git a/jimfs/src/test/java/com/google/common/jimfs/ByteBufferChannel.java b/jimfs/src/test/java/com/google/common/jimfs/ByteBufferChannel.java
index fac8381..d72c030 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/ByteBufferChannel.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/ByteBufferChannel.java
@@ -96,6 +96,5 @@
}
@Override
- public void close() throws IOException {
- }
+ public void close() throws IOException {}
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/ClassLoaderTest.java b/jimfs/src/test/java/com/google/common/jimfs/ClassLoaderTest.java
index a97bb39..eee3d08 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/ClassLoaderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/ClassLoaderTest.java
@@ -58,9 +58,9 @@
// Anything we can do if it isn't a URLClassLoader?
URLClassLoader urlLoader = (URLClassLoader) loader;
- ClassLoader separateLoader = new URLClassLoader(
- urlLoader.getURLs(),
- systemLoader.getParent()); // either null or the boostrap loader
+ ClassLoader separateLoader =
+ new URLClassLoader(
+ urlLoader.getURLs(), systemLoader.getParent()); // either null or the boostrap loader
Thread.currentThread().setContextClassLoader(separateLoader);
try {
@@ -88,8 +88,8 @@
// And for the heck of it, test the contents of the file that was created in
// createFileSystem too
- assertEquals("blah",
- Files.readAllLines(((FileSystem) fs).getPath("foo.txt"), UTF_8).get(0));
+ assertEquals(
+ "blah", Files.readAllLines(((FileSystem) fs).getPath("foo.txt"), UTF_8).get(0));
} finally {
Thread.currentThread().setContextClassLoader(contextLoader);
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java b/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
index 1885a75..727d20e 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
@@ -78,8 +78,8 @@
.containsExactlyElementsIn(ImmutableList.of(fs.getPath("/")))
.inOrder();
assertThatPath(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("/work"));
- assertThat(Iterables.getOnlyElement(fs.getFileStores()).getTotalSpace()).isEqualTo(
- 4L * 1024 * 1024 * 1024);
+ assertThat(Iterables.getOnlyElement(fs.getFileStores()).getTotalSpace())
+ .isEqualTo(4L * 1024 * 1024 * 1024);
assertThat(fs.supportedFileAttributeViews()).containsExactly("basic");
Files.createFile(fs.getPath("/foo"));
@@ -112,8 +112,8 @@
.containsExactlyElementsIn(ImmutableList.of(fs.getPath("/")))
.inOrder();
assertThatPath(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("/work"));
- assertThat(Iterables.getOnlyElement(fs.getFileStores()).getTotalSpace()).isEqualTo(
- 4L * 1024 * 1024 * 1024);
+ assertThat(Iterables.getOnlyElement(fs.getFileStores()).getTotalSpace())
+ .isEqualTo(4L * 1024 * 1024 * 1024);
assertThat(fs.supportedFileAttributeViews()).containsExactly("basic");
Files.createFile(fs.getPath("/foo"));
@@ -151,8 +151,8 @@
.containsExactlyElementsIn(ImmutableList.of(fs.getPath("C:\\")))
.inOrder();
assertThatPath(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("C:\\work"));
- assertThat(Iterables.getOnlyElement(fs.getFileStores()).getTotalSpace()).isEqualTo(
- 4L * 1024 * 1024 * 1024);
+ assertThat(Iterables.getOnlyElement(fs.getFileStores()).getTotalSpace())
+ .isEqualTo(4L * 1024 * 1024 * 1024);
assertThat(fs.supportedFileAttributeViews()).containsExactly("basic");
Files.createFile(fs.getPath("C:\\foo"));
@@ -168,20 +168,21 @@
public void testBuilder() {
AttributeProvider unixProvider = StandardAttributeProviders.get("unix");
- Configuration config = Configuration.builder(PathType.unix())
- .setRoots("/")
- .setWorkingDirectory("/hello/world")
- .setNameCanonicalNormalization(NFD, CASE_FOLD_UNICODE)
- .setNameDisplayNormalization(NFC)
- .setPathEqualityUsesCanonicalForm(true)
- .setBlockSize(10)
- .setMaxSize(100)
- .setMaxCacheSize(50)
- .setAttributeViews("basic", "posix")
- .addAttributeProvider(unixProvider)
- .setDefaultAttributeValue(
- "posix:permissions", PosixFilePermissions.fromString("---------"))
- .build();
+ Configuration config =
+ Configuration.builder(PathType.unix())
+ .setRoots("/")
+ .setWorkingDirectory("/hello/world")
+ .setNameCanonicalNormalization(NFD, CASE_FOLD_UNICODE)
+ .setNameDisplayNormalization(NFC)
+ .setPathEqualityUsesCanonicalForm(true)
+ .setBlockSize(10)
+ .setMaxSize(100)
+ .setMaxCacheSize(50)
+ .setAttributeViews("basic", "posix")
+ .addAttributeProvider(unixProvider)
+ .setDefaultAttributeValue(
+ "posix:permissions", PosixFilePermissions.fromString("---------"))
+ .build();
assertThat(config.pathType).isEqualTo(PathType.unix());
assertThat(config.roots).containsExactly("/");
@@ -200,19 +201,20 @@
@Test
public void testFileSystemForCustomConfiguration() throws IOException {
- Configuration config = Configuration.builder(PathType.unix())
- .setRoots("/")
- .setWorkingDirectory("/hello/world")
- .setNameCanonicalNormalization(NFD, CASE_FOLD_UNICODE)
- .setNameDisplayNormalization(NFC)
- .setPathEqualityUsesCanonicalForm(true)
- .setBlockSize(10)
- .setMaxSize(100)
- .setMaxCacheSize(50)
- .setAttributeViews("unix")
- .setDefaultAttributeValue(
- "posix:permissions", PosixFilePermissions.fromString("---------"))
- .build();
+ Configuration config =
+ Configuration.builder(PathType.unix())
+ .setRoots("/")
+ .setWorkingDirectory("/hello/world")
+ .setNameCanonicalNormalization(NFD, CASE_FOLD_UNICODE)
+ .setNameDisplayNormalization(NFC)
+ .setPathEqualityUsesCanonicalForm(true)
+ .setBlockSize(10)
+ .setMaxSize(100)
+ .setMaxCacheSize(50)
+ .setAttributeViews("unix")
+ .setDefaultAttributeValue(
+ "posix:permissions", PosixFilePermissions.fromString("---------"))
+ .build();
FileSystem fs = Jimfs.newFileSystem(config);
@@ -224,8 +226,8 @@
assertThat(fs.supportedFileAttributeViews()).containsExactly("basic", "owner", "posix", "unix");
Files.createFile(fs.getPath("/foo"));
- assertThat(Files.getAttribute(fs.getPath("/foo"), "posix:permissions")).isEqualTo(
- PosixFilePermissions.fromString("---------"));
+ assertThat(Files.getAttribute(fs.getPath("/foo"), "posix:permissions"))
+ .isEqualTo(PosixFilePermissions.fromString("---------"));
try {
Files.createFile(fs.getPath("/FOO"));
@@ -236,10 +238,12 @@
@Test
public void testToBuilder() {
- Configuration config = Configuration.unix().toBuilder()
- .setWorkingDirectory("/hello/world")
- .setAttributeViews("basic", "posix")
- .build();
+ Configuration config =
+ Configuration.unix()
+ .toBuilder()
+ .setWorkingDirectory("/hello/world")
+ .setAttributeViews("basic", "posix")
+ .build();
assertThat(config.pathType).isEqualTo(PathType.unix());
assertThat(config.roots).containsExactly("/");
@@ -294,7 +298,8 @@
assertIllegalNormalizations(CASE_FOLD_ASCII, CASE_FOLD_UNICODE);
}
- private static void assertIllegalNormalizations(PathNormalization first, PathNormalization... more) {
+ private static void assertIllegalNormalizations(
+ PathNormalization first, PathNormalization... more) {
try {
Configuration.builder(PathType.unix()).setNameCanonicalNormalization(first, more);
fail();
@@ -320,10 +325,12 @@
@Test // how's that for a name?
public void testCreateFileSystemFromConfigurationWithWorkingDirectoryNotUnderConfiguredRoot() {
try {
- Jimfs.newFileSystem(Configuration.windows().toBuilder()
- .setRoots("C:\\", "D:\\")
- .setWorkingDirectory("E:\\foo")
- .build());
+ Jimfs.newFileSystem(
+ Configuration.windows()
+ .toBuilder()
+ .setRoots("C:\\", "D:\\")
+ .setWorkingDirectory("E:\\foo")
+ .build());
fail();
} catch (IllegalArgumentException expected) {
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java b/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java
index 459c7d4..e6236cb 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java
@@ -244,9 +244,9 @@
@Test
public void testInitialState() {
assertThat(dir.entryCount()).isEqualTo(2);
- assertThat(ImmutableSet.copyOf(dir)).containsExactly(
- new DirectoryEntry(dir, Name.SELF, dir),
- new DirectoryEntry(dir, Name.PARENT, root));
+ assertThat(ImmutableSet.copyOf(dir))
+ .containsExactly(
+ new DirectoryEntry(dir, Name.SELF, dir), new DirectoryEntry(dir, Name.PARENT, root));
assertThat(dir.get(Name.simple("foo"))).isNull();
}
@@ -261,8 +261,7 @@
dir.put(entry("bar"));
assertThat(dir.entryCount()).isEqualTo(4);
- assertThat(ImmutableSet.copyOf(dir))
- .containsAllOf(entry("foo"), entry("bar"));
+ assertThat(ImmutableSet.copyOf(dir)).containsAllOf(entry("foo"), entry("bar"));
assertThat(dir.get(Name.simple("foo"))).isEqualTo(entry("foo"));
assertThat(dir.get(Name.simple("bar"))).isEqualTo(entry("bar"));
}
@@ -274,7 +273,8 @@
try {
dir.put(entry("foo"));
fail();
- } catch (IllegalArgumentException expected) {}
+ } catch (IllegalArgumentException expected) {
+ }
}
@Test
@@ -285,10 +285,11 @@
dir.remove(Name.simple("foo"));
assertThat(dir.entryCount()).isEqualTo(3);
- assertThat(ImmutableSet.copyOf(dir)).containsExactly(
- entry("bar"),
- new DirectoryEntry(dir, Name.SELF, dir),
- new DirectoryEntry(dir, Name.PARENT, root));
+ assertThat(ImmutableSet.copyOf(dir))
+ .containsExactly(
+ entry("bar"),
+ new DirectoryEntry(dir, Name.SELF, dir),
+ new DirectoryEntry(dir, Name.PARENT, root));
assertThat(dir.get(Name.simple("foo"))).isNull();
assertThat(dir.get(Name.simple("bar"))).isEqualTo(entry("bar"));
diff --git a/jimfs/src/test/java/com/google/common/jimfs/DosAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/DosAttributeProviderTest.java
index 6de2d2f..af830ee 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/DosAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/DosAttributeProviderTest.java
@@ -72,9 +72,11 @@
@Test
public void testView() throws IOException {
- DosFileAttributeView view = provider.view(fileLookup(),
- ImmutableMap.<String, FileAttributeView>of(
- "basic", new BasicAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
+ DosFileAttributeView view =
+ provider.view(
+ fileLookup(),
+ ImmutableMap.<String, FileAttributeView>of(
+ "basic", new BasicAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
assertNotNull(view);
assertThat(view.name()).isEqualTo("dos");
diff --git a/jimfs/src/test/java/com/google/common/jimfs/FileSystemStateTest.java b/jimfs/src/test/java/com/google/common/jimfs/FileSystemStateTest.java
index b2bb069..378b4c0 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/FileSystemStateTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/FileSystemStateTest.java
@@ -99,8 +99,8 @@
@Test
public void testClose_multipleRegisteredResourcesAreClosed() throws IOException {
- List<TestCloseable> resources = ImmutableList.of(
- new TestCloseable(), new TestCloseable(), new TestCloseable());
+ List<TestCloseable> resources =
+ ImmutableList.of(new TestCloseable(), new TestCloseable(), new TestCloseable());
for (TestCloseable resource : resources) {
state.register(resource);
assertFalse(resource.closed);
@@ -113,14 +113,15 @@
@Test
public void testClose_resourcesThatThrowOnClose() {
- List<TestCloseable> resources = ImmutableList.of(
- new TestCloseable(),
- new ThrowsOnClose("a"),
- new TestCloseable(),
- new ThrowsOnClose("b"),
- new ThrowsOnClose("c"),
- new TestCloseable(),
- new TestCloseable());
+ List<TestCloseable> resources =
+ ImmutableList.of(
+ new TestCloseable(),
+ new ThrowsOnClose("a"),
+ new TestCloseable(),
+ new ThrowsOnClose("b"),
+ new ThrowsOnClose("c"),
+ new TestCloseable(),
+ new TestCloseable());
for (TestCloseable resource : resources) {
state.register(resource);
assertFalse(resource.closed);
@@ -132,10 +133,9 @@
} catch (IOException expected) {
Throwable[] suppressed = expected.getSuppressed();
assertEquals(2, suppressed.length);
- ImmutableSet<String> messages = ImmutableSet.of(
- expected.getMessage(),
- suppressed[0].getMessage(),
- suppressed[1].getMessage());
+ ImmutableSet<String> messages =
+ ImmutableSet.of(
+ expected.getMessage(), suppressed[0].getMessage(), suppressed[1].getMessage());
assertEquals(ImmutableSet.of("a", "b", "c"), messages);
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/FileTreeTest.java b/jimfs/src/test/java/com/google/common/jimfs/FileTreeTest.java
index 790fe20..0cac0ad 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/FileTreeTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/FileTreeTest.java
@@ -76,37 +76,39 @@
* a path like "$foo/bar" and one like "/$foo/bar". They would become "/$foo/bar" and
* "//$foo/bar" respectively.
*/
- private final PathService pathService = PathServiceTest.fakePathService(
- new PathType(true, '/') {
- @Override
- public ParseResult parsePath(String path) {
- String root = null;
- if (path.matches("^[/$!].*")) {
- root = path.substring(0, 1);
- path = path.substring(1);
- }
- return new ParseResult(root, Splitter.on('/').omitEmptyStrings().split(path));
- }
+ private final PathService pathService =
+ PathServiceTest.fakePathService(
+ new PathType(true, '/') {
+ @Override
+ public ParseResult parsePath(String path) {
+ String root = null;
+ if (path.matches("^[/$!].*")) {
+ root = path.substring(0, 1);
+ path = path.substring(1);
+ }
+ return new ParseResult(root, Splitter.on('/').omitEmptyStrings().split(path));
+ }
- @Override
- public String toString(@Nullable String root, Iterable<String> names) {
- root = Strings.nullToEmpty(root);
- return root + Joiner.on('/').join(names);
- }
+ @Override
+ public String toString(@Nullable String root, Iterable<String> names) {
+ root = Strings.nullToEmpty(root);
+ return root + Joiner.on('/').join(names);
+ }
- @Override
- public String toUriPath(String root, Iterable<String> names, boolean directory) {
- // need to add extra / to differentiate between paths "/$foo/bar" and "$foo/bar".
- return "/" + toString(root, names);
- }
+ @Override
+ public String toUriPath(String root, Iterable<String> names, boolean directory) {
+ // need to add extra / to differentiate between paths "/$foo/bar" and "$foo/bar".
+ return "/" + toString(root, names);
+ }
- @Override
- public ParseResult parseUriPath(String uriPath) {
- checkArgument(uriPath.matches("^/[/$!].*"),
- "uriPath (%s) must start with // or /$ or /!");
- return parsePath(uriPath.substring(1)); // skip leading /
- }
- }, false);
+ @Override
+ public ParseResult parseUriPath(String uriPath) {
+ checkArgument(
+ uriPath.matches("^/[/$!].*"), "uriPath (%s) must start with // or /$ or /!");
+ return parsePath(uriPath.substring(1)); // skip leading /
+ }
+ },
+ false);
private FileTree fileTree;
private File workingDirectory;
diff --git a/jimfs/src/test/java/com/google/common/jimfs/HeapDiskTest.java b/jimfs/src/test/java/com/google/common/jimfs/HeapDiskTest.java
index e542952..1736d91 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/HeapDiskTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/HeapDiskTest.java
@@ -56,11 +56,13 @@
@Test
public void testInitialSettings_fromConfiguration() {
- Configuration config = Configuration.unix().toBuilder()
- .setBlockSize(4)
- .setMaxSize(99) // not a multiple of 4
- .setMaxCacheSize(25)
- .build();
+ Configuration config =
+ Configuration.unix()
+ .toBuilder()
+ .setBlockSize(4)
+ .setMaxSize(99) // not a multiple of 4
+ .setMaxCacheSize(25)
+ .build();
HeapDisk disk = new HeapDisk(config);
@@ -207,7 +209,8 @@
try {
disk.allocate(blocks, 1);
fail();
- } catch (IOException expected) {}
+ } catch (IOException expected) {
+ }
}
@Test
@@ -220,7 +223,8 @@
try {
disk.allocate(blocks2, 5);
fail();
- } catch (IOException expected) {}
+ } catch (IOException expected) {
+ }
assertThat(blocks2.blockCount()).isEqualTo(0);
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java b/jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java
index 17ed975..03b3545 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java
@@ -63,9 +63,11 @@
private static JimfsAsynchronousFileChannel channel(
RegularFile file, ExecutorService executor, OpenOption... options) throws IOException {
- JimfsFileChannel channel = new JimfsFileChannel(file,
- Options.getOptionsForChannel(ImmutableSet.copyOf(options)),
- new FileSystemState(Runnables.doNothing()));
+ JimfsFileChannel channel =
+ new JimfsFileChannel(
+ file,
+ Options.getOptionsForChannel(ImmutableSet.copyOf(options)),
+ new FileSystemState(Runnables.doNothing()));
return new JimfsAsynchronousFileChannel(channel, executor);
}
@@ -129,18 +131,20 @@
final CountDownLatch handlerLatch = new CountDownLatch(1);
final AtomicBoolean gotAsyncCloseException = new AtomicBoolean(false);
- channel.write(ByteBuffer.allocate(10), 0, null, new CompletionHandler<Integer, Object>() {
- @Override
- public void completed(Integer result, Object attachment) {
- handlerLatch.countDown();
- }
+ channel.write(
+ ByteBuffer.allocate(10), 0, null,
+ new CompletionHandler<Integer, Object>() {
+ @Override
+ public void completed(Integer result, Object attachment) {
+ handlerLatch.countDown();
+ }
- @Override
- public void failed(Throwable exc, Object attachment) {
- gotAsyncCloseException.set(exc instanceof AsynchronousCloseException);
- handlerLatch.countDown();
- }
- });
+ @Override
+ public void failed(Throwable exc, Object attachment) {
+ gotAsyncCloseException.set(exc instanceof AsynchronousCloseException);
+ handlerLatch.countDown();
+ }
+ });
// give enough time to ensure both writes start blocking
Uninterruptibles.sleepUninterruptibly(10, MILLISECONDS);
@@ -176,18 +180,20 @@
final CountDownLatch handlerLatch = new CountDownLatch(1);
final AtomicBoolean gotAsyncCloseException = new AtomicBoolean(false);
- channel.read(ByteBuffer.allocate(10), 0, null, new CompletionHandler<Integer, Object>() {
- @Override
- public void completed(Integer result, Object attachment) {
- handlerLatch.countDown();
- }
+ channel.read(
+ ByteBuffer.allocate(10), 0, null,
+ new CompletionHandler<Integer, Object>() {
+ @Override
+ public void completed(Integer result, Object attachment) {
+ handlerLatch.countDown();
+ }
- @Override
- public void failed(Throwable exc, Object attachment) {
- gotAsyncCloseException.set(exc instanceof AsynchronousCloseException);
- handlerLatch.countDown();
- }
- });
+ @Override
+ public void failed(Throwable exc, Object attachment) {
+ gotAsyncCloseException.set(exc instanceof AsynchronousCloseException);
+ handlerLatch.countDown();
+ }
+ });
// give enough time to ensure both reads start blocking
Uninterruptibles.sleepUninterruptibly(10, MILLISECONDS);
@@ -217,19 +223,21 @@
final AtomicInteger resultHolder = new AtomicInteger(-1);
final AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
final CountDownLatch completionLatch = new CountDownLatch(1);
- channel.read(buf, 0, null, new CompletionHandler<Integer, Object>() {
- @Override
- public void completed(Integer result, Object attachment) {
- resultHolder.set(result);
- completionLatch.countDown();
- }
+ channel.read(
+ buf, 0, null,
+ new CompletionHandler<Integer, Object>() {
+ @Override
+ public void completed(Integer result, Object attachment) {
+ resultHolder.set(result);
+ completionLatch.countDown();
+ }
- @Override
- public void failed(Throwable exc, Object attachment) {
- exceptionHolder.set(exc);
- completionLatch.countDown();
- }
- });
+ @Override
+ public void failed(Throwable exc, Object attachment) {
+ exceptionHolder.set(exc);
+ completionLatch.countDown();
+ }
+ });
completionLatch.await();
Throwable exception = exceptionHolder.get();
@@ -248,19 +256,21 @@
final AtomicInteger resultHolder = new AtomicInteger(-1);
final AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
final CountDownLatch completionLatch = new CountDownLatch(1);
- asyncChannel.write(buf, 0, null, new CompletionHandler<Integer, Object>() {
- @Override
- public void completed(Integer result, Object attachment) {
- resultHolder.set(result);
- completionLatch.countDown();
- }
+ asyncChannel.write(
+ buf, 0, null,
+ new CompletionHandler<Integer, Object>() {
+ @Override
+ public void completed(Integer result, Object attachment) {
+ resultHolder.set(result);
+ completionLatch.countDown();
+ }
- @Override
- public void failed(Throwable exc, Object attachment) {
- exceptionHolder.set(exc);
- completionLatch.countDown();
- }
- });
+ @Override
+ public void failed(Throwable exc, Object attachment) {
+ exceptionHolder.set(exc);
+ completionLatch.countDown();
+ }
+ });
completionLatch.await();
Throwable exception = exceptionHolder.get();
@@ -278,19 +288,21 @@
final AtomicReference<FileLock> lockHolder = new AtomicReference<>();
final AtomicReference<Throwable> exceptionHolder = new AtomicReference<>();
final CountDownLatch completionLatch = new CountDownLatch(1);
- channel.lock(0, 10, true, null, new CompletionHandler<FileLock, Object>() {
- @Override
- public void completed(FileLock result, Object attachment) {
- lockHolder.set(result);
- completionLatch.countDown();
- }
+ channel.lock(
+ 0, 10, true, null,
+ new CompletionHandler<FileLock, Object>() {
+ @Override
+ public void completed(FileLock result, Object attachment) {
+ lockHolder.set(result);
+ completionLatch.countDown();
+ }
- @Override
- public void failed(Throwable exc, Object attachment) {
- exceptionHolder.set(exc);
- completionLatch.countDown();
- }
- });
+ @Override
+ public void failed(Throwable exc, Object attachment) {
+ exceptionHolder.set(exc);
+ completionLatch.countDown();
+ }
+ });
completionLatch.await();
Throwable exception = exceptionHolder.get();
diff --git a/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java b/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java
index 33407b6..029c660 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java
@@ -62,7 +62,6 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-
/**
* Most of the behavior of {@link JimfsFileChannel} is handled by the {@link RegularFile}
* implementations, so the thorough tests of that are in {@link RegularFileTest}. This mostly
@@ -73,9 +72,9 @@
@RunWith(JUnit4.class)
public class JimfsFileChannelTest {
- private static FileChannel channel(RegularFile file, OpenOption... options)
- throws IOException {
- return new JimfsFileChannel(file,
+ private static FileChannel channel(RegularFile file, OpenOption... options) throws IOException {
+ return new JimfsFileChannel(
+ file,
Options.getOptionsForChannel(ImmutableSet.copyOf(options)),
new FileSystemState(Runnables.doNothing()));
}
@@ -111,13 +110,13 @@
assertEquals(10, channel.position());
buf.flip();
- assertEquals(10, channel.read(new ByteBuffer[]{buf, buf2}));
+ assertEquals(10, channel.read(new ByteBuffer[] {buf, buf2}));
assertEquals(20, channel.position());
buf.flip();
buf2.flip();
file.write(20, new byte[10], 0, 10);
- assertEquals(10, channel.read(new ByteBuffer[]{buf, buf2}, 0, 2));
+ assertEquals(10, channel.read(new ByteBuffer[] {buf, buf2}, 0, 2));
assertEquals(30, channel.position());
buf.flip();
@@ -141,12 +140,12 @@
assertEquals(10, channel.position());
buf.flip();
- assertEquals(20, channel.write(new ByteBuffer[]{buf, buf2}));
+ assertEquals(20, channel.write(new ByteBuffer[] {buf, buf2}));
assertEquals(30, channel.position());
buf.flip();
buf2.flip();
- assertEquals(20, channel.write(new ByteBuffer[]{buf, buf2}, 0, 2));
+ assertEquals(20, channel.write(new ByteBuffer[] {buf, buf2}, 0, 2));
assertEquals(50, channel.position());
buf.flip();
@@ -168,13 +167,13 @@
buf.flip();
channel.position(0);
- assertEquals(20, channel.write(new ByteBuffer[]{buf, buf2}));
+ assertEquals(20, channel.write(new ByteBuffer[] {buf, buf2}));
assertEquals(30, channel.position());
buf.flip();
buf2.flip();
channel.position(0);
- assertEquals(20, channel.write(new ByteBuffer[]{buf, buf2}, 0, 2));
+ assertEquals(20, channel.write(new ByteBuffer[] {buf, buf2}, 0, 2));
assertEquals(50, channel.position());
buf.flip();
@@ -230,8 +229,11 @@
@Test
public void testFileTimeUpdates() throws IOException {
RegularFile file = regularFile(10);
- FileChannel channel = new JimfsFileChannel(file, ImmutableSet.<OpenOption>of(READ, WRITE),
- new FileSystemState(Runnables.doNothing()));
+ FileChannel channel =
+ new JimfsFileChannel(
+ file,
+ ImmutableSet.<OpenOption>of(READ, WRITE),
+ new FileSystemState(Runnables.doNothing()));
// accessed
long accessTime = file.getLastAccessTime();
@@ -249,13 +251,13 @@
accessTime = file.getLastAccessTime();
Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
- channel.read(new ByteBuffer[]{ByteBuffer.allocate(10)});
+ channel.read(new ByteBuffer[] {ByteBuffer.allocate(10)});
assertNotEquals(accessTime, file.getLastAccessTime());
accessTime = file.getLastAccessTime();
Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
- channel.read(new ByteBuffer[]{ByteBuffer.allocate(10)}, 0, 1);
+ channel.read(new ByteBuffer[] {ByteBuffer.allocate(10)}, 0, 1);
assertNotEquals(accessTime, file.getLastAccessTime());
accessTime = file.getLastAccessTime();
@@ -280,13 +282,13 @@
modifiedTime = file.getLastModifiedTime();
Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
- channel.write(new ByteBuffer[]{ByteBuffer.allocate(10)});
+ channel.write(new ByteBuffer[] {ByteBuffer.allocate(10)});
assertNotEquals(modifiedTime, file.getLastModifiedTime());
modifiedTime = file.getLastModifiedTime();
Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
- channel.write(new ByteBuffer[]{ByteBuffer.allocate(10)}, 0, 1);
+ channel.write(new ByteBuffer[] {ByteBuffer.allocate(10)}, 0, 1);
assertNotEquals(modifiedTime, file.getLastModifiedTime());
modifiedTime = file.getLastModifiedTime();
@@ -365,13 +367,13 @@
}
try {
- channel.write(new ByteBuffer[]{buffer("111"), buffer("111")});
+ channel.write(new ByteBuffer[] {buffer("111"), buffer("111")});
fail();
} catch (ClosedChannelException expected) {
}
try {
- channel.write(new ByteBuffer[]{buffer("111"), buffer("111")}, 0, 2);
+ channel.write(new ByteBuffer[] {buffer("111"), buffer("111")}, 0, 2);
fail();
} catch (ClosedChannelException expected) {
}
@@ -401,13 +403,13 @@
}
try {
- channel.read(new ByteBuffer[]{buffer("111"), buffer("111")});
+ channel.read(new ByteBuffer[] {buffer("111"), buffer("111")});
fail();
} catch (ClosedChannelException expected) {
}
try {
- channel.read(new ByteBuffer[]{buffer("111"), buffer("111")}, 0, 2);
+ channel.read(new ByteBuffer[] {buffer("111"), buffer("111")}, 0, 2);
fail();
} catch (ClosedChannelException expected) {
}
@@ -438,13 +440,13 @@
}
try {
- channel.write(new ByteBuffer[]{buffer("111"), buffer("111")});
+ channel.write(new ByteBuffer[] {buffer("111"), buffer("111")});
fail();
} catch (NonWritableChannelException expected) {
}
try {
- channel.write(new ByteBuffer[]{buffer("111"), buffer("111")}, 0, 2);
+ channel.write(new ByteBuffer[] {buffer("111"), buffer("111")}, 0, 2);
fail();
} catch (NonWritableChannelException expected) {
}
@@ -463,6 +465,7 @@
try {
channel.lock(0, 10, false);
+ fail();
} catch (NonWritableChannelException expected) {
}
}
@@ -484,13 +487,13 @@
}
try {
- channel.read(new ByteBuffer[]{buffer("111"), buffer("111")});
+ channel.read(new ByteBuffer[] {buffer("111"), buffer("111")});
fail();
} catch (NonReadableChannelException expected) {
}
try {
- channel.read(new ByteBuffer[]{buffer("111"), buffer("111")}, 0, 2);
+ channel.read(new ByteBuffer[] {buffer("111"), buffer("111")}, 0, 2);
fail();
} catch (NonReadableChannelException expected) {
}
@@ -503,6 +506,7 @@
try {
channel.lock(0, 10, true);
+ fail();
} catch (NonReadableChannelException expected) {
}
}
@@ -717,18 +721,20 @@
// blocked on the lock that guards the position field and the specification that only one method
// on the channel will be in progress at a time. That lock is not interruptible, so we must
// interrupt this thread.
- Thread thread = new Thread(new Runnable() {
- @Override
- public void run() {
- threadStartLatch.countDown();
- try {
- channel.write(ByteBuffer.allocate(20));
- interruptException.set(null);
- } catch (Throwable e) {
- interruptException.set(e);
- }
- }
- });
+ Thread thread =
+ new Thread(
+ new Runnable() {
+ @Override
+ public void run() {
+ threadStartLatch.countDown();
+ try {
+ channel.write(ByteBuffer.allocate(20));
+ interruptException.set(null);
+ } catch (Throwable e) {
+ interruptException.set(e);
+ }
+ }
+ });
thread.start();
// let the thread start running
@@ -780,95 +786,115 @@
List<Future<?>> futures = new ArrayList<>();
final ByteBuffer buffer = ByteBuffer.allocate(10);
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.write(buffer);
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.write(buffer);
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.write(buffer, 0);
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.write(buffer, 0);
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.write(new ByteBuffer[] {buffer, buffer});
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.write(new ByteBuffer[] {buffer, buffer});
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.write(new ByteBuffer[] {buffer, buffer, buffer}, 0, 2);
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.write(new ByteBuffer[] {buffer, buffer, buffer}, 0, 2);
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.read(buffer);
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.read(buffer);
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.read(buffer, 0);
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.read(buffer, 0);
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.read(new ByteBuffer[] {buffer, buffer});
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.read(new ByteBuffer[] {buffer, buffer});
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.read(new ByteBuffer[] {buffer, buffer, buffer}, 0, 2);
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.read(new ByteBuffer[] {buffer, buffer, buffer}, 0, 2);
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.transferTo(0, 10, new ByteBufferChannel(buffer));
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.transferTo(0, 10, new ByteBufferChannel(buffer));
+ return null;
+ }
+ }));
- futures.add(executor.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- startLatch.countDown();
- channel.transferFrom(new ByteBufferChannel(buffer), 0, 10);
- return null;
- }
- }));
+ futures.add(
+ executor.submit(
+ new Callable<Object>() {
+ @Override
+ public Object call() throws Exception {
+ startLatch.countDown();
+ channel.transferFrom(new ByteBufferChannel(buffer), 0, 10);
+ return null;
+ }
+ }));
return futures;
}
@@ -881,91 +907,119 @@
@Test
public void testInterruptedThreads() throws IOException {
final ByteBuffer buf = ByteBuffer.allocate(10);
- final ByteBuffer[] bufArray = { buf };
+ final ByteBuffer[] bufArray = {buf};
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.size();
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.size();
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.position();
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.position();
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.position(0);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.position(0);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.write(buf);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.write(buf);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.write(bufArray, 0, 1);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.write(bufArray, 0, 1);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.read(buf);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.read(buf);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.read(bufArray, 0, 1);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.read(bufArray, 0, 1);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.write(buf, 0);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.write(buf, 0);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.read(buf, 0);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.read(buf, 0);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.transferTo(0, 1, channel(regularFile(10), READ, WRITE));
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.transferTo(0, 1, channel(regularFile(10), READ, WRITE));
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.transferFrom(channel(regularFile(10), READ, WRITE), 0, 1);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.transferFrom(channel(regularFile(10), READ, WRITE), 0, 1);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.force(true);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.force(true);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.truncate(0);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.truncate(0);
+ }
+ });
- assertClosedByInterrupt(new FileChannelMethod() {
- @Override public void call(FileChannel channel) throws IOException {
- channel.lock(0, 1, true);
- }
- });
+ assertClosedByInterrupt(
+ new FileChannelMethod() {
+ @Override
+ public void call(FileChannel channel) throws IOException {
+ channel.lock(0, 1, true);
+ }
+ });
// tryLock() does not handle interruption
// map() always throws UOE; it doesn't make sense for it to try to handle interruption
@@ -985,8 +1039,9 @@
Thread.currentThread().interrupt();
try {
method.call(channel);
- fail("expected the method to throw ClosedByInterruptException or "
- + "FileLockInterruptionException");
+ fail(
+ "expected the method to throw ClosedByInterruptException or "
+ + "FileLockInterruptionException");
} catch (ClosedByInterruptException | FileLockInterruptionException expected) {
assertFalse("expected the channel to be closed", channel.isOpen());
assertTrue("expected the thread to still be interrupted", Thread.interrupted());
diff --git a/jimfs/src/test/java/com/google/common/jimfs/JimfsInputStreamTest.java b/jimfs/src/test/java/com/google/common/jimfs/JimfsInputStreamTest.java
index 4dea651..768e8a4 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsInputStreamTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsInputStreamTest.java
@@ -47,7 +47,7 @@
}
@Test
- public void testRead_wholeArray() throws IOException {
+ public void testRead_wholeArray() throws IOException {
JimfsInputStream in = newInputStream(1, 2, 3, 4, 5, 6, 7, 8);
byte[] bytes = new byte[8];
assertThat(in.read(bytes)).isEqualTo(8);
@@ -157,6 +157,7 @@
assertEmpty(in);
}
+ @SuppressWarnings("GuardedByChecker")
@Test
public void testFullyReadInputStream_doesNotChangeStateWhenStoreChanges() throws IOException {
JimfsInputStream in = newInputStream(1, 2, 3, 4, 5);
diff --git a/jimfs/src/test/java/com/google/common/jimfs/JimfsOutputStreamTest.java b/jimfs/src/test/java/com/google/common/jimfs/JimfsOutputStreamTest.java
index cddd118..27d4a14 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsOutputStreamTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsOutputStreamTest.java
@@ -52,14 +52,14 @@
@Test
public void testWrite_wholeArray() throws IOException {
JimfsOutputStream out = newOutputStream(false);
- out.write(new byte[]{1, 2, 3, 4});
+ out.write(new byte[] {1, 2, 3, 4});
assertStoreContains(out, 1, 2, 3, 4);
}
@Test
public void testWrite_partialArray() throws IOException {
JimfsOutputStream out = newOutputStream(false);
- out.write(new byte[]{1, 2, 3, 4, 5, 6}, 1, 3);
+ out.write(new byte[] {1, 2, 3, 4, 5, 6}, 1, 3);
assertStoreContains(out, 2, 3, 4);
}
@@ -100,7 +100,7 @@
public void testWrite_wholeArray_appendMode() throws IOException {
JimfsOutputStream out = newOutputStream(true);
addBytesToStore(out, 9, 8, 7);
- out.write(new byte[]{1, 2, 3, 4});
+ out.write(new byte[] {1, 2, 3, 4});
assertStoreContains(out, 9, 8, 7, 1, 2, 3, 4);
}
@@ -108,7 +108,7 @@
public void testWrite_partialArray_appendMode() throws IOException {
JimfsOutputStream out = newOutputStream(true);
addBytesToStore(out, 9, 8, 7);
- out.write(new byte[]{1, 2, 3, 4, 5, 6}, 1, 3);
+ out.write(new byte[] {1, 2, 3, 4, 5, 6}, 1, 3);
assertStoreContains(out, 9, 8, 7, 2, 3, 4);
}
@@ -126,7 +126,7 @@
public void testWrite_wholeArray_overwriting() throws IOException {
JimfsOutputStream out = newOutputStream(false);
addBytesToStore(out, 9, 8, 7, 6, 5, 4, 3);
- out.write(new byte[]{1, 2, 3, 4});
+ out.write(new byte[] {1, 2, 3, 4});
assertStoreContains(out, 1, 2, 3, 4, 5, 4, 3);
}
@@ -134,7 +134,7 @@
public void testWrite_partialArray_overwriting() throws IOException {
JimfsOutputStream out = newOutputStream(false);
addBytesToStore(out, 9, 8, 7, 6, 5, 4, 3);
- out.write(new byte[]{1, 2, 3, 4, 5, 6}, 1, 3);
+ out.write(new byte[] {1, 2, 3, 4, 5, 6}, 1, 3);
assertStoreContains(out, 2, 3, 4, 6, 5, 4, 3);
}
@@ -189,6 +189,7 @@
return new JimfsOutputStream(file, append, new FileSystemState(Runnables.doNothing()));
}
+ @SuppressWarnings("GuardedByChecker")
private static void addBytesToStore(JimfsOutputStream out, int... bytes) throws IOException {
RegularFile file = out.file;
long pos = file.sizeWithoutLocking();
@@ -197,6 +198,7 @@
}
}
+ @SuppressWarnings("GuardedByChecker")
private static void assertStoreContains(JimfsOutputStream out, int... bytes) {
byte[] actualBytes = new byte[bytes.length];
out.file.read(0, actualBytes, 0, actualBytes.length);
diff --git a/jimfs/src/test/java/com/google/common/jimfs/JimfsPathTest.java b/jimfs/src/test/java/com/google/common/jimfs/JimfsPathTest.java
index 1253cb0..71e6aba 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsPathTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsPathTest.java
@@ -108,26 +108,23 @@
public void testPathParsing_withAlternateSeparator() {
// windows recognizes / as an alternate separator
PathService windowsPathService = PathServiceTest.fakeWindowsPathService();
- assertEquals(windowsPathService.parsePath("foo\\bar\\baz"),
- windowsPathService.parsePath("foo/bar/baz"));
- assertEquals(windowsPathService.parsePath("C:\\foo\\bar"),
- windowsPathService.parsePath("C:\\foo/bar"));
- assertEquals(windowsPathService.parsePath("c:\\foo\\bar\\baz"),
+ assertEquals(
+ windowsPathService.parsePath("foo\\bar\\baz"), windowsPathService.parsePath("foo/bar/baz"));
+ assertEquals(
+ windowsPathService.parsePath("C:\\foo\\bar"), windowsPathService.parsePath("C:\\foo/bar"));
+ assertEquals(
+ windowsPathService.parsePath("c:\\foo\\bar\\baz"),
windowsPathService.parsePath("c:", "foo/", "bar/baz"));
}
@Test
public void testRootPath() {
- new PathTester(pathService, "/")
- .root("/")
- .test("/");
+ new PathTester(pathService, "/").root("/").test("/");
}
@Test
public void testRelativePath_singleName() {
- new PathTester(pathService, "test")
- .names("test")
- .test("test");
+ new PathTester(pathService, "test").names("test").test("test");
Path path = pathService.parsePath("test");
assertEquals(path, path.getFileName());
@@ -135,8 +132,7 @@
@Test
public void testRelativePath_twoNames() {
- PathTester tester = new PathTester(pathService, "foo/bar")
- .names("foo", "bar");
+ PathTester tester = new PathTester(pathService, "foo/bar").names("foo", "bar");
tester.test("foo/bar");
}
@@ -144,8 +140,7 @@
@Test
public void testRelativePath_fourNames() {
new PathTester(pathService, "foo/bar/baz/test")
- .names("foo", "bar", "baz", "test")
- .test("foo/bar/baz/test");
+ .names("foo", "bar", "baz", "test").test("foo/bar/baz/test");
}
@Test
@@ -346,8 +341,8 @@
@Test
public void testNullPointerExceptions() throws NoSuchMethodException {
- NullPointerTester tester = new NullPointerTester()
- .ignore(JimfsPath.class.getMethod("toRealPath", LinkOption[].class));
+ NullPointerTester tester =
+ new NullPointerTester().ignore(JimfsPath.class.getMethod("toRealPath", LinkOption[].class));
// ignore toRealPath because the pathService creates fake paths that do not have a
// JimfsFileSystem instance, causing it to fail since it needs to access the file system
@@ -362,8 +357,8 @@
tester.testAllPublicInstanceMethods(pathService.parsePath(".."));
}
- private void assertResolvedPathEquals(String expected, Path path, String firstResolvePath,
- String... moreResolvePaths) {
+ private void assertResolvedPathEquals(
+ String expected, Path path, String firstResolvePath, String... moreResolvePaths) {
Path resolved = path.resolve(firstResolvePath);
for (String additionalPath : moreResolvePaths) {
resolved = resolved.resolve(additionalPath);
diff --git a/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java b/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java
index ac4bc3e..9379208 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java
@@ -110,11 +110,13 @@
@RunWith(JUnit4.class)
public class JimfsUnixLikeFileSystemTest extends AbstractJimfsIntegrationTest {
- private static final Configuration UNIX_CONFIGURATION = Configuration.unix().toBuilder()
- .setAttributeViews("basic", "owner", "posix", "unix")
- .setMaxSize(1024 * 1024 * 1024) // 1 GB
- .setMaxCacheSize(256 * 1024 * 1024) // 256 MB
- .build();
+ private static final Configuration UNIX_CONFIGURATION =
+ Configuration.unix()
+ .toBuilder()
+ .setAttributeViews("basic", "owner", "posix", "unix")
+ .setMaxSize(1024 * 1024 * 1024) // 1 GB
+ .setMaxCacheSize(256 * 1024 * 1024) // 256 MB
+ .build();
@Override
protected FileSystem createFileSystem() {
@@ -129,8 +131,7 @@
.inOrder();
assertThat(fs.isOpen()).isTrue();
assertThat(fs.isReadOnly()).isFalse();
- assertThat(fs.supportedFileAttributeViews())
- .containsExactly("basic", "owner", "posix", "unix");
+ assertThat(fs.supportedFileAttributeViews()).containsExactly("basic", "owner", "posix", "unix");
assertThat(fs.provider()).isInstanceOf(JimfsFileSystemProvider.class);
}
@@ -191,8 +192,8 @@
Path p3 = path("c");
Path p4 = path("D");
- assertThat(Ordering.natural().immutableSortedCopy(Arrays.asList(p3, p4, p1, p2))).isEqualTo(
- ImmutableList.of(p2, p4, p1, p3));
+ assertThat(Ordering.natural().immutableSortedCopy(Arrays.asList(p3, p4, p1, p2)))
+ .isEqualTo(ImmutableList.of(p2, p4, p1, p3));
// would be p1, p2, p3, p4 if sorting were case insensitive
}
@@ -302,16 +303,11 @@
@Test
public void testPaths_getFromUri() {
- assertThatPath(Paths.get(URI.create("jimfs://unix/")))
- .isEqualTo(path("/"));
- assertThatPath(Paths.get(URI.create("jimfs://unix/foo")))
- .isEqualTo(path("/foo"));
- assertThatPath(Paths.get(URI.create("jimfs://unix/foo%20bar")))
- .isEqualTo(path("/foo bar"));
- assertThatPath(Paths.get(URI.create("jimfs://unix/foo/./bar")))
- .isEqualTo(path("/foo/./bar"));
- assertThatPath(Paths.get(URI.create("jimfs://unix/foo/bar/")))
- .isEqualTo(path("/foo/bar"));
+ assertThatPath(Paths.get(URI.create("jimfs://unix/"))).isEqualTo(path("/"));
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo"))).isEqualTo(path("/foo"));
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo%20bar"))).isEqualTo(path("/foo bar"));
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo/./bar"))).isEqualTo(path("/foo/./bar"));
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo/bar/"))).isEqualTo(path("/foo/bar"));
}
@Test
@@ -402,15 +398,16 @@
public void testCreateSymbolicLink_absolute() throws IOException {
Files.createSymbolicLink(path("/link.txt"), path("test.txt"));
- assertThatPath("/link.txt", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("test.txt");
+ assertThatPath("/link.txt", NOFOLLOW_LINKS).isSymbolicLink().withTarget("test.txt");
assertThatPath("/").hasChildren("link.txt", "work");
Files.createDirectory(path("/foo"));
Files.createSymbolicLink(path("/foo/link.txt"), path("test.txt"));
- assertThatPath("/foo/link.txt").noFollowLinks()
- .isSymbolicLink().withTarget("test.txt");
+ assertThatPath("/foo/link.txt")
+ .noFollowLinks()
+ .isSymbolicLink()
+ .withTarget("test.txt");
assertThatPath("/foo").hasChildren("link.txt");
}
@@ -473,19 +470,15 @@
public void testCreateSymbolicLink_relative() throws IOException {
Files.createSymbolicLink(path("link.txt"), path("test.txt"));
- assertThatPath("/work/link.txt", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("test.txt");
- assertThatPath("link.txt", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("test.txt");
+ assertThatPath("/work/link.txt", NOFOLLOW_LINKS).isSymbolicLink().withTarget("test.txt");
+ assertThatPath("link.txt", NOFOLLOW_LINKS).isSymbolicLink().withTarget("test.txt");
assertThatPath("/work").hasChildren("link.txt");
Files.createDirectory(path("foo"));
Files.createSymbolicLink(path("foo/link.txt"), path("test.txt"));
- assertThatPath("/work/foo/link.txt", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("test.txt");
- assertThatPath("foo/link.txt", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("test.txt");
+ assertThatPath("/work/foo/link.txt", NOFOLLOW_LINKS).isSymbolicLink().withTarget("test.txt");
+ assertThatPath("foo/link.txt", NOFOLLOW_LINKS).isSymbolicLink().withTarget("test.txt");
assertThatPath("/work/foo").hasChildren("link.txt");
assertThatPath("foo").hasChildren("link.txt");
}
@@ -665,8 +658,9 @@
assertThatPath("/normal").attribute("posix:permissions").isNot(permissions);
assertThatPath("/foo").attribute("posix:permissions").is(permissions);
- FileAttribute<UserPrincipal> ownerAttr = new BasicFileAttribute<>(
- "posix:owner", fs.getUserPrincipalLookupService().lookupPrincipalByName("foo"));
+ FileAttribute<UserPrincipal> ownerAttr =
+ new BasicFileAttribute<>(
+ "posix:owner", fs.getUserPrincipalLookupService().lookupPrincipalByName("foo"));
Files.createFile(path("/foo2"), ownerAttr, permissionsAttr);
@@ -678,16 +672,18 @@
@Test
public void testCreateFile_withInitialAttributes_illegalInitialAttribute() throws IOException {
try {
- Files.createFile(path("/foo"),
+ Files.createFile(
+ path("/foo"),
new BasicFileAttribute<>("basic:lastModifiedTime", FileTime.fromMillis(0L)));
+ fail();
} catch (UnsupportedOperationException expected) {
}
assertThatPath("/foo").doesNotExist();
try {
- Files.createFile(path("/foo"),
- new BasicFileAttribute<>("basic:noSuchAttribute", "foo"));
+ Files.createFile(path("/foo"), new BasicFileAttribute<>("basic:noSuchAttribute", "foo"));
+ fail();
} catch (IllegalArgumentException expected) {
}
@@ -696,8 +692,8 @@
@Test
public void testOpenChannel_withInitialAttributes_createNewFile() throws IOException {
- FileAttribute<Set<PosixFilePermission>> permissions = PosixFilePermissions.asFileAttribute(
- PosixFilePermissions.fromString("rwxrwxrwx"));
+ FileAttribute<Set<PosixFilePermission>> permissions =
+ PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx"));
Files.newByteChannel(path("/foo"), ImmutableSet.of(WRITE, CREATE), permissions).close();
assertThatPath("/foo").isRegularFile()
@@ -708,8 +704,8 @@
public void testOpenChannel_withInitialAttributes_fileExists() throws IOException {
Files.createFile(path("/foo"));
- FileAttribute<Set<PosixFilePermission>> permissions = PosixFilePermissions.asFileAttribute(
- PosixFilePermissions.fromString("rwxrwxrwx"));
+ FileAttribute<Set<PosixFilePermission>> permissions =
+ PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx"));
Files.newByteChannel(path("/foo"), ImmutableSet.of(WRITE, CREATE), permissions).close();
assertThatPath("/foo").isRegularFile()
@@ -718,8 +714,8 @@
@Test
public void testCreateDirectory_withInitialAttributes() throws IOException {
- FileAttribute<Set<PosixFilePermission>> permissions = PosixFilePermissions.asFileAttribute(
- PosixFilePermissions.fromString("rwxrwxrwx"));
+ FileAttribute<Set<PosixFilePermission>> permissions =
+ PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx"));
Files.createDirectory(path("/foo"), permissions);
@@ -734,8 +730,8 @@
@Test
public void testCreateSymbolicLink_withInitialAttributes() throws IOException {
- FileAttribute<Set<PosixFilePermission>> permissions = PosixFilePermissions.asFileAttribute(
- PosixFilePermissions.fromString("rwxrwxrwx"));
+ FileAttribute<Set<PosixFilePermission>> permissions =
+ PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwxrwx"));
Files.createSymbolicLink(path("/foo"), path("bar"), permissions);
@@ -859,7 +855,7 @@
assertEquals(test.toString(), expected.getMessage());
}
- Files.write(test, new byte[]{4, 5}, CREATE); // succeeds, ok for file to already exist
+ Files.write(test, new byte[] {4, 5}, CREATE); // succeeds, ok for file to already exist
assertThatPath("/test").containsBytes(4, 5, 2, 3); // did not truncate or append, so overwrote
Files.write(test, bytes, WRITE, CREATE, TRUNCATE_EXISTING); // default options
@@ -874,7 +870,8 @@
try {
Files.write(test, bytes, READ, WRITE); // READ not allowed
fail();
- } catch (UnsupportedOperationException expected) {}
+ } catch (UnsupportedOperationException expected) {
+ }
}
@Test
@@ -922,7 +919,8 @@
try {
Files.write(test, lines, UTF_8, CREATE_NEW); // CREATE_NEW requires file not exist
fail();
- } catch (FileAlreadyExistsException expected) {}
+ } catch (FileAlreadyExistsException expected) {
+ }
// succeeds, ok for file to already exist
Files.write(test, ImmutableList.of("foo"), UTF_8, CREATE);
@@ -946,7 +944,8 @@
try {
Files.write(test, lines, UTF_8, READ, WRITE); // READ not allowed
fail();
- } catch (UnsupportedOperationException expected) {}
+ } catch (UnsupportedOperationException expected) {
+ }
}
@Test
@@ -956,6 +955,7 @@
try {
// non-CREATE mode
Files.write(path("/foo"), preFilledBytes(10), WRITE);
+ fail();
} catch (FileSystemException expected) {
assertThat(expected.getFile()).isEqualTo("/foo");
assertThat(expected.getMessage()).contains("regular file");
@@ -964,6 +964,7 @@
try {
// CREATE mode
Files.write(path("/foo"), preFilledBytes(10));
+ fail();
} catch (FileSystemException expected) {
assertThat(expected.getFile()).isEqualTo("/foo");
assertThat(expected.getMessage()).contains("regular file");
@@ -1185,27 +1186,27 @@
@Test
public void testSymbolicLinks() throws IOException {
Files.createSymbolicLink(path("/link.txt"), path("/file.txt"));
- assertThatPath("/link.txt", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("/file.txt");
+ assertThatPath("/link.txt", NOFOLLOW_LINKS).isSymbolicLink().withTarget("/file.txt");
assertThatPath("/link.txt").doesNotExist(); // following the link; target doesn't exist
try {
Files.createFile(path("/link.txt"));
fail();
- } catch (FileAlreadyExistsException expected) {}
+ } catch (FileAlreadyExistsException expected) {
+ }
try {
Files.readAllBytes(path("/link.txt"));
fail();
- } catch (NoSuchFileException expected) {}
+ } catch (NoSuchFileException expected) {
+ }
Files.createFile(path("/file.txt"));
assertThatPath("/link.txt").isRegularFile(); // following the link; target does exist
assertThatPath("/link.txt").containsNoBytes();
Files.createSymbolicLink(path("/foo"), path("/bar/baz"));
- assertThatPath("/foo", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("/bar/baz");
+ assertThatPath("/foo", NOFOLLOW_LINKS).isSymbolicLink().withTarget("/bar/baz");
assertThatPath("/foo").doesNotExist(); // following the link; target doesn't exist
Files.createDirectories(path("/bar/baz"));
@@ -1260,8 +1261,7 @@
Files.createDirectories(path("one/two/three"));
Files.createSymbolicLink(path("/work/one/two/three/link"), path("/foo/bar"));
- assertThatPath("one/two/three/link/baz/file")
- .isSameFileAs("/foo/bar/baz/file");
+ assertThatPath("one/two/three/link/baz/file").isSameFileAs("/foo/bar/baz/file");
}
@Test
@@ -1400,7 +1400,7 @@
ByteBuffer buf1 = UTF_8.encode("hello");
ByteBuffer buf2 = UTF_8.encode(" world");
while (buf1.hasRemaining() || buf2.hasRemaining()) {
- channel.write(new ByteBuffer[]{buf1, buf2});
+ channel.write(new ByteBuffer[] {buf1, buf2});
}
assertEquals(11, channel.position());
@@ -1417,8 +1417,7 @@
assertEquals(12, channel.size());
ByteBuffer buffer = ByteBuffer.allocate(100);
- while (channel.read(buffer) != -1) {
- }
+ while (channel.read(buffer) != -1) {}
buffer.flip();
assertEquals("hello world!", UTF_8.decode(buffer).toString());
}
@@ -1521,10 +1520,8 @@
Path foo = path("/foo");
Files.createFile(foo);
- Files.getFileAttributeView(foo, BasicFileAttributeView.class).setTimes(
- FileTime.fromMillis(100),
- FileTime.fromMillis(1000),
- FileTime.fromMillis(10000));
+ Files.getFileAttributeView(foo, BasicFileAttributeView.class)
+ .setTimes(FileTime.fromMillis(100), FileTime.fromMillis(1000), FileTime.fromMillis(10000));
assertThat(Files.getAttribute(foo, "lastModifiedTime")).isEqualTo(FileTime.fromMillis(100));
@@ -1692,8 +1689,7 @@
Files.delete(path("/bar"));
Files.copy(path("/link"), path("/bar"), NOFOLLOW_LINKS);
- assertThatPath("/bar", NOFOLLOW_LINKS)
- .isSymbolicLink().withTarget("/test");
+ assertThatPath("/bar", NOFOLLOW_LINKS).isSymbolicLink().withTarget("/test");
assertThatPath("/bar").isRegularFile();
assertThatPath("/bar").containsBytes(bytes);
@@ -1730,8 +1726,7 @@
UserPrincipal owner = fs.getUserPrincipalLookupService().lookupPrincipalByName("foobar");
Files.setOwner(foo, owner);
- assertThatPath(foo)
- .attribute("owner:owner").is(owner);
+ assertThatPath(foo).attribute("owner:owner").is(owner);
Path foo2 = fs2.getPath("/foo");
Files.copy(foo, foo2, COPY_ATTRIBUTES);
@@ -1760,9 +1755,8 @@
Files.move(path("/foo"), path("/bar"));
assertThatPath("/foo").doesNotExist()
- .andThat("/bar")
- .containsBytes(bytes).and()
- .attribute("fileKey").is(fooKey);
+ .andThat("/bar").containsBytes(bytes)
+ .and().attribute("fileKey").is(fooKey);
Files.createDirectory(path("/foo"));
Files.move(path("/bar"), path("/foo/bar"));
@@ -1785,17 +1779,14 @@
Files.move(path("/link"), path("/link.txt"));
- assertThatPath("/foo.txt").noFollowLinks()
- .isRegularFile()
+ assertThatPath("/foo.txt").noFollowLinks().isRegularFile()
.and().containsBytes(bytes);
assertThatPath(path("/link")).doesNotExist();
- assertThatPath(path("/link.txt")).noFollowLinks()
- .isSymbolicLink();
+ assertThatPath(path("/link.txt")).noFollowLinks().isSymbolicLink();
- assertThatPath(path("/link.txt"))
- .isRegularFile()
+ assertThatPath(path("/link.txt")).isRegularFile()
.and().containsBytes(bytes);
}
@@ -1838,9 +1829,8 @@
assertEquals("/bar", expected.getMessage());
}
- assertThatPath("/test")
- .containsBytes(bytes).and()
- .attribute("fileKey").is(testKey);
+ assertThatPath("/test").containsBytes(bytes)
+ .and().attribute("fileKey").is(testKey);
Files.delete(path("/bar"));
Files.createDirectory(path("/bar"));
@@ -1852,9 +1842,8 @@
assertEquals("/bar", expected.getMessage());
}
- assertThatPath("/test")
- .containsBytes(bytes).and()
- .attribute("fileKey").is(testKey);
+ assertThatPath("/test").containsBytes(bytes)
+ .and().attribute("fileKey").is(testKey);
}
@Test
@@ -1900,8 +1889,11 @@
@Test
public void testIsSameFile_forPathFromDifferentFileSystemProvider() throws IOException {
- Path defaultFileSystemRoot = FileSystems.getDefault()
- .getRootDirectories().iterator().next();
+ Path defaultFileSystemRoot =
+ FileSystems.getDefault()
+ .getRootDirectories()
+ .iterator()
+ .next();
assertThat(Files.isSameFile(path("/"), defaultFileSystemRoot)).isFalse();
}
@@ -1935,9 +1927,10 @@
SecureDirectoryStream<Path> secureStream = (SecureDirectoryStream<Path>) stream;
- assertThat(ImmutableList.copyOf(secureStream)).isEqualTo(
- ImmutableList.of(
- path("/foo/a"), path("/foo/b"), path("/foo/bar"), path("/foo/barLink")));
+ assertThat(ImmutableList.copyOf(secureStream))
+ .isEqualTo(
+ ImmutableList.of(
+ path("/foo/a"), path("/foo/b"), path("/foo/bar"), path("/foo/barLink")));
secureStream.deleteFile(path("b"));
assertThatPath("/foo/b").doesNotExist();
@@ -1959,13 +1952,19 @@
assertThatPath("/baz/stuff/b").doesNotExist();
assertThatPath("/baz/stuff").hasChildren("a", "bar", "barLink");
- assertThat(secureStream.getFileAttributeView(BasicFileAttributeView.class)
- .readAttributes()
- .isDirectory()).isTrue();
+ assertThat(
+ secureStream
+ .getFileAttributeView(BasicFileAttributeView.class)
+ .readAttributes()
+ .isDirectory())
+ .isTrue();
- assertThat(secureStream.getFileAttributeView(path("a"), BasicFileAttributeView.class)
- .readAttributes()
- .isRegularFile()).isTrue();
+ assertThat(
+ secureStream
+ .getFileAttributeView(path("a"), BasicFileAttributeView.class)
+ .readAttributes()
+ .isRegularFile())
+ .isTrue();
try {
secureStream.deleteFile(path("bar"));
@@ -1983,27 +1982,36 @@
try (SecureDirectoryStream<Path> barStream = secureStream.newDirectoryStream(path("bar"))) {
barStream.newByteChannel(path("stuff"), ImmutableSet.of(WRITE, CREATE_NEW)).close();
- assertThat(barStream.getFileAttributeView(path("stuff"), BasicFileAttributeView.class)
- .readAttributes()
- .isRegularFile()).isTrue();
+ assertThat(
+ barStream
+ .getFileAttributeView(path("stuff"), BasicFileAttributeView.class)
+ .readAttributes()
+ .isRegularFile())
+ .isTrue();
- assertThat(secureStream.getFileAttributeView(
- path("bar/stuff"), BasicFileAttributeView.class)
- .readAttributes()
- .isRegularFile()).isTrue();
+ assertThat(
+ secureStream
+ .getFileAttributeView(path("bar/stuff"), BasicFileAttributeView.class)
+ .readAttributes()
+ .isRegularFile())
+ .isTrue();
}
- try (SecureDirectoryStream<Path> barLinkStream = secureStream
- .newDirectoryStream(path("barLink"))) {
- assertThat(barLinkStream.getFileAttributeView(
- path("stuff"), BasicFileAttributeView.class)
- .readAttributes()
- .isRegularFile()).isTrue();
+ try (SecureDirectoryStream<Path> barLinkStream =
+ secureStream.newDirectoryStream(path("barLink"))) {
+ assertThat(
+ barLinkStream
+ .getFileAttributeView(path("stuff"), BasicFileAttributeView.class)
+ .readAttributes()
+ .isRegularFile())
+ .isTrue();
- assertThat(barLinkStream.getFileAttributeView(
- path(".."), BasicFileAttributeView.class)
- .readAttributes()
- .isDirectory()).isTrue();
+ assertThat(
+ barLinkStream
+ .getFileAttributeView(path(".."), BasicFileAttributeView.class)
+ .readAttributes()
+ .isDirectory())
+ .isTrue();
}
try {
@@ -2019,9 +2027,12 @@
assertThatPath(path("/baz/stuff/a")).doesNotExist();
assertThatPath(path("/baz/stuff/bar/moved")).isRegularFile();
- assertThat(barStream.getFileAttributeView(path("moved"), BasicFileAttributeView.class)
- .readAttributes()
- .isRegularFile()).isTrue();
+ assertThat(
+ barStream
+ .getFileAttributeView(path("moved"), BasicFileAttributeView.class)
+ .readAttributes()
+ .isRegularFile())
+ .isTrue();
}
}
}
@@ -2042,8 +2053,7 @@
.containsExactly(path("foo/a"), path("foo/b"), path("foo/c"));
try (DirectoryStream<Path> stream2 = secureStream.newDirectoryStream(path("c"))) {
- assertThat(ImmutableList.copyOf(stream2))
- .containsExactly(path("foo/c/d"), path("foo/c/e"));
+ assertThat(ImmutableList.copyOf(stream2)).containsExactly(path("foo/c/d"), path("foo/c/e"));
}
}
}
@@ -2114,8 +2124,8 @@
Iterator<Path> iter = stream.iterator();
BasicFileAttributeView view1 = stream.getFileAttributeView(BasicFileAttributeView.class);
- BasicFileAttributeView view2 = stream.getFileAttributeView(
- path("bar"), BasicFileAttributeView.class);
+ BasicFileAttributeView view2 =
+ stream.getFileAttributeView(path("bar"), BasicFileAttributeView.class);
try {
stream.iterator();
@@ -2224,7 +2234,7 @@
Uninterruptibles.sleepUninterruptibly(1, MILLISECONDS);
try {
- channel.write(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}));
+ channel.write(ByteBuffer.wrap(new byte[] {0, 1, 2, 3}));
} catch (NonWritableChannelException ignore) {
}
@@ -2246,14 +2256,14 @@
tester.assertModifiedTimeDidNotChange();
Uninterruptibles.sleepUninterruptibly(1, MILLISECONDS);
- channel.write(ByteBuffer.wrap(new byte[]{0, 1, 2, 3}));
+ channel.write(ByteBuffer.wrap(new byte[] {0, 1, 2, 3}));
// write call on channel does
tester.assertAccessTimeDidNotChange();
tester.assertModifiedTimeChanged();
Uninterruptibles.sleepUninterruptibly(1, MILLISECONDS);
- channel.write(ByteBuffer.wrap(new byte[]{4, 5, 6, 7}));
+ channel.write(ByteBuffer.wrap(new byte[] {4, 5, 6, 7}));
tester.assertAccessTimeDidNotChange();
tester.assertModifiedTimeChanged();
@@ -2278,9 +2288,12 @@
@Test
public void testUnsupportedFeatures() throws IOException {
- FileSystem fileSystem = Jimfs.newFileSystem(Configuration.unix().toBuilder()
- .setSupportedFeatures() // none
- .build());
+ FileSystem fileSystem =
+ Jimfs.newFileSystem(
+ Configuration.unix()
+ .toBuilder()
+ .setSupportedFeatures() // none
+ .build());
Path foo = fileSystem.getPath("foo");
Path bar = foo.resolveSibling("bar");
diff --git a/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java b/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java
index 69e333b..df9ff93 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java
@@ -48,10 +48,13 @@
@Override
protected FileSystem createFileSystem() {
- return Jimfs.newFileSystem("win", Configuration.windows().toBuilder()
- .setRoots("C:\\", "E:\\")
- .setAttributeViews("basic", "owner", "dos", "acl", "user")
- .build());
+ return Jimfs.newFileSystem(
+ "win",
+ Configuration.windows()
+ .toBuilder()
+ .setRoots("C:\\", "E:\\")
+ .setAttributeViews("basic", "owner", "dos", "acl", "user")
+ .build());
}
@Test
@@ -94,8 +97,8 @@
Path p3 = path("c");
Path p4 = path("D");
- assertThat(Ordering.natural().immutableSortedCopy(Arrays.asList(p3, p4, p1, p2))).isEqualTo(
- ImmutableList.of(p1, p2, p3, p4));
+ assertThat(Ordering.natural().immutableSortedCopy(Arrays.asList(p3, p4, p1, p2)))
+ .isEqualTo(ImmutableList.of(p1, p2, p3, p4));
// would be p2, p4, p1, p3 if sorting were case sensitive
}
@@ -104,18 +107,15 @@
public void testPaths_withSlash() {
assertThatPath("foo/bar").isRelative()
.and().hasNameComponents("foo", "bar")
- .and()
- .isEqualTo(path("foo\\bar"));
+ .and().isEqualTo(path("foo\\bar"));
assertThatPath("C:/foo/bar/baz").isAbsolute()
.and().hasRootComponent("C:\\")
.and().hasNameComponents("foo", "bar", "baz")
- .and()
- .isEqualTo(path("C:\\foo\\bar\\baz"));
+ .and().isEqualTo(path("C:\\foo\\bar\\baz"));
assertThatPath("C:/foo\\bar/baz").isAbsolute()
.and().hasRootComponent("C:\\")
.and().hasNameComponents("foo", "bar", "baz")
- .and()
- .isEqualTo(path("C:\\foo\\bar\\baz"));
+ .and().isEqualTo(path("C:\\foo\\bar\\baz"));
}
@Test
@@ -233,10 +233,8 @@
@Test
public void testPaths_getFromUri() {
- assertThatPath(Paths.get(URI.create("jimfs://win/C:/")))
- .isEqualTo(fs.getPath("C:\\"));
- assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo")))
- .isEqualTo(fs.getPath("C:\\foo"));
+ assertThatPath(Paths.get(URI.create("jimfs://win/C:/"))).isEqualTo(fs.getPath("C:\\"));
+ assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo"))).isEqualTo(fs.getPath("C:\\foo"));
assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo%20bar")))
.isEqualTo(fs.getPath("C:\\foo bar"));
assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo/./bar")))
diff --git a/jimfs/src/test/java/com/google/common/jimfs/OwnerAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/OwnerAttributeProviderTest.java
index eb81eb2..c92e6ad 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/OwnerAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/OwnerAttributeProviderTest.java
@@ -35,8 +35,8 @@
* @author Colin Decker
*/
@RunWith(JUnit4.class)
-public class OwnerAttributeProviderTest extends
- AbstractAttributeProviderTest<OwnerAttributeProvider> {
+public class OwnerAttributeProviderTest
+ extends AbstractAttributeProviderTest<OwnerAttributeProvider> {
@Override
protected OwnerAttributeProvider createProvider() {
diff --git a/jimfs/src/test/java/com/google/common/jimfs/PathNormalizationTest.java b/jimfs/src/test/java/com/google/common/jimfs/PathNormalizationTest.java
index 8000e5c..6fb6d00 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PathNormalizationTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PathNormalizationTest.java
@@ -54,21 +54,21 @@
}
private static final String[][] CASE_FOLD_TEST_DATA = {
- {"foo", "fOo", "foO", "Foo", "FOO"},
- {"efficient", "efficient", "efficient", "Efficient", "EFFICIENT"},
- {"flour", "flour", "flour", "Flour", "FLOUR"},
- {"poſt", "post", "poſt", "Poſt", "POST"},
- {"poſt", "post", "poſt", "Poſt", "POST"},
- {"ſtop", "stop", "ſtop", "Stop", "STOP"},
- {"tschüß", "tschüss", "tschüß", "Tschüß", "TSCHÜSS"},
- {"weiß", "weiss", "weiß", "Weiß", "WEISS"},
- {"WEIẞ", "weiss", "weiß", "Weiß", "WEIẞ"},
- {"στιγμας", "στιγμασ", "στιγμας", "Στιγμας", "ΣΤΙΓΜΑΣ"},
- {"á¾² στο διάολο", "á½°ι στο διάολο", "á¾² στο διάολο", "Ὰͅ Στο Διάολο", "á¾ºΙ ΣΤΟ ΔΙΆΟΛΟ"},
- {"Henry â…§", "henry â…·", "henry â…·", "Henry â…§", "HENRY â…§"},
- {"I Work At â“€", "i work at â“š", "i work at â“š", "I Work At â“€", "I WORK AT â“€"},
- {"ʀᴀʀᴇ", "ʀᴀʀᴇ", "ʀᴀʀᴇ", "Ʀᴀʀᴇ", "ƦᴀƦᴇ"},
- {"Ὰͅ", "á½°ι", "á¾²", "Ὰͅ", "ᾺΙ"}
+ {"foo", "fOo", "foO", "Foo", "FOO"},
+ {"efficient", "efficient", "efficient", "Efficient", "EFFICIENT"},
+ {"flour", "flour", "flour", "Flour", "FLOUR"},
+ {"poſt", "post", "poſt", "Poſt", "POST"},
+ {"poſt", "post", "poſt", "Poſt", "POST"},
+ {"ſtop", "stop", "ſtop", "Stop", "STOP"},
+ {"tschüß", "tschüss", "tschüß", "Tschüß", "TSCHÜSS"},
+ {"weiß", "weiss", "weiß", "Weiß", "WEISS"},
+ {"WEIẞ", "weiss", "weiß", "Weiß", "WEIẞ"},
+ {"στιγμας", "στιγμασ", "στιγμας", "Στιγμας", "ΣΤΙΓΜΑΣ"},
+ {"á¾² στο διάολο", "á½°ι στο διάολο", "á¾² στο διάολο", "Ὰͅ Στο Διάολο", "á¾ºΙ ΣΤΟ ΔΙΆΟΛΟ"},
+ {"Henry â…§", "henry â…·", "henry â…·", "Henry â…§", "HENRY â…§"},
+ {"I Work At â“€", "i work at â“š", "i work at â“š", "I Work At â“€", "I WORK AT â“€"},
+ {"ʀᴀʀᴇ", "ʀᴀʀᴇ", "ʀᴀʀᴇ", "Ʀᴀʀᴇ", "ƦᴀƦᴇ"},
+ {"Ὰͅ", "á½°ι", "á¾²", "Ὰͅ", "ᾺΙ"}
};
@Test
@@ -99,8 +99,8 @@
}
private static final String[][] NORMALIZE_TEST_DATA = {
- {"\u00c5", "\u212b"}, // two forms of Å (one code point each)
- {"Am\u00e9lie", "Ame\u0301lie"} // two forms of Amélie (one composed, one decomposed)
+ {"\u00c5", "\u212b"}, // two forms of Å (one code point each)
+ {"Am\u00e9lie", "Ame\u0301lie"} // two forms of Amélie (one composed, one decomposed)
};
@Test
@@ -130,8 +130,8 @@
}
private static final String[][] NORMALIZE_CASE_FOLD_TEST_DATA = {
- {"\u00c5", "\u00e5", "\u212b"},
- {"Am\u00e9lie", "Am\u00c9lie", "Ame\u0301lie", "AME\u0301LIE"}
+ {"\u00c5", "\u00e5", "\u212b"},
+ {"Am\u00e9lie", "Am\u00c9lie", "Ame\u0301lie", "AME\u0301LIE"}
};
@Test
@@ -161,8 +161,8 @@
}
private static final String[][] NORMALIZED_CASE_INSENSITIVE_ASCII_TEST_DATA = {
- {"\u00e5", "\u212b"},
- {"Am\u00e9lie", "AME\u0301LIE"}
+ {"\u00e5", "\u212b"},
+ {"Am\u00e9lie", "AME\u0301LIE"}
};
@Test
@@ -329,11 +329,13 @@
*/
private void assertNormalizedPatternMatches(String first, String second) {
Pattern pattern = PathNormalization.compilePattern(first, normalizations);
- assertTrue("pattern '" + pattern + "' does not match '" + second + "'",
+ assertTrue(
+ "pattern '" + pattern + "' does not match '" + second + "'",
pattern.matcher(second).matches());
pattern = PathNormalization.compilePattern(second, normalizations);
- assertTrue("pattern '" + pattern + "' does not match '" + first + "'",
+ assertTrue(
+ "pattern '" + pattern + "' does not match '" + first + "'",
pattern.matcher(first).matches());
}
@@ -343,11 +345,13 @@
*/
private void assertNormalizedPatternDoesNotMatch(String first, String second) {
Pattern pattern = PathNormalization.compilePattern(first, normalizations);
- assertFalse("pattern '" + pattern + "' should not match '" + second + "'",
+ assertFalse(
+ "pattern '" + pattern + "' should not match '" + second + "'",
pattern.matcher(second).matches());
pattern = PathNormalization.compilePattern(second, normalizations);
- assertFalse("pattern '" + pattern + "' should not match '" + first + "'",
+ assertFalse(
+ "pattern '" + pattern + "' should not match '" + first + "'",
pattern.matcher(first).matches());
}
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/PathServiceTest.java b/jimfs/src/test/java/com/google/common/jimfs/PathServiceTest.java
index 173a7d8..e0b24c0 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PathServiceTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PathServiceTest.java
@@ -17,8 +17,8 @@
package com.google.common.jimfs;
import static com.google.common.jimfs.PathSubject.paths;
+import static com.google.common.truth.Truth.assertAbout;
import static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assert_;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -38,7 +38,7 @@
*/
@RunWith(JUnit4.class)
public class PathServiceTest {
-
+
private static final ImmutableSet<PathNormalization> NO_NORMALIZATIONS = ImmutableSet.of();
private final PathService service = fakeUnixPathService();
@@ -51,54 +51,54 @@
@Test
public void testPathCreation() {
- assert_().about(paths()).that(service.emptyPath())
- .hasRootComponent(null).and()
- .hasNameComponents("");
+ assertAbout(paths()).that(service.emptyPath())
+ .hasRootComponent(null)
+ .and().hasNameComponents("");
- assert_().about(paths()).that(service.createRoot(service.name("/")))
- .isAbsolute().and()
- .hasRootComponent("/").and()
- .hasNoNameComponents();
+ assertAbout(paths()).that(service.createRoot(service.name("/")))
+ .isAbsolute()
+ .and().hasRootComponent("/")
+ .and().hasNoNameComponents();
- assert_().about(paths()).that(service.createFileName(service.name("foo")))
- .hasRootComponent(null).and()
- .hasNameComponents("foo");
+ assertAbout(paths()).that(service.createFileName(service.name("foo")))
+ .hasRootComponent(null)
+ .and().hasNameComponents("foo");
JimfsPath relative = service.createRelativePath(service.names(ImmutableList.of("foo", "bar")));
- assert_().about(paths()).that(relative)
- .hasRootComponent(null).and()
- .hasNameComponents("foo", "bar");
+ assertAbout(paths()).that(relative)
+ .hasRootComponent(null)
+ .and().hasNameComponents("foo", "bar");
- JimfsPath absolute = service.createPath(
- service.name("/"), service.names(ImmutableList.of("foo", "bar")));
- assert_().about(paths()).that(absolute)
- .isAbsolute().and()
- .hasRootComponent("/").and()
- .hasNameComponents("foo", "bar");
+ JimfsPath absolute =
+ service.createPath(service.name("/"), service.names(ImmutableList.of("foo", "bar")));
+ assertAbout(paths()).that(absolute)
+ .isAbsolute()
+ .and().hasRootComponent("/")
+ .and().hasNameComponents("foo", "bar");
}
@Test
public void testPathCreation_emptyPath() {
// normalized to empty path with single empty string name
- assert_().about(paths()).that(service.createPath(null, ImmutableList.<Name>of()))
- .hasRootComponent(null).and()
- .hasNameComponents("");
+ assertAbout(paths()).that(service.createPath(null, ImmutableList.<Name>of()))
+ .hasRootComponent(null)
+ .and().hasNameComponents("");
}
@Test
public void testPathCreation_parseIgnoresEmptyString() {
// if the empty string wasn't ignored, the resulting path would be "/foo" since the empty
// string would be joined with foo
- assert_().about(paths()).that(service.parsePath("", "foo"))
- .hasRootComponent(null).and()
- .hasNameComponents("foo");
+ assertAbout(paths()).that(service.parsePath("", "foo"))
+ .hasRootComponent(null)
+ .and().hasNameComponents("foo");
}
@Test
public void testToString() {
// not much to test for this since it just delegates to PathType anyway
- JimfsPath path = new JimfsPath(
- service, null, ImmutableList.of(Name.simple("foo"), Name.simple("bar")));
+ JimfsPath path =
+ new JimfsPath(service, null, ImmutableList.of(Name.simple("foo"), Name.simple("bar")));
assertThat(service.toString(path)).isEqualTo("foo/bar");
path = new JimfsPath(service, Name.simple("/"), ImmutableList.of(Name.simple("foo")));
@@ -109,12 +109,11 @@
public void testHash_usingDisplayForm() {
PathService pathService = fakePathService(PathType.unix(), false);
- JimfsPath path1 = new JimfsPath(pathService, null,
- ImmutableList.of(Name.create("FOO", "foo")));
- JimfsPath path2 = new JimfsPath(pathService, null,
- ImmutableList.of(Name.create("FOO", "FOO")));
- JimfsPath path3 = new JimfsPath(pathService, null,
- ImmutableList.of(Name.create("FOO", "9874238974897189741")));
+ JimfsPath path1 = new JimfsPath(pathService, null, ImmutableList.of(Name.create("FOO", "foo")));
+ JimfsPath path2 = new JimfsPath(pathService, null, ImmutableList.of(Name.create("FOO", "FOO")));
+ JimfsPath path3 =
+ new JimfsPath(
+ pathService, null, ImmutableList.of(Name.create("FOO", "9874238974897189741")));
assertThat(pathService.hash(path1)).isEqualTo(pathService.hash(path2));
assertThat(pathService.hash(path2)).isEqualTo(pathService.hash(path3));
@@ -124,12 +123,11 @@
public void testHash_usingCanonicalForm() {
PathService pathService = fakePathService(PathType.unix(), true);
- JimfsPath path1 = new JimfsPath(pathService, null,
- ImmutableList.of(Name.create("foo", "foo")));
- JimfsPath path2 = new JimfsPath(pathService, null,
- ImmutableList.of(Name.create("FOO", "foo")));
- JimfsPath path3 = new JimfsPath(pathService, null,
- ImmutableList.of(Name.create("28937497189478912374897", "foo")));
+ JimfsPath path1 = new JimfsPath(pathService, null, ImmutableList.of(Name.create("foo", "foo")));
+ JimfsPath path2 = new JimfsPath(pathService, null, ImmutableList.of(Name.create("FOO", "foo")));
+ JimfsPath path3 =
+ new JimfsPath(
+ pathService, null, ImmutableList.of(Name.create("28937497189478912374897", "foo")));
assertThat(pathService.hash(path1)).isEqualTo(pathService.hash(path2));
assertThat(pathService.hash(path2)).isEqualTo(pathService.hash(path3));
@@ -176,8 +174,8 @@
}
public static PathService fakePathService(PathType type, boolean equalityUsesCanonicalForm) {
- PathService service = new PathService(
- type, NO_NORMALIZATIONS, NO_NORMALIZATIONS, equalityUsesCanonicalForm);
+ PathService service =
+ new PathService(type, NO_NORMALIZATIONS, NO_NORMALIZATIONS, equalityUsesCanonicalForm);
service.setFileSystem(FILE_SYSTEM);
return service;
}
@@ -186,8 +184,9 @@
static {
try {
- FILE_SYSTEM = JimfsFileSystems.newFileSystem(
- new JimfsFileSystemProvider(), URI.create("jimfs://foo"), Configuration.unix());
+ FILE_SYSTEM =
+ JimfsFileSystems.newFileSystem(
+ new JimfsFileSystemProvider(), URI.create("jimfs://foo"), Configuration.unix());
} catch (IOException e) {
throw new AssertionError(e);
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/PathTester.java b/jimfs/src/test/java/com/google/common/jimfs/PathTester.java
index a77a7c1..3130701 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PathTester.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PathTester.java
@@ -120,8 +120,7 @@
}
if (parent != null) {
- String parentName = names.size() == 1 ? root :
- string.substring(0, string.lastIndexOf('/'));
+ String parentName = names.size() == 1 ? root : string.substring(0, string.lastIndexOf('/'));
new PathTester(pathService, parentName)
.root(root)
.names(names.subList(0, names.size() - 1))
@@ -140,20 +139,19 @@
// test start + 1 to end and start to end - 1 subpaths... this recursively tests all subpaths
// actually tests most possible subpaths multiple times but... eh
Path startSubpath = path.subpath(1, path.getNameCount());
- List<String> startNames = ImmutableList.copyOf(Splitter.on('/').split(stringWithoutRoot))
- .subList(1, path.getNameCount());
+ List<String> startNames =
+ ImmutableList.copyOf(Splitter.on('/').split(stringWithoutRoot))
+ .subList(1, path.getNameCount());
new PathTester(pathService, Joiner.on('/').join(startNames))
- .names(startNames)
- .test(startSubpath);
+ .names(startNames).test(startSubpath);
Path endSubpath = path.subpath(0, path.getNameCount() - 1);
- List<String> endNames = ImmutableList.copyOf(Splitter.on('/').split(stringWithoutRoot))
- .subList(0, path.getNameCount() - 1);
+ List<String> endNames =
+ ImmutableList.copyOf(Splitter.on('/').split(stringWithoutRoot))
+ .subList(0, path.getNameCount() - 1);
- new PathTester(pathService, Joiner.on('/').join(endNames))
- .names(endNames)
- .test(endSubpath);
+ new PathTester(pathService, Joiner.on('/').join(endNames)).names(endNames).test(endSubpath);
}
}
@@ -162,10 +160,9 @@
if (root != null || !names.isEmpty()) {
Path other = path;
while (other != null) {
- assertTrue(path + ".startsWith(" + other + ") should be true",
- path.startsWith(other));
- assertTrue(path + ".startsWith(" + other + ") should be true",
- path.startsWith(other.toString()));
+ assertTrue(path + ".startsWith(" + other + ") should be true", path.startsWith(other));
+ assertTrue(
+ path + ".startsWith(" + other + ") should be true", path.startsWith(other.toString()));
other = other.getParent();
}
}
@@ -176,10 +173,9 @@
if (root != null || !names.isEmpty()) {
Path other = path;
while (other != null) {
- assertTrue(path + ".endsWith(" + other + ") should be true",
- path.endsWith(other));
- assertTrue(path + ".endsWith(" + other + ") should be true",
- path.endsWith(other.toString()));
+ assertTrue(path + ".endsWith(" + other + ") should be true", path.endsWith(other));
+ assertTrue(
+ path + ".endsWith(" + other + ") should be true", path.endsWith(other.toString()));
if (other.getRoot() != null && other.getNameCount() > 0) {
other = other.subpath(0, other.getNameCount());
} else if (other.getNameCount() > 1) {
@@ -192,8 +188,6 @@
}
private static List<String> names(Path path) {
- return FluentIterable.from(path)
- .transform(toStringFunction())
- .toList();
+ return FluentIterable.from(path).transform(toStringFunction()).toList();
}
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java b/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java
index 2988e72..eaac73b 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java
@@ -97,8 +97,7 @@
assertUriRoundTripsCorrectly(type, "$foo/bar baz");
}
- static void assertParseResult(
- ParseResult result, @Nullable String root, String... names) {
+ static void assertParseResult(ParseResult result, @Nullable String root, String... names) {
assertThat(result.root()).isEqualTo(root);
assertThat(result.names()).containsExactly((Object[]) names).inOrder();
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java b/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java
index 045e523..f75443d 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java
@@ -60,8 +60,12 @@
@Before
public void setUp() {
fs = (JimfsFileSystem) Jimfs.newFileSystem(Configuration.unix());
- watcher = new PollingWatchService(fs.getDefaultView(),
- fs.getPathService(), new FileSystemState(Runnables.doNothing()), 4, MILLISECONDS);
+ watcher =
+ new PollingWatchService(
+ fs.getDefaultView(),
+ fs.getPathService(),
+ new FileSystemState(Runnables.doNothing()),
+ 4, MILLISECONDS);
}
@After
@@ -215,8 +219,8 @@
assertWatcherHasEvents(Arrays.asList(events), ImmutableList.<WatchEvent<?>>of());
}
- private void assertWatcherHasEvents(
- List<WatchEvent<?>> expected, List<WatchEvent<?>> alternate) throws InterruptedException {
+ private void assertWatcherHasEvents(List<WatchEvent<?>> expected, List<WatchEvent<?>> alternate)
+ throws InterruptedException {
ensureTimeToPoll(); // otherwise we could read 1 event but not all the events we're expecting
WatchKey key = watcher.take();
List<WatchEvent<?>> keyEvents = key.pollEvents();
diff --git a/jimfs/src/test/java/com/google/common/jimfs/PosixAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/PosixAttributeProviderTest.java
index 3d38bad..94f00b8 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PosixAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PosixAttributeProviderTest.java
@@ -42,8 +42,8 @@
* @author Colin Decker
*/
@RunWith(JUnit4.class)
-public class PosixAttributeProviderTest extends
- AbstractAttributeProviderTest<PosixAttributeProvider> {
+public class PosixAttributeProviderTest
+ extends AbstractAttributeProviderTest<PosixAttributeProvider> {
@Override
protected PosixAttributeProvider createProvider() {
@@ -57,7 +57,8 @@
@Test
public void testInitialAttributes() {
- assertContainsAll(file,
+ assertContainsAll(
+ file,
ImmutableMap.of(
"group", createGroupPrincipal("group"),
"permissions", PosixFilePermissions.fromString("rw-r--r--")));
@@ -83,10 +84,12 @@
public void testView() throws IOException {
file.setAttribute("owner", "owner", createUserPrincipal("user"));
- PosixFileAttributeView view = provider.view(fileLookup(),
- ImmutableMap.of(
- "basic", new BasicAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS),
- "owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
+ PosixFileAttributeView view =
+ provider.view(
+ fileLookup(),
+ ImmutableMap.of(
+ "basic", new BasicAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS),
+ "owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS)));
assertNotNull(view);
assertThat(view.name()).isEqualTo("posix");
@@ -107,10 +110,10 @@
assertThat(file.getAttribute("posix", "group")).isEqualTo(createGroupPrincipal("root"));
view.setPermissions(PosixFilePermissions.fromString("rwx------"));
- assertThat(view.readAttributes().permissions()).isEqualTo(
- PosixFilePermissions.fromString("rwx------"));
- assertThat(file.getAttribute("posix", "permissions")).isEqualTo(
- PosixFilePermissions.fromString("rwx------"));
+ assertThat(view.readAttributes().permissions())
+ .isEqualTo(PosixFilePermissions.fromString("rwx------"));
+ assertThat(file.getAttribute("posix", "permissions"))
+ .isEqualTo(PosixFilePermissions.fromString("rwx------"));
}
@Test
diff --git a/jimfs/src/test/java/com/google/common/jimfs/RegexGlobMatcherTest.java b/jimfs/src/test/java/com/google/common/jimfs/RegexGlobMatcherTest.java
index 47290ee..7b6ea44 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/RegexGlobMatcherTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/RegexGlobMatcherTest.java
@@ -39,7 +39,8 @@
@Override
protected PathMatcher matcher(String pattern) {
- return PathMatchers.getPathMatcher("glob:" + pattern, "/", ImmutableSet.<PathNormalization>of());
+ return PathMatchers.getPathMatcher(
+ "glob:" + pattern, "/", ImmutableSet.<PathNormalization>of());
}
@Override
diff --git a/jimfs/src/test/java/com/google/common/jimfs/RegularFileBlocksTest.java b/jimfs/src/test/java/com/google/common/jimfs/RegularFileBlocksTest.java
index c0d3bd1..bf517a0 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/RegularFileBlocksTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/RegularFileBlocksTest.java
@@ -140,7 +140,7 @@
assertThat(file.blockCount()).isEqualTo(1);
assertThat(other.blockCount()).isEqualTo(2);
assertThat(other.getBlock(2)).isNull();
- assertThat(Bytes.asList(file.getBlock(0))).isEqualTo(Bytes.asList(new byte[]{1, 2, 3}));
+ assertThat(Bytes.asList(file.getBlock(0))).isEqualTo(Bytes.asList(new byte[] {1, 2, 3}));
assertThat(file.getBlock(1)).isNull();
}
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/RegularFileTest.java b/jimfs/src/test/java/com/google/common/jimfs/RegularFileTest.java
index 837d7a1..4b871b4 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/RegularFileTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/RegularFileTest.java
@@ -58,8 +58,8 @@
for (ReuseStrategy reuseStrategy : EnumSet.allOf(ReuseStrategy.class)) {
TestSuite suiteForReuseStrategy = new TestSuite(reuseStrategy.toString());
- Set<List<Integer>> sizeOptions = Sets.cartesianProduct(
- ImmutableList.of(BLOCK_SIZES, CACHE_SIZES));
+ Set<List<Integer>> sizeOptions =
+ Sets.cartesianProduct(ImmutableList.of(BLOCK_SIZES, CACHE_SIZES));
for (List<Integer> options : sizeOptions) {
int blockSize = options.get(0);
int cacheSize = options.get(1);
@@ -86,17 +86,18 @@
public static final ImmutableSet<Integer> BLOCK_SIZES = ImmutableSet.of(2, 8, 128, 8192);
public static final ImmutableSet<Integer> CACHE_SIZES = ImmutableSet.of(0, 4, 16, 128, -1);
- private static final ImmutableList<Method> TEST_METHODS = FluentIterable
- .from(Arrays.asList(RegularFileTestRunner.class.getDeclaredMethods()))
- .filter(new Predicate<Method>() {
- @Override
- public boolean apply(Method method) {
- return method.getName().startsWith("test")
- && Modifier.isPublic(method.getModifiers())
- && method.getParameterTypes().length == 0;
- }
- })
- .toList();
+ private static final ImmutableList<Method> TEST_METHODS =
+ FluentIterable.from(Arrays.asList(RegularFileTestRunner.class.getDeclaredMethods()))
+ .filter(
+ new Predicate<Method>() {
+ @Override
+ public boolean apply(Method method) {
+ return method.getName().startsWith("test")
+ && Modifier.isPublic(method.getModifiers())
+ && method.getParameterTypes().length == 0;
+ }
+ })
+ .toList();
/**
* Different strategies for handling reuse of disks and/or files between tests, intended to
diff --git a/jimfs/src/test/java/com/google/common/jimfs/TestAttributeProvider.java b/jimfs/src/test/java/com/google/common/jimfs/TestAttributeProvider.java
index a912299..79b92ac 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/TestAttributeProvider.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/TestAttributeProvider.java
@@ -35,10 +35,7 @@
*/
public final class TestAttributeProvider extends AttributeProvider {
- private static final ImmutableSet<String> ATTRIBUTES = ImmutableSet.of(
- "foo",
- "bar",
- "baz");
+ private static final ImmutableSet<String> ATTRIBUTES = ImmutableSet.of("foo", "bar", "baz");
@Override
public String name() {
@@ -74,17 +71,15 @@
}
@Override
- public void set(
- File file, String view, String attribute, Object value, boolean create) {
+ public void set(File file, String view, String attribute, Object value, boolean create) {
switch (attribute) {
case "bar":
checkNotCreate(view, attribute, create);
- file.setAttribute("test", "bar",
- checkType(view, attribute, value, Number.class).longValue());
+ file.setAttribute(
+ "test", "bar", checkType(view, attribute, value, Number.class).longValue());
break;
case "baz":
- file.setAttribute("test", "baz",
- checkType(view, attribute, value, Integer.class));
+ file.setAttribute("test", "baz", checkType(view, attribute, value, Integer.class));
break;
default:
throw unsettable(view, attribute);
@@ -144,7 +139,8 @@
public void setTimes(
@Nullable FileTime lastModifiedTime,
@Nullable FileTime lastAccessTime,
- @Nullable FileTime createTime) throws IOException {
+ @Nullable FileTime createTime)
+ throws IOException {
basicView.setTimes(lastModifiedTime, lastAccessTime, createTime);
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/TestUtils.java b/jimfs/src/test/java/com/google/common/jimfs/TestUtils.java
index fb6b016..7ae2c52 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/TestUtils.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/TestUtils.java
@@ -87,7 +87,8 @@
* Returns a number of permutations of the given path that should all locate the same file.
*/
public static Iterable<Path> permutations(Path path) throws IOException {
- Path workingDir = path.getFileSystem().getPath("").toRealPath();
+ Path workingDir =
+ path.getFileSystem().getPath("").toRealPath();
boolean directory = Files.isDirectory(path);
Set<Path> results = new HashSet<>();
@@ -106,9 +107,12 @@
&& !fileName.toString().equals(".")
&& !fileName.toString().equals("..")) {
results.add(p.resolve("..").resolve(fileName));
- results.add(p.resolve("..").resolve(".").resolve(fileName));
- results.add(p.resolve("..").resolve(".").resolve(fileName).resolve("."));
- results.add(p.resolve(".").resolve("..").resolve(".").resolve(fileName));
+ results.add(
+ p.resolve("..").resolve(".").resolve(fileName));
+ results.add(
+ p.resolve("..").resolve(".").resolve(fileName).resolve("."));
+ results.add(
+ p.resolve(".").resolve("..").resolve(".").resolve(fileName));
}
}
@@ -118,10 +122,12 @@
Path childName = child.getFileName();
for (Path p : ImmutableList.copyOf(results)) {
results.add(p.resolve(childName).resolve(".."));
- results.add(p.resolve(childName).resolve(".").resolve(".").resolve(".."));
- results.add(p.resolve(childName).resolve("..").resolve("."));
- results.add(p.resolve(childName).resolve("..")
- .resolve(childName).resolve(".").resolve(".."));
+ results.add(
+ p.resolve(childName).resolve(".").resolve(".").resolve(".."));
+ results.add(
+ p.resolve(childName).resolve("..").resolve("."));
+ results.add(
+ p.resolve(childName).resolve("..").resolve(childName).resolve(".").resolve(".."));
}
break; // no need to add more than one child
}
@@ -133,8 +139,8 @@
// equivalent to the Junit 4.11 method.
public static void assertNotEquals(Object unexpected, Object actual) {
- assertFalse("Values should be different. Actual: " + actual,
- Objects.equals(unexpected, actual));
+ assertFalse(
+ "Values should be different. Actual: " + actual, Objects.equals(unexpected, actual));
}
static RegularFile regularFile(int size) {
diff --git a/jimfs/src/test/java/com/google/common/jimfs/UnixAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/UnixAttributeProviderTest.java
index f1f5a2c..f7d9847 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/UnixAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/UnixAttributeProviderTest.java
@@ -37,8 +37,8 @@
*/
@RunWith(JUnit4.class)
@SuppressWarnings("OctalInteger")
-public class UnixAttributeProviderTest extends
- AbstractAttributeProviderTest<UnixAttributeProvider> {
+public class UnixAttributeProviderTest
+ extends AbstractAttributeProviderTest<UnixAttributeProvider> {
@Override
protected UnixAttributeProvider createProvider() {
@@ -48,9 +48,7 @@
@Override
protected Set<? extends AttributeProvider> createInheritedProviders() {
return ImmutableSet.of(
- new BasicAttributeProvider(),
- new OwnerAttributeProvider(),
- new PosixAttributeProvider());
+ new BasicAttributeProvider(), new OwnerAttributeProvider(), new PosixAttributeProvider());
}
@Test
@@ -58,8 +56,8 @@
// unix provider relies on other providers to set their initial attributes
file.setAttribute("owner", "owner", createUserPrincipal("foo"));
file.setAttribute("posix", "group", createGroupPrincipal("bar"));
- file.setAttribute("posix", "permissions",
- ImmutableSet.copyOf(PosixFilePermissions.fromString("rw-r--r--")));
+ file.setAttribute(
+ "posix", "permissions", ImmutableSet.copyOf(PosixFilePermissions.fromString("rw-r--r--")));
// these are pretty much meaningless here since they aren't properties this
// file system actually has, so don't really care about the exact value of these
@@ -71,8 +69,7 @@
// these have logical origins in attributes from other views
assertThat(provider.get(file, "mode")).isEqualTo(0644); // rw-r--r--
- assertThat(provider.get(file, "ctime"))
- .isEqualTo(FileTime.fromMillis(file.getCreationTime()));
+ assertThat(provider.get(file, "ctime")).isEqualTo(FileTime.fromMillis(file.getCreationTime()));
// this is based on a property this file system does actually have
assertThat(provider.get(file, "nlink")).isEqualTo(1);
diff --git a/jimfs/src/test/java/com/google/common/jimfs/UnixPathTypeTest.java b/jimfs/src/test/java/com/google/common/jimfs/UnixPathTypeTest.java
index ae1d38f..3454509 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/UnixPathTypeTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/UnixPathTypeTest.java
@@ -62,8 +62,8 @@
assertThat(fileUri.toString()).isEqualTo("jimfs://foo/foo/bar");
assertThat(fileUri.getPath()).isEqualTo("/foo/bar");
- URI directoryUri = PathType.unix()
- .toUri(fileSystemUri, "/", ImmutableList.of("foo", "bar"), true);
+ URI directoryUri =
+ PathType.unix().toUri(fileSystemUri, "/", ImmutableList.of("foo", "bar"), true);
assertThat(directoryUri.toString()).isEqualTo("jimfs://foo/foo/bar/");
assertThat(directoryUri.getPath()).isEqualTo("/foo/bar/");
diff --git a/jimfs/src/test/java/com/google/common/jimfs/UrlTest.java b/jimfs/src/test/java/com/google/common/jimfs/UrlTest.java
index 9b7ce42..ddde80e 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/UrlTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/UrlTest.java
@@ -72,10 +72,7 @@
URL url = path.toUri().toURL();
assertThat(Resources.asCharSource(url, UTF_8).read())
- .isEqualTo(""
- + "a.txt\n"
- + "b.txt\n"
- + "c\n");
+ .isEqualTo("a.txt\nb.txt\nc\n");
}
@Test
@@ -88,10 +85,9 @@
URLConnection conn = url.openConnection();
// read header fields directly
- assertThat(conn.getHeaderFields()).containsEntry("content-length",
- ImmutableList.of("3"));
- assertThat(conn.getHeaderFields()).containsEntry("content-type",
- ImmutableList.of("application/octet-stream"));
+ assertThat(conn.getHeaderFields()).containsEntry("content-length", ImmutableList.of("3"));
+ assertThat(conn.getHeaderFields())
+ .containsEntry("content-type", ImmutableList.of("application/octet-stream"));
if (lastModified != null) {
assertThat(conn.getHeaderFields()).containsKey("last-modified");
diff --git a/jimfs/src/test/java/com/google/common/jimfs/WindowsPathTypeTest.java b/jimfs/src/test/java/com/google/common/jimfs/WindowsPathTypeTest.java
index b71ab1d..a547cd8 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/WindowsPathTypeTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/WindowsPathTypeTest.java
@@ -161,39 +161,41 @@
@Test
public void testWindows_toUri_normal() {
- URI fileUri = PathType.windows()
- .toUri(fileSystemUri, "C:\\", ImmutableList.of("foo", "bar"), false);
+ URI fileUri =
+ PathType.windows().toUri(fileSystemUri, "C:\\", ImmutableList.of("foo", "bar"), false);
assertThat(fileUri.toString()).isEqualTo("jimfs://foo/C:/foo/bar");
assertThat(fileUri.getPath()).isEqualTo("/C:/foo/bar");
- URI directoryUri = PathType.windows()
- .toUri(fileSystemUri, "C:\\", ImmutableList.of("foo", "bar"), true);
+ URI directoryUri =
+ PathType.windows().toUri(fileSystemUri, "C:\\", ImmutableList.of("foo", "bar"), true);
assertThat(directoryUri.toString()).isEqualTo("jimfs://foo/C:/foo/bar/");
assertThat(directoryUri.getPath()).isEqualTo("/C:/foo/bar/");
- URI rootUri = PathType.windows()
- .toUri(fileSystemUri, "C:\\", ImmutableList.<String>of(), true);
+ URI rootUri = PathType.windows().toUri(fileSystemUri, "C:\\", ImmutableList.<String>of(), true);
assertThat(rootUri.toString()).isEqualTo("jimfs://foo/C:/");
assertThat(rootUri.getPath()).isEqualTo("/C:/");
}
@Test
public void testWindows_toUri_unc() {
- URI fileUri = PathType.windows()
- .toUri(fileSystemUri, "\\\\host\\share\\", ImmutableList.of("foo", "bar"), false);
+ URI fileUri =
+ PathType.windows()
+ .toUri(fileSystemUri, "\\\\host\\share\\", ImmutableList.of("foo", "bar"), false);
assertThat(fileUri.toString()).isEqualTo("jimfs://foo//host/share/foo/bar");
assertThat(fileUri.getPath()).isEqualTo("//host/share/foo/bar");
- URI rootUri = PathType.windows()
- .toUri(fileSystemUri, "\\\\host\\share\\", ImmutableList.<String>of(), true);
+ URI rootUri =
+ PathType.windows()
+ .toUri(fileSystemUri, "\\\\host\\share\\", ImmutableList.<String>of(), true);
assertThat(rootUri.toString()).isEqualTo("jimfs://foo//host/share/");
assertThat(rootUri.getPath()).isEqualTo("//host/share/");
}
@Test
public void testWindows_toUri_escaping() {
- URI uri = PathType.windows()
- .toUri(fileSystemUri, "C:\\", ImmutableList.of("Users", "foo", "My Documents"), true);
+ URI uri =
+ PathType.windows()
+ .toUri(fileSystemUri, "C:\\", ImmutableList.of("Users", "foo", "My Documents"), true);
assertThat(uri.toString()).isEqualTo("jimfs://foo/C:/Users/foo/My%20Documents/");
assertThat(uri.getRawPath()).isEqualTo("/C:/Users/foo/My%20Documents/");
assertThat(uri.getPath()).isEqualTo("/C:/Users/foo/My Documents/");