diff options
Diffstat (limited to 'jimfs/src/test/java/com')
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/AbstractAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/AbstractAttributeProviderTest.java) | 32 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/AbstractGlobMatcherTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/AbstractGlobMatcherTest.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/AbstractJimfsIntegrationTest.java | 4 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/AbstractPathMatcherTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/AbstractPathMatcherTest.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/AbstractWatchServiceTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/AbstractWatchServiceTest.java) | 6 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/AclAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/AclAttributeProviderTest.java) | 12 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/AttributeServiceTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/AttributeServiceTest.java) | 196 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/BasicAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/BasicAttributeProviderTest.java) | 14 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/BasicFileAttribute.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/BasicFileAttribute.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/BlockListTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/BlockListTest.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/ByteBufferChannel.java (renamed from jimfs/src/test/java/com/google/jimfs/testing/ByteBufferChannel.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/ByteStoreTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/ByteStoreTest.java) | 9 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/ConfigurationTest.java | 134 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/DirectoryEntryMapTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/DirectoryEntryMapTest.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/DirectoryTableTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/DirectoryTableTest.java) | 18 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/DosAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/DosAttributeProviderTest.java) | 14 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/FakeFileContent.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/FakeFileContent.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/FileFactoryTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/FileFactoryTest.java) | 5 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/FileTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/FileTest.java) | 30 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/FileTreeTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/FileTreeTest.java) | 9 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/HeapDiskTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/HeapDiskTest.java) | 4 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/JimfsAsynchronousFileChannelTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/JimfsAsynchronousFileChannelTest.java) | 6 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/JimfsFileChannelTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/JimfsFileChannelTest.java) | 11 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/JimfsInputStreamTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/JimfsInputStreamTest.java) | 6 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/JimfsOutputStreamTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/JimfsOutputStreamTest.java) | 6 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/JimfsPathTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/JimfsPathTest.java) | 12 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/JimfsUnixLikeFileSystemTest.java | 10 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/JimfsWindowsLikeFileSystemTest.java | 1 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/NameTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/NameTest.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/OwnerAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/OwnerAttributeProviderTest.java) | 10 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/PathNormalizationTest.java (renamed from jimfs/src/test/java/com/google/jimfs/path/NormalizationTest.java) | 34 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/PathServiceTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/PathServiceTest.java) | 9 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/PathSubject.java (renamed from jimfs/src/test/java/com/google/jimfs/testing/PathSubject.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/PathTester.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/PathTester.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/PathTypeTest.java (renamed from jimfs/src/test/java/com/google/jimfs/path/PathTypeTest.java) | 4 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/PollingWatchServiceTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/PollingWatchServiceTest.java) | 8 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/PosixAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/PosixAttributeProviderTest.java) | 24 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/RegexGlobMatcherTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/RegexGlobMatcherTest.java) | 5 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/ResourceManagerTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/ResourceManagerTest.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/TestAttributeProvider.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/TestAttributeProvider.java) | 28 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/TestAttributeView.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/TestAttributeView.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/TestAttributes.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/TestAttributes.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/TestUtils.java (renamed from jimfs/src/test/java/com/google/jimfs/testing/TestUtils.java) | 12 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/UnixAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/UnixAttributeProviderTest.java) | 40 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/UnixPathTypeTest.java (renamed from jimfs/src/test/java/com/google/jimfs/path/UnixPathTypeTest.java) | 8 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/UserDefinedAttributeProviderTest.java (renamed from jimfs/src/test/java/com/google/jimfs/attribute/UserDefinedAttributeProviderTest.java) | 22 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/UserLookupServiceTest.java (renamed from jimfs/src/test/java/com/google/jimfs/internal/UserLookupServiceTest.java) | 2 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/WindowsPathTypeTest.java (renamed from jimfs/src/test/java/com/google/jimfs/path/WindowsPathTypeTest.java) | 10 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/attribute/FakeInode.java | 61 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/attribute/InodeTest.java | 55 | ||||
-rw-r--r-- | jimfs/src/test/java/com/google/jimfs/internal/InternalTestUtils.java | 38 |
51 files changed, 389 insertions, 546 deletions
diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/AbstractAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/AbstractAttributeProviderTest.java index 4a9bfec..77e546b 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/AbstractAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/AbstractAttributeProviderTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; @@ -39,7 +39,7 @@ public abstract class AbstractAttributeProviderTest<P extends AttributeProvider> ImmutableMap.of(); protected P provider; - protected Inode inode; + protected File file; /** * Create the provider being tested. @@ -51,11 +51,11 @@ public abstract class AbstractAttributeProviderTest<P extends AttributeProvider> */ protected abstract Set<? extends AttributeProvider> createInheritedProviders(); - protected Inode.Lookup inodeLookup() { - return new Inode.Lookup() { + protected FileLookup fileLookup() { + return new FileLookup() { @Override - public Inode lookup() throws IOException { - return inode; + public File lookup() throws IOException { + return file; } }; } @@ -63,25 +63,25 @@ public abstract class AbstractAttributeProviderTest<P extends AttributeProvider> @Before public void setUp() { this.provider = createProvider(); - this.inode = new FakeInode(0); + this.file = new File(0, new DirectoryTable()); Map<String, ?> defaultValues = createDefaultValues(); - setDefaultValues(inode, provider, defaultValues); + setDefaultValues(file, provider, defaultValues); Set<? extends AttributeProvider> inheritedProviders = createInheritedProviders(); for (AttributeProvider inherited : inheritedProviders) { - setDefaultValues(inode, inherited, defaultValues); + setDefaultValues(file, inherited, defaultValues); } } private static void setDefaultValues( - Inode inode, AttributeProvider provider, Map<String, ?> defaultValues) { + File file, AttributeProvider provider, Map<String, ?> defaultValues) { Map<String, ?> defaults = provider.defaultValues(defaultValues); for (Map.Entry<String, ?> entry : defaults.entrySet()) { int separatorIndex = entry.getKey().indexOf(':'); String view = entry.getKey().substring(0, separatorIndex); String attr = entry.getKey().substring(separatorIndex + 1); - inode.setAttribute(view, attr, entry.getValue()); + file.setAttribute(view, attr, entry.getValue()); } } @@ -98,7 +98,7 @@ public abstract class AbstractAttributeProviderTest<P extends AttributeProvider> } protected void assertContainsAll( - Inode store, ImmutableMap<String, Object> expectedAttributes) { + File store, ImmutableMap<String, Object> expectedAttributes) { for (Map.Entry<String, Object> entry : expectedAttributes.entrySet()) { String attribute = entry.getKey(); Object value = entry.getValue(); @@ -116,14 +116,14 @@ public abstract class AbstractAttributeProviderTest<P extends AttributeProvider> } protected void assertSetAndGetSucceeds(String attribute, Object value, boolean create) { - provider.set(inode, provider.name(), attribute, value, create); - ASSERT.that(provider.get(inode, attribute)).is(value); + provider.set(file, provider.name(), attribute, value, create); + ASSERT.that(provider.get(file, attribute)).is(value); } @SuppressWarnings("EmptyCatchBlock") protected void assertSetFails(String attribute, Object value) { try { - provider.set(inode, provider.name(), attribute, value, false); + provider.set(file, provider.name(), attribute, value, false); fail(); } catch (IllegalArgumentException expected) { } @@ -132,7 +132,7 @@ public abstract class AbstractAttributeProviderTest<P extends AttributeProvider> @SuppressWarnings("EmptyCatchBlock") protected void assertSetFailsOnCreate(String attribute, Object value) { try { - provider.set(inode, provider.name(), attribute, value, true); + provider.set(file, provider.name(), attribute, value, true); fail(); } catch (UnsupportedOperationException expected) { } diff --git a/jimfs/src/test/java/com/google/jimfs/internal/AbstractGlobMatcherTest.java b/jimfs/src/test/java/com/google/jimfs/AbstractGlobMatcherTest.java index 55c9134..4cf8fdf 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/AbstractGlobMatcherTest.java +++ b/jimfs/src/test/java/com/google/jimfs/AbstractGlobMatcherTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import org.junit.Test; diff --git a/jimfs/src/test/java/com/google/jimfs/AbstractJimfsIntegrationTest.java b/jimfs/src/test/java/com/google/jimfs/AbstractJimfsIntegrationTest.java index 1ec8634..7671c49 100644 --- a/jimfs/src/test/java/com/google/jimfs/AbstractJimfsIntegrationTest.java +++ b/jimfs/src/test/java/com/google/jimfs/AbstractJimfsIntegrationTest.java @@ -16,11 +16,9 @@ package com.google.jimfs; -import static com.google.jimfs.testing.PathSubject.paths; +import static com.google.jimfs.PathSubject.paths; import static org.truth0.Truth.ASSERT; -import com.google.jimfs.testing.PathSubject; - import org.junit.After; import org.junit.Before; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/AbstractPathMatcherTest.java b/jimfs/src/test/java/com/google/jimfs/AbstractPathMatcherTest.java index ac3ccf2..32c97d1 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/AbstractPathMatcherTest.java +++ b/jimfs/src/test/java/com/google/jimfs/AbstractPathMatcherTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/AbstractWatchServiceTest.java b/jimfs/src/test/java/com/google/jimfs/AbstractWatchServiceTest.java index 4a5e47e..5187701 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/AbstractWatchServiceTest.java +++ b/jimfs/src/test/java/com/google/jimfs/AbstractWatchServiceTest.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.AbstractWatchService.Key.State.READY; -import static com.google.jimfs.internal.AbstractWatchService.Key.State.SIGNALLED; +import static com.google.jimfs.AbstractWatchService.Key.State.READY; +import static com.google.jimfs.AbstractWatchService.Key.State.SIGNALLED; import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/AclAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/AclAttributeProviderTest.java index 34f15f7..f11e728 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/AclAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/AclAttributeProviderTest.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; -import static com.google.jimfs.attribute.UserPrincipals.createUserPrincipal; +import static com.google.jimfs.UserPrincipals.createUserPrincipal; import static java.nio.file.attribute.AclEntryFlag.DIRECTORY_INHERIT; import static java.nio.file.attribute.AclEntryPermission.APPEND_DATA; import static java.nio.file.attribute.AclEntryPermission.DELETE; @@ -83,7 +83,7 @@ public class AclAttributeProviderTest extends AbstractAttributeProviderTest<AclA @Test public void testInitialAttributes() { - ASSERT.that(provider.get(inode, "acl")).is(defaultAcl); + ASSERT.that(provider.get(file, "acl")).is(defaultAcl); } @Test @@ -96,9 +96,9 @@ public class AclAttributeProviderTest extends AbstractAttributeProviderTest<AclA @Test public void testView() throws IOException { - AclFileAttributeView view = provider.view(inodeLookup(), + AclFileAttributeView view = provider.view(fileLookup(), ImmutableMap.<String, FileAttributeView>of( - "owner", new OwnerAttributeProvider().view(inodeLookup(), NO_INHERITED_VIEWS))); + "owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS))); assertNotNull(view); ASSERT.that(view.name()).is("acl"); @@ -111,6 +111,6 @@ public class AclAttributeProviderTest extends AbstractAttributeProviderTest<AclA ASSERT.that(view.getAcl()).is(ImmutableList.<AclEntry>of()); ASSERT.that(view.getOwner()).is(FOO); - ASSERT.that(inode.getAttribute("acl", "acl")).is(ImmutableList.<AclEntry>of()); + ASSERT.that(file.getAttribute("acl", "acl")).is(ImmutableList.<AclEntry>of()); } } diff --git a/jimfs/src/test/java/com/google/jimfs/internal/AttributeServiceTest.java b/jimfs/src/test/java/com/google/jimfs/AttributeServiceTest.java index 095ea04..02b20c3 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/AttributeServiceTest.java +++ b/jimfs/src/test/java/com/google/jimfs/AttributeServiceTest.java @@ -14,21 +14,13 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.jimfs.attribute.AttributeProvider; -import com.google.jimfs.attribute.BasicFileAttribute; -import com.google.jimfs.attribute.FakeInode; -import com.google.jimfs.attribute.Inode; -import com.google.jimfs.attribute.StandardAttributeProviders; -import com.google.jimfs.attribute.TestAttributeProvider; -import com.google.jimfs.attribute.TestAttributeView; -import com.google.jimfs.attribute.TestAttributes; import org.junit.Before; import org.junit.Test; @@ -77,49 +69,49 @@ public class AttributeServiceTest { @Test public void testSetInitialAttributes() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); - ASSERT.that(inode.getAttributeNames("test")).has().exactly("bar", "baz"); - ASSERT.that(inode.getAttributeNames("owner")).has().exactly("owner"); + ASSERT.that(file.getAttributeNames("test")).has().exactly("bar", "baz"); + ASSERT.that(file.getAttributeNames("owner")).has().exactly("owner"); - ASSERT.that(service.getAttribute(inode, "basic:lastModifiedTime")).isA(FileTime.class); - ASSERT.that(inode.getAttribute("test", "bar")).is(0L); - ASSERT.that(inode.getAttribute("test", "baz")).is(1); + ASSERT.that(service.getAttribute(file, "basic:lastModifiedTime")).isA(FileTime.class); + ASSERT.that(file.getAttribute("test", "bar")).is(0L); + ASSERT.that(file.getAttribute("test", "baz")).is(1); } @Test public void testGetAttribute() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); - - ASSERT.that(service.getAttribute(inode, "test:foo")).is("hello"); - ASSERT.that(service.getAttribute(inode, "test", "foo")).is("hello"); - ASSERT.that(service.getAttribute(inode, "basic:isRegularFile")).is(false); - ASSERT.that(service.getAttribute(inode, "isDirectory")).is(true); - ASSERT.that(service.getAttribute(inode, "test:baz")).is(1); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); + + ASSERT.that(service.getAttribute(file, "test:foo")).is("hello"); + ASSERT.that(service.getAttribute(file, "test", "foo")).is("hello"); + ASSERT.that(service.getAttribute(file, "basic:isRegularFile")).is(false); + ASSERT.that(service.getAttribute(file, "isDirectory")).is(true); + ASSERT.that(service.getAttribute(file, "test:baz")).is(1); } @Test public void testGetAttribute_fromInheritedProvider() { - Inode inode = new FakeInode(0); - ASSERT.that(service.getAttribute(inode, "test:isRegularFile")).is(false); - ASSERT.that(service.getAttribute(inode, "test:isDirectory")).is(true); - ASSERT.that(service.getAttribute(inode, "test", "fileKey")).is(0); + File file = new File(0, new DirectoryTable()); + ASSERT.that(service.getAttribute(file, "test:isRegularFile")).is(false); + ASSERT.that(service.getAttribute(file, "test:isDirectory")).is(true); + ASSERT.that(service.getAttribute(file, "test", "fileKey")).is(0); } @Test public void testGetAttribute_failsForAttributesNotDefinedByProvider() { - Inode inode = new FakeInode(0); + File file = new File(0, new DirectoryTable()); try { - service.getAttribute(inode, "test:blah"); + service.getAttribute(file, "test:blah"); fail(); } catch (IllegalArgumentException expected) { } try { // baz is defined by "test", but basic doesn't inherit test - service.getAttribute(inode, "basic", "baz"); + service.getAttribute(file, "basic", "baz"); fail(); } catch (IllegalArgumentException expected) { } @@ -127,110 +119,110 @@ public class AttributeServiceTest { @Test public void testSetAttribute() { - Inode inode = new FakeInode(0); - service.setAttribute(inode, "test:bar", 10L, false); - ASSERT.that(inode.getAttribute("test", "bar")).is(10L); + File file = new File(0, new DirectoryTable()); + service.setAttribute(file, "test:bar", 10L, false); + ASSERT.that(file.getAttribute("test", "bar")).is(10L); - service.setAttribute(inode, "test:baz", 100, false); - ASSERT.that(inode.getAttribute("test", "baz")).is(100); + service.setAttribute(file, "test:baz", 100, false); + ASSERT.that(file.getAttribute("test", "baz")).is(100); } @Test public void testSetAttribute_forInheritedProvider() { - Inode inode = new FakeInode(0); - service.setAttribute(inode, "test:lastModifiedTime", FileTime.fromMillis(0), false); - ASSERT.that(inode.getAttribute("test", "lastModifiedTime")).isNull(); - ASSERT.that(service.getAttribute(inode, "basic:lastModifiedTime")).is(FileTime.fromMillis(0)); + File file = new File(0, new DirectoryTable()); + service.setAttribute(file, "test:lastModifiedTime", FileTime.fromMillis(0), false); + ASSERT.that(file.getAttribute("test", "lastModifiedTime")).isNull(); + ASSERT.that(service.getAttribute(file, "basic:lastModifiedTime")).is(FileTime.fromMillis(0)); } @Test public void testSetAttribute_withAlternateAcceptedType() { - Inode inode = new FakeInode(0); - service.setAttribute(inode, "test:bar", 10F, false); - ASSERT.that(inode.getAttribute("test", "bar")).is(10L); + File file = new File(0, new DirectoryTable()); + service.setAttribute(file, "test:bar", 10F, false); + ASSERT.that(file.getAttribute("test", "bar")).is(10L); - service.setAttribute(inode, "test:bar", BigInteger.valueOf(123), false); - ASSERT.that(inode.getAttribute("test", "bar")).is(123L); + service.setAttribute(file, "test:bar", BigInteger.valueOf(123), false); + ASSERT.that(file.getAttribute("test", "bar")).is(123L); } @Test public void testSetAttribute_onCreate() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode, new BasicFileAttribute<>("test:baz", 123)); - ASSERT.that(inode.getAttribute("test", "baz")).is(123); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file, new BasicFileAttribute<>("test:baz", 123)); + ASSERT.that(file.getAttribute("test", "baz")).is(123); } @Test public void testSetAttribute_failsForAttributesNotDefinedByProvider() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); try { - service.setAttribute(inode, "test:blah", "blah", false); + service.setAttribute(file, "test:blah", "blah", false); fail(); } catch (IllegalArgumentException expected) { } try { // baz is defined by "test", but basic doesn't inherit test - service.setAttribute(inode, "basic:baz", 5, false); + service.setAttribute(file, "basic:baz", 5, false); fail(); } catch (IllegalArgumentException expected) { } - ASSERT.that(inode.getAttribute("test", "baz")).is(1); + ASSERT.that(file.getAttribute("test", "baz")).is(1); } @Test public void testSetAttribute_failsForArgumentThatIsNotOfCorrectType() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); try { - service.setAttribute(inode, "test:bar", "wrong", false); + service.setAttribute(file, "test:bar", "wrong", false); fail(); } catch (IllegalArgumentException expected) { } - ASSERT.that(inode.getAttribute("test", "bar")).is(0L); + ASSERT.that(file.getAttribute("test", "bar")).is(0L); } @Test public void testSetAttribute_failsForNullArgument() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); try { - service.setAttribute(inode, "test:bar", null, false); + service.setAttribute(file, "test:bar", null, false); fail(); } catch (NullPointerException expected) { } - ASSERT.that(inode.getAttribute("test", "bar")).is(0L); + ASSERT.that(file.getAttribute("test", "bar")).is(0L); } @Test public void testSetAttribute_failsForAttributeThatIsNotSettable() { - Inode inode = new FakeInode(0); + File file = new File(0, new DirectoryTable()); try { - service.setAttribute(inode, "test:foo", "world", false); + service.setAttribute(file, "test:foo", "world", false); fail(); } catch (IllegalArgumentException expected) { } - ASSERT.that(inode.getAttribute("test", "foo")).isNull(); + ASSERT.that(file.getAttribute("test", "foo")).isNull(); } @Test public void testSetAttribute_onCreate_failsForAttributeThatIsNotSettableOnCreate() { - Inode inode = new FakeInode(0); + File file = new File(0, new DirectoryTable()); try { - service.setInitialAttributes(inode, new BasicFileAttribute<>("test:foo", "world")); + service.setInitialAttributes(file, new BasicFileAttribute<>("test:foo", "world")); fail(); } catch (IllegalArgumentException expected) { // IAE because test:foo just can't be set } try { - service.setInitialAttributes(inode, new BasicFileAttribute<>("test:bar", 5)); + service.setInitialAttributes(file, new BasicFileAttribute<>("test:bar", 5)); fail(); } catch (UnsupportedOperationException expected) { } @@ -239,23 +231,23 @@ public class AttributeServiceTest { @SuppressWarnings("ConstantConditions") @Test public void testGetFileAttributeView() throws IOException { - final Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); + final File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); - Inode.Lookup inodeLookup = new Inode.Lookup() { + FileLookup fileLookup = new FileLookup() { @Override - public Inode lookup() throws IOException { - return inode; + public File lookup() throws IOException { + return file; } }; - ASSERT.that(service.getFileAttributeView(inodeLookup, TestAttributeView.class)) + ASSERT.that(service.getFileAttributeView(fileLookup, TestAttributeView.class)) .isNotNull(); - ASSERT.that(service.getFileAttributeView(inodeLookup, BasicFileAttributeView.class)) + ASSERT.that(service.getFileAttributeView(fileLookup, BasicFileAttributeView.class)) .isNotNull(); TestAttributes attrs - = service.getFileAttributeView(inodeLookup, TestAttributeView.class).readAttributes(); + = service.getFileAttributeView(fileLookup, TestAttributeView.class).readAttributes(); ASSERT.that(attrs.foo()).is("hello"); ASSERT.that(attrs.bar()).is(0); ASSERT.that(attrs.baz()).is(1); @@ -263,32 +255,32 @@ public class AttributeServiceTest { @Test public void testGetFileAttributeView_isNullForUnsupportedView() { - final Inode inode = new FakeInode(0); - Inode.Lookup inodeLookup = new Inode.Lookup() { + final File file = new File(0, new DirectoryTable()); + FileLookup fileLookup = new FileLookup() { @Override - public Inode lookup() throws IOException { - return inode; + public File lookup() throws IOException { + return file; } }; - ASSERT.that(service.getFileAttributeView(inodeLookup, PosixFileAttributeView.class)) + ASSERT.that(service.getFileAttributeView(fileLookup, PosixFileAttributeView.class)) .isNull(); } @Test public void testReadAttributes_asMap() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); - ImmutableMap<String, Object> map = service.readAttributes(inode, "test:foo,bar,baz"); + ImmutableMap<String, Object> map = service.readAttributes(file, "test:foo,bar,baz"); ASSERT.that(map).isEqualTo( ImmutableMap.of( "foo", "hello", "bar", 0L, "baz", 1)); - FileTime time = service.getAttribute(inode, "basic:creationTime"); + FileTime time = service.getAttribute(file, "basic:creationTime"); - map = service.readAttributes(inode, "test:*"); + map = service.readAttributes(file, "test:*"); ASSERT.that(map).isEqualTo( ImmutableMap.<String, Object>builder() .put("foo", "hello") @@ -305,7 +297,7 @@ public class AttributeServiceTest { .put("creationTime", time) .build()); - map = service.readAttributes(inode, "basic:*"); + map = service.readAttributes(file, "basic:*"); ASSERT.that(map).isEqualTo( ImmutableMap.<String, Object>builder() .put("fileKey", 0) @@ -322,16 +314,16 @@ public class AttributeServiceTest { @Test public void testReadAttributes_asMap_failsForInvalidAttributes() { - Inode inode = new FakeInode(0); + File file = new File(0, new DirectoryTable()); try { - service.readAttributes(inode, "basic:fileKey,isOther,*,creationTime"); + service.readAttributes(file, "basic:fileKey,isOther,*,creationTime"); fail(); } catch (IllegalArgumentException expected) { ASSERT.that(expected.getMessage()).contains("invalid attributes"); } try { - service.readAttributes(inode, "basic:fileKey,isOther,foo"); + service.readAttributes(file, "basic:fileKey,isOther,foo"); fail(); } catch (IllegalArgumentException expected) { ASSERT.that(expected.getMessage()).contains("invalid attribute"); @@ -340,28 +332,28 @@ public class AttributeServiceTest { @Test public void testReadAttributes_asObject() { - Inode inode = new FakeInode(0); - service.setInitialAttributes(inode); + File file = new File(0, new DirectoryTable()); + service.setInitialAttributes(file); - BasicFileAttributes basicAttrs = service.readAttributes(inode, BasicFileAttributes.class); + BasicFileAttributes basicAttrs = service.readAttributes(file, BasicFileAttributes.class); ASSERT.that(basicAttrs.fileKey()).is(0); ASSERT.that(basicAttrs.isDirectory()).isTrue(); ASSERT.that(basicAttrs.isRegularFile()).isFalse(); - TestAttributes testAttrs = service.readAttributes(inode, TestAttributes.class); + TestAttributes testAttrs = service.readAttributes(file, TestAttributes.class); ASSERT.that(testAttrs.foo()).is("hello"); ASSERT.that(testAttrs.bar()).is(0); ASSERT.that(testAttrs.baz()).is(1); - inode.setAttribute("test", "baz", 100); - ASSERT.that(service.readAttributes(inode, TestAttributes.class).baz()).is(100); + file.setAttribute("test", "baz", 100); + ASSERT.that(service.readAttributes(file, TestAttributes.class).baz()).is(100); } @Test public void testReadAttributes_failsForUnsupportedAttributesType() { - Inode inode = new FakeInode(0); + File file = new File(0, new DirectoryTable()); try { - service.readAttributes(inode, PosixFileAttributes.class); + service.readAttributes(file, PosixFileAttributes.class); fail(); } catch (UnsupportedOperationException expected) { } @@ -369,30 +361,30 @@ public class AttributeServiceTest { @Test public void testIllegalAttributeFormats() { - Inode inode = new FakeInode(0); + File file = new File(0, new DirectoryTable()); try { - service.getAttribute(inode, ":bar"); + service.getAttribute(file, ":bar"); fail(); } catch (IllegalArgumentException expected) { ASSERT.that(expected.getMessage()).contains("attribute format"); } try { - service.getAttribute(inode, "test:"); + service.getAttribute(file, "test:"); fail(); } catch (IllegalArgumentException expected) { ASSERT.that(expected.getMessage()).contains("attribute format"); } try { - service.getAttribute(inode, "basic:test:isDirectory"); + service.getAttribute(file, "basic:test:isDirectory"); fail(); } catch (IllegalArgumentException expected) { ASSERT.that(expected.getMessage()).contains("attribute format"); } try { - service.getAttribute(inode, "basic:fileKey,size"); + service.getAttribute(file, "basic:fileKey,size"); fail(); } catch (IllegalArgumentException expected) { ASSERT.that(expected.getMessage()).contains("single attribute"); diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/BasicAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/BasicAttributeProviderTest.java index 4e45903..5c67d69 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/BasicAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/BasicAttributeProviderTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import static org.truth0.Truth.ASSERT; @@ -58,12 +58,12 @@ public class BasicAttributeProviderTest extends @Test public void testInitialAttributes() { - long time = inode.getCreationTime(); + long time = file.getCreationTime(); ASSERT.that(time).isNotEqualTo(0L); - ASSERT.that(time).isEqualTo(inode.getLastAccessTime()); - ASSERT.that(time).isEqualTo(inode.getLastModifiedTime()); + ASSERT.that(time).isEqualTo(file.getLastAccessTime()); + ASSERT.that(time).isEqualTo(file.getLastModifiedTime()); - assertContainsAll(inode, + assertContainsAll(file, ImmutableMap.<String, Object>builder() .put("fileKey", 0) .put("size", 0L) @@ -106,7 +106,7 @@ public class BasicAttributeProviderTest extends @Test public void testView() throws IOException { - BasicFileAttributeView view = provider.view(inodeLookup(), NO_INHERITED_VIEWS); + BasicFileAttributeView view = provider.view(fileLookup(), NO_INHERITED_VIEWS); ASSERT.that(view).isNotNull(); ASSERT.that(view.name()).is("basic"); @@ -135,7 +135,7 @@ public class BasicAttributeProviderTest extends @Test public void testAttributes() { - BasicFileAttributes attrs = provider.readAttributes(inode); + BasicFileAttributes attrs = provider.readAttributes(file); ASSERT.that(attrs.fileKey()).is(0); ASSERT.that(attrs.isDirectory()).isTrue(); ASSERT.that(attrs.isRegularFile()).isFalse(); diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/BasicFileAttribute.java b/jimfs/src/test/java/com/google/jimfs/BasicFileAttribute.java index 8206527..091228e 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/BasicFileAttribute.java +++ b/jimfs/src/test/java/com/google/jimfs/BasicFileAttribute.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/BlockListTest.java b/jimfs/src/test/java/com/google/jimfs/BlockListTest.java index 3b1c9bd..2bb2068 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/BlockListTest.java +++ b/jimfs/src/test/java/com/google/jimfs/BlockListTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/testing/ByteBufferChannel.java b/jimfs/src/test/java/com/google/jimfs/ByteBufferChannel.java index 9968f95..3a4f9d1 100644 --- a/jimfs/src/test/java/com/google/jimfs/testing/ByteBufferChannel.java +++ b/jimfs/src/test/java/com/google/jimfs/ByteBufferChannel.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.testing; +package com.google.jimfs; import java.io.IOException; import java.nio.ByteBuffer; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/ByteStoreTest.java b/jimfs/src/test/java/com/google/jimfs/ByteStoreTest.java index 77d11f1..2a6933f 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/ByteStoreTest.java +++ b/jimfs/src/test/java/com/google/jimfs/ByteStoreTest.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static com.google.common.primitives.Bytes.concat; -import static com.google.jimfs.testing.TestUtils.buffer; -import static com.google.jimfs.testing.TestUtils.buffers; -import static com.google.jimfs.testing.TestUtils.bytes; +import static com.google.jimfs.TestUtils.buffer; +import static com.google.jimfs.TestUtils.buffers; +import static com.google.jimfs.TestUtils.bytes; import static org.junit.Assert.assertArrayEquals; import com.google.common.base.Predicate; @@ -27,7 +27,6 @@ import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -import com.google.jimfs.testing.ByteBufferChannel; import junit.framework.TestCase; import junit.framework.TestSuite; diff --git a/jimfs/src/test/java/com/google/jimfs/ConfigurationTest.java b/jimfs/src/test/java/com/google/jimfs/ConfigurationTest.java index afbf673..413349f 100644 --- a/jimfs/src/test/java/com/google/jimfs/ConfigurationTest.java +++ b/jimfs/src/test/java/com/google/jimfs/ConfigurationTest.java @@ -16,19 +16,15 @@ package com.google.jimfs; -import static com.google.jimfs.path.Normalization.CASE_FOLD_ASCII; -import static com.google.jimfs.path.Normalization.CASE_FOLD_UNICODE; -import static com.google.jimfs.path.Normalization.NFC; -import static com.google.jimfs.path.Normalization.NFD; +import static com.google.jimfs.PathNormalization.CASE_FOLD_ASCII; +import static com.google.jimfs.PathNormalization.CASE_FOLD_UNICODE; +import static com.google.jimfs.PathNormalization.NFC; +import static com.google.jimfs.PathNormalization.NFD; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.jimfs.attribute.AttributeProvider; -import com.google.jimfs.attribute.StandardAttributeProviders; -import com.google.jimfs.path.Normalization; -import com.google.jimfs.path.PathType; import org.junit.Test; import org.junit.runner.RunWith; @@ -53,18 +49,18 @@ public class ConfigurationTest { public void testDefaultUnixConfiguration() { Configuration config = Configuration.unix(); - ASSERT.that(config.pathType()).is(PathType.unix()); - ASSERT.that(config.roots()).has().exactly("/"); - ASSERT.that(config.workingDirectory()).is("/work"); - ASSERT.that(config.nameCanonicalNormalization()).isEmpty(); - ASSERT.that(config.nameDisplayNormalization()).isEmpty(); - ASSERT.that(config.pathEqualityUsesCanonicalForm()).isFalse(); - ASSERT.that(config.blockSize()).is(8192); - ASSERT.that(config.maxSize()).is(4L * 1024 * 1024 * 1024); - ASSERT.that(config.maxCacheSize()).is(-1); - ASSERT.that(config.attributeViews()).has().exactly("basic"); - ASSERT.that(config.attributeProviders()).isEmpty(); - ASSERT.that(config.defaultAttributeValues()).isEmpty(); + ASSERT.that(config.pathType).is(PathType.unix()); + ASSERT.that(config.roots).has().exactly("/"); + ASSERT.that(config.workingDirectory).is("/work"); + ASSERT.that(config.nameCanonicalNormalization).isEmpty(); + ASSERT.that(config.nameDisplayNormalization).isEmpty(); + ASSERT.that(config.pathEqualityUsesCanonicalForm).isFalse(); + ASSERT.that(config.blockSize).is(8192); + ASSERT.that(config.maxSize).is(4L * 1024 * 1024 * 1024); + ASSERT.that(config.maxCacheSize).is(-1); + ASSERT.that(config.attributeViews).has().exactly("basic"); + ASSERT.that(config.attributeProviders).isEmpty(); + ASSERT.that(config.defaultAttributeValues).isEmpty(); } @Test @@ -85,18 +81,18 @@ public class ConfigurationTest { public void testDefaultOsXConfiguration() { Configuration config = Configuration.osX(); - ASSERT.that(config.pathType()).is(PathType.unix()); - ASSERT.that(config.roots()).has().exactly("/"); - ASSERT.that(config.workingDirectory()).is("/work"); - ASSERT.that(config.nameCanonicalNormalization()).has().exactly(NFD, CASE_FOLD_ASCII); - ASSERT.that(config.nameDisplayNormalization()).has().exactly(NFC); - ASSERT.that(config.pathEqualityUsesCanonicalForm()).isFalse(); - ASSERT.that(config.blockSize()).is(8192); - ASSERT.that(config.maxSize()).is(4L * 1024 * 1024 * 1024); - ASSERT.that(config.maxCacheSize()).is(-1); - ASSERT.that(config.attributeViews()).has().exactly("basic"); - ASSERT.that(config.attributeProviders()).isEmpty(); - ASSERT.that(config.defaultAttributeValues()).isEmpty(); + ASSERT.that(config.pathType).is(PathType.unix()); + ASSERT.that(config.roots).has().exactly("/"); + ASSERT.that(config.workingDirectory).is("/work"); + ASSERT.that(config.nameCanonicalNormalization).has().exactly(NFD, CASE_FOLD_ASCII); + ASSERT.that(config.nameDisplayNormalization).has().exactly(NFC); + ASSERT.that(config.pathEqualityUsesCanonicalForm).isFalse(); + ASSERT.that(config.blockSize).is(8192); + ASSERT.that(config.maxSize).is(4L * 1024 * 1024 * 1024); + ASSERT.that(config.maxCacheSize).is(-1); + ASSERT.that(config.attributeViews).has().exactly("basic"); + ASSERT.that(config.attributeProviders).isEmpty(); + ASSERT.that(config.defaultAttributeValues).isEmpty(); } @Test @@ -122,18 +118,18 @@ public class ConfigurationTest { public void testDefaultWindowsConfiguration() { Configuration config = Configuration.windows(); - ASSERT.that(config.pathType()).is(PathType.windows()); - ASSERT.that(config.roots()).has().exactly("C:\\"); - ASSERT.that(config.workingDirectory()).is("C:\\work"); - ASSERT.that(config.nameCanonicalNormalization()).has().exactly(CASE_FOLD_ASCII); - ASSERT.that(config.nameDisplayNormalization()).isEmpty(); - ASSERT.that(config.pathEqualityUsesCanonicalForm()).isTrue(); - ASSERT.that(config.blockSize()).is(8192); - ASSERT.that(config.maxSize()).is(4L * 1024 * 1024 * 1024); - ASSERT.that(config.maxCacheSize()).is(-1); - ASSERT.that(config.attributeViews()).has().exactly("basic"); - ASSERT.that(config.attributeProviders()).isEmpty(); - ASSERT.that(config.defaultAttributeValues()).isEmpty(); + ASSERT.that(config.pathType).is(PathType.windows()); + ASSERT.that(config.roots).has().exactly("C:\\"); + ASSERT.that(config.workingDirectory).is("C:\\work"); + ASSERT.that(config.nameCanonicalNormalization).has().exactly(CASE_FOLD_ASCII); + ASSERT.that(config.nameDisplayNormalization).isEmpty(); + ASSERT.that(config.pathEqualityUsesCanonicalForm).isTrue(); + ASSERT.that(config.blockSize).is(8192); + ASSERT.that(config.maxSize).is(4L * 1024 * 1024 * 1024); + ASSERT.that(config.maxCacheSize).is(-1); + ASSERT.that(config.attributeViews).has().exactly("basic"); + ASSERT.that(config.attributeProviders).isEmpty(); + ASSERT.that(config.defaultAttributeValues).isEmpty(); } @Test @@ -174,18 +170,18 @@ public class ConfigurationTest { "posix:permissions", PosixFilePermissions.fromString("---------")) .build(); - ASSERT.that(config.pathType()).is(PathType.unix()); - ASSERT.that(config.roots()).has().exactly("/"); - ASSERT.that(config.workingDirectory()).is("/hello/world"); - ASSERT.that(config.nameCanonicalNormalization()).has().exactly(NFD, CASE_FOLD_UNICODE); - ASSERT.that(config.nameDisplayNormalization()).has().exactly(NFC); - ASSERT.that(config.pathEqualityUsesCanonicalForm()).isTrue(); - ASSERT.that(config.blockSize()).is(10); - ASSERT.that(config.maxSize()).is(100); - ASSERT.that(config.maxCacheSize()).is(50); - ASSERT.that(config.attributeViews()).has().exactly("basic", "posix"); - ASSERT.that(config.attributeProviders()).has().exactly(unixProvider); - ASSERT.that(config.defaultAttributeValues()) + ASSERT.that(config.pathType).is(PathType.unix()); + ASSERT.that(config.roots).has().exactly("/"); + ASSERT.that(config.workingDirectory).is("/hello/world"); + ASSERT.that(config.nameCanonicalNormalization).has().exactly(NFD, CASE_FOLD_UNICODE); + ASSERT.that(config.nameDisplayNormalization).has().exactly(NFC); + ASSERT.that(config.pathEqualityUsesCanonicalForm).isTrue(); + ASSERT.that(config.blockSize).is(10); + ASSERT.that(config.maxSize).is(100); + ASSERT.that(config.maxCacheSize).is(50); + ASSERT.that(config.attributeViews).has().exactly("basic", "posix"); + ASSERT.that(config.attributeProviders).has().exactly(unixProvider); + ASSERT.that(config.defaultAttributeValues) .hasKey("posix:permissions").withValue(PosixFilePermissions.fromString("---------")); } @@ -231,18 +227,18 @@ public class ConfigurationTest { .setAttributeViews("basic", "posix") .build(); - ASSERT.that(config.pathType()).is(PathType.unix()); - ASSERT.that(config.roots()).has().exactly("/"); - ASSERT.that(config.workingDirectory()).is("/hello/world"); - ASSERT.that(config.nameCanonicalNormalization()).isEmpty(); - ASSERT.that(config.nameDisplayNormalization()).isEmpty(); - ASSERT.that(config.pathEqualityUsesCanonicalForm()).isFalse(); - ASSERT.that(config.blockSize()).is(8192); - ASSERT.that(config.maxSize()).is(4L * 1024 * 1024 * 1024); - ASSERT.that(config.maxCacheSize()).is(-1); - ASSERT.that(config.attributeViews()).has().exactly("basic", "posix"); - ASSERT.that(config.attributeProviders()).isEmpty(); - ASSERT.that(config.defaultAttributeValues()).isEmpty(); + ASSERT.that(config.pathType).is(PathType.unix()); + ASSERT.that(config.roots).has().exactly("/"); + ASSERT.that(config.workingDirectory).is("/hello/world"); + ASSERT.that(config.nameCanonicalNormalization).isEmpty(); + ASSERT.that(config.nameDisplayNormalization).isEmpty(); + ASSERT.that(config.pathEqualityUsesCanonicalForm).isFalse(); + ASSERT.that(config.blockSize).is(8192); + ASSERT.that(config.maxSize).is(4L * 1024 * 1024 * 1024); + ASSERT.that(config.maxCacheSize).is(-1); + ASSERT.that(config.attributeViews).has().exactly("basic", "posix"); + ASSERT.that(config.attributeProviders).isEmpty(); + ASSERT.that(config.defaultAttributeValues).isEmpty(); } @Test @@ -284,7 +280,7 @@ public class ConfigurationTest { assertIllegalNormalizations(CASE_FOLD_ASCII, CASE_FOLD_UNICODE); } - private static void assertIllegalNormalizations(Normalization first, Normalization... more) { + private static void assertIllegalNormalizations(PathNormalization first, PathNormalization... more) { try { Configuration.builder(PathType.unix()).setNameCanonicalNormalization(first, more); fail(); diff --git a/jimfs/src/test/java/com/google/jimfs/internal/DirectoryEntryMapTest.java b/jimfs/src/test/java/com/google/jimfs/DirectoryEntryMapTest.java index 1c8fbbd..38b4da8 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/DirectoryEntryMapTest.java +++ b/jimfs/src/test/java/com/google/jimfs/DirectoryEntryMapTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/DirectoryTableTest.java b/jimfs/src/test/java/com/google/jimfs/DirectoryTableTest.java index 544a0c3..e6843f2 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/DirectoryTableTest.java +++ b/jimfs/src/test/java/com/google/jimfs/DirectoryTableTest.java @@ -14,18 +14,16 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.InternalTestUtils.byteStore; -import static com.google.jimfs.internal.Name.PARENT; -import static com.google.jimfs.internal.Name.SELF; +import static com.google.jimfs.Name.PARENT; +import static com.google.jimfs.Name.SELF; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; import com.google.common.base.Functions; import com.google.common.collect.ImmutableSortedSet; import com.google.common.collect.Iterables; -import com.google.jimfs.path.Normalization; import org.junit.Before; import org.junit.Test; @@ -217,8 +215,8 @@ public class DirectoryTableTest { @Test public void testSnapshot() { - root.link(Name.simple("bar"), new File(2, byteStore(10))); - root.link(Name.simple("abc"), new File(3, byteStore(10))); + root.link(Name.simple("bar"), new File(2, TestUtils.byteStore(10))); + root.link(Name.simple("abc"), new File(3, TestUtils.byteStore(10))); // does not include . or .. and is sorted by the name ASSERT.that(root.snapshot()) @@ -227,8 +225,8 @@ public class DirectoryTableTest { @Test public void testSnapshot_sortsUsingStringAndNotCanonicalValueOfNames() { - table.link(caseInsensitive("FOO"), new File(2, byteStore(10))); - table.link(caseInsensitive("bar"), new File(3, byteStore(10))); + table.link(caseInsensitive("FOO"), new File(2, TestUtils.byteStore(10))); + table.link(caseInsensitive("bar"), new File(3, TestUtils.byteStore(10))); ImmutableSortedSet<Name> snapshot = table.snapshot(); Iterable<String> strings = Iterables.transform(snapshot, Functions.toStringFunction()); @@ -252,6 +250,6 @@ public class DirectoryTableTest { } private static Name caseInsensitive(String name) { - return Name.create(name, Normalization.CASE_FOLD_UNICODE.apply(name)); + return Name.create(name, PathNormalization.CASE_FOLD_UNICODE.apply(name)); } } diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/DosAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/DosAttributeProviderTest.java index 0bb8695..de90783 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/DosAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/DosAttributeProviderTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import static org.junit.Assert.assertNotNull; import static org.truth0.Truth.ASSERT; @@ -58,7 +58,7 @@ public class DosAttributeProviderTest extends AbstractAttributeProviderTest<DosA @Test public void testInitialAttributes() { for (String attribute : DOS_ATTRIBUTES) { - ASSERT.that(provider.get(inode, attribute)).is(false); + ASSERT.that(provider.get(file, attribute)).is(false); } } @@ -72,9 +72,9 @@ public class DosAttributeProviderTest extends AbstractAttributeProviderTest<DosA @Test public void testView() throws IOException { - DosFileAttributeView view = provider.view(inodeLookup(), + DosFileAttributeView view = provider.view(fileLookup(), ImmutableMap.<String, FileAttributeView>of( - "basic", new BasicAttributeProvider().view(inodeLookup(), NO_INHERITED_VIEWS))); + "basic", new BasicAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS))); assertNotNull(view); ASSERT.that(view.name()).is("dos"); @@ -107,15 +107,15 @@ public class DosAttributeProviderTest extends AbstractAttributeProviderTest<DosA @Test public void testAttributes() { - DosFileAttributes attrs = provider.readAttributes(inode); + DosFileAttributes attrs = provider.readAttributes(file); ASSERT.that(attrs.isHidden()).isFalse(); ASSERT.that(attrs.isArchive()).isFalse(); ASSERT.that(attrs.isReadOnly()).isFalse(); ASSERT.that(attrs.isSystem()).isFalse(); - inode.setAttribute("dos", "hidden", true); + file.setAttribute("dos", "hidden", true); - attrs = provider.readAttributes(inode); + attrs = provider.readAttributes(file); ASSERT.that(attrs.isHidden()).isTrue(); ASSERT.that(attrs.isArchive()).isFalse(); ASSERT.that(attrs.isReadOnly()).isFalse(); diff --git a/jimfs/src/test/java/com/google/jimfs/internal/FakeFileContent.java b/jimfs/src/test/java/com/google/jimfs/FakeFileContent.java index 7926aed..a0f6310 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/FakeFileContent.java +++ b/jimfs/src/test/java/com/google/jimfs/FakeFileContent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static com.google.common.base.Preconditions.checkNotNull; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/FileFactoryTest.java b/jimfs/src/test/java/com/google/jimfs/FileFactoryTest.java index bc6a116..0e50525 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/FileFactoryTest.java +++ b/jimfs/src/test/java/com/google/jimfs/FileFactoryTest.java @@ -14,9 +14,8 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.PathServiceTest.fakeUnixPathService; import static org.truth0.Truth.ASSERT; import org.junit.Before; @@ -70,6 +69,6 @@ public class FileFactoryTest { } static JimfsPath fakePath() { - return fakeUnixPathService().emptyPath(); + return PathServiceTest.fakeUnixPathService().emptyPath(); } } diff --git a/jimfs/src/test/java/com/google/jimfs/internal/FileTest.java b/jimfs/src/test/java/com/google/jimfs/FileTest.java index 80d966d..55282c2 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/FileTest.java +++ b/jimfs/src/test/java/com/google/jimfs/FileTest.java @@ -14,10 +14,9 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.FileFactoryTest.fakePath; -import static com.google.jimfs.internal.InternalTestUtils.byteStore; +import static com.google.jimfs.FileFactoryTest.fakePath; import static org.truth0.Truth.ASSERT; import org.junit.Test; @@ -33,6 +32,29 @@ import org.junit.runners.JUnit4; public class FileTest { @Test + public void testAttributes() { + // these methods are basically just thin wrappers around a map, so no need to test too + // thoroughly + + File file = new File(0, new ByteStore(new HeapDisk(10, 10, 10))); + + ASSERT.that(file.getAttributeKeys()).isEmpty(); + ASSERT.that(file.getAttribute("foo", "foo")).isNull(); + + file.deleteAttribute("foo", "foo"); // doesn't throw + + file.setAttribute("foo", "foo", "foo"); + + ASSERT.that(file.getAttributeKeys()).iteratesAs("foo:foo"); + ASSERT.that(file.getAttribute("foo", "foo")).is("foo"); + + file.deleteAttribute("foo", "foo"); + + ASSERT.that(file.getAttributeKeys()).isEmpty(); + ASSERT.that(file.getAttribute("foo", "foo")).isNull(); + } + + @Test public void testFileBasics() { FileContent content = new FakeFileContent(); File file = new File(0, content); @@ -53,7 +75,7 @@ public class FileTest { @Test public void testRegularFile() { - File file = new File(0, byteStore(10)); + File file = new File(0, TestUtils.byteStore(10)); ASSERT.that(file.isDirectory()).isFalse(); ASSERT.that(file.isRegularFile()).isTrue(); ASSERT.that(file.isSymbolicLink()).isFalse(); diff --git a/jimfs/src/test/java/com/google/jimfs/internal/FileTreeTest.java b/jimfs/src/test/java/com/google/jimfs/FileTreeTest.java index c12b061..151e176 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/FileTreeTest.java +++ b/jimfs/src/test/java/com/google/jimfs/FileTreeTest.java @@ -14,11 +14,9 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.jimfs.internal.InternalTestUtils.byteStore; -import static com.google.jimfs.internal.PathServiceTest.fakePathService; import static java.nio.file.LinkOption.NOFOLLOW_LINKS; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; @@ -26,7 +24,6 @@ import static org.truth0.Truth.ASSERT; import com.google.common.base.Joiner; import com.google.common.base.Splitter; import com.google.common.base.Strings; -import com.google.jimfs.path.PathType; import org.junit.Before; import org.junit.Test; @@ -78,7 +75,7 @@ public class FileTreeTest { * a path like "$foo/bar" and one like "/$foo/bar". They would become "/$foo/bar" and * "//$foo/bar" respectively. */ - private final PathService pathService = fakePathService( + private final PathService pathService = PathServiceTest.fakePathService( new PathType(true, '/') { @Override public ParseResult parsePath(String path) { @@ -460,7 +457,7 @@ public class FileTreeTest { private File createFile(String parent, String name) { File dir = files.get(parent); - File newFile = new File(new Random().nextInt(), byteStore(0)); + File newFile = new File(new Random().nextInt(), TestUtils.byteStore(0)); dir.asDirectory().link(Name.simple(name), newFile); diff --git a/jimfs/src/test/java/com/google/jimfs/internal/HeapDiskTest.java b/jimfs/src/test/java/com/google/jimfs/HeapDiskTest.java index f74143b..8500284 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/HeapDiskTest.java +++ b/jimfs/src/test/java/com/google/jimfs/HeapDiskTest.java @@ -14,13 +14,11 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; -import com.google.jimfs.Configuration; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/JimfsAsynchronousFileChannelTest.java b/jimfs/src/test/java/com/google/jimfs/JimfsAsynchronousFileChannelTest.java index 53f6d73..dfcab8f 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/JimfsAsynchronousFileChannelTest.java +++ b/jimfs/src/test/java/com/google/jimfs/JimfsAsynchronousFileChannelTest.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.InternalTestUtils.byteStore; -import static com.google.jimfs.testing.TestUtils.buffer; +import static com.google.jimfs.TestUtils.buffer; +import static com.google.jimfs.TestUtils.byteStore; import static java.nio.file.StandardOpenOption.READ; import static java.nio.file.StandardOpenOption.WRITE; import static java.util.concurrent.TimeUnit.MILLISECONDS; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/JimfsFileChannelTest.java b/jimfs/src/test/java/com/google/jimfs/JimfsFileChannelTest.java index bc78223..d38e3d5 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/JimfsFileChannelTest.java +++ b/jimfs/src/test/java/com/google/jimfs/JimfsFileChannelTest.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.InternalTestUtils.byteStore; -import static com.google.jimfs.testing.TestUtils.assertNotEquals; -import static com.google.jimfs.testing.TestUtils.buffer; -import static com.google.jimfs.testing.TestUtils.bytes; +import static com.google.jimfs.TestUtils.assertNotEquals; +import static com.google.jimfs.TestUtils.buffer; +import static com.google.jimfs.TestUtils.byteStore; +import static com.google.jimfs.TestUtils.bytes; import static java.nio.file.StandardOpenOption.APPEND; import static java.nio.file.StandardOpenOption.READ; import static java.nio.file.StandardOpenOption.WRITE; @@ -34,7 +34,6 @@ import static org.junit.Assert.fail; import com.google.common.collect.ImmutableSet; import com.google.common.testing.NullPointerTester; import com.google.common.util.concurrent.Uninterruptibles; -import com.google.jimfs.testing.ByteBufferChannel; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/JimfsInputStreamTest.java b/jimfs/src/test/java/com/google/jimfs/JimfsInputStreamTest.java index dec458b..f130bb5 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/JimfsInputStreamTest.java +++ b/jimfs/src/test/java/com/google/jimfs/JimfsInputStreamTest.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.InternalTestUtils.byteStore; -import static com.google.jimfs.testing.TestUtils.bytes; +import static com.google.jimfs.TestUtils.byteStore; +import static com.google.jimfs.TestUtils.bytes; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/JimfsOutputStreamTest.java b/jimfs/src/test/java/com/google/jimfs/JimfsOutputStreamTest.java index cd55ae7..5890255 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/JimfsOutputStreamTest.java +++ b/jimfs/src/test/java/com/google/jimfs/JimfsOutputStreamTest.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.InternalTestUtils.byteStore; -import static com.google.jimfs.testing.TestUtils.bytes; +import static com.google.jimfs.TestUtils.byteStore; +import static com.google.jimfs.TestUtils.bytes; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/JimfsPathTest.java b/jimfs/src/test/java/com/google/jimfs/JimfsPathTest.java index a59ad00..c105fb8 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/JimfsPathTest.java +++ b/jimfs/src/test/java/com/google/jimfs/JimfsPathTest.java @@ -14,10 +14,8 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.internal.PathServiceTest.fakeUnixPathService; -import static com.google.jimfs.internal.PathServiceTest.fakeWindowsPathService; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -41,7 +39,7 @@ import java.nio.file.Path; @RunWith(JUnit4.class) public class JimfsPathTest { - private final PathService pathService = fakeUnixPathService(); + private final PathService pathService = PathServiceTest.fakeUnixPathService(); @Test public void testPathParsing() { @@ -68,7 +66,7 @@ public class JimfsPathTest { @Test public void testPathParsing_windowsStylePaths() throws IOException { - PathService windowsPathService = fakeWindowsPathService(); + PathService windowsPathService = PathServiceTest.fakeWindowsPathService(); assertEquals("C:\\", pathService.parsePath("C:\\").toString()); assertEquals("C:\\foo", windowsPathService.parsePath("C:\\foo").toString()); assertEquals("C:\\foo", windowsPathService.parsePath("C:\\", "foo").toString()); @@ -79,7 +77,7 @@ public class JimfsPathTest { @Test public void testParsing_windowsStylePaths_invalidPaths() { - PathService windowsPathService = fakeWindowsPathService(); + PathService windowsPathService = PathServiceTest.fakeWindowsPathService(); try { // The actual windows implementation seems to allow "C:" but treat it as a *name*, not a root @@ -109,7 +107,7 @@ public class JimfsPathTest { @Test public void testPathParsing_withAlternateSeparator() { // windows recognizes / as an alternate separator - PathService windowsPathService = fakeWindowsPathService(); + PathService windowsPathService = PathServiceTest.fakeWindowsPathService(); assertEquals(windowsPathService.parsePath("foo\\bar\\baz"), windowsPathService.parsePath("foo/bar/baz")); assertEquals(windowsPathService.parsePath("C:\\foo\\bar"), diff --git a/jimfs/src/test/java/com/google/jimfs/JimfsUnixLikeFileSystemTest.java b/jimfs/src/test/java/com/google/jimfs/JimfsUnixLikeFileSystemTest.java index fd1539b..656b163 100644 --- a/jimfs/src/test/java/com/google/jimfs/JimfsUnixLikeFileSystemTest.java +++ b/jimfs/src/test/java/com/google/jimfs/JimfsUnixLikeFileSystemTest.java @@ -17,10 +17,10 @@ package com.google.jimfs; import static com.google.common.primitives.Bytes.concat; -import static com.google.jimfs.attribute.UserPrincipals.createUserPrincipal; -import static com.google.jimfs.testing.TestUtils.bytes; -import static com.google.jimfs.testing.TestUtils.permutations; -import static com.google.jimfs.testing.TestUtils.preFilledBytes; +import static com.google.jimfs.TestUtils.bytes; +import static com.google.jimfs.TestUtils.permutations; +import static com.google.jimfs.TestUtils.preFilledBytes; +import static com.google.jimfs.UserPrincipals.createUserPrincipal; import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.file.LinkOption.NOFOLLOW_LINKS; import static java.nio.file.StandardCopyOption.ATOMIC_MOVE; @@ -52,8 +52,6 @@ import com.google.common.io.ByteStreams; import com.google.common.io.CharStreams; import com.google.common.primitives.Bytes; import com.google.common.util.concurrent.Uninterruptibles; -import com.google.jimfs.attribute.BasicFileAttribute; -import com.google.jimfs.internal.JimfsFileSystemProvider; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jimfs/src/test/java/com/google/jimfs/JimfsWindowsLikeFileSystemTest.java b/jimfs/src/test/java/com/google/jimfs/JimfsWindowsLikeFileSystemTest.java index 607e834..5f53833 100644 --- a/jimfs/src/test/java/com/google/jimfs/JimfsWindowsLikeFileSystemTest.java +++ b/jimfs/src/test/java/com/google/jimfs/JimfsWindowsLikeFileSystemTest.java @@ -23,7 +23,6 @@ import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Ordering; -import com.google.jimfs.internal.JimfsFileSystemProvider; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/NameTest.java b/jimfs/src/test/java/com/google/jimfs/NameTest.java index 034d09f..1401554 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/NameTest.java +++ b/jimfs/src/test/java/com/google/jimfs/NameTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/OwnerAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/OwnerAttributeProviderTest.java index 51be8d0..e6b2070 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/OwnerAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/OwnerAttributeProviderTest.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; -import static com.google.jimfs.attribute.UserPrincipals.createUserPrincipal; +import static com.google.jimfs.UserPrincipals.createUserPrincipal; import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableSet; @@ -50,7 +50,7 @@ public class OwnerAttributeProviderTest extends @Test public void testInitialAttributes() { - ASSERT.that(provider.get(inode, "owner")).isEqualTo(createUserPrincipal("user")); + ASSERT.that(provider.get(file, "owner")).isEqualTo(createUserPrincipal("user")); } @Test @@ -64,7 +64,7 @@ public class OwnerAttributeProviderTest extends @Test public void testView() throws IOException { - FileOwnerAttributeView view = provider.view(inodeLookup(), NO_INHERITED_VIEWS); + FileOwnerAttributeView view = provider.view(fileLookup(), NO_INHERITED_VIEWS); ASSERT.that(view).isNotNull(); ASSERT.that(view.name()).is("owner"); @@ -72,6 +72,6 @@ public class OwnerAttributeProviderTest extends view.setOwner(createUserPrincipal("root")); ASSERT.that(view.getOwner()).isEqualTo(createUserPrincipal("root")); - ASSERT.that(inode.getAttribute("owner", "owner")).isEqualTo(createUserPrincipal("root")); + ASSERT.that(file.getAttribute("owner", "owner")).isEqualTo(createUserPrincipal("root")); } } diff --git a/jimfs/src/test/java/com/google/jimfs/path/NormalizationTest.java b/jimfs/src/test/java/com/google/jimfs/PathNormalizationTest.java index 6935426..0c813dc 100644 --- a/jimfs/src/test/java/com/google/jimfs/path/NormalizationTest.java +++ b/jimfs/src/test/java/com/google/jimfs/PathNormalizationTest.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package com.google.jimfs.path; +package com.google.jimfs; -import static com.google.jimfs.path.Normalization.CASE_FOLD_ASCII; -import static com.google.jimfs.path.Normalization.CASE_FOLD_UNICODE; -import static com.google.jimfs.path.Normalization.NFC; -import static com.google.jimfs.path.Normalization.NFD; -import static com.google.jimfs.testing.TestUtils.assertNotEquals; +import static com.google.jimfs.PathNormalization.CASE_FOLD_ASCII; +import static com.google.jimfs.PathNormalization.CASE_FOLD_UNICODE; +import static com.google.jimfs.PathNormalization.NFC; +import static com.google.jimfs.PathNormalization.NFD; +import static com.google.jimfs.TestUtils.assertNotEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -34,14 +34,14 @@ import org.junit.runners.JUnit4; import java.util.regex.Pattern; /** - * Tests for {@link Normalization}. + * Tests for {@link PathNormalization}. * * @author Colin Decker */ @RunWith(JUnit4.class) -public class NormalizationTest { +public class PathNormalizationTest { - private ImmutableSet<Normalization> normalizations; + private ImmutableSet<PathNormalization> normalizations; @Test public void testNone() { @@ -310,8 +310,8 @@ public class NormalizationTest { */ private void assertNormalizedEqual(String first, String second) { assertEquals( - Normalization.normalize(first, normalizations), - Normalization.normalize(second, normalizations)); + PathNormalization.normalize(first, normalizations), + PathNormalization.normalize(second, normalizations)); } /** @@ -319,8 +319,8 @@ public class NormalizationTest { */ private void assertNormalizedUnequal(String first, String second) { assertNotEquals( - Normalization.normalize(first, normalizations), - Normalization.normalize(second, normalizations)); + PathNormalization.normalize(first, normalizations), + PathNormalization.normalize(second, normalizations)); } /** @@ -328,11 +328,11 @@ public class NormalizationTest { * normalizer and matched against the other. */ private void assertNormalizedPatternMatches(String first, String second) { - Pattern pattern = Normalization.compilePattern(first, normalizations); + Pattern pattern = PathNormalization.compilePattern(first, normalizations); assertTrue("pattern '" + pattern + "' does not match '" + second + "'", pattern.matcher(second).matches()); - pattern = Normalization.compilePattern(second, normalizations); + pattern = PathNormalization.compilePattern(second, normalizations); assertTrue("pattern '" + pattern + "' does not match '" + first + "'", pattern.matcher(first).matches()); } @@ -342,11 +342,11 @@ public class NormalizationTest { * current normalizer and matched against the other. */ private void assertNormalizedPatternDoesNotMatch(String first, String second) { - Pattern pattern = Normalization.compilePattern(first, normalizations); + Pattern pattern = PathNormalization.compilePattern(first, normalizations); assertFalse("pattern '" + pattern + "' should not match '" + second + "'", pattern.matcher(second).matches()); - pattern = Normalization.compilePattern(second, normalizations); + pattern = PathNormalization.compilePattern(second, normalizations); assertFalse("pattern '" + pattern + "' should not match '" + first + "'", pattern.matcher(first).matches()); } diff --git a/jimfs/src/test/java/com/google/jimfs/internal/PathServiceTest.java b/jimfs/src/test/java/com/google/jimfs/PathServiceTest.java index 6cebe13..193f248 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/PathServiceTest.java +++ b/jimfs/src/test/java/com/google/jimfs/PathServiceTest.java @@ -14,16 +14,13 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; -import static com.google.jimfs.testing.PathSubject.paths; +import static com.google.jimfs.PathSubject.paths; import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.jimfs.Configuration; -import com.google.jimfs.path.Normalization; -import com.google.jimfs.path.PathType; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,7 +38,7 @@ import java.nio.file.FileSystem; @RunWith(JUnit4.class) public class PathServiceTest { - private static final ImmutableSet<Normalization> NO_NORMALIZATIONS = ImmutableSet.of(); + private static final ImmutableSet<PathNormalization> NO_NORMALIZATIONS = ImmutableSet.of(); private final PathService service = fakeUnixPathService(); diff --git a/jimfs/src/test/java/com/google/jimfs/testing/PathSubject.java b/jimfs/src/test/java/com/google/jimfs/PathSubject.java index 25b0298..35b6c2d 100644 --- a/jimfs/src/test/java/com/google/jimfs/testing/PathSubject.java +++ b/jimfs/src/test/java/com/google/jimfs/PathSubject.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.testing; +package com.google.jimfs; import static com.google.common.base.Preconditions.checkNotNull; import static java.nio.charset.StandardCharsets.UTF_8; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/PathTester.java b/jimfs/src/test/java/com/google/jimfs/PathTester.java index 6acc038..0c31e79 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/PathTester.java +++ b/jimfs/src/test/java/com/google/jimfs/PathTester.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static com.google.common.base.Functions.toStringFunction; import static org.junit.Assert.assertEquals; diff --git a/jimfs/src/test/java/com/google/jimfs/path/PathTypeTest.java b/jimfs/src/test/java/com/google/jimfs/PathTypeTest.java index 5a25dbd..2dffeab 100644 --- a/jimfs/src/test/java/com/google/jimfs/path/PathTypeTest.java +++ b/jimfs/src/test/java/com/google/jimfs/PathTypeTest.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.jimfs.path; +package com.google.jimfs; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.jimfs.path.PathType.ParseResult; +import static com.google.jimfs.PathType.ParseResult; import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableList; diff --git a/jimfs/src/test/java/com/google/jimfs/internal/PollingWatchServiceTest.java b/jimfs/src/test/java/com/google/jimfs/PollingWatchServiceTest.java index 8b87fcf..119aaf7 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/PollingWatchServiceTest.java +++ b/jimfs/src/test/java/com/google/jimfs/PollingWatchServiceTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE; @@ -25,10 +25,8 @@ import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Uninterruptibles; -import com.google.jimfs.Configuration; -import com.google.jimfs.Jimfs; -import com.google.jimfs.internal.AbstractWatchService.Event; -import com.google.jimfs.internal.AbstractWatchService.Key; +import com.google.jimfs.AbstractWatchService.Event; +import com.google.jimfs.AbstractWatchService.Key; import org.junit.After; import org.junit.Before; diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/PosixAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/PosixAttributeProviderTest.java index 73dffdd..a3e9f21 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/PosixAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/PosixAttributeProviderTest.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; -import static com.google.jimfs.attribute.UserPrincipals.createGroupPrincipal; -import static com.google.jimfs.attribute.UserPrincipals.createUserPrincipal; +import static com.google.jimfs.UserPrincipals.createGroupPrincipal; +import static com.google.jimfs.UserPrincipals.createUserPrincipal; import static org.junit.Assert.assertNotNull; import static org.truth0.Truth.ASSERT; @@ -58,7 +58,7 @@ public class PosixAttributeProviderTest extends @Test public void testInitialAttributes() { - assertContainsAll(inode, + assertContainsAll(file, ImmutableMap.of( "group", createGroupPrincipal("group"), "permissions", PosixFilePermissions.fromString("rw-r--r--"))); @@ -82,12 +82,12 @@ public class PosixAttributeProviderTest extends @Test public void testView() throws IOException { - inode.setAttribute("owner", "owner", createUserPrincipal("user")); + file.setAttribute("owner", "owner", createUserPrincipal("user")); - PosixFileAttributeView view = provider.view(inodeLookup(), + PosixFileAttributeView view = provider.view(fileLookup(), ImmutableMap.<String, FileAttributeView>of( - "basic", new BasicAttributeProvider().view(inodeLookup(), NO_INHERITED_VIEWS), - "owner", new OwnerAttributeProvider().view(inodeLookup(), NO_INHERITED_VIEWS))); + "basic", new BasicAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS), + "owner", new OwnerAttributeProvider().view(fileLookup(), NO_INHERITED_VIEWS))); assertNotNull(view); ASSERT.that(view.name()).is("posix"); @@ -101,22 +101,22 @@ public class PosixAttributeProviderTest extends view.setOwner(createUserPrincipal("root")); ASSERT.that(view.getOwner()).is(createUserPrincipal("root")); - ASSERT.that(inode.getAttribute("owner", "owner")).is(createUserPrincipal("root")); + ASSERT.that(file.getAttribute("owner", "owner")).is(createUserPrincipal("root")); view.setGroup(createGroupPrincipal("root")); ASSERT.that(view.readAttributes().group()).is(createGroupPrincipal("root")); - ASSERT.that(inode.getAttribute("posix", "group")).is(createGroupPrincipal("root")); + ASSERT.that(file.getAttribute("posix", "group")).is(createGroupPrincipal("root")); view.setPermissions(PosixFilePermissions.fromString("rwx------")); ASSERT.that(view.readAttributes().permissions()) .is(PosixFilePermissions.fromString("rwx------")); - ASSERT.that(inode.getAttribute("posix", "permissions")) + ASSERT.that(file.getAttribute("posix", "permissions")) .is(PosixFilePermissions.fromString("rwx------")); } @Test public void testAttributes() { - PosixFileAttributes attrs = provider.readAttributes(inode); + PosixFileAttributes attrs = provider.readAttributes(file); ASSERT.that(attrs.permissions()).is(PosixFilePermissions.fromString("rw-r--r--")); ASSERT.that(attrs.group()).is(createGroupPrincipal("group")); ASSERT.that(attrs.fileKey()).is(0); diff --git a/jimfs/src/test/java/com/google/jimfs/internal/RegexGlobMatcherTest.java b/jimfs/src/test/java/com/google/jimfs/RegexGlobMatcherTest.java index c3b842b..35b2cee 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/RegexGlobMatcherTest.java +++ b/jimfs/src/test/java/com/google/jimfs/RegexGlobMatcherTest.java @@ -14,12 +14,11 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.junit.Assert.assertEquals; import com.google.common.collect.ImmutableSet; -import com.google.jimfs.path.Normalization; import org.junit.Test; import org.junit.runner.RunWith; @@ -40,7 +39,7 @@ public class RegexGlobMatcherTest extends AbstractGlobMatcherTest { @Override protected PathMatcher matcher(String pattern) { - return PathMatchers.getPathMatcher("glob:" + pattern, "/", ImmutableSet.<Normalization>of()); + return PathMatchers.getPathMatcher("glob:" + pattern, "/", ImmutableSet.<PathNormalization>of()); } @Override diff --git a/jimfs/src/test/java/com/google/jimfs/internal/ResourceManagerTest.java b/jimfs/src/test/java/com/google/jimfs/ResourceManagerTest.java index 6040590..827127c 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/ResourceManagerTest.java +++ b/jimfs/src/test/java/com/google/jimfs/ResourceManagerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/TestAttributeProvider.java b/jimfs/src/test/java/com/google/jimfs/TestAttributeProvider.java index 32ca776..85c0d47 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/TestAttributeProvider.java +++ b/jimfs/src/test/java/com/google/jimfs/TestAttributeProvider.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import static com.google.common.base.Preconditions.checkNotNull; @@ -75,15 +75,15 @@ public final class TestAttributeProvider extends AttributeProvider { @Override public void set( - Inode inode, String view, String attribute, Object value, boolean create) { + File file, String view, String attribute, Object value, boolean create) { switch (attribute) { case "bar": checkNotCreate(view, attribute, create); - inode.setAttribute("test", "bar", + file.setAttribute("test", "bar", checkType(view, attribute, value, Number.class).longValue()); break; case "baz": - inode.setAttribute("test", "baz", + file.setAttribute("test", "baz", checkType(view, attribute, value, Integer.class)); break; default: @@ -92,11 +92,11 @@ public final class TestAttributeProvider extends AttributeProvider { } @Override - public Object get(Inode inode, String attribute) { + public Object get(File file, String attribute) { if (attribute.equals("foo")) { return "hello"; } - return inode.getAttribute("test", attribute); + return file.getAttribute("test", attribute); } @Override @@ -106,7 +106,7 @@ public final class TestAttributeProvider extends AttributeProvider { @Override public TestAttributeView view( - Inode.Lookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { + FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup, (BasicFileAttributeView) inheritedViews.get("basic")); } @@ -116,16 +116,16 @@ public final class TestAttributeProvider extends AttributeProvider { } @Override - public TestAttributes readAttributes(Inode inode) { - return new Attributes(inode); + public TestAttributes readAttributes(File file) { + return new Attributes(file); } static final class View implements TestAttributeView { - private final Inode.Lookup lookup; + private final FileLookup lookup; private final BasicFileAttributeView basicView; - public View(Inode.Lookup lookup, BasicFileAttributeView basicView) { + public View(FileLookup lookup, BasicFileAttributeView basicView) { this.lookup = checkNotNull(lookup); this.basicView = checkNotNull(basicView); } @@ -164,9 +164,9 @@ public final class TestAttributeProvider extends AttributeProvider { private final Long bar; private final Integer baz; - public Attributes(Inode inode) { - this.bar = (Long) inode.getAttribute("test", "bar"); - this.baz = (Integer) inode.getAttribute("test", "baz"); + public Attributes(File file) { + this.bar = (Long) file.getAttribute("test", "bar"); + this.baz = (Integer) file.getAttribute("test", "baz"); } @Override diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/TestAttributeView.java b/jimfs/src/test/java/com/google/jimfs/TestAttributeView.java index fdb280b..4c4f5b6 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/TestAttributeView.java +++ b/jimfs/src/test/java/com/google/jimfs/TestAttributeView.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import java.io.IOException; import java.nio.file.attribute.BasicFileAttributeView; diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/TestAttributes.java b/jimfs/src/test/java/com/google/jimfs/TestAttributes.java index c7cef49..970b257 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/TestAttributes.java +++ b/jimfs/src/test/java/com/google/jimfs/TestAttributes.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import java.nio.file.attribute.BasicFileAttributes; diff --git a/jimfs/src/test/java/com/google/jimfs/testing/TestUtils.java b/jimfs/src/test/java/com/google/jimfs/TestUtils.java index 73e7b6a..c300e2a 100644 --- a/jimfs/src/test/java/com/google/jimfs/testing/TestUtils.java +++ b/jimfs/src/test/java/com/google/jimfs/TestUtils.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.testing; +package com.google.jimfs; import static java.nio.file.LinkOption.NOFOLLOW_LINKS; import static org.junit.Assert.assertFalse; @@ -136,4 +136,14 @@ public final class TestUtils { assertFalse("Values should be different. Actual: " + actual, Objects.equal(unexpected, actual)); } + + static ByteStore byteStore(int size) { + ByteStore store = new ByteStore(new HeapDisk(8096, 1000, 1000)); + try { + store.write(0, new byte[size], 0, size); + return store; + } catch (IOException e) { + throw new AssertionError(e); + } + } } diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/UnixAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/UnixAttributeProviderTest.java index 5f6806f..c21d4b1 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/UnixAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/UnixAttributeProviderTest.java @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; -import static com.google.jimfs.attribute.UserPrincipals.createGroupPrincipal; -import static com.google.jimfs.attribute.UserPrincipals.createUserPrincipal; +import static com.google.jimfs.UserPrincipals.createGroupPrincipal; +import static com.google.jimfs.UserPrincipals.createUserPrincipal; import static org.truth0.Truth.ASSERT; import com.google.common.collect.ImmutableSet; @@ -56,31 +56,31 @@ public class UnixAttributeProviderTest extends @Test public void testInitialAttributes() { // unix provider relies on other providers to set their initial attributes - inode.setAttribute("owner", "owner", createUserPrincipal("foo")); - inode.setAttribute("posix", "group", createGroupPrincipal("bar")); - inode.setAttribute("posix", "permissions", + file.setAttribute("owner", "owner", createUserPrincipal("foo")); + file.setAttribute("posix", "group", createGroupPrincipal("bar")); + file.setAttribute("posix", "permissions", ImmutableSet.copyOf(PosixFilePermissions.fromString("rw-r--r--"))); // these are pretty much meaningless here since they aren't properties this // file system actually has, so don't really care about the exact value of these - ASSERT.that(provider.get(inode, "uid")).isA(Integer.class); - ASSERT.that(provider.get(inode, "gid")).isA(Integer.class); - ASSERT.that(provider.get(inode, "rdev")).is(0L); - ASSERT.that(provider.get(inode, "dev")).is(1L); - ASSERT.that(provider.get(inode, "ino")).isA(Integer.class); + ASSERT.that(provider.get(file, "uid")).isA(Integer.class); + ASSERT.that(provider.get(file, "gid")).isA(Integer.class); + ASSERT.that(provider.get(file, "rdev")).is(0L); + ASSERT.that(provider.get(file, "dev")).is(1L); + ASSERT.that(provider.get(file, "ino")).isA(Integer.class); // these have logical origins in attributes from other views - ASSERT.that(provider.get(inode, "mode")).is(0644); // rw-r--r-- - ASSERT.that(provider.get(inode, "ctime")) - .isEqualTo(FileTime.fromMillis(inode.getCreationTime())); + ASSERT.that(provider.get(file, "mode")).is(0644); // rw-r--r-- + ASSERT.that(provider.get(file, "ctime")) + .isEqualTo(FileTime.fromMillis(file.getCreationTime())); // this is based on a property this file system does actually have - ASSERT.that(provider.get(inode, "nlink")).is(0); - inode.incrementLinkCount(); - inode.incrementLinkCount(); - ASSERT.that(provider.get(inode, "nlink")).is(2); - inode.decrementLinkCount(); - ASSERT.that(provider.get(inode, "nlink")).is(1); + ASSERT.that(provider.get(file, "nlink")).is(0); + file.incrementLinkCount(); + file.incrementLinkCount(); + ASSERT.that(provider.get(file, "nlink")).is(2); + file.decrementLinkCount(); + ASSERT.that(provider.get(file, "nlink")).is(1); } @Test diff --git a/jimfs/src/test/java/com/google/jimfs/path/UnixPathTypeTest.java b/jimfs/src/test/java/com/google/jimfs/UnixPathTypeTest.java index 722b58c..6c1274f 100644 --- a/jimfs/src/test/java/com/google/jimfs/path/UnixPathTypeTest.java +++ b/jimfs/src/test/java/com/google/jimfs/UnixPathTypeTest.java @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.google.jimfs.path; +package com.google.jimfs; -import static com.google.jimfs.path.PathTypeTest.assertParseResult; -import static com.google.jimfs.path.PathTypeTest.assertUriRoundTripsCorrectly; -import static com.google.jimfs.path.PathTypeTest.fileSystemUri; +import static com.google.jimfs.PathTypeTest.assertParseResult; +import static com.google.jimfs.PathTypeTest.assertUriRoundTripsCorrectly; +import static com.google.jimfs.PathTypeTest.fileSystemUri; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/UserDefinedAttributeProviderTest.java b/jimfs/src/test/java/com/google/jimfs/UserDefinedAttributeProviderTest.java index 4b64e41..d1d2c7d 100644 --- a/jimfs/src/test/java/com/google/jimfs/attribute/UserDefinedAttributeProviderTest.java +++ b/jimfs/src/test/java/com/google/jimfs/UserDefinedAttributeProviderTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.attribute; +package com.google.jimfs; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -55,24 +55,24 @@ public class UserDefinedAttributeProviderTest @Test public void testInitialAttributes() { // no initial attributes - ASSERT.that(ImmutableList.copyOf(inode.getAttributeKeys())).isEmpty(); - ASSERT.that(provider.attributes(inode)).isEmpty(); + ASSERT.that(ImmutableList.copyOf(file.getAttributeKeys())).isEmpty(); + ASSERT.that(provider.attributes(file)).isEmpty(); } @Test public void testGettingAndSetting() { byte[] bytes = {0, 1, 2, 3}; - provider.set(inode, "user", "one", bytes, false); - provider.set(inode, "user", "two", ByteBuffer.wrap(bytes), false); + provider.set(file, "user", "one", bytes, false); + provider.set(file, "user", "two", ByteBuffer.wrap(bytes), false); - byte[] one = (byte[]) provider.get(inode, "one"); - byte[] two = (byte[]) provider.get(inode, "two"); + byte[] one = (byte[]) provider.get(file, "one"); + byte[] two = (byte[]) provider.get(file, "two"); ASSERT.that(Arrays.equals(one, bytes)).isTrue(); ASSERT.that(Arrays.equals(two, bytes)).isTrue(); assertSetFails("foo", "hello"); - ASSERT.that(provider.attributes(inode)).has().exactly("one", "two"); + ASSERT.that(provider.attributes(file)).has().exactly("one", "two"); } @Test @@ -82,7 +82,7 @@ public class UserDefinedAttributeProviderTest @Test public void testView() throws IOException { - UserDefinedFileAttributeView view = provider.view(inodeLookup(), NO_INHERITED_VIEWS); + UserDefinedFileAttributeView view = provider.view(fileLookup(), NO_INHERITED_VIEWS); assertNotNull(view); ASSERT.that(view.name()).is("user"); @@ -95,7 +95,7 @@ public class UserDefinedAttributeProviderTest view.write("b2", ByteBuffer.wrap(b2)); ASSERT.that(view.list()).has().allOf("b1", "b2"); - ASSERT.that(inode.getAttributeKeys()).has().exactly("user:b1", "user:b2"); + ASSERT.that(file.getAttributeKeys()).has().exactly("user:b1", "user:b2"); ASSERT.that(view.size("b1")).is(3); ASSERT.that(view.size("b2")).is(5); @@ -112,7 +112,7 @@ public class UserDefinedAttributeProviderTest view.delete("b2"); ASSERT.that(view.list()).has().exactly("b1"); - ASSERT.that(inode.getAttributeKeys()).has().exactly("user:b1"); + ASSERT.that(file.getAttributeKeys()).has().exactly("user:b1"); try { view.size("b2"); diff --git a/jimfs/src/test/java/com/google/jimfs/internal/UserLookupServiceTest.java b/jimfs/src/test/java/com/google/jimfs/UserLookupServiceTest.java index 9a573e4..73e012f 100644 --- a/jimfs/src/test/java/com/google/jimfs/internal/UserLookupServiceTest.java +++ b/jimfs/src/test/java/com/google/jimfs/UserLookupServiceTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.google.jimfs.internal; +package com.google.jimfs; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/path/WindowsPathTypeTest.java b/jimfs/src/test/java/com/google/jimfs/WindowsPathTypeTest.java index 5dd3244..b9f138f 100644 --- a/jimfs/src/test/java/com/google/jimfs/path/WindowsPathTypeTest.java +++ b/jimfs/src/test/java/com/google/jimfs/WindowsPathTypeTest.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.google.jimfs.path; +package com.google.jimfs; -import static com.google.jimfs.path.PathType.windows; -import static com.google.jimfs.path.PathTypeTest.assertParseResult; -import static com.google.jimfs.path.PathTypeTest.assertUriRoundTripsCorrectly; -import static com.google.jimfs.path.PathTypeTest.fileSystemUri; +import static com.google.jimfs.PathType.windows; +import static com.google.jimfs.PathTypeTest.assertParseResult; +import static com.google.jimfs.PathTypeTest.assertUriRoundTripsCorrectly; +import static com.google.jimfs.PathTypeTest.fileSystemUri; import static org.junit.Assert.fail; import static org.truth0.Truth.ASSERT; diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/FakeInode.java b/jimfs/src/test/java/com/google/jimfs/attribute/FakeInode.java deleted file mode 100644 index 88d974b..0000000 --- a/jimfs/src/test/java/com/google/jimfs/attribute/FakeInode.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2013 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.jimfs.attribute; - -/** - * @author Colin Decker - */ -public class FakeInode extends Inode { - - private final boolean directory; - private final boolean regularFile; - private final boolean symbolicLink; - private final long size; - - public FakeInode(int id) { - this(id, true, false, false, 0); - } - - public FakeInode(int id, - boolean directory, boolean regularFile, boolean symbolicLink, long size) { - super(id); - this.directory = directory; - this.regularFile = regularFile; - this.symbolicLink = symbolicLink; - this.size = size; - } - - @Override - public boolean isDirectory() { - return directory; - } - - @Override - public boolean isRegularFile() { - return regularFile; - } - - @Override - public boolean isSymbolicLink() { - return symbolicLink; - } - - @Override - public long size() { - return size; - } -} diff --git a/jimfs/src/test/java/com/google/jimfs/attribute/InodeTest.java b/jimfs/src/test/java/com/google/jimfs/attribute/InodeTest.java deleted file mode 100644 index 34fee3d..0000000 --- a/jimfs/src/test/java/com/google/jimfs/attribute/InodeTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2013 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.jimfs.attribute; - -import static org.truth0.Truth.ASSERT; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * Tests for {@link Inode}. - * - * @author Colin Decker - */ -@RunWith(JUnit4.class) -public class InodeTest { - - @Test - public void testAttributes() { - // these methods are basically just thin wrappers around a map, so no need to test too - // thoroughly - - Inode inode = new FakeInode(0, false, true, false, 0); - - ASSERT.that(inode.getAttributeKeys()).isEmpty(); - ASSERT.that(inode.getAttribute("foo", "foo")).isNull(); - - inode.deleteAttribute("foo", "foo"); // doesn't throw - - inode.setAttribute("foo", "foo", "foo"); - - ASSERT.that(inode.getAttributeKeys()).iteratesAs("foo:foo"); - ASSERT.that(inode.getAttribute("foo", "foo")).is("foo"); - - inode.deleteAttribute("foo", "foo"); - - ASSERT.that(inode.getAttributeKeys()).isEmpty(); - ASSERT.that(inode.getAttribute("foo", "foo")).isNull(); - } -} diff --git a/jimfs/src/test/java/com/google/jimfs/internal/InternalTestUtils.java b/jimfs/src/test/java/com/google/jimfs/internal/InternalTestUtils.java deleted file mode 100644 index c215894..0000000 --- a/jimfs/src/test/java/com/google/jimfs/internal/InternalTestUtils.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2013 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.jimfs.internal; - -import java.io.IOException; - -/** - * @author Colin Decker - */ -class InternalTestUtils { - - private InternalTestUtils() {} - - - static ByteStore byteStore(int size) { - ByteStore store = new ByteStore(new HeapDisk(8096, 1000, 1000)); - try { - store.write(0, new byte[size], 0, size); - return store; - } catch (IOException e) { - throw new AssertionError(e); - } - } -} |