diff options
author | kak <kak@google.com> | 2014-10-27 09:29:44 -0700 |
---|---|---|
committer | Colin Decker <cgdecker@google.com> | 2014-11-05 17:10:54 -0500 |
commit | 4eeb06e581635585b9c9ab4b929e0d6139b9ddb0 (patch) | |
tree | 38d8e4201a10652e7541ddd0a9fc11a059493089 /jimfs/src/test/java | |
parent | 378defb36f8a774aeb7cc32eff5e8d0e09a1dc66 (diff) | |
download | jimfs-4eeb06e581635585b9c9ab4b929e0d6139b9ddb0.tar.gz |
Migrate off of deprecated Truth methods
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=78584467
Diffstat (limited to 'jimfs/src/test/java')
10 files changed, 70 insertions, 57 deletions
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 0362ac7..7e07d10 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/AbstractWatchServiceTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/AbstractWatchServiceTest.java @@ -90,7 +90,7 @@ public class AbstractWatchServiceTest { key.post(event); key.signal(); - assertThat(watcher.queuedKeys()).has().exactly(key); + assertThat(watcher.queuedKeys()).containsExactly(key); WatchKey retrievedKey = watcher.poll(); assertThat(retrievedKey).isEqualTo(key); @@ -121,8 +121,8 @@ public class AbstractWatchServiceTest { assertThat(key.state()).isEqualTo(SIGNALLED); // key was not queued twice - assertThat(watcher.queuedKeys()).has().exactly(key); - assertThat(watcher.poll().pollEvents()).has().exactly(event, event2); + assertThat(watcher.queuedKeys()).containsExactly(key); + assertThat(watcher.poll().pollEvents()).containsExactly(event, event2); assertThat(watcher.poll()).isNull(); @@ -130,7 +130,7 @@ public class AbstractWatchServiceTest { // still not added to queue; already signalled assertThat(watcher.poll()).isNull(); - assertThat(key.pollEvents()).has().exactly(event); + assertThat(key.pollEvents()).containsExactly(event); key.reset(); assertThat(key.state()).isEqualTo(READY); 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 ce8b29d..f4766bc 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/AttributeServiceTest.java @@ -72,8 +72,8 @@ public class AttributeServiceTest { File file = Directory.create(0); service.setInitialAttributes(file); - assertThat(file.getAttributeNames("test")).has().exactly("bar", "baz"); - assertThat(file.getAttributeNames("owner")).has().exactly("owner"); + assertThat(file.getAttributeNames("test")).containsExactly("bar", "baz"); + assertThat(file.getAttributeNames("owner")).containsExactly("owner"); assertThat(service.getAttribute(file, "basic:lastModifiedTime")).isInstanceOf(FileTime.class); assertThat(file.getAttribute("test", "bar")).isEqualTo(0L); 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 e34412a..111bd60 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java @@ -58,7 +58,7 @@ public class ConfigurationTest { Configuration config = Configuration.unix(); assertThat(config.pathType).isEqualTo(PathType.unix()); - assertThat(config.roots).has().exactly("/"); + assertThat(config.roots).containsExactly("/"); assertThat(config.workingDirectory).isEqualTo("/work"); assertThat(config.nameCanonicalNormalization).isEmpty(); assertThat(config.nameDisplayNormalization).isEmpty(); @@ -66,7 +66,7 @@ public class ConfigurationTest { assertThat(config.blockSize).is(8192); assertThat(config.maxSize).isEqualTo(4L * 1024 * 1024 * 1024); assertThat(config.maxCacheSize).is(-1); - assertThat(config.attributeViews).has().exactly("basic"); + assertThat(config.attributeViews).containsExactly("basic"); assertThat(config.attributeProviders).isEmpty(); assertThat(config.defaultAttributeValues).isEmpty(); } @@ -75,11 +75,13 @@ public class ConfigurationTest { public void testFileSystemForDefaultUnixConfiguration() throws IOException { FileSystem fs = Jimfs.newFileSystem(Configuration.unix()); - assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("/"))); + assertThat(fs.getRootDirectories()) + .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(fs.supportedFileAttributeViews()).has().exactly("basic"); + assertThat(fs.supportedFileAttributeViews()).containsExactly("basic"); Files.createFile(fs.getPath("/foo")); Files.createFile(fs.getPath("/FOO")); @@ -90,15 +92,15 @@ public class ConfigurationTest { Configuration config = Configuration.osX(); assertThat(config.pathType).isEqualTo(PathType.unix()); - assertThat(config.roots).has().exactly("/"); + assertThat(config.roots).containsExactly("/"); assertThat(config.workingDirectory).isEqualTo("/work"); - assertThat(config.nameCanonicalNormalization).has().exactly(NFD, CASE_FOLD_ASCII); - assertThat(config.nameDisplayNormalization).has().exactly(NFC); + assertThat(config.nameCanonicalNormalization).containsExactly(NFD, CASE_FOLD_ASCII); + assertThat(config.nameDisplayNormalization).containsExactly(NFC); assertThat(config.pathEqualityUsesCanonicalForm).isFalse(); assertThat(config.blockSize).is(8192); assertThat(config.maxSize).isEqualTo(4L * 1024 * 1024 * 1024); assertThat(config.maxCacheSize).is(-1); - assertThat(config.attributeViews).has().exactly("basic"); + assertThat(config.attributeViews).containsExactly("basic"); assertThat(config.attributeProviders).isEmpty(); assertThat(config.defaultAttributeValues).isEmpty(); } @@ -107,11 +109,13 @@ public class ConfigurationTest { public void testFileSystemForDefaultOsXConfiguration() throws IOException { FileSystem fs = Jimfs.newFileSystem(Configuration.osX()); - assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("/"))); + assertThat(fs.getRootDirectories()) + .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(fs.supportedFileAttributeViews()).has().exactly("basic"); + assertThat(fs.supportedFileAttributeViews()).containsExactly("basic"); Files.createFile(fs.getPath("/foo")); @@ -127,15 +131,15 @@ public class ConfigurationTest { Configuration config = Configuration.windows(); assertThat(config.pathType).isEqualTo(PathType.windows()); - assertThat(config.roots).has().exactly("C:\\"); + assertThat(config.roots).containsExactly("C:\\"); assertThat(config.workingDirectory).isEqualTo("C:\\work"); - assertThat(config.nameCanonicalNormalization).has().exactly(CASE_FOLD_ASCII); + assertThat(config.nameCanonicalNormalization).containsExactly(CASE_FOLD_ASCII); assertThat(config.nameDisplayNormalization).isEmpty(); assertThat(config.pathEqualityUsesCanonicalForm).isTrue(); assertThat(config.blockSize).is(8192); assertThat(config.maxSize).isEqualTo(4L * 1024 * 1024 * 1024); assertThat(config.maxCacheSize).is(-1); - assertThat(config.attributeViews).has().exactly("basic"); + assertThat(config.attributeViews).containsExactly("basic"); assertThat(config.attributeProviders).isEmpty(); assertThat(config.defaultAttributeValues).isEmpty(); } @@ -144,11 +148,13 @@ public class ConfigurationTest { public void testFileSystemForDefaultWindowsConfiguration() throws IOException { FileSystem fs = Jimfs.newFileSystem(Configuration.windows()); - assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("C:\\"))); + assertThat(fs.getRootDirectories()) + .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(fs.supportedFileAttributeViews()).has().exactly("basic"); + assertThat(fs.supportedFileAttributeViews()).containsExactly("basic"); Files.createFile(fs.getPath("C:\\foo")); @@ -179,16 +185,16 @@ public class ConfigurationTest { .build(); assertThat(config.pathType).isEqualTo(PathType.unix()); - assertThat(config.roots).has().exactly("/"); + assertThat(config.roots).containsExactly("/"); assertThat(config.workingDirectory).isEqualTo("/hello/world"); - assertThat(config.nameCanonicalNormalization).has().exactly(NFD, CASE_FOLD_UNICODE); - assertThat(config.nameDisplayNormalization).has().exactly(NFC); + assertThat(config.nameCanonicalNormalization).containsExactly(NFD, CASE_FOLD_UNICODE); + assertThat(config.nameDisplayNormalization).containsExactly(NFC); assertThat(config.pathEqualityUsesCanonicalForm).isTrue(); assertThat(config.blockSize).is(10); assertThat(config.maxSize).is(100); assertThat(config.maxCacheSize).is(50); - assertThat(config.attributeViews).has().exactly("basic", "posix"); - assertThat(config.attributeProviders).has().exactly(unixProvider); + assertThat(config.attributeViews).containsExactly("basic", "posix"); + assertThat(config.attributeProviders).containsExactly(unixProvider); assertThat(config.defaultAttributeValues) .containsEntry("posix:permissions", PosixFilePermissions.fromString("---------")); } @@ -211,10 +217,12 @@ public class ConfigurationTest { FileSystem fs = Jimfs.newFileSystem(config); - assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("/"))); + assertThat(fs.getRootDirectories()) + .containsExactlyElementsIn(ImmutableList.of(fs.getPath("/"))) + .inOrder(); assertThatPath(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("/hello/world")); assertThat(Iterables.getOnlyElement(fs.getFileStores()).getTotalSpace()).is(100); - assertThat(fs.supportedFileAttributeViews()).has().exactly("basic", "owner", "posix", "unix"); + assertThat(fs.supportedFileAttributeViews()).containsExactly("basic", "owner", "posix", "unix"); Files.createFile(fs.getPath("/foo")); assertThat(Files.getAttribute(fs.getPath("/foo"), "posix:permissions")).isEqualTo( @@ -235,7 +243,7 @@ public class ConfigurationTest { .build(); assertThat(config.pathType).isEqualTo(PathType.unix()); - assertThat(config.roots).has().exactly("/"); + assertThat(config.roots).containsExactly("/"); assertThat(config.workingDirectory).isEqualTo("/hello/world"); assertThat(config.nameCanonicalNormalization).isEmpty(); assertThat(config.nameDisplayNormalization).isEmpty(); @@ -243,7 +251,7 @@ public class ConfigurationTest { assertThat(config.blockSize).is(8192); assertThat(config.maxSize).isEqualTo(4L * 1024 * 1024 * 1024); assertThat(config.maxCacheSize).is(-1); - assertThat(config.attributeViews).has().exactly("basic", "posix"); + assertThat(config.attributeViews).containsExactly("basic", "posix"); assertThat(config.attributeProviders).isEmpty(); assertThat(config.defaultAttributeValues).isEmpty(); } 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 f7db823..5995b51 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/DirectoryTest.java @@ -220,7 +220,7 @@ public class DirectoryTest { // does not include . or .. and is sorted by the name assertThat(root.snapshot()) - .has().exactly(Name.simple("abc"), Name.simple("bar"), Name.simple("foo")); + .containsExactly(Name.simple("abc"), Name.simple("bar"), Name.simple("foo")); } @Test @@ -244,7 +244,7 @@ public class DirectoryTest { @Test public void testInitialState() { assertThat(dir.entryCount()).is(2); - assertThat(ImmutableSet.copyOf(dir)).has().exactly( + assertThat(ImmutableSet.copyOf(dir)).containsExactly( new DirectoryEntry(dir, Name.SELF, dir), new DirectoryEntry(dir, Name.PARENT, root)); assertThat(dir.get(Name.simple("foo"))).isNull(); @@ -255,14 +255,14 @@ public class DirectoryTest { dir.put(entry("foo")); assertThat(dir.entryCount()).is(3); - assertThat(ImmutableSet.copyOf(dir)).has().item(entry("foo")); + assertThat(ImmutableSet.copyOf(dir)).contains(entry("foo")); assertThat(dir.get(Name.simple("foo"))).isEqualTo(entry("foo")); dir.put(entry("bar")); assertThat(dir.entryCount()).is(4); assertThat(ImmutableSet.copyOf(dir)) - .has().allOf(entry("foo"), entry("bar")); + .containsAllOf(entry("foo"), entry("bar")); assertThat(dir.get(Name.simple("foo"))).isEqualTo(entry("foo")); assertThat(dir.get(Name.simple("bar"))).isEqualTo(entry("bar")); } @@ -285,7 +285,7 @@ public class DirectoryTest { dir.remove(Name.simple("foo")); assertThat(dir.entryCount()).is(3); - assertThat(ImmutableSet.copyOf(dir)).has().exactly( + assertThat(ImmutableSet.copyOf(dir)).containsExactly( entry("bar"), new DirectoryEntry(dir, Name.SELF, dir), new DirectoryEntry(dir, Name.PARENT, root)); 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 7349aee..2eb0743 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsFileChannelTest.java @@ -60,7 +60,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicReference; /** @@ -693,8 +692,9 @@ public class JimfsFileChannelTest { future.get(); fail(); } catch (ExecutionException expected) { - assertThat(expected.getCause()).named("blocking thread exception") - .isA(AsynchronousCloseException.class); + assertThat(expected.getCause()) + .named("blocking thread exception") + .isInstanceOf(AsynchronousCloseException.class); } } } @@ -751,7 +751,7 @@ public class JimfsFileChannelTest { // get the exception that caused the interrupted operation to terminate assertThat(interruptException.get(200, MILLISECONDS)) .named("interrupted thread exception") - .isA(ClosedByInterruptException.class); + .isInstanceOf(ClosedByInterruptException.class); // check that each other thread got AsynchronousCloseException (since the interrupt, on a // different thread, closed the channel) @@ -760,8 +760,9 @@ public class JimfsFileChannelTest { future.get(); fail(); } catch (ExecutionException expected) { - assertThat(expected.getCause()).named("blocking thread exception") - .isA(AsynchronousCloseException.class); + assertThat(expected.getCause()) + .named("blocking thread exception") + .isInstanceOf(AsynchronousCloseException.class); } } } 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 1e86c14..e00d98c 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java @@ -124,11 +124,13 @@ public class JimfsUnixLikeFileSystemTest extends AbstractJimfsIntegrationTest { @Test public void testFileSystem() { assertThat(fs.getSeparator()).isEqualTo("/"); - assertThat(fs.getRootDirectories()).iteratesAs(ImmutableSet.of(path("/"))); + assertThat(fs.getRootDirectories()) + .containsExactlyElementsIn(ImmutableSet.of(path("/"))) + .inOrder(); assertThat(fs.isOpen()).isTrue(); assertThat(fs.isReadOnly()).isFalse(); assertThat(fs.supportedFileAttributeViews()) - .has().exactly("basic", "owner", "posix", "unix"); + .containsExactly("basic", "owner", "posix", "unix"); assertThat(fs.provider()).isInstanceOf(JimfsFileSystemProvider.class); } @@ -2036,12 +2038,12 @@ public class JimfsUnixLikeFileSystemTest extends AbstractJimfsIntegrationTest { try (DirectoryStream<Path> stream = Files.newDirectoryStream(path("foo"))) { SecureDirectoryStream<Path> secureStream = (SecureDirectoryStream<Path>) stream; - assertThat(ImmutableList.copyOf(secureStream)).has() - .exactly(path("foo/a"), path("foo/b"), path("foo/c")); + assertThat(ImmutableList.copyOf(secureStream)) + .containsExactly(path("foo/a"), path("foo/b"), path("foo/c")); try (DirectoryStream<Path> stream2 = secureStream.newDirectoryStream(path("c"))) { - assertThat(ImmutableList.copyOf(stream2)).has() - .exactly(path("foo/c/d"), path("foo/c/e")); + assertThat(ImmutableList.copyOf(stream2)) + .containsExactly(path("foo/c/d"), path("foo/c/e")); } } } 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 1e761e8..b9aacbc 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java @@ -57,11 +57,13 @@ public class JimfsWindowsLikeFileSystemTest extends AbstractJimfsIntegrationTest @Test public void testFileSystem() { assertThat(fs.getSeparator()).isEqualTo("\\"); - assertThat(fs.getRootDirectories()).iteratesAs(ImmutableSet.of(path("C:\\"), path("E:\\"))); + assertThat(fs.getRootDirectories()) + .containsExactlyElementsIn(ImmutableSet.of(path("C:\\"), path("E:\\"))) + .inOrder(); assertThat(fs.isOpen()).isTrue(); assertThat(fs.isReadOnly()).isFalse(); assertThat(fs.supportedFileAttributeViews()) - .has().exactly("basic", "owner", "dos", "acl", "user"); + .containsExactly("basic", "owner", "dos", "acl", "user"); assertThat(fs.provider()).isInstanceOf(JimfsFileSystemProvider.class); } 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 784a1a5..19ea9a0 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/PathTypeTest.java @@ -96,7 +96,7 @@ public class PathTypeTest { static void assertParseResult( ParseResult result, @Nullable String root, String... names) { assertThat(result.root()).isEqualTo(root); - assertThat(result.names()).iteratesAs((Object[]) names); + assertThat(result.names()).containsExactly((Object[]) names).inOrder(); } static void assertUriRoundTripsCorrectly(PathType type, String path) { @@ -104,7 +104,7 @@ public class PathTypeTest { URI uri = type.toUri(fileSystemUri, result.root(), result.names()); ParseResult parsedUri = type.fromUri(uri); assertThat(parsedUri.root()).isEqualTo(result.root()); - assertThat(parsedUri.names()).iteratesAs(result.names()); + assertThat(parsedUri.names()).containsExactlyElementsIn(result.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 ea77947..045e523 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/PollingWatchServiceTest.java @@ -222,9 +222,9 @@ public class PollingWatchServiceTest { List<WatchEvent<?>> keyEvents = key.pollEvents(); if (keyEvents.size() == expected.size() || alternate.isEmpty()) { - assertThat(keyEvents).has().exactlyAs(expected); + assertThat(keyEvents).containsExactlyElementsIn(expected); } else { - assertThat(keyEvents).has().exactlyAs(alternate); + assertThat(keyEvents).containsExactlyElementsIn(alternate); } key.reset(); } diff --git a/jimfs/src/test/java/com/google/common/jimfs/UserDefinedAttributeProviderTest.java b/jimfs/src/test/java/com/google/common/jimfs/UserDefinedAttributeProviderTest.java index 56e1816..5710254 100644 --- a/jimfs/src/test/java/com/google/common/jimfs/UserDefinedAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/common/jimfs/UserDefinedAttributeProviderTest.java @@ -72,7 +72,7 @@ public class UserDefinedAttributeProviderTest assertSetFails("foo", "hello"); - assertThat(provider.attributes(file)).has().exactly("one", "two"); + assertThat(provider.attributes(file)).containsExactly("one", "two"); } @Test @@ -95,7 +95,7 @@ public class UserDefinedAttributeProviderTest view.write("b2", ByteBuffer.wrap(b2)); assertThat(view.list()).has().allOf("b1", "b2"); - assertThat(file.getAttributeKeys()).has().exactly("user:b1", "user:b2"); + assertThat(file.getAttributeKeys()).containsExactly("user:b1", "user:b2"); assertThat(view.size("b1")).is(3); assertThat(view.size("b2")).is(5); @@ -111,8 +111,8 @@ public class UserDefinedAttributeProviderTest view.delete("b2"); - assertThat(view.list()).has().exactly("b1"); - assertThat(file.getAttributeKeys()).has().exactly("user:b1"); + assertThat(view.list()).containsExactly("b1"); + assertThat(file.getAttributeKeys()).containsExactly("user:b1"); try { view.size("b2"); |