aboutsummaryrefslogtreecommitdiff
path: root/jimfs/src
diff options
context:
space:
mode:
authorkak <kak@google.com>2014-08-12 11:20:31 -0700
committerColin Decker <cgdecker@google.com>2014-11-05 17:10:00 -0500
commit0c9f373906f54c0f7c8025d6a24411449dda59df (patch)
treeba711e26224992188c9fd8766f244fe856f86d05 /jimfs/src
parent1e39f6a57e0c77dabda4bd277a31bb57099eed5c (diff)
downloadjimfs-0c9f373906f54c0f7c8025d6a24411449dda59df.tar.gz
Add assertThat(Comparable) overload for custom comparable types.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=73145243
Diffstat (limited to 'jimfs/src')
-rw-r--r--jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java16
-rw-r--r--jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java24
-rw-r--r--jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java36
3 files changed, 42 insertions, 34 deletions
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 f13c44e..ac2f783 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
@@ -20,11 +20,14 @@ import static com.google.common.jimfs.PathNormalization.CASE_FOLD_ASCII;
import static com.google.common.jimfs.PathNormalization.CASE_FOLD_UNICODE;
import static com.google.common.jimfs.PathNormalization.NFC;
import static com.google.common.jimfs.PathNormalization.NFD;
+import static com.google.common.jimfs.PathSubject.paths;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assert_;
import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import com.google.common.jimfs.PathSubject;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,6 +37,7 @@ import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileSystem;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermissions;
/**
@@ -45,6 +49,10 @@ import java.nio.file.attribute.PosixFilePermissions;
@RunWith(JUnit4.class)
public class ConfigurationTest {
+ private static PathSubject assertThatPath(Path path) {
+ return assert_().about(paths()).that(path);
+ }
+
@Test
public void testDefaultUnixConfiguration() {
Configuration config = Configuration.unix();
@@ -68,7 +76,7 @@ public class ConfigurationTest {
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("/")));
- assertThat(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("/work"));
+ 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");
@@ -100,7 +108,7 @@ public class ConfigurationTest {
FileSystem fs = Jimfs.newFileSystem(Configuration.osX());
assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("/")));
- assertThat(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("/work"));
+ 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");
@@ -137,7 +145,7 @@ public class ConfigurationTest {
FileSystem fs = Jimfs.newFileSystem(Configuration.windows());
assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("C:\\")));
- assertThat(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("C:\\work"));
+ 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");
@@ -204,7 +212,7 @@ public class ConfigurationTest {
FileSystem fs = Jimfs.newFileSystem(config);
assertThat(fs.getRootDirectories()).iteratesAs(ImmutableList.of(fs.getPath("/")));
- assertThat(fs.getPath("").toRealPath()).isEqualTo(fs.getPath("/hello/world"));
+ 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");
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 01b4e7f..2e67fcc 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsUnixLikeFileSystemTest.java
@@ -277,14 +277,14 @@ public class JimfsUnixLikeFileSystemTest extends AbstractJimfsIntegrationTest {
Files.createDirectories(path("/foo/bar"));
Files.createSymbolicLink(path("/link"), path("/"));
- assertThat(path("/link/foo/bar").toRealPath()).isEqualTo(path("/foo/bar"));
+ assertThatPath(path("/link/foo/bar").toRealPath()).isEqualTo(path("/foo/bar"));
- assertThat(path("").toRealPath()).isEqualTo(path("/work"));
- assertThat(path(".").toRealPath()).isEqualTo(path("/work"));
- assertThat(path("..").toRealPath()).isEqualTo(path("/"));
- assertThat(path("../..").toRealPath()).isEqualTo(path("/"));
- assertThat(path("./.././..").toRealPath()).isEqualTo(path("/"));
- assertThat(path("./.././../.").toRealPath()).isEqualTo(path("/"));
+ assertThatPath(path("").toRealPath()).isEqualTo(path("/work"));
+ assertThatPath(path(".").toRealPath()).isEqualTo(path("/work"));
+ assertThatPath(path("..").toRealPath()).isEqualTo(path("/"));
+ assertThatPath(path("../..").toRealPath()).isEqualTo(path("/"));
+ assertThatPath(path("./.././..").toRealPath()).isEqualTo(path("/"));
+ assertThatPath(path("./.././../.").toRealPath()).isEqualTo(path("/"));
}
@Test
@@ -300,15 +300,15 @@ public class JimfsUnixLikeFileSystemTest extends AbstractJimfsIntegrationTest {
@Test
public void testPaths_getFromUri() {
- assertThat(Paths.get(URI.create("jimfs://unix/")))
+ assertThatPath(Paths.get(URI.create("jimfs://unix/")))
.isEqualTo(path("/"));
- assertThat(Paths.get(URI.create("jimfs://unix/foo")))
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo")))
.isEqualTo(path("/foo"));
- assertThat(Paths.get(URI.create("jimfs://unix/foo%20bar")))
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo%20bar")))
.isEqualTo(path("/foo bar"));
- assertThat(Paths.get(URI.create("jimfs://unix/foo/./bar")))
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo/./bar")))
.isEqualTo(path("/foo/./bar"));
- assertThat(Paths.get(URI.create("jimfs://unix/foo/bar/")))
+ assertThatPath(Paths.get(URI.create("jimfs://unix/foo/bar/")))
.isEqualTo(path("/foo/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 48eb334..138e22a 100644
--- a/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java
+++ b/jimfs/src/test/java/com/google/common/jimfs/JimfsWindowsLikeFileSystemTest.java
@@ -198,14 +198,14 @@ public class JimfsWindowsLikeFileSystemTest extends AbstractJimfsIntegrationTest
Files.createDirectories(path("C:\\foo\\bar"));
Files.createSymbolicLink(path("C:\\link"), path("C:\\"));
- assertThat(path("C:\\link\\foo\\bar").toRealPath()).isEqualTo(path("C:\\foo\\bar"));
-
- assertThat(path("").toRealPath()).isEqualTo(path("C:\\work"));
- assertThat(path(".").toRealPath()).isEqualTo(path("C:\\work"));
- assertThat(path("..").toRealPath()).isEqualTo(path("C:\\"));
- assertThat(path("..\\..").toRealPath()).isEqualTo(path("C:\\"));
- assertThat(path(".\\..\\.\\..").toRealPath()).isEqualTo(path("C:\\"));
- assertThat(path(".\\..\\.\\..\\.").toRealPath()).isEqualTo(path("C:\\"));
+ assertThatPath(path("C:\\link\\foo\\bar").toRealPath()).isEqualTo(path("C:\\foo\\bar"));
+
+ assertThatPath(path("").toRealPath()).isEqualTo(path("C:\\work"));
+ assertThatPath(path(".").toRealPath()).isEqualTo(path("C:\\work"));
+ assertThatPath(path("..").toRealPath()).isEqualTo(path("C:\\"));
+ assertThatPath(path("..\\..").toRealPath()).isEqualTo(path("C:\\"));
+ assertThatPath(path(".\\..\\.\\..").toRealPath()).isEqualTo(path("C:\\"));
+ assertThatPath(path(".\\..\\.\\..\\.").toRealPath()).isEqualTo(path("C:\\"));
}
@Test
@@ -231,29 +231,29 @@ public class JimfsWindowsLikeFileSystemTest extends AbstractJimfsIntegrationTest
@Test
public void testPaths_getFromUri() {
- assertThat(Paths.get(URI.create("jimfs://win/C:/")))
+ assertThatPath(Paths.get(URI.create("jimfs://win/C:/")))
.isEqualTo(fs.getPath("C:\\"));
- assertThat(Paths.get(URI.create("jimfs://win/C:/foo")))
+ assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo")))
.isEqualTo(fs.getPath("C:\\foo"));
- assertThat(Paths.get(URI.create("jimfs://win/C:/foo%20bar")))
+ assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo%20bar")))
.isEqualTo(fs.getPath("C:\\foo bar"));
- assertThat(Paths.get(URI.create("jimfs://win/C:/foo/./bar")))
+ assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo/./bar")))
.isEqualTo(fs.getPath("C:\\foo\\.\\bar"));
- assertThat(Paths.get(URI.create("jimfs://win/C:/foo/bar/")))
+ assertThatPath(Paths.get(URI.create("jimfs://win/C:/foo/bar/")))
.isEqualTo(fs.getPath("C:\\foo\\bar"));
}
@Test
public void testPaths_getFromUri_unc() {
- assertThat(Paths.get(URI.create("jimfs://win//host/share/")))
+ assertThatPath(Paths.get(URI.create("jimfs://win//host/share/")))
.isEqualTo(fs.getPath("\\\\host\\share\\"));
- assertThat(Paths.get(URI.create("jimfs://win//host/share/foo")))
+ assertThatPath(Paths.get(URI.create("jimfs://win//host/share/foo")))
.isEqualTo(fs.getPath("\\\\host\\share\\foo"));
- assertThat(Paths.get(URI.create("jimfs://win//host/share/foo%20bar")))
+ assertThatPath(Paths.get(URI.create("jimfs://win//host/share/foo%20bar")))
.isEqualTo(fs.getPath("\\\\host\\share\\foo bar"));
- assertThat(Paths.get(URI.create("jimfs://win//host/share/foo/./bar")))
+ assertThatPath(Paths.get(URI.create("jimfs://win//host/share/foo/./bar")))
.isEqualTo(fs.getPath("\\\\host\\share\\foo\\.\\bar"));
- assertThat(Paths.get(URI.create("jimfs://win//host/share/foo/bar/")))
+ assertThatPath(Paths.get(URI.create("jimfs://win//host/share/foo/bar/")))
.isEqualTo(fs.getPath("\\\\host\\share\\foo\\bar"));
}