names) {
StringBuilder builder = new StringBuilder();
if (root != null) {
builder.append(root);
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 47a75b0a..939aa876 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
@@ -19,7 +19,9 @@
* use the {@link com.google.common.jimfs.Jimfs Jimfs} and {@link
* com.google.common.jimfs.Configuration Configuration} classes.
*/
+@CheckReturnValue
@ParametersAreNonnullByDefault
package com.google.common.jimfs;
+import com.google.errorprone.annotations.CheckReturnValue;
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 7e2bdf95..1b9a639b 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AbstractAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AbstractAttributeProviderTest.java
@@ -36,6 +36,8 @@ public abstract class AbstractAttributeProviderTest
protected static final ImmutableMap NO_INHERITED_VIEWS =
ImmutableMap.of();
+ protected final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
protected P provider;
protected File file;
@@ -57,7 +59,7 @@ public File lookup() throws IOException {
@Before
public void setUp() {
this.provider = createProvider();
- this.file = Directory.create(0);
+ this.file = Directory.create(0, fileTimeSource.now());
Map defaultValues = createDefaultValues();
setDefaultValues(file, provider, defaultValues);
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 70ac0e99..141cc133 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AbstractPathMatcherTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AbstractPathMatcherTest.java
@@ -20,6 +20,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.File;
import java.io.IOException;
import java.net.URI;
@@ -33,7 +34,7 @@
import java.nio.file.WatchService;
import java.util.Iterator;
import java.util.regex.PatternSyntaxException;
-import org.checkerframework.checker.nullness.compatqual.NullableDecl;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Abstract base class for tests of {@link PathMatcher} implementations.
@@ -48,8 +49,7 @@ public abstract class AbstractPathMatcherTest {
protected abstract PathMatcher matcher(String pattern);
/** Override to return a real matcher for the given pattern. */
- @NullableDecl
- protected PathMatcher realMatcher(String pattern) {
+ protected @Nullable PathMatcher realMatcher(String pattern) {
return null;
}
@@ -77,13 +77,14 @@ protected final class PatternAsserter {
private final PathMatcher matcher;
- @NullableDecl private final PathMatcher realMatcher;
+ private final @Nullable PathMatcher realMatcher;
PatternAsserter(String pattern) {
this.matcher = matcher(pattern);
this.realMatcher = realMatcher(pattern);
}
+ @CanIgnoreReturnValue
PatternAsserter matches(String... paths) {
for (String path : paths) {
assertTrue(
@@ -98,6 +99,7 @@ PatternAsserter matches(String... paths) {
return this;
}
+ @CanIgnoreReturnValue
PatternAsserter doesNotMatch(String... paths) {
for (String path : paths) {
assertFalse(
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 80b01910..c7a12f4f 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java
@@ -43,6 +43,8 @@ public class AttributeServiceTest {
private AttributeService service;
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
@Before
public void setUp() {
ImmutableSet providers =
@@ -53,6 +55,10 @@ public void setUp() {
service = new AttributeService(providers, ImmutableMap.of());
}
+ private File createFile() {
+ return Directory.create(0, fileTimeSource.now());
+ }
+
@Test
public void testSupportedFileAttributeViews() {
assertThat(service.supportedFileAttributeViews())
@@ -68,7 +74,7 @@ public void testSupportsFileAttributeView() {
@Test
public void testSetInitialAttributes() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file);
assertThat(file.getAttributeNames("test")).containsExactly("bar", "baz");
@@ -81,7 +87,7 @@ public void testSetInitialAttributes() {
@Test
public void testGetAttribute() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file);
assertThat(service.getAttribute(file, "test:foo")).isEqualTo("hello");
@@ -93,7 +99,7 @@ public void testGetAttribute() {
@Test
public void testGetAttribute_fromInheritedProvider() {
- File file = Directory.create(0);
+ File file = createFile();
assertThat(service.getAttribute(file, "test:isRegularFile")).isEqualTo(false);
assertThat(service.getAttribute(file, "test:isDirectory")).isEqualTo(true);
assertThat(service.getAttribute(file, "test", "fileKey")).isEqualTo(0);
@@ -101,7 +107,7 @@ public void testGetAttribute_fromInheritedProvider() {
@Test
public void testGetAttribute_failsForAttributesNotDefinedByProvider() {
- File file = Directory.create(0);
+ File file = createFile();
try {
service.getAttribute(file, "test:blah");
fail();
@@ -118,7 +124,7 @@ public void testGetAttribute_failsForAttributesNotDefinedByProvider() {
@Test
public void testSetAttribute() {
- File file = Directory.create(0);
+ File file = createFile();
service.setAttribute(file, "test:bar", 10L, false);
assertThat(file.getAttribute("test", "bar")).isEqualTo(10L);
@@ -128,7 +134,7 @@ public void testSetAttribute() {
@Test
public void testSetAttribute_forInheritedProvider() {
- File file = Directory.create(0);
+ File file = createFile();
service.setAttribute(file, "test:lastModifiedTime", FileTime.fromMillis(0), false);
assertThat(file.getAttribute("test", "lastModifiedTime")).isNull();
assertThat(service.getAttribute(file, "basic:lastModifiedTime"))
@@ -137,7 +143,7 @@ public void testSetAttribute_forInheritedProvider() {
@Test
public void testSetAttribute_withAlternateAcceptedType() {
- File file = Directory.create(0);
+ File file = createFile();
service.setAttribute(file, "test:bar", 10F, false);
assertThat(file.getAttribute("test", "bar")).isEqualTo(10L);
@@ -147,14 +153,14 @@ public void testSetAttribute_withAlternateAcceptedType() {
@Test
public void testSetAttribute_onCreate() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file, new BasicFileAttribute<>("test:baz", 123));
assertThat(file.getAttribute("test", "baz")).isEqualTo(123);
}
@Test
public void testSetAttribute_failsForAttributesNotDefinedByProvider() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file);
try {
@@ -175,7 +181,7 @@ public void testSetAttribute_failsForAttributesNotDefinedByProvider() {
@Test
public void testSetAttribute_failsForArgumentThatIsNotOfCorrectType() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file);
try {
service.setAttribute(file, "test:bar", "wrong", false);
@@ -188,7 +194,7 @@ public void testSetAttribute_failsForArgumentThatIsNotOfCorrectType() {
@Test
public void testSetAttribute_failsForNullArgument() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file);
try {
service.setAttribute(file, "test:bar", null, false);
@@ -201,7 +207,7 @@ public void testSetAttribute_failsForNullArgument() {
@Test
public void testSetAttribute_failsForAttributeThatIsNotSettable() {
- File file = Directory.create(0);
+ File file = createFile();
try {
service.setAttribute(file, "test:foo", "world", false);
fail();
@@ -213,7 +219,7 @@ public void testSetAttribute_failsForAttributeThatIsNotSettable() {
@Test
public void testSetAttribute_onCreate_failsForAttributeThatIsNotSettableOnCreate() {
- File file = Directory.create(0);
+ File file = createFile();
try {
service.setInitialAttributes(file, new BasicFileAttribute<>("test:foo", "world"));
fail();
@@ -232,7 +238,7 @@ public void testSetAttribute_onCreate_failsForAttributeThatIsNotSettableOnCreate
@SuppressWarnings("ConstantConditions")
@Test
public void testGetFileAttributeView() throws IOException {
- final File file = Directory.create(0);
+ final File file = createFile();
service.setInitialAttributes(file);
FileLookup fileLookup =
@@ -255,7 +261,7 @@ public File lookup() throws IOException {
@Test
public void testGetFileAttributeView_isNullForUnsupportedView() {
- final File file = Directory.create(0);
+ final File file = createFile();
FileLookup fileLookup =
new FileLookup() {
@Override
@@ -268,13 +274,13 @@ public File lookup() throws IOException {
@Test
public void testReadAttributes_asMap() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file);
ImmutableMap map = service.readAttributes(file, "test:foo,bar,baz");
assertThat(map).isEqualTo(ImmutableMap.of("foo", "hello", "bar", 0L, "baz", 1));
- FileTime time = (FileTime) service.getAttribute(file, "basic:creationTime");
+ FileTime time = fileTimeSource.now();
map = service.readAttributes(file, "test:*");
assertThat(map)
@@ -312,7 +318,7 @@ public void testReadAttributes_asMap() {
@Test
public void testReadAttributes_asMap_failsForInvalidAttributes() {
- File file = Directory.create(0);
+ File file = createFile();
try {
service.readAttributes(file, "basic:fileKey,isOther,*,creationTime");
fail();
@@ -330,7 +336,7 @@ public void testReadAttributes_asMap_failsForInvalidAttributes() {
@Test
public void testReadAttributes_asObject() {
- File file = Directory.create(0);
+ File file = createFile();
service.setInitialAttributes(file);
BasicFileAttributes basicAttrs = service.readAttributes(file, BasicFileAttributes.class);
@@ -349,7 +355,7 @@ public void testReadAttributes_asObject() {
@Test
public void testReadAttributes_failsForUnsupportedAttributesType() {
- File file = Directory.create(0);
+ File file = createFile();
try {
service.readAttributes(file, PosixFileAttributes.class);
fail();
@@ -359,7 +365,7 @@ public void testReadAttributes_failsForUnsupportedAttributesType() {
@Test
public void testIllegalAttributeFormats() {
- File file = Directory.create(0);
+ File file = createFile();
try {
service.getAttribute(file, ":bar");
fail();
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 a101b789..5c72eeb6 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/BasicAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/BasicAttributeProviderTest.java
@@ -64,10 +64,10 @@ public void testSupportedAttributes() {
@Test
public void testInitialAttributes() {
- long time = file.getCreationTime();
- assertThat(time).isNotEqualTo(0L);
- assertThat(time).isEqualTo(file.getLastAccessTime());
- assertThat(time).isEqualTo(file.getLastModifiedTime());
+ FileTime expected = fileTimeSource.now();
+ assertThat(file.getCreationTime()).isEqualTo(expected);
+ assertThat(file.getLastAccessTime()).isEqualTo(expected);
+ assertThat(file.getLastModifiedTime()).isEqualTo(expected);
assertContainsAll(
file,
@@ -121,22 +121,22 @@ public void testView() throws IOException {
BasicFileAttributes attrs = view.readAttributes();
assertThat(attrs.fileKey()).isEqualTo(0);
- FileTime time = attrs.creationTime();
- assertThat(attrs.lastAccessTime()).isEqualTo(time);
- assertThat(attrs.lastModifiedTime()).isEqualTo(time);
+ FileTime initial = fileTimeSource.now();
+ assertThat(attrs.creationTime()).isEqualTo(initial);
+ assertThat(attrs.lastAccessTime()).isEqualTo(initial);
+ assertThat(attrs.lastModifiedTime()).isEqualTo(initial);
view.setTimes(null, null, null);
- attrs = view.readAttributes();
- assertThat(attrs.creationTime()).isEqualTo(time);
- assertThat(attrs.lastAccessTime()).isEqualTo(time);
- assertThat(attrs.lastModifiedTime()).isEqualTo(time);
+ assertThat(attrs.creationTime()).isEqualTo(initial);
+ assertThat(attrs.lastAccessTime()).isEqualTo(initial);
+ assertThat(attrs.lastModifiedTime()).isEqualTo(initial);
view.setTimes(FileTime.fromMillis(0L), null, null);
attrs = view.readAttributes();
- assertThat(attrs.creationTime()).isEqualTo(time);
- assertThat(attrs.lastAccessTime()).isEqualTo(time);
+ assertThat(attrs.creationTime()).isEqualTo(initial);
+ assertThat(attrs.lastAccessTime()).isEqualTo(initial);
assertThat(attrs.lastModifiedTime()).isEqualTo(FileTime.fromMillis(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 74289757..0041318e 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/ByteBufferChannel.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/ByteBufferChannel.java
@@ -16,6 +16,7 @@
package com.google.common.jimfs;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
@@ -72,6 +73,7 @@ public long position() throws IOException {
}
@Override
+ @CanIgnoreReturnValue
public SeekableByteChannel position(long newPosition) throws IOException {
buffer.position((int) newPosition);
return this;
@@ -83,6 +85,7 @@ public long size() throws IOException {
}
@Override
+ @CanIgnoreReturnValue
public SeekableByteChannel truncate(long size) throws IOException {
buffer.limit((int) size);
return this;
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 0404f57f..19898c90 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
@@ -70,6 +70,7 @@ public void testDefaultUnixConfiguration() {
assertThat(config.attributeViews).containsExactly("basic");
assertThat(config.attributeProviders).isEmpty();
assertThat(config.defaultAttributeValues).isEmpty();
+ assertThat(config.fileTimeSource).isEqualTo(SystemFileTimeSource.INSTANCE);
}
@Test
@@ -104,6 +105,7 @@ public void testDefaultOsXConfiguration() {
assertThat(config.attributeViews).containsExactly("basic");
assertThat(config.attributeProviders).isEmpty();
assertThat(config.defaultAttributeValues).isEmpty();
+ assertThat(config.fileTimeSource).isEqualTo(SystemFileTimeSource.INSTANCE);
}
@Test
@@ -143,6 +145,7 @@ public void testDefaultWindowsConfiguration() {
assertThat(config.attributeViews).containsExactly("basic");
assertThat(config.attributeProviders).isEmpty();
assertThat(config.defaultAttributeValues).isEmpty();
+ assertThat(config.fileTimeSource).isEqualTo(SystemFileTimeSource.INSTANCE);
}
@Test
@@ -170,6 +173,7 @@ public void testFileSystemForDefaultWindowsConfiguration() throws IOException {
public void testBuilder() {
AttributeProvider unixProvider = StandardAttributeProviders.get("unix");
+ FileTimeSource fileTimeSource = new FakeFileTimeSource();
Configuration config =
Configuration.builder(PathType.unix())
.setRoots("/")
@@ -184,6 +188,7 @@ public void testBuilder() {
.addAttributeProvider(unixProvider)
.setDefaultAttributeValue(
"posix:permissions", PosixFilePermissions.fromString("---------"))
+ .setFileTimeSource(fileTimeSource)
.build();
assertThat(config.pathType).isEqualTo(PathType.unix());
@@ -199,10 +204,12 @@ public void testBuilder() {
assertThat(config.attributeProviders).containsExactly(unixProvider);
assertThat(config.defaultAttributeValues)
.containsEntry("posix:permissions", PosixFilePermissions.fromString("---------"));
+ assertThat(config.fileTimeSource).isEqualTo(fileTimeSource);
}
@Test
public void testFileSystemForCustomConfiguration() throws IOException {
+ FileTimeSource fileTimeSource = new FakeFileTimeSource();
Configuration config =
Configuration.builder(PathType.unix())
.setRoots("/")
@@ -216,6 +223,7 @@ public void testFileSystemForCustomConfiguration() throws IOException {
.setAttributeViews("unix")
.setDefaultAttributeValue(
"posix:permissions", PosixFilePermissions.fromString("---------"))
+ .setFileTimeSource(fileTimeSource)
.build();
FileSystem fs = Jimfs.newFileSystem(config);
@@ -230,6 +238,8 @@ public void testFileSystemForCustomConfiguration() throws IOException {
Files.createFile(fs.getPath("/foo"));
assertThat(Files.getAttribute(fs.getPath("/foo"), "posix:permissions"))
.isEqualTo(PosixFilePermissions.fromString("---------"));
+ assertThat(Files.getAttribute(fs.getPath("/foo"), "creationTime"))
+ .isEqualTo(fileTimeSource.now());
try {
Files.createFile(fs.getPath("/FOO"));
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 1fee1e5c..ed097d8e 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java
@@ -28,7 +28,7 @@
import com.google.common.collect.Iterables;
import java.util.HashSet;
import java.util.Set;
-import org.checkerframework.checker.nullness.compatqual.NullableDecl;
+import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,17 +42,23 @@
@RunWith(JUnit4.class)
public class DirectoryTest {
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
private Directory root;
private Directory dir;
@Before
public void setUp() {
- root = Directory.createRoot(0, Name.simple("/"));
+ root = Directory.createRoot(0, fileTimeSource.now(), Name.simple("/"));
- dir = Directory.create(1);
+ dir = createDirectory(1);
root.link(Name.simple("foo"), dir);
}
+ private Directory createDirectory(int id) {
+ return Directory.create(id, fileTimeSource.now());
+ }
+
@Test
public void testRootDirectory() {
assertThat(root.entryCount()).isEqualTo(3); // two for parent/self, one for dir
@@ -82,7 +88,7 @@ public void testGet() {
public void testLink() {
assertThat(dir.get(Name.simple("bar"))).isNull();
- File bar = Directory.create(2);
+ File bar = createDirectory(2);
dir.link(Name.simple("bar"), bar);
assertThat(dir.get(Name.simple("bar"))).isEqualTo(entry(dir, "bar", bar));
@@ -91,7 +97,7 @@ public void testLink() {
@Test
public void testLink_existingNameFails() {
try {
- root.link(Name.simple("foo"), Directory.create(2));
+ root.link(Name.simple("foo"), createDirectory(2));
fail();
} catch (IllegalArgumentException expected) {
}
@@ -100,13 +106,13 @@ public void testLink_existingNameFails() {
@Test
public void testLink_parentAndSelfNameFails() {
try {
- dir.link(Name.simple("."), Directory.create(2));
+ dir.link(Name.simple("."), createDirectory(2));
fail();
} catch (IllegalArgumentException expected) {
}
try {
- dir.link(Name.simple(".."), Directory.create(2));
+ dir.link(Name.simple(".."), createDirectory(2));
fail();
} catch (IllegalArgumentException expected) {
}
@@ -114,7 +120,7 @@ public void testLink_parentAndSelfNameFails() {
@Test
public void testGet_normalizingCaseInsensitive() {
- File bar = Directory.create(2);
+ File bar = createDirectory(2);
Name barName = caseInsensitive("bar");
dir.link(barName, bar);
@@ -161,7 +167,7 @@ public void testUnlink_parentAndSelfNameFails() {
@Test
public void testUnlink_normalizingCaseInsensitive() {
- dir.link(caseInsensitive("bar"), Directory.create(2));
+ dir.link(caseInsensitive("bar"), createDirectory(2));
assertThat(dir.get(caseInsensitive("bar"))).isNotNull();
@@ -172,7 +178,7 @@ public void testUnlink_normalizingCaseInsensitive() {
@Test
public void testLinkDirectory() {
- Directory newDir = Directory.create(10);
+ Directory newDir = createDirectory(10);
assertThat(newDir.entryInParent()).isNull();
assertThat(newDir.get(Name.SELF).file()).isEqualTo(newDir);
@@ -191,7 +197,7 @@ public void testLinkDirectory() {
@Test
public void testUnlinkDirectory() {
- Directory newDir = Directory.create(10);
+ Directory newDir = createDirectory(10);
dir.link(Name.simple("foo"), newDir);
@@ -215,15 +221,8 @@ public void testSnapshot() {
root.link(Name.simple("bar"), regularFile(10));
root.link(Name.simple("abc"), regularFile(10));
- /*
- * If we inline this into the assertThat call below, javac resolves it to assertThat(SortedSet),
- * which isn't available publicly. Our internal build system considers that to be an error, even
- * though the code will compile fine externally by resolving to assertThat(Iterable) instead. So
- * we avoid that by assigning to a non-SortedSet type here.
- */
- ImmutableSet snapshot = root.snapshot();
// does not include . or .. and is sorted by the name
- assertThat(snapshot)
+ assertThat(root.snapshot())
.containsExactly(Name.simple("abc"), Name.simple("bar"), Name.simple("foo"))
.inOrder();
}
@@ -244,7 +243,7 @@ public void testSnapshot_sortsUsingStringAndNotCanonicalValueOfNames() {
// Tests for internal hash table implementation
- private static final Directory A = Directory.create(0);
+ private final Directory a = createDirectory(0);
@Test
public void testInitialState() {
@@ -361,15 +360,15 @@ public void testManyPutsAndRemoves() {
}
}
- private static DirectoryEntry entry(String name) {
- return new DirectoryEntry(A, Name.simple(name), A);
+ private DirectoryEntry entry(String name) {
+ return new DirectoryEntry(a, Name.simple(name), a);
}
- private static DirectoryEntry entry(Directory dir, String name, @NullableDecl File file) {
+ private DirectoryEntry entry(Directory dir, String name, @Nullable File file) {
return new DirectoryEntry(dir, Name.simple(name), file);
}
- private static void assertParentAndSelf(Directory dir, File parent, File self) {
+ private void assertParentAndSelf(Directory dir, File parent, File self) {
assertThat(dir).isEqualTo(self);
assertThat(dir.parent()).isEqualTo(parent);
diff --git a/jimfs/src/test/java/com/google/common/jimfs/FakeFileTimeSource.java b/jimfs/src/test/java/com/google/common/jimfs/FakeFileTimeSource.java
new file mode 100644
index 00000000..8fcb64b2
--- /dev/null
+++ b/jimfs/src/test/java/com/google/common/jimfs/FakeFileTimeSource.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2021 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.common.jimfs;
+
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
+import java.nio.file.attribute.FileTime;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Random;
+
+/** Fake implementation of {@link FileTimeSource}. */
+final class FakeFileTimeSource implements FileTimeSource {
+
+ private final Random random = new Random(System.currentTimeMillis());
+ private Instant now;
+
+ FakeFileTimeSource() {
+ randomize();
+ }
+
+ @CanIgnoreReturnValue
+ FakeFileTimeSource randomize() {
+ now =
+ Instant.ofEpochSecond(
+ random
+ .longs(Instant.MIN.getEpochSecond(), Instant.MAX.getEpochSecond())
+ .findAny()
+ .getAsLong(),
+ random.nextInt(1_000_000_000));
+ return this;
+ }
+
+ @CanIgnoreReturnValue
+ FakeFileTimeSource advance(Duration duration) {
+ this.now = now.plus(duration);
+ return this;
+ }
+
+ @Override
+ public FileTime now() {
+ return FileTime.from(now);
+ }
+}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/FileFactoryTest.java b/jimfs/src/test/java/com/google/common/jimfs/FileFactoryTest.java
index 9e3cb403..ad2e0dc4 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/FileFactoryTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/FileFactoryTest.java
@@ -31,11 +31,13 @@
@RunWith(JUnit4.class)
public class FileFactoryTest {
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
private FileFactory factory;
@Before
public void setUp() {
- factory = new FileFactory(new HeapDisk(2, 2, 0));
+ factory = new FileFactory(new HeapDisk(2, 2, 0), fileTimeSource);
}
@Test
@@ -43,14 +45,19 @@ public void testCreateFiles_basic() {
File file = factory.createDirectory();
assertThat(file.id()).isEqualTo(0L);
assertThat(file.isDirectory()).isTrue();
+ assertThat(file.getCreationTime()).isEqualTo(fileTimeSource.now());
+ fileTimeSource.randomize();
file = factory.createRegularFile();
assertThat(file.id()).isEqualTo(1L);
assertThat(file.isRegularFile()).isTrue();
+ assertThat(file.getCreationTime()).isEqualTo(fileTimeSource.now());
+ fileTimeSource.randomize();
file = factory.createSymbolicLink(fakePath());
assertThat(file.id()).isEqualTo(2L);
assertThat(file.isSymbolicLink()).isTrue();
+ assertThat(file.getCreationTime()).isEqualTo(fileTimeSource.now());
}
@Test
@@ -58,14 +65,19 @@ public void testCreateFiles_withSupplier() {
File file = factory.directoryCreator().get();
assertThat(file.id()).isEqualTo(0L);
assertThat(file.isDirectory()).isTrue();
+ assertThat(file.getCreationTime()).isEqualTo(fileTimeSource.now());
+ fileTimeSource.randomize();
file = factory.regularFileCreator().get();
assertThat(file.id()).isEqualTo(1L);
assertThat(file.isRegularFile()).isTrue();
+ assertThat(file.getCreationTime()).isEqualTo(fileTimeSource.now());
+ fileTimeSource.randomize();
file = factory.symbolicLinkCreator(fakePath()).get();
assertThat(file.id()).isEqualTo(2L);
assertThat(file.isSymbolicLink()).isTrue();
+ assertThat(file.getCreationTime()).isEqualTo(fileTimeSource.now());
}
static JimfsPath fakePath() {
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 f8143b6e..8ad5c51c 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/FileSystemStateTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/FileSystemStateTest.java
@@ -16,6 +16,7 @@
package com.google.common.jimfs;
+import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -26,6 +27,7 @@
import java.io.Closeable;
import java.io.IOException;
import java.nio.file.ClosedFileSystemException;
+import java.time.Duration;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,7 +42,8 @@
public class FileSystemStateTest {
private final TestRunnable onClose = new TestRunnable();
- private final FileSystemState state = new FileSystemState(onClose);
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+ private final FileSystemState state = new FileSystemState(fileTimeSource, onClose);
@Test
public void testIsOpen() throws IOException {
@@ -60,6 +63,13 @@ public void testCheckOpen() throws IOException {
}
}
+ @Test
+ public void testNow() {
+ assertThat(state.now()).isEqualTo(fileTimeSource.now());
+ fileTimeSource.advance(Duration.ofSeconds(1));
+ assertThat(state.now()).isEqualTo(fileTimeSource.now());
+ }
+
@Test
public void testClose_callsOnCloseRunnable() throws IOException {
assertEquals(0, onClose.runCount);
diff --git a/jimfs/src/test/java/com/google/common/jimfs/FileTest.java b/jimfs/src/test/java/com/google/common/jimfs/FileTest.java
index 83cda00e..d128c6a2 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/FileTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/FileTest.java
@@ -32,12 +32,14 @@
@RunWith(JUnit4.class)
public class FileTest {
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
@Test
public void testAttributes() {
// these methods are basically just thin wrappers around a map, so no need to test too
// thoroughly
- File file = RegularFile.create(0, new HeapDisk(10, 10, 10));
+ File file = RegularFile.create(0, fileTimeSource.now(), new HeapDisk(10, 10, 10));
assertThat(file.getAttributeKeys()).isEmpty();
assertThat(file.getAttribute("foo", "foo")).isNull();
@@ -65,7 +67,7 @@ public void testFileBasics() {
@Test
public void testDirectory() {
- File file = Directory.create(0);
+ File file = Directory.create(0, fileTimeSource.now());
assertThat(file.isDirectory()).isTrue();
assertThat(file.isRegularFile()).isFalse();
assertThat(file.isSymbolicLink()).isFalse();
@@ -81,7 +83,7 @@ public void testRegularFile() {
@Test
public void testSymbolicLink() {
- File file = SymbolicLink.create(0, fakePath());
+ File file = SymbolicLink.create(0, fileTimeSource.now(), fakePath());
assertThat(file.isDirectory()).isFalse();
assertThat(file.isRegularFile()).isFalse();
assertThat(file.isSymbolicLink()).isTrue();
@@ -89,10 +91,10 @@ public void testSymbolicLink() {
@Test
public void testRootDirectory() {
- Directory file = Directory.createRoot(0, Name.simple("/"));
+ Directory file = Directory.createRoot(0, fileTimeSource.now(), Name.simple("/"));
assertThat(file.isRootDirectory()).isTrue();
- Directory otherFile = Directory.createRoot(1, Name.simple("$"));
+ Directory otherFile = Directory.createRoot(1, fileTimeSource.now(), Name.simple("$"));
assertThat(otherFile.isRootDirectory()).isTrue();
}
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 54f590d2..55032d93 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/FileTreeTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/FileTreeTest.java
@@ -25,13 +25,14 @@
import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.nio.file.LinkOption;
import java.nio.file.NoSuchFileException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
-import org.checkerframework.checker.nullness.compatqual.NullableDecl;
+import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -87,7 +88,7 @@ public ParseResult parsePath(String path) {
}
@Override
- public String toString(@NullableDecl String root, Iterable names) {
+ public String toString(@Nullable String root, Iterable names) {
root = Strings.nullToEmpty(root);
return root + Joiner.on('/').join(names);
}
@@ -101,22 +102,26 @@ public String toUriPath(String root, Iterable names, boolean directory)
@Override
public ParseResult parseUriPath(String uriPath) {
checkArgument(
- uriPath.matches("^/[/$!].*"), "uriPath (%s) must start with // or /$ or /!");
+ uriPath.matches("^/[/$!].*"),
+ "uriPath (%s) must start with // or /$ or /!",
+ uriPath);
return parsePath(uriPath.substring(1)); // skip leading /
}
},
false);
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
private FileTree fileTree;
private File workingDirectory;
private final Map files = new HashMap<>();
@Before
public void setUp() {
- Directory root = Directory.createRoot(0, Name.simple("/"));
+ Directory root = Directory.createRoot(0, fileTimeSource.now(), Name.simple("/"));
files.put("/", root);
- Directory otherRoot = Directory.createRoot(2, Name.simple("$"));
+ Directory otherRoot = Directory.createRoot(2, fileTimeSource.now(), Name.simple("$"));
files.put("$", otherRoot);
Map roots = new HashMap<>();
@@ -437,14 +442,16 @@ private void assertParentExists(DirectoryEntry entry, String parent) {
}
}
+ @CanIgnoreReturnValue
private File createDirectory(String parent, String name) {
Directory dir = (Directory) files.get(parent);
- Directory newFile = Directory.create(new Random().nextInt());
+ Directory newFile = Directory.create(new Random().nextInt(), fileTimeSource.now());
dir.link(Name.simple(name), newFile);
files.put(name, newFile);
return newFile;
}
+ @CanIgnoreReturnValue
private File createFile(String parent, String name) {
Directory dir = (Directory) files.get(parent);
File newFile = regularFile(0);
@@ -453,9 +460,12 @@ private File createFile(String parent, String name) {
return newFile;
}
+ @CanIgnoreReturnValue
private File createSymbolicLink(String parent, String name, String target) {
Directory dir = (Directory) files.get(parent);
- File newFile = SymbolicLink.create(new Random().nextInt(), pathService.parsePath(target));
+ File newFile =
+ SymbolicLink.create(
+ new Random().nextInt(), fileTimeSource.now(), pathService.parsePath(target));
dir.link(Name.simple(name), newFile);
files.put(name, newFile);
return newFile;
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 af09b85e..48235893 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/HeapDiskTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/HeapDiskTest.java
@@ -35,12 +35,14 @@
@RunWith(JUnit4.class)
public class HeapDiskTest {
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
private RegularFile blocks;
@Before
public void setUp() {
// the HeapDisk of this file is unused; it's passed to other HeapDisks to test operations
- blocks = RegularFile.create(-1, new HeapDisk(2, 2, 2));
+ blocks = RegularFile.create(-1, fileTimeSource.now(), new HeapDisk(2, 2, 2));
}
@Test
@@ -216,7 +218,7 @@ public void testFullDisk_doesNotAllocatePartiallyWhenTooManyBlocksRequested() th
HeapDisk disk = new HeapDisk(4, 10, 4);
disk.allocate(blocks, 6);
- RegularFile blocks2 = RegularFile.create(-2, disk);
+ RegularFile blocks2 = RegularFile.create(-2, fileTimeSource.now(), disk);
try {
disk.allocate(blocks2, 5);
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 7d47588a..a4a4ba91 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsAsynchronousFileChannelTest.java
@@ -63,7 +63,7 @@ private static JimfsAsynchronousFileChannel channel(
new JimfsFileChannel(
file,
Options.getOptionsForChannel(ImmutableSet.copyOf(options)),
- new FileSystemState(Runnables.doNothing()));
+ new FileSystemState(new FakeFileTimeSource(), Runnables.doNothing()));
return new JimfsAsynchronousFileChannel(channel, executor);
}
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 c525ef1f..295dd7c1 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java
@@ -48,6 +48,8 @@
import java.nio.channels.NonReadableChannelException;
import java.nio.channels.NonWritableChannelException;
import java.nio.file.OpenOption;
+import java.nio.file.attribute.FileTime;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
@@ -74,7 +76,7 @@ private static FileChannel channel(RegularFile file, OpenOption... options) thro
return new JimfsFileChannel(
file,
Options.getOptionsForChannel(ImmutableSet.copyOf(options)),
- new FileSystemState(Runnables.doNothing()));
+ new FileSystemState(new FakeFileTimeSource(), Runnables.doNothing()));
}
@Test
@@ -227,76 +229,77 @@ public void testTruncate() throws IOException {
@Test
public void testFileTimeUpdates() throws IOException {
RegularFile file = regularFile(10);
+ FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
FileChannel channel =
new JimfsFileChannel(
file,
ImmutableSet.of(READ, WRITE),
- new FileSystemState(Runnables.doNothing()));
+ new FileSystemState(fileTimeSource, Runnables.doNothing()));
- // accessed
- long accessTime = file.getLastAccessTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ // accessedTime
+ FileTime accessTime = file.getLastAccessTime();
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.read(ByteBuffer.allocate(10));
assertNotEquals(accessTime, file.getLastAccessTime());
accessTime = file.getLastAccessTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.read(ByteBuffer.allocate(10), 0);
assertNotEquals(accessTime, file.getLastAccessTime());
accessTime = file.getLastAccessTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.read(new ByteBuffer[] {ByteBuffer.allocate(10)});
assertNotEquals(accessTime, file.getLastAccessTime());
accessTime = file.getLastAccessTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.read(new ByteBuffer[] {ByteBuffer.allocate(10)}, 0, 1);
assertNotEquals(accessTime, file.getLastAccessTime());
accessTime = file.getLastAccessTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.transferTo(0, 10, new ByteBufferChannel(10));
assertNotEquals(accessTime, file.getLastAccessTime());
// modified
- long modifiedTime = file.getLastModifiedTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ FileTime modifiedTime = file.getLastModifiedTime();
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.write(ByteBuffer.allocate(10));
assertNotEquals(modifiedTime, file.getLastModifiedTime());
modifiedTime = file.getLastModifiedTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.write(ByteBuffer.allocate(10), 0);
assertNotEquals(modifiedTime, file.getLastModifiedTime());
modifiedTime = file.getLastModifiedTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.write(new ByteBuffer[] {ByteBuffer.allocate(10)});
assertNotEquals(modifiedTime, file.getLastModifiedTime());
modifiedTime = file.getLastModifiedTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.write(new ByteBuffer[] {ByteBuffer.allocate(10)}, 0, 1);
assertNotEquals(modifiedTime, file.getLastModifiedTime());
modifiedTime = file.getLastModifiedTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.truncate(0);
assertNotEquals(modifiedTime, file.getLastModifiedTime());
modifiedTime = file.getLastModifiedTime();
- Uninterruptibles.sleepUninterruptibly(2, MILLISECONDS);
+ fileTimeSource.advance(Duration.ofMillis(2));
channel.transferFrom(new ByteBufferChannel(10), 0, 10);
assertNotEquals(modifiedTime, file.getLastModifiedTime());
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 94cc5f47..8a2947e1 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsInputStreamTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsInputStreamTest.java
@@ -228,7 +228,8 @@ private static JimfsInputStream newInputStream(int... bytes) throws IOException
RegularFile file = regularFile(0);
file.write(0, b, 0, b.length);
- return new JimfsInputStream(file, new FileSystemState(Runnables.doNothing()));
+ return new JimfsInputStream(
+ file, new FileSystemState(new FakeFileTimeSource(), Runnables.doNothing()));
}
private static void assertEmpty(JimfsInputStream in) throws IOException {
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 3c230a74..4a8b1690 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsOutputStreamTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsOutputStreamTest.java
@@ -184,7 +184,8 @@ public void testClosedOutputStream_doesNotThrowOnFlush() throws IOException {
private static JimfsOutputStream newOutputStream(boolean append) {
RegularFile file = regularFile(0);
- return new JimfsOutputStream(file, append, new FileSystemState(Runnables.doNothing()));
+ return new JimfsOutputStream(
+ file, append, new FileSystemState(new FakeFileTimeSource(), Runnables.doNothing()));
}
@SuppressWarnings("GuardedByChecker")
@@ -199,7 +200,7 @@ private static void addBytesToStore(JimfsOutputStream out, int... bytes) throws
@SuppressWarnings("GuardedByChecker")
private static void assertStoreContains(JimfsOutputStream out, int... bytes) {
byte[] actualBytes = new byte[bytes.length];
- out.file.read(0, actualBytes, 0, actualBytes.length);
+ int unused = out.file.read(0, actualBytes, 0, actualBytes.length);
assertArrayEquals(bytes(bytes), actualBytes);
}
}
diff --git a/jimfs/src/test/java/com/google/common/jimfs/PathSubject.java b/jimfs/src/test/java/com/google/common/jimfs/PathSubject.java
index f6927a5e..991b1286 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PathSubject.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PathSubject.java
@@ -26,6 +26,7 @@
import com.google.common.io.BaseEncoding;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.Subject;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.DirectoryStream;
@@ -36,7 +37,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.checkerframework.checker.nullness.compatqual.NullableDecl;
+import org.checkerframework.checker.nullness.qual.Nullable;
/**
* Subject for doing assertions on file system paths.
@@ -67,11 +68,13 @@ private Path toPath(String path) {
}
/** Returns this, for readability of chained assertions. */
+ @CanIgnoreReturnValue
public PathSubject and() {
return this;
}
/** Do not follow links when looking up the path. */
+ @CanIgnoreReturnValue
public PathSubject noFollowLinks() {
this.linkOptions = NOFOLLOW_LINKS;
return this;
@@ -81,12 +84,14 @@ public PathSubject noFollowLinks() {
* Set the given charset to be used when reading the file at this path as text. Default charset if
* not set is UTF-8.
*/
+ @CanIgnoreReturnValue
public PathSubject withCharset(Charset charset) {
this.charset = checkNotNull(charset);
return this;
}
/** Asserts that the path is absolute (it has a root component). */
+ @CanIgnoreReturnValue
public PathSubject isAbsolute() {
if (!actual.isAbsolute()) {
failWithActual(simpleFact("expected to be absolute"));
@@ -95,6 +100,7 @@ public PathSubject isAbsolute() {
}
/** Asserts that the path is relative (it has no root component). */
+ @CanIgnoreReturnValue
public PathSubject isRelative() {
if (actual.isAbsolute()) {
failWithActual(simpleFact("expected to be relative"));
@@ -103,7 +109,8 @@ public PathSubject isRelative() {
}
/** Asserts that the path has the given root component. */
- public PathSubject hasRootComponent(@NullableDecl String root) {
+ @CanIgnoreReturnValue
+ public PathSubject hasRootComponent(@Nullable String root) {
Path rootComponent = actual.getRoot();
if (root == null && rootComponent != null) {
failWithActual("expected to have root component", root);
@@ -114,12 +121,14 @@ public PathSubject hasRootComponent(@NullableDecl String root) {
}
/** Asserts that the path has no name components. */
+ @CanIgnoreReturnValue
public PathSubject hasNoNameComponents() {
check("getNameCount()").that(actual.getNameCount()).isEqualTo(0);
return this;
}
/** Asserts that the path has the given name components. */
+ @CanIgnoreReturnValue
public PathSubject hasNameComponents(String... names) {
ImmutableList.Builder builder = ImmutableList.builder();
for (Path name : actual) {
@@ -133,6 +142,7 @@ public PathSubject hasNameComponents(String... names) {
}
/** Asserts that the path matches the given syntax and pattern. */
+ @CanIgnoreReturnValue
public PathSubject matches(String syntaxAndPattern) {
PathMatcher matcher = actual.getFileSystem().getPathMatcher(syntaxAndPattern);
if (!matcher.matches(actual)) {
@@ -142,6 +152,7 @@ public PathSubject matches(String syntaxAndPattern) {
}
/** Asserts that the path does not match the given syntax and pattern. */
+ @CanIgnoreReturnValue
public PathSubject doesNotMatch(String syntaxAndPattern) {
PathMatcher matcher = actual.getFileSystem().getPathMatcher(syntaxAndPattern);
if (matcher.matches(actual)) {
@@ -151,6 +162,7 @@ public PathSubject doesNotMatch(String syntaxAndPattern) {
}
/** Asserts that the path exists. */
+ @CanIgnoreReturnValue
public PathSubject exists() {
if (!Files.exists(actual, linkOptions)) {
failWithActual(simpleFact("expected to exist"));
@@ -162,6 +174,7 @@ public PathSubject exists() {
}
/** Asserts that the path does not exist. */
+ @CanIgnoreReturnValue
public PathSubject doesNotExist() {
if (!Files.notExists(actual, linkOptions)) {
failWithActual(simpleFact("expected not to exist"));
@@ -173,6 +186,7 @@ public PathSubject doesNotExist() {
}
/** Asserts that the path is a directory. */
+ @CanIgnoreReturnValue
public PathSubject isDirectory() {
exists(); // check for directoryness should imply check for existence
@@ -183,6 +197,7 @@ public PathSubject isDirectory() {
}
/** Asserts that the path is a regular file. */
+ @CanIgnoreReturnValue
public PathSubject isRegularFile() {
exists(); // check for regular fileness should imply check for existence
@@ -193,6 +208,7 @@ public PathSubject isRegularFile() {
}
/** Asserts that the path is a symbolic link. */
+ @CanIgnoreReturnValue
public PathSubject isSymbolicLink() {
exists(); // check for symbolic linkness should imply check for existence
@@ -203,6 +219,7 @@ public PathSubject isSymbolicLink() {
}
/** Asserts that the path, which is a symbolic link, has the given path as a target. */
+ @CanIgnoreReturnValue
public PathSubject withTarget(String targetPath) throws IOException {
Path actualTarget = Files.readSymbolicLink(actual);
if (!actualTarget.equals(toPath(targetPath))) {
@@ -218,6 +235,7 @@ public PathSubject withTarget(String targetPath) throws IOException {
* Asserts that the file the path points to exists and has the given number of links to it. Fails
* on a file system that does not support the "unix" view.
*/
+ @CanIgnoreReturnValue
public PathSubject hasLinkCount(int count) throws IOException {
exists();
@@ -229,11 +247,13 @@ public PathSubject hasLinkCount(int count) throws IOException {
}
/** Asserts that the path resolves to the same file as the given path. */
+ @CanIgnoreReturnValue
public PathSubject isSameFileAs(String path) throws IOException {
return isSameFileAs(toPath(path));
}
/** Asserts that the path resolves to the same file as the given path. */
+ @CanIgnoreReturnValue
public PathSubject isSameFileAs(Path path) throws IOException {
if (!Files.isSameFile(actual, path)) {
failWithActual("expected to be same file as", path);
@@ -242,6 +262,7 @@ public PathSubject isSameFileAs(Path path) throws IOException {
}
/** Asserts that the path does not resolve to the same file as the given path. */
+ @CanIgnoreReturnValue
public PathSubject isNotSameFileAs(String path) throws IOException {
if (Files.isSameFile(actual, toPath(path))) {
failWithActual("expected not to be same file as", path);
@@ -250,6 +271,7 @@ public PathSubject isNotSameFileAs(String path) throws IOException {
}
/** Asserts that the directory has no children. */
+ @CanIgnoreReturnValue
public PathSubject hasNoChildren() throws IOException {
isDirectory();
@@ -262,6 +284,7 @@ public PathSubject hasNoChildren() throws IOException {
}
/** Asserts that the directory has children with the given names, in the given order. */
+ @CanIgnoreReturnValue
public PathSubject hasChildren(String... children) throws IOException {
isDirectory();
@@ -287,6 +310,7 @@ public PathSubject hasChildren(String... children) throws IOException {
}
/** Asserts that the file has the given size. */
+ @CanIgnoreReturnValue
public PathSubject hasSize(long size) throws IOException {
if (Files.size(actual) != size) {
failWithActual("expected to have size", size);
@@ -295,6 +319,7 @@ public PathSubject hasSize(long size) throws IOException {
}
/** Asserts that the file is a regular file containing no bytes. */
+ @CanIgnoreReturnValue
public PathSubject containsNoBytes() throws IOException {
return containsBytes(new byte[0]);
}
@@ -302,6 +327,7 @@ public PathSubject containsNoBytes() throws IOException {
/**
* Asserts that the file is a regular file containing exactly the byte values of the given ints.
*/
+ @CanIgnoreReturnValue
public PathSubject containsBytes(int... bytes) throws IOException {
byte[] realBytes = new byte[bytes.length];
for (int i = 0; i < bytes.length; i++) {
@@ -311,6 +337,7 @@ public PathSubject containsBytes(int... bytes) throws IOException {
}
/** Asserts that the file is a regular file containing exactly the given bytes. */
+ @CanIgnoreReturnValue
public PathSubject containsBytes(byte[] bytes) throws IOException {
isRegularFile();
hasSize(bytes.length);
@@ -328,6 +355,7 @@ public PathSubject containsBytes(byte[] bytes) throws IOException {
* Asserts that the file is a regular file containing the same bytes as the regular file at the
* given path.
*/
+ @CanIgnoreReturnValue
public PathSubject containsSameBytesAs(String path) throws IOException {
isRegularFile();
@@ -342,6 +370,7 @@ public PathSubject containsSameBytesAs(String path) throws IOException {
* Asserts that the file is a regular file containing the given lines of text. By default, the
* bytes are decoded as UTF-8; for a different charset, use {@link #withCharset(Charset)}.
*/
+ @CanIgnoreReturnValue
public PathSubject containsLines(String... lines) throws IOException {
return containsLines(Arrays.asList(lines));
}
@@ -350,6 +379,7 @@ public PathSubject containsLines(String... lines) throws IOException {
* Asserts that the file is a regular file containing the given lines of text. By default, the
* bytes are decoded as UTF-8; for a different charset, use {@link #withCharset(Charset)}.
*/
+ @CanIgnoreReturnValue
public PathSubject containsLines(Iterable lines) throws IOException {
isRegularFile();
@@ -395,9 +425,11 @@ public PathSubject createSubject(FailureMetadata failureMetadata, Path that) {
public interface Attribute {
/** Asserts that the value of this attribute is equal to the given value. */
+ @CanIgnoreReturnValue
Attribute is(Object value) throws IOException;
/** Asserts that the value of this attribute is not equal to the given value. */
+ @CanIgnoreReturnValue
Attribute isNot(Object value) throws IOException;
/** Returns the path subject for further chaining. */
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 b96d77e1..54a56b5d 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PathTester.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PathTester.java
@@ -27,6 +27,7 @@
import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
+import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
@@ -44,16 +45,19 @@ public PathTester(PathService pathService, String string) {
this.string = string;
}
+ @CanIgnoreReturnValue
public PathTester root(String root) {
this.root = root;
return this;
}
+ @CanIgnoreReturnValue
public PathTester names(Iterable names) {
this.names = ImmutableList.copyOf(names);
return this;
}
+ @CanIgnoreReturnValue
public PathTester names(String... names) {
return names(Arrays.asList(names));
}
@@ -108,7 +112,7 @@ private void testNames(Path path) {
private void testParents(Path path) {
Path parent = path.getParent();
- if (root != null && names.size() >= 1 || names.size() > 1) {
+ if ((root != null && names.size() >= 1) || names.size() > 1) {
assertNotNull(parent);
}
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 59fc1142..53e08fe7 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java
@@ -17,12 +17,12 @@
package com.google.common.jimfs;
import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.jimfs.PathType.ParseResult;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
+import com.google.common.jimfs.PathType.ParseResult;
import java.net.URI;
-import org.checkerframework.checker.nullness.compatqual.NullableDecl;
+import org.checkerframework.checker.nullness.qual.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -94,7 +94,7 @@ public void testUriRoundTrips() {
assertUriRoundTripsCorrectly(type, "$foo/bar baz");
}
- static void assertParseResult(ParseResult result, @NullableDecl 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();
}
@@ -126,7 +126,7 @@ public ParseResult parsePath(String path) {
}
@Override
- public String toString(@NullableDecl String root, Iterable names) {
+ public String toString(@Nullable String root, Iterable names) {
StringBuilder builder = new StringBuilder();
if (root != null) {
builder.append(root);
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 86f98323..407f70dd 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java
@@ -62,7 +62,7 @@ public void setUp() {
new PollingWatchService(
fs.getDefaultView(),
fs.getPathService(),
- new FileSystemState(Runnables.doNothing()),
+ new FileSystemState(new FakeFileTimeSource(), Runnables.doNothing()),
4,
MILLISECONDS);
}
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 1dc9df22..22697ffc 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/RegularFileBlocksTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/RegularFileBlocksTest.java
@@ -19,6 +19,9 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.primitives.Bytes;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.channels.Channels;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -32,6 +35,10 @@
@RunWith(JUnit4.class)
public class RegularFileBlocksTest {
+ private static final int BLOCK_SIZE = 2;
+
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
private RegularFile file;
@Before
@@ -39,8 +46,8 @@ public void setUp() {
file = createFile();
}
- private static RegularFile createFile() {
- return RegularFile.create(-1, new HeapDisk(2, 2, 2));
+ private RegularFile createFile() {
+ return RegularFile.create(-1, fileTimeSource.now(), new HeapDisk(BLOCK_SIZE, 2, 2));
}
@Test
@@ -142,4 +149,33 @@ public void testTransferTo() {
assertThat(Bytes.asList(file.getBlock(0))).isEqualTo(Bytes.asList(new byte[] {1, 2, 3}));
assertThat(file.getBlock(1)).isNull();
}
+
+ @Test
+ public void testTransferFrom() throws IOException {
+ // Test that when a transferFrom ends on a block boundary because the input has no further bytes
+ // and not because count bytes have been transferred, we don't leave an extra empty block
+ // allocated on the end of the file.
+ // https://github.com/google/jimfs/issues/163
+ byte[] bytes = new byte[BLOCK_SIZE];
+ RegularFile file = createFile();
+
+ long transferred =
+ file.transferFrom(Channels.newChannel(new ByteArrayInputStream(bytes)), 0, Long.MAX_VALUE);
+ assertThat(transferred).isEqualTo(bytes.length);
+ assertThat(file.blockCount()).isEqualTo(1);
+ }
+
+ @Test
+ public void testTransferFrom_noBytesNoAllocation() throws IOException {
+ // Similar to the previous test but ensures that if no bytes are transferred at all, no new
+ // blocks remain allocated.
+ // https://github.com/google/jimfs/issues/163
+ byte[] bytes = new byte[0];
+ RegularFile file = createFile();
+
+ long transferred =
+ file.transferFrom(Channels.newChannel(new ByteArrayInputStream(bytes)), 0, Long.MAX_VALUE);
+ assertThat(transferred).isEqualTo(0);
+ assertThat(file.blockCount()).isEqualTo(0);
+ }
}
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 f581690b..77d756d3 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/RegularFileTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/RegularFileTest.java
@@ -121,6 +121,8 @@ public static final class TestConfiguration {
private final int cacheSize;
private final ReuseStrategy reuseStrategy;
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
+
private HeapDisk disk;
public TestConfiguration(int blockSize, int cacheSize, ReuseStrategy reuseStrategy) {
@@ -142,7 +144,7 @@ public RegularFile createRegularFile() {
if (reuseStrategy == ReuseStrategy.NEW_DISK) {
disk = createDisk();
}
- return RegularFile.create(0, disk);
+ return RegularFile.create(0, fileTimeSource.now(), disk);
}
public void tearDown(RegularFile file) {
@@ -172,6 +174,7 @@ public String toString() {
public static class RegularFileTestRunner extends TestCase {
private final TestConfiguration configuration;
+ private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();
protected RegularFile file;
@@ -334,23 +337,31 @@ public void testEmpty_transferFrom_fromStart_countGreaterThanSrcSize() throws IO
assertContentEquals("111111", file);
}
- public void testEmpty_transferFrom_fromBeyondStart_countEqualsSrcSize() throws IOException {
+ public void testEmpty_transferFrom_positionGreaterThanSize() throws IOException {
long transferred = file.transferFrom(new ByteBufferChannel(buffer("111111")), 4, 6);
- assertEquals(6, transferred);
- assertContentEquals("0000111111", file);
+ assertEquals(0, transferred);
+ assertContentEquals(bytes(), file);
}
- public void testEmpty_transferFrom_fromBeyondStart_countLessThanSrcSize() throws IOException {
+ public void testEmpty_transferFrom_positionGreaterThanSize_countEqualsSrcSize()
+ throws IOException {
+ long transferred = file.transferFrom(new ByteBufferChannel(buffer("111111")), 4, 6);
+ assertEquals(0, transferred);
+ assertContentEquals(bytes(), file);
+ }
+
+ public void testEmpty_transferFrom_positionGreaterThanSize_countLessThanSrcSize()
+ throws IOException {
long transferred = file.transferFrom(new ByteBufferChannel(buffer("111111")), 4, 3);
- assertEquals(3, transferred);
- assertContentEquals("0000111", file);
+ assertEquals(0, transferred);
+ assertContentEquals(bytes(), file);
}
- public void testEmpty_transferFrom_fromBeyondStart_countGreaterThanSrcSize()
+ public void testEmpty_transferFrom_positionGreaterThanSize_countGreaterThanSrcSize()
throws IOException {
long transferred = file.transferFrom(new ByteBufferChannel(buffer("111111")), 4, 12);
- assertEquals(6, transferred);
- assertContentEquals("0000111111", file);
+ assertEquals(0, transferred);
+ assertContentEquals(bytes(), file);
}
public void testEmpty_transferFrom_fromStart_noBytes_countEqualsSrcSize() throws IOException {
@@ -366,18 +377,18 @@ public void testEmpty_transferFrom_fromStart_noBytes_countGreaterThanSrcSize()
assertContentEquals(bytes(), file);
}
- public void testEmpty_transferFrom_fromBeyondStart_noBytes_countEqualsSrcSize()
+ public void testEmpty_transferFrom_postionGreaterThanSrcSize_noBytes_countEqualsSrcSize()
throws IOException {
long transferred = file.transferFrom(new ByteBufferChannel(buffer("")), 5, 0);
assertEquals(0, transferred);
- assertContentEquals(bytes("00000"), file);
+ assertContentEquals(bytes(), file);
}
- public void testEmpty_transferFrom_fromBeyondStart_noBytes_countGreaterThanSrcSize()
+ public void testEmpty_transferFrom_postionGreaterThanSrcSize_noBytes_countGreaterThanSrcSize()
throws IOException {
long transferred = file.transferFrom(new ByteBufferChannel(buffer("")), 5, 10);
assertEquals(0, transferred);
- assertContentEquals(bytes("00000"), file);
+ assertContentEquals(bytes(), file);
}
public void testEmpty_transferTo() throws IOException {
@@ -386,7 +397,7 @@ public void testEmpty_transferTo() throws IOException {
}
public void testEmpty_copy() throws IOException {
- RegularFile copy = file.copyWithoutContent(1);
+ RegularFile copy = file.copyWithoutContent(1, fileTimeSource.now());
assertContentEquals("", copy);
}
@@ -565,7 +576,7 @@ public void testNonEmpty_read_fromPastEnd_byteArray() throws IOException {
public void testNonEmpty_read_fromPastEnd_singleBuffer() throws IOException {
fillContent("123");
ByteBuffer buffer = ByteBuffer.allocate(3);
- file.read(3, buffer);
+ assertEquals(-1, file.read(3, buffer));
assertBufferEquals("000", 3, buffer);
}
@@ -793,11 +804,11 @@ public void testNonEmpty_transferFrom_toEnd() throws IOException {
assertContentEquals("222222111111", file);
}
- public void testNonEmpty_transferFrom_toPastEnd() throws IOException {
+ public void testNonEmpty_transferFrom_positionGreaterThanSize() throws IOException {
fillContent("222222");
ByteBufferChannel channel = new ByteBufferChannel(buffer("111111"));
- assertEquals(6, file.transferFrom(channel, 10, 6));
- assertContentEquals("2222220000111111", file);
+ assertEquals(0, file.transferFrom(channel, 10, 6));
+ assertContentEquals("222222", file);
}
public void testNonEmpty_transferFrom_hugeOverestimateCount() throws IOException {
@@ -809,16 +820,16 @@ public void testNonEmpty_transferFrom_hugeOverestimateCount() throws IOException
public void testNonEmpty_copy() throws IOException {
fillContent("123456");
- RegularFile copy = file.copyWithoutContent(1);
+ RegularFile copy = file.copyWithoutContent(1, fileTimeSource.now());
file.copyContentTo(copy);
assertContentEquals("123456", copy);
}
public void testNonEmpty_copy_multipleTimes() throws IOException {
fillContent("123456");
- RegularFile copy = file.copyWithoutContent(1);
+ RegularFile copy = file.copyWithoutContent(1, fileTimeSource.now());
file.copyContentTo(copy);
- RegularFile copy2 = copy.copyWithoutContent(2);
+ RegularFile copy2 = copy.copyWithoutContent(2, fileTimeSource.now());
copy.copyContentTo(copy2);
assertContentEquals("123456", copy);
}
@@ -885,7 +896,7 @@ private static void assertContentEquals(String expected, RegularFile actual) {
protected static void assertContentEquals(byte[] expected, RegularFile actual) {
assertEquals(expected.length, actual.sizeWithoutLocking());
byte[] actualBytes = new byte[(int) actual.sizeWithoutLocking()];
- actual.read(0, ByteBuffer.wrap(actualBytes));
+ int unused = actual.read(0, ByteBuffer.wrap(actualBytes));
assertArrayEquals(expected, actualBytes);
}
}
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 4518132a..b5360477 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/TestAttributeProvider.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/TestAttributeProvider.java
@@ -26,7 +26,7 @@
import java.nio.file.attribute.FileTime;
import java.util.HashMap;
import java.util.Map;
-import org.checkerframework.checker.nullness.compatqual.NullableDecl;
+import org.checkerframework.checker.nullness.qual.Nullable;
/** @author Colin Decker */
public final class TestAttributeProvider extends AttributeProvider {
@@ -133,9 +133,9 @@ public Attributes readAttributes() throws IOException {
@Override
public void setTimes(
- @NullableDecl FileTime lastModifiedTime,
- @NullableDecl FileTime lastAccessTime,
- @NullableDecl FileTime createTime)
+ @Nullable FileTime lastModifiedTime,
+ @Nullable FileTime lastAccessTime,
+ @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 30e0930b..61e138e9 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/TestUtils.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/TestUtils.java
@@ -133,7 +133,8 @@ public static void assertNotEquals(Object unexpected, Object actual) {
}
static RegularFile regularFile(int size) {
- RegularFile file = RegularFile.create(0, new HeapDisk(8096, 1000, 1000));
+ RegularFile file =
+ RegularFile.create(0, new FakeFileTimeSource().now(), new HeapDisk(8096, 1000, 1000));
try {
file.write(0, new byte[size], 0, size);
return file;
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 dc32d202..e0c4608e 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/UnixAttributeProviderTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/UnixAttributeProviderTest.java
@@ -21,7 +21,6 @@
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableSet;
-import java.nio.file.attribute.FileTime;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Set;
import org.junit.Test;
@@ -67,7 +66,7 @@ public void testInitialAttributes() {
// 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(file.getCreationTime());
// this is based on a property this file system does actually have
assertThat(provider.get(file, "nlink")).isEqualTo(1);
diff --git a/pom.xml b/pom.xml
index eed6efd3..c7b82dcb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,17 +94,11 @@
UTF-8
- 1.0-rc7
- 1.7
- 30.1-android
-
- 2.4.0
- 9+181-r4173-1
+ 1.1.1
+ 1.2.2
+ 1.8
+ 33.2.1-jre
+ 2.28.0
@@ -120,7 +114,7 @@
com.ibm.icu
icu4j
- 68.2
+ 75.1
@@ -136,15 +130,15 @@
org.checkerframework
- checker-compat-qual
- 2.5.5
+ checker-qual
+ 3.45.0
junit
junit
- 4.13.1
+ 4.13.2
test
@@ -156,7 +150,7 @@
com.google.truth
truth
- 1.1
+ 1.4.4
test
@@ -167,23 +161,23 @@
maven-compiler-plugin
- 3.8.1
+ 3.13.0
maven-source-plugin
- 3.2.1
+ 3.3.1
maven-javadoc-plugin
- 3.2.0
+ 3.7.0
true
UTF-8
UTF-8
UTF-8
+ ${java.version}
false
- https://checkerframework.org/api/
https://guava.dev/releases/${guava.version}/api/docs/
https://unicode-org.github.io/icu-docs/apidoc/released/icu4j
@@ -193,16 +187,16 @@
maven-gpg-plugin
- 1.6
+ 3.2.4
maven-surefire-plugin
- 3.0.0-M5
+ 3.3.0
org.apache.felix
maven-bundle-plugin
- 5.1.1
+ 5.1.9
@@ -213,10 +207,6 @@
${java.version}
${java.version}
-
- -XDcompilePolicy=simple
- -Xplugin:ErrorProne
-
com.google.errorprone
@@ -233,23 +223,25 @@
auto-service
${auto-service.version}
+
+ com.google.auto
+ auto-common
+ ${auto-common.version}
+
-
-
- default-testCompile
- test-compile
-
- testCompile
-
-
-
- -XDcompilePolicy=simple
- -Xplugin:ErrorProne -Xep:BetaApi:OFF
-
-
-
-
+