aboutsummaryrefslogtreecommitdiff
path: root/jimfs/src/test/java
AgeCommit message (Collapse)Author
2019-10-04Mostly migrate off jsr305.cpovirk
- Mostly migrate to Checker Framework declaration annotations. - Migrate @GuardedBy to a custom annotation for now. (We would migrate to Error Prone's, but that's causing me problems as I experiment with JPMS.) Compare to b/69411537 for Guava. I've left @ParametersAreNonnullByDefault in place for now, but we'd need to remove it to fully eliminate the jsr305 dep. RELNOTES=Migrated from jsr305 `@Nullable` to Checker Framework `@NullableDecl`. In addition to the new dependency on the Checker Framework annotations, we keep the dependency on jsr305 for now so that we can keep using `@ParametersAreNonNullByDefault`. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=272713254
2019-06-06Update to Truth 0.45, and address deprecations.cpovirk
Renames may include: - containsAllOf => containsAtLeast - containsAllIn => containsAtLeastElementsIn - isSameAs => isSameInstanceAs - isOrdered => isInOrder - isStrictlyOrdered => isInStrictOrder The other major change is to change custom subjects to extend raw Subject instead of supplying type parameters. The type parameters are being removed from Subject. This CL will temporarily produce rawtypes warnings, which will go away when I remove the type parameters (as soon as this batch of CLs is submitted). Some CLs in this batch also migrate calls away from actualAsString(). Its literal replacement is `"<" + actual + ">"` (unless an object overrides actualCustomStringRepresentation()), but usually I've made a larger change, such as switching from an old-style "Not true that..." failure message to one generated with the Fact API. In that case, the new code usually contains a direct reference to this.actual (a field that I occasionally had to create). Another larger change I sometimes made is to switch from a manual check-and-fail approach to instead use check(...). And sometimes I just remove a withMessage() call that's no longer necessary now that the code uses check(...), or I introduce a check(...) call. (An assertion made with check(...) automatically includes the actual value from the original subject, so there's no need to set it again with withMessage().) Finally, there's one CL in this batch in which I migrate a Correspondence subclass to instead use Correspondence.from. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=251486146
2019-06-06Assert that snapshot elements are ordered, as suggested by the comment.glorioso
RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=250762064
2019-06-06Fix internal build breakage from making assertThat(SortedSet) @GoogleInternal.cpovirk
(https://github.com/google/truth/issues/556) RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=250746093
2019-05-15Migrate users from the old, deprecated Subject.fail* methods to the new ↵cpovirk
Subject.fail* methods or, in some cases, to Subject.check. Most of the changes in this CL were made manually. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=247414164
2019-05-08Instead of calling Subject.actual(), store the actual value in a field, and ↵cpovirk
read that. actual() is being removed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=247003356
2019-05-07Remove PathSubject.andThat().cgdecker
RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=246869377
2019-05-07Migrate Truth Subjects from no-arg check() to the overload that accepts a ↵cpovirk
description. The overload that accepts a description generally produces better failure messages: - The first line of the message it produces is something like: "value of: myProto.getResponse()" (where "getResponse()" is taken from the provided description) - The last line of the message it produces is something like: "myProto was: response: query was throttled" (the full value of myProto) - And the existing text goes in between. Additional motivation: We are deleting the no-arg overload externally (and probably internally thereafter). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=246824728
2019-05-05Migrate Truth subjects from the old fail(String, Object) to the new ↵cpovirk
failWithActual(String, Object), tweaking verbs for the new grammar. Before: fail("has foo", expected); After: failWithActual("expected to have foo", expected); ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=246144541
2019-04-29Migrate from assertThat(foo).named("foo") to assertWithMessage("foo").that(foo).cpovirk
(The exact change is slightly different in some cases, like when using custom subjects or check(), but it's always a migration from named(...) to [assert]WithMessage(...).) named(...) is being removed. This CL may slightly modify the failure messages produced, but all the old information will still be present. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=245027649
2019-04-29Migrate from containsAllOf to containsAtLeast.cpovirk
The two behave identically, and containsAllOf is being removed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244876613
2019-04-29Migrate Truth subjects from a manual "test and fail" approach to one using ↵cpovirk
Subject.check(...). Before: if (actual().foo() != expected) { fail("has foo", expected); } After: check("foo()").that(actual().foo()).isEqualTo(expected); This CL changes the format of the failure message. The new message will typically contain the same information as the old, but if some is missing, let us know, and consider adding a test. The overload of check(...) used by this CL was added in Truth 0.40. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244408001
2019-04-29Run google-java-format over all of JimFS.kak
RELNOTES=Run google-java-format over all of JimFS. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=244231542
2019-03-21Fix an issue with Files.newOutputStream for Jimfs where it wouldn't truncate ↵cgdecker
the file if the TRUNCATE_EXISTING option was explicitly provided and the WRITE option wasn't. The code that handles TRUNCATE_EXISTING requires that WRITE also be present for it to do anything (because it's documented that it's ignored otherwise), but newOutputStream should always add the WRITE option if the user doesn't provide it because an OutputStream is obviously for writing. (This matches the default behavior of FileSystemProvider.newOutputStream as well.) Fixes #77 RELNOTES=Fixed an issue where `Files.newOutputStream` wouldn't truncate the file if the `TRUNCATE_EXISTING` option was explicitly provided and the `WRITE` option wasn't. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=237818016
2018-04-03Change getSubject() to actual() in PathSubject.cgdecker
RELNOTES=n/a ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=191319699
2018-01-16Suppress errors for streams that contain closeable resources (#63)Ron Shapiro
RELNOTES=N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=181787747
2018-01-05Ensure streams that encapsulate a closeable resource are closedcushon
This cleanup is being performed in preparation for enabling a compiler error. From the javadoc for Files.list: The returned stream encapsulates a DirectoryStream. If timely disposal of file system resources is required, the try-with-resources construct should be used to ensure that the stream's close method is invoked after the stream operations are completed. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=180930883
2017-11-20Replace truth.FailureStrategy with truth.FailureMetadata in custom Subjects.jijiang
Also changed truth.SubjectFactory to truth.Subject.Factory (plain renaming) and use method reference instead of anonymous class to create the factory when applicable. FailureMetadata, an opaque object to its users, is introduced to replace FailureStrategy in in custom Subject in order to resolve some existing flaws of FailureStrategy as well as enable new features to be added to Truth. New API is available in Truth-0.36, if there is a build/pom.xml, it's also updated to use this version. More information: See [] & [] Tested: TAP --sample for global presubmit queue [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175818007
2016-03-23A couple attribute-related changes:cgdecker
- Throw UOE instead of IAE when attempting to set an attribute that can't be set at all during file creation. This matches the behavior of the real file system implementations. - Make the owner:owner attribute not settable during file creation, which also matches the actual behavior. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=117965277
2016-03-21Throw UOE when setting unsupported attributesJason Tedor
This commit modifies the behavior when setting unsupported attributes to throw an UnsupportedOperationException instead of an IllegalArgumentException. This is to make JimfsFileSystemProvider#createDirectory and JimfsFileSystemProvider#newByteChannel behave consistently with the Javadocs for FileSystemProvider#createDirectory and FileSystemProvider#newByteChannel which require an UnsupportedOperationException to be thrown when the array of attributes contains attributes which can not be set. In particular, these methods are invoked via Files#createTempDirectory and Files#createFile which have the same requirement regarding throwing an UnsupportedOperationException when the array of attributes contains attributes which can not be set. Most notably, this causes a discrepancy between the handling of Jimfs when configured to act like a Windows filesystem versus the behavior of sun.nio.fs.WindowsFileSystem where the former will throw an IllegalArgumentException if an attempt is made to set a POSIX attribute but the latter will throw an UnsupportedOperationException (consistent with the Javadocs).
2016-01-20Fix flakiness in JimfsAsynchronousFileChannelTest.cgdecker
The tests are racy, and I don't have a good way to fix that. This change just makes the (much) rarer case where the race ends with the channel being closed before the read/write operations get to the point where they check that the channel is open also pass the test. Unfortunately it doesn't differentiate between that case happening once in a thousand times and happening every time (which would be a problem). Also simplify a bunch of stuff using SettableFuture. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=112606151
2016-01-12Partially rollback previous change adding Turkish path normalization.cgdecker
We've determined that NTFS does not do locale-dependent case mapping (and neither do any other file systems we know of), so providing this option is unnecessary and misleading. I'm leaving the removal of a TODO I had to consider allowing Turkish-correct case folding and also adding in some notes about the whole situation for posterity. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111990375
2016-01-12Add long-requested ability to configure the polling rate for the ↵cgdecker
WatchService that Jimfs creates for watching for directory changes. This is done in such a way that it doesn't make it awkward to create a new WatchService implementation in the future. Fixes https://github.com/google/jimfs/issues/14. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111885937
2016-01-07Add Turkish path normalizationBen Hamilton
2015-06-22Fix cases where return value of method in java.nio.file.Path is not used.eaftan
This is in preparation for turning on a static analysis check for this. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=96412671
2015-06-03Format Jimfs with google-java-format.cgdecker
Made a bunch of manual fixes, but mostly pretty good. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=94692335
2015-04-22Couple interruption-related fixes for JimfsFileChannel.cgdecker
- tryLock() shouldn't handle interruption. - lock() should throw FileLockInterruptionException rather than ClosedByInterruptException. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=91829785
2015-04-17Several changes to JimfsFileChannel.cgdecker
- Update it to handle thread interruption for all methods that handle interruption in the default FileChannel implementation (with the exception of map(), for which we always throw UOE). For most methods that weren't already handling interruption, this mostly just means that if they're called on a thread that's already interrupted they'll throw ClosedByInterruptException and close the channel. Requested in GitHub issue #21. Also add tests for this. - Make it possible for FileChannel methods that don't use the channel's position (they have a parameter for a specific file position) to proceed concurrently with other FileChannel methods, which is specified as legal in the FileChannel docs: "Other operations, in particular those that take an explicit position, may proceed concurrently". ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=91435386
2015-02-26Change URIs for Unix- and Windows-like paths to end with a / if the file is ↵cgdecker
a directory. See this issue: https://github.com/google/jimfs/issues/16 I was initially reluctant to do this because it seems strange to actually access the file system to convert a path to a URI, but this does in fact seem to be the behavior for actual Unix paths. Additionally, when looking into creating a ClassLoader that takes Path objects for the classpath, I noticed that URLClassLoader treats URLs that end with / differently (as directories) from those that don't, which indicates that there are real consequences for not doing this. Note: URLClassLoader is tied to the default file system via File/JarFile by default, so it's not like this change actually enables it to just work with Jimfs files (nor do I have any real reason to think you'd even want to do that, I was just curious). This involves changing the PathType API to take a boolean parameter indicating whether or not the file is a directory in its method for getting a URI path, which makes this an incompatible change that would probably require a 2.0 release (not that I expect anyone's actually implementing their own PathType). ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=87278575
2015-02-25Change usages of deprecated Objects methods to MoreObjects.cgdecker
Also change usages of base.Objects methods to java.util.Objects where possible. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=87182713
2015-02-25Rename testMethod to createFileSystem.cgdecker
Maven build errors, suggesting that the method should be annotated with @Test. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=87177747
2015-02-25Split JimfsFileSystemProvider up to work around classloader issues.cgdecker
See https://github.com/google/jimfs/issues/18 for more information. - SystemJimfsFileSystemProvider (which is loaded as a service by the system classloader) only serves as a cache of FileSystem instances as needed to make Paths.get(URI) work. - JimfsFileSystemProvider is the actual provider that is returned by JimfsFileSystem.provider(). It is a singleton and provides the real implementation of most of the FileSystemProvider methods, but does not cache FileSystem instances. We now create the FileSystem instances directly when the user calls Jimfs.newFileSystem rather than passing the Configuration off to FileSystems.newFileSystem. This should ensure no classloader issues when creating the FileSystem. Once created, the FileSystem itself is passed to FileSystems.newFileSystem. There should be no classloader issues here either, since the new SystemJimfsFileSystemProvider implementation does not deal with any other Jimfs-specific classes. Also add a test that fails without this change. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=87170296
2015-02-23Remove unused imports.cgdecker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=86811396
2015-02-18Add support for "jimfs:" protocol URLs.cgdecker
For URLs to work, Java has to be able to find a URLStreamHandler implementation for the URL protocol/scheme. There isn't any really ideal way to do this programatically, but what this CL does is add "com.google.common" to the "java.protocol.handler.pkgs" system property when JimfsFileSystemProvider is initialized. This means that when Java tries to create a URL with the "jimfs" protocol, it'll look for "jimfs.Handler" under "com.google.common", find it and use it. (Documentation of that behavior found here: http://docs.oracle.com/javase/8/docs/api/java/net/URL.html#URL-java.lang.String-java.lang.String-int-java.lang.String-) Fixes Github issue #13. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=86627713
2015-02-18Migrate from Truth's deprecated .is(expected) to .isEqualTo(expected).kak
Tested: TAP --sample for global presubmit queue [] ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=86014119
2015-02-18Cleanup usages of deprecated Truth APIs.kak
Tested: TAP --sample for global presubmit queue [] ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=85451232
2015-01-21Change JimfsOutputStream.flush() to do nothing rather than throw an ↵cgdecker
exception when the stream is already already closed. This matches the behavior of other core OutputStream implementations such as that returned by Files.newOutputStream(Path) for the default FileSystem and prevents an exception when nesting an OutputStream inside a BufferedOutputStream inside an OutputStreamWriter using try-with-resources under JDK8 (among any number of other situations that could cause the same problem). (Details: try-with-resources closes each declared resource in reverse order. Closing the OutputStreamWriter causes the BufferedOutputStream to be closed which causes the unbuffered OutputStream to be flushed and then closed. Closing the BufferedOutputStream then tries to flush the unbuffered OutputStream again. Prior to JDK8, any exception thrown by this flush() was swallowed and completely ignored; in JDK8, the behavior changed to (correctly) throw that exception.) ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=84439059
2014-11-05Migrate from Truth's deprecated iteratesAs(...) to ↵kak
containsExactly(...).inOrder(). ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=78848947
2014-11-05Clean up usages of deprecated Truth has() Collection methods:kak
-has().item(...) -> contains(...) -has().allOf(...) -> containsAllOf(...) -has().exactly(...) -> containsExactly(...) -has().exactlyAs(...) -> containsExactlyElementsIn(...) ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=78681455
2014-11-05Migrate off of deprecated Truth methodskak
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=78584467
2014-11-05Migrate users off of deprecated (or soon to be deprecated) Truth APIs.kak
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=74628842
2014-11-05Reduce visibility of Subject.isNotA()kak
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=74309082
2014-11-05Fix another case in PollingWatchServiceTest where it's possible to see ↵cgdecker
either one or two events depending on when exactly a poll occurs. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=73325083
2014-11-05Misc changes to FileTree.cgdecker
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=73318805
2014-11-05Migrate usages of:kak
-MapSubject.hasKey(key).withValue(value) to MapSubject.containsEntry(key, value) -MapSubject.hasKey(key) to MapSubject.containsKey(key) -MapSubject.lacksKey(key) to MapSubject.doesNotContainKey(key) ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=73223123
2014-11-05Add assertThat(Comparable) overload for custom comparable types.kak
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=73145243
2014-11-05Rename helper methods named "assertThat" in AbstractJimfsIntegrationTest to ↵cgdecker
"assertThatPath" so that we can static import Truth.assertThat for normal Truth assertions instead of using assert_().that. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72751369
2014-11-05Attempt to fix up some test flakiness.cgdecker
- Greatly increase timeout on PollingWatchService tests. The timeout shouldn't matter unless something's terribly wrong, so it should be ok to make it long. - Try to ensure that asynchronous close tests for JimfsFileChannel are working as expected by being more careful in ensuring that all threads start blocking properly. Also switch to using Truth instead of assertTrue so that we'll get error messages that are actually helpful if the tests still fail. ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72748113
2014-11-05Migrate from Truth.ASSERT to Truth.assert_ or Truth.assertThat.kak
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72563991
2014-11-05Update Truth package name to the new location.kak
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=72403557