This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push: new 5b1f21b [VFS-497] Ported filters from Commons IO #9. 5b1f21b is described below commit 5b1f21b8c8c61dbd764f39635c6b2e1ec7ea909b Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Sun Mar 31 22:43:48 2019 -0400 [VFS-497] Ported filters from Commons IO #9. Add CanExecuteFileFilter. Better test method name. Use try-with-resources. Longer formatted lines. --- .../apache/commons/vfs2/filter/AgeFileFilter.java | 87 ++++------ .../apache/commons/vfs2/filter/AndFileFilter.java | 10 +- ...enFileFilter.java => CanExecuteFileFilter.java} | 38 ++--- .../commons/vfs2/filter/CanReadFileFilter.java | 6 +- .../commons/vfs2/filter/CanWriteFileFilter.java | 9 +- .../commons/vfs2/filter/ConditionalFileFilter.java | 13 +- .../commons/vfs2/filter/DirectoryFileFilter.java | 3 +- .../commons/vfs2/filter/EmptyFileFilter.java | 7 +- .../commons/vfs2/filter/FalseFileFilter.java | 3 +- .../apache/commons/vfs2/filter/FileFileFilter.java | 3 +- .../commons/vfs2/filter/HiddenFileFilter.java | 9 +- .../org/apache/commons/vfs2/filter/IOCase.java | 106 ++++++------ .../apache/commons/vfs2/filter/NameFileFilter.java | 27 ++- .../apache/commons/vfs2/filter/NotFileFilter.java | 10 +- .../apache/commons/vfs2/filter/OrFileFilter.java | 6 +- .../commons/vfs2/filter/PrefixFileFilter.java | 27 ++- .../commons/vfs2/filter/RegexFileFilter.java | 28 ++-- .../apache/commons/vfs2/filter/SizeFileFilter.java | 24 ++- .../commons/vfs2/filter/SizeRangeFileFilter.java | 7 +- .../commons/vfs2/filter/SuffixFileFilter.java | 23 +-- .../apache/commons/vfs2/filter/TrueFileFilter.java | 3 +- .../commons/vfs2/filter/WildcardFileFilter.java | 57 +++---- .../commons/vfs2/filter/AgeFileFilterTest.java | 15 +- .../commons/vfs2/filter/AndFileFilterTest.java | 11 +- .../apache/commons/vfs2/filter/BaseFilterTest.java | 181 +++++++-------------- .../vfs2/filter/CanExecuteFileFilterTest.java | 122 ++++++++++++++ .../commons/vfs2/filter/CanReadFileFilterTest.java | 36 ++-- .../vfs2/filter/CanWriteFileFilterTest.java | 33 ++-- .../vfs2/filter/DirectoryAndFileFilterTest.java | 18 +- .../commons/vfs2/filter/EmptyFileFilterTest.java | 19 +-- .../commons/vfs2/filter/HiddenFileFilterTest.java | 12 +- .../commons/vfs2/filter/NameFileFilterTest.java | 54 +++--- .../commons/vfs2/filter/NotFileFilterTest.java | 2 +- .../commons/vfs2/filter/OrFileFilterTest.java | 5 +- .../commons/vfs2/filter/PrefixFileFilterTest.java | 51 +++--- .../vfs2/filter/RegexFileFilterTestCase.java | 45 +++-- .../commons/vfs2/filter/SizeFileFilterTest.java | 33 ++-- .../commons/vfs2/filter/SuffixFileFilterTest.java | 54 +++--- .../vfs2/filter/WildcardFileFilterTest.java | 144 ++++++++-------- 39 files changed, 634 insertions(+), 707 deletions(-) diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java index 8bdce0a..275c1a6 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AgeFileFilter.java @@ -62,16 +62,13 @@ public class AgeFileFilter implements FileFilter, Serializable { * Tests if the specified <code>File</code> is newer than the specified time * reference. * - * @param fileObject - * the <code>File</code> of which the modification date must be - * compared, must not be {@code null} - * @param timeMillis - * the time reference measured in milliseconds since the epoch - * (00:00:00 GMT, January 1, 1970) - * @return true if the <code>File</code> exists and has been modified after - * the given time reference. - * @throws IllegalArgumentException - * if the file is {@code null} + * @param fileObject the <code>File</code> of which the modification date must + * be compared, must not be {@code null} + * @param timeMillis the time reference measured in milliseconds since the epoch + * (00:00:00 GMT, January 1, 1970) + * @return true if the <code>File</code> exists and has been modified after the + * given time reference. + * @throws IllegalArgumentException if the file is {@code null} */ private static boolean isFileNewer(final FileObject fileObject, final long timeMillis) { if (fileObject == null) { @@ -94,8 +91,7 @@ public class AgeFileFilter implements FileFilter, Serializable { * Constructs a new age file filter for files older than (at or before) a * certain cutoff date. * - * @param cutoffDate - * the threshold age of the files + * @param cutoffDate the threshold age of the files */ public AgeFileFilter(final Date cutoffDate) { this(cutoffDate, true); @@ -105,11 +101,9 @@ public class AgeFileFilter implements FileFilter, Serializable { * Constructs a new age file filter for files on any one side of a certain * cutoff date. * - * @param cutoffDate - * the threshold age of the files - * @param acceptOlder - * if true, older files (at or before the cutoff) are accepted, - * else newer ones (after the cutoff). + * @param cutoffDate the threshold age of the files + * @param acceptOlder if true, older files (at or before the cutoff) are + * accepted, else newer ones (after the cutoff). */ public AgeFileFilter(final Date cutoffDate, final boolean acceptOlder) { this(cutoffDate.getTime(), acceptOlder); @@ -119,44 +113,37 @@ public class AgeFileFilter implements FileFilter, Serializable { * Constructs a new age file filter for files older than (at or before) a * certain File (whose last modification time will be used as reference). * - * @param cutoffReference - * the file whose last modification time is usesd as the - * threshold age of the files + * @param cutoffReference the file whose last modification time is usesd as the + * threshold age of the files * - * @throws FileSystemException - * Error reading the last modification time from the reference - * file object. + * @throws FileSystemException Error reading the last modification time from the + * reference file object. */ public AgeFileFilter(final FileObject cutoffReference) throws FileSystemException { this(cutoffReference, true); } /** - * Constructs a new age file filter for files on any one side of a certain - * File (whose last modification time will be used as reference). + * Constructs a new age file filter for files on any one side of a certain File + * (whose last modification time will be used as reference). * - * @param cutoffReference - * the file whose last modification time is usesd as the - * threshold age of the files - * @param acceptOlder - * if true, older files (at or before the cutoff) are accepted, - * else newer ones (after the cutoff). + * @param cutoffReference the file whose last modification time is usesd as the + * threshold age of the files + * @param acceptOlder if true, older files (at or before the cutoff) are + * accepted, else newer ones (after the cutoff). * - * @throws FileSystemException - * Error reading the last modification time from the reference - * file object. + * @throws FileSystemException Error reading the last modification time from the + * reference file object. */ - public AgeFileFilter(final FileObject cutoffReference, final boolean acceptOlder) - throws FileSystemException { + public AgeFileFilter(final FileObject cutoffReference, final boolean acceptOlder) throws FileSystemException { this(cutoffReference.getContent().getLastModifiedTime(), acceptOlder); } /** - * Constructs a new age file filter for files equal to or older than a - * certain cutoff. + * Constructs a new age file filter for files equal to or older than a certain + * cutoff. * - * @param cutoff - * the threshold age of the files + * @param cutoff the threshold age of the files */ public AgeFileFilter(final long cutoff) { this(cutoff, true); @@ -166,11 +153,9 @@ public class AgeFileFilter implements FileFilter, Serializable { * Constructs a new age file filter for files on any one side of a certain * cutoff. * - * @param cutoff - * the threshold age of the files - * @param acceptOlder - * if true, older files (at or before the cutoff) are accepted, - * else newer ones (after the cutoff). + * @param cutoff the threshold age of the files + * @param acceptOlder if true, older files (at or before the cutoff) are + * accepted, else newer ones (after the cutoff). */ public AgeFileFilter(final long cutoff, final boolean acceptOlder) { this.acceptOlder = acceptOlder; @@ -178,15 +163,13 @@ public class AgeFileFilter implements FileFilter, Serializable { } /** - * Checks to see if the last modification of the file matches cutoff - * favorably. + * Checks to see if the last modification of the file matches cutoff favorably. * <p> - * If last modification time equals cutoff and newer files are required, - * file <b>IS NOT</b> selected. If last modification time equals cutoff and - * older files are required, file <b>IS</b> selected. + * If last modification time equals cutoff and newer files are required, file + * <b>IS NOT</b> selected. If last modification time equals cutoff and older + * files are required, file <b>IS</b> selected. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return true if the filename matches */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AndFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AndFileFilter.java index 19ec1e6..f90a882 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AndFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/AndFileFilter.java @@ -52,8 +52,7 @@ public class AndFileFilter implements FileFilter, ConditionalFileFilter, Seriali /** * Constructs a new file filter that ANDs the result of other filters. * - * @param filters - * array of filters, must not be null or empty + * @param filters array of filters, must not be null or empty */ public AndFileFilter(final FileFilter... filters) { if (filters == null || filters.length == 0) { @@ -68,11 +67,10 @@ public class AndFileFilter implements FileFilter, ConditionalFileFilter, Seriali } /** - * Constructs a new instance of <code>AndFileFilter</code> with the - * specified list of filters. + * Constructs a new instance of <code>AndFileFilter</code> with the specified + * list of filters. * - * @param fileFilters - * a List of FileFilter instances, copied, null ignored + * @param fileFilters a List of FileFilter instances, copied, null ignored */ public AndFileFilter(final List<FileFilter> fileFilters) { if (fileFilters == null) { diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/HiddenFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanExecuteFileFilter.java similarity index 67% copy from commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/HiddenFileFilter.java copy to commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanExecuteFileFilter.java index 792d4aa..71fd2bc 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/HiddenFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanExecuteFileFilter.java @@ -23,15 +23,15 @@ import org.apache.commons.vfs2.FileSelectInfo; import org.apache.commons.vfs2.FileSystemException; /** - * This filter accepts <code>File</code>s that are hidden. + * This filter accepts <code>File</code>s that can be executed. * <p> * Example, showing how to print out a list of the current directory's - * <i>hidden</i> files: + * <i>executable</i> files: * * <pre> * FileSystemManager fsManager = VFS.getManager(); * FileObject dir = fsManager.toFileObject(new File(".")); - * FileObject[] files = dir.findFiles(new FileFilterSelector(HiddenFileFilter.HIDDEN)); + * FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.CAN_EXECUTE)); * for (int i = 0; i < files.length; i++) { * System.out.println(files[i]); * } @@ -39,12 +39,12 @@ import org.apache.commons.vfs2.FileSystemException; * * <p> * Example, showing how to print out a list of the current directory's - * <i>visible</i> (i.e. not hidden) files: + * <i>un-executable</i> files: * * <pre> * FileSystemManager fsManager = VFS.getManager(); * FileObject dir = fsManager.toFileObject(new File(".")); - * FileObject[] files = dir.findFiles(new FileFilterSelector(HiddenFileFilter.VISIBLE)); + * FileObject[] files = dir.findFiles(new FileFilterSelector(CanReadFileFilter.CANNOT_EXECUTE)); * for (int i = 0; i < files.length; i++) { * System.out.println(files[i]); * } @@ -54,39 +54,33 @@ import org.apache.commons.vfs2.FileSystemException; * @see "http://commons.apache.org/proper/commons-io/" * @since 2.4 */ -public class HiddenFileFilter implements FileFilter, Serializable { +public class CanExecuteFileFilter implements FileFilter, Serializable { - private static final long serialVersionUID = 1L; + /** Singleton instance of <i>executed</i> filter. */ + public static final FileFilter CAN_EXECUTE = new CanExecuteFileFilter(); - /** Singleton instance of <i>hidden</i> filter. */ - public static final FileFilter HIDDEN = new HiddenFileFilter(); + /** Singleton instance of not <i>executed</i> filter. */ + public static final FileFilter CANNOT_EXECUTE = new NotFileFilter(CAN_EXECUTE); - /** Singleton instance of <i>visible</i> filter. */ - public static final FileFilter VISIBLE = new NotFileFilter(HIDDEN); + private static final long serialVersionUID = 1L; /** * Restrictive constructor. */ - protected HiddenFileFilter() { + protected CanExecuteFileFilter() { } /** - * Checks to see if the file is hidden. Non existing files won't be - * accepted. + * Checks to see if the file can be executed. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check. * - * @return {@code true} if the file is <i>hidden</i>, otherwise - * {@code false}. + * @return {@code true} if the file can be executed, otherwise {@code false}. */ @Override public boolean accept(final FileSelectInfo fileInfo) { try { - if (!fileInfo.getFile().exists()) { - return false; - } - return fileInfo.getFile().isHidden(); + return fileInfo.getFile().isExecutable(); } catch (final FileSystemException ex) { throw new RuntimeException(ex); } diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanReadFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanReadFileFilter.java index 7dfa12d..deb04e6 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanReadFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanReadFileFilter.java @@ -76,8 +76,7 @@ public class CanReadFileFilter implements FileFilter, Serializable { public static final FileFilter CANNOT_READ = new NotFileFilter(CAN_READ); /** Singleton instance of <i>read-only</i> filter. */ - public static final FileFilter READ_ONLY = new AndFileFilter(CAN_READ, - CanWriteFileFilter.CANNOT_WRITE); + public static final FileFilter READ_ONLY = new AndFileFilter(CAN_READ, CanWriteFileFilter.CANNOT_WRITE); private static final long serialVersionUID = 1L; @@ -90,8 +89,7 @@ public class CanReadFileFilter implements FileFilter, Serializable { /** * Checks to see if the file can be read. * - * @param fileInfo - * the File to check. + * @param fileInfo the File to check. * * @return {@code true} if the file can be read, otherwise {@code false}. */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanWriteFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanWriteFileFilter.java index 0a448f0..536d7df 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanWriteFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/CanWriteFileFilter.java @@ -53,7 +53,8 @@ import org.apache.commons.vfs2.FileSystemException; * </pre> * * <p> - * <b>N.B.</b> For read-only files, use <code>CanReadFileFilter.READ_ONLY</code>. + * <b>N.B.</b> For read-only files, use + * <code>CanReadFileFilter.READ_ONLY</code>. * * @author This code was originally ported from Apache Commons IO File Filter * @see "http://commons.apache.org/proper/commons-io/" @@ -78,11 +79,9 @@ public class CanWriteFileFilter implements FileFilter, Serializable { /** * Checks to see if the file can be written to. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * - * @return {@code true} if the file can be written to, otherwise - * {@code false}. + * @return {@code true} if the file can be written to, otherwise {@code false}. */ @Override public boolean accept(final FileSelectInfo fileInfo) { diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/ConditionalFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/ConditionalFileFilter.java index 82e7d16..90fb919 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/ConditionalFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/ConditionalFileFilter.java @@ -30,11 +30,10 @@ import org.apache.commons.vfs2.FileFilter; public interface ConditionalFileFilter { /** - * Adds the specified file filter to the list of file filters at the end of - * the list. + * Adds the specified file filter to the list of file filters at the end of the + * list. * - * @param fileFilter - * the filter to be added + * @param fileFilter the filter to be added */ void addFileFilter(FileFilter fileFilter); @@ -48,8 +47,7 @@ public interface ConditionalFileFilter { /** * Removes the specified file filter. * - * @param fileFilter - * filter to be removed + * @param fileFilter filter to be removed * * @return {@code true} if the filter was found in the list, {@code false} * otherwise @@ -60,8 +58,7 @@ public interface ConditionalFileFilter { * Sets the list of file filters, replacing any previously configured file * filters on this filter. * - * @param fileFilters - * the list of filters + * @param fileFilters the list of filters */ void setFileFilters(List<FileFilter> fileFilters); diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/DirectoryFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/DirectoryFileFilter.java index 5aeb8c9..b7a9b91 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/DirectoryFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/DirectoryFileFilter.java @@ -60,8 +60,7 @@ public class DirectoryFileFilter implements FileFilter, Serializable { /** * Checks to see if the file is a directory. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return {@code true} if the file is a directory */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java index 87578ec..24dc6dc 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/EmptyFileFilter.java @@ -76,11 +76,10 @@ public class EmptyFileFilter implements FileFilter, Serializable { } /** - * Checks to see if the file is empty. A non-existing file is also - * considered empty. + * Checks to see if the file is empty. A non-existing file is also considered + * empty. * - * @param fileInfo - * the file or directory to check + * @param fileInfo the file or directory to check * * @return {@code true} if the file or directory is <i>empty</i>, otherwise * {@code false}. diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FalseFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FalseFileFilter.java index f2eed55..c00f5ef 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FalseFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FalseFileFilter.java @@ -46,8 +46,7 @@ public class FalseFileFilter implements FileFilter, Serializable { /** * Returns false. * - * @param fileInfo - * the file to check (ignored) + * @param fileInfo the file to check (ignored) * * @return Always {@code false} */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FileFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FileFileFilter.java index 73098e6..5d52e0e 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FileFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/FileFileFilter.java @@ -58,8 +58,7 @@ public class FileFileFilter implements FileFilter, Serializable { /** * Checks to see if the file is a file. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return true if the file is a file */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/HiddenFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/HiddenFileFilter.java index 792d4aa..d2b58fc 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/HiddenFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/HiddenFileFilter.java @@ -71,14 +71,11 @@ public class HiddenFileFilter implements FileFilter, Serializable { } /** - * Checks to see if the file is hidden. Non existing files won't be - * accepted. + * Checks to see if the file is hidden. Non existing files won't be accepted. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * - * @return {@code true} if the file is <i>hidden</i>, otherwise - * {@code false}. + * @return {@code true} if the file is <i>hidden</i>, otherwise {@code false}. */ @Override public boolean accept(final FileSelectInfo fileInfo) { diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java index 4a2ff39..72fe846 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/IOCase.java @@ -21,13 +21,13 @@ import java.io.File; /** * Enumeration of IO case sensitivity. * <p> - * Different filing systems have different rules for case-sensitivity. - * Windows is case-insensitive, Unix is case-sensitive. + * Different filing systems have different rules for case-sensitivity. Windows + * is case-insensitive, Unix is case-sensitive. * </p> * <p> - * This class captures that difference, providing an enumeration to - * control how filename comparisons should be performed. It also provides - * methods that use the enumeration to perform comparisons. + * This class captures that difference, providing an enumeration to control how + * filename comparisons should be performed. It also provides methods that use + * the enumeration to perform comparisons. * </p> * <p> * Wherever possible, you should use the <code>check</code> methods in this @@ -43,12 +43,12 @@ public enum IOCase { /** * The constant for case sensitive regardless of operating system. */ - SENSITIVE ("Sensitive", true), + SENSITIVE("Sensitive", true), /** * The constant for case insensitive regardless of operating system. */ - INSENSITIVE ("Insensitive", false), + INSENSITIVE("Insensitive", false), /** * The constant for case sensitivity determined by the current operating system. @@ -56,13 +56,13 @@ public enum IOCase { * <p> * <strong>Note:</strong> This only caters for Windows and Unix. Other operating * systems (e.g. OSX and OpenVMS) are treated as case sensitive if they use the - * Unix file separator and case-insensitive if they use the Windows file separator - * (see {@link java.io.File#separatorChar}). + * Unix file separator and case-insensitive if they use the Windows file + * separator (see {@link java.io.File#separatorChar}). * <p> * If you serialize this constant on Windows, and deserialize on Unix, or vice * versa, then the value of the case-sensitivity flag will change. */ - SYSTEM ("System", !(File.separatorChar == '\\')); + SYSTEM("System", !(File.separatorChar == '\\')); /** Serialization version. */ private static final long serialVersionUID = -6343169151696340687L; @@ -73,31 +73,29 @@ public enum IOCase { /** The sensitivity flag. */ private final transient boolean sensitive; - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** * Factory method to create an IOCase from a name. * - * @param name the name to find + * @param name the name to find * @return the IOCase object * @throws IllegalArgumentException if the name is invalid */ public static IOCase forName(final String name) { - for (final IOCase ioCase : IOCase.values()) - { - if (ioCase.getName().equals(name)) - { + for (final IOCase ioCase : IOCase.values()) { + if (ioCase.getName().equals(name)) { return ioCase; } } throw new IllegalArgumentException("Invalid IOCase name: " + name); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** * Constructs a new instance. * - * @param name the name - * @param sensitive the sensitivity + * @param name the name + * @param sensitive the sensitivity */ IOCase(final String name, final boolean sensitive) { this.name = name; @@ -105,8 +103,8 @@ public enum IOCase { } /** - * Replaces the enumeration from the stream with a real one. - * This ensures that the correct flag is set for SYSTEM. + * Replaces the enumeration from the stream with a real one. This ensures that + * the correct flag is set for SYSTEM. * * @return the resolved object */ @@ -114,7 +112,7 @@ public enum IOCase { return forName(name); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** * Gets the name of the constant. * @@ -133,15 +131,15 @@ public enum IOCase { return sensitive; } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** * Compares two strings using the case-sensitivity rule. * <p> - * This method mimics {@link String#compareTo} but takes case-sensitivity - * into account. + * This method mimics {@link String#compareTo} but takes case-sensitivity into + * account. * - * @param str1 the first string to compare, not null - * @param str2 the second string to compare, not null + * @param str1 the first string to compare, not null + * @param str2 the second string to compare, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ @@ -155,11 +153,11 @@ public enum IOCase { /** * Compares two strings using the case-sensitivity rule. * <p> - * This method mimics {@link String#equals} but takes case-sensitivity - * into account. + * This method mimics {@link String#equals} but takes case-sensitivity into + * account. * - * @param str1 the first string to compare, not null - * @param str2 the second string to compare, not null + * @param str1 the first string to compare, not null + * @param str2 the second string to compare, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ @@ -173,11 +171,11 @@ public enum IOCase { /** * Checks if one string starts with another using the case-sensitivity rule. * <p> - * This method mimics {@link String#startsWith(String)} but takes case-sensitivity - * into account. + * This method mimics {@link String#startsWith(String)} but takes + * case-sensitivity into account. * - * @param str the string to check, not null - * @param start the start to compare against, not null + * @param str the string to check, not null + * @param start the start to compare against, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ @@ -188,11 +186,11 @@ public enum IOCase { /** * Checks if one string ends with another using the case-sensitivity rule. * <p> - * This method mimics {@link String#endsWith} but takes case-sensitivity - * into account. + * This method mimics {@link String#endsWith} but takes case-sensitivity into + * account. * - * @param str the string to check, not null - * @param end the end to compare against, not null + * @param str the string to check, not null + * @param end the end to compare against, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ @@ -205,14 +203,14 @@ public enum IOCase { * Checks if one string contains another starting at a specific index using the * case-sensitivity rule. * <p> - * This method mimics parts of {@link String#indexOf(String, int)} - * but takes case-sensitivity into account. + * This method mimics parts of {@link String#indexOf(String, int)} but takes + * case-sensitivity into account. * - * @param str the string to check, not null - * @param strStartIndex the index to start at in str - * @param search the start to search for, not null - * @return the first index of the search String, - * -1 if no match or {@code null} string input + * @param str the string to check, not null + * @param strStartIndex the index to start at in str + * @param search the start to search for, not null + * @return the first index of the search String, -1 if no match or {@code null} + * string input * @throws NullPointerException if either string is null * @since 2.0 */ @@ -229,14 +227,16 @@ public enum IOCase { } /** - * Checks if one string contains another at a specific index using the case-sensitivity rule. + * Checks if one string contains another at a specific index using the + * case-sensitivity rule. * <p> - * This method mimics parts of {@link String#regionMatches(boolean, int, String, int, int)} - * but takes case-sensitivity into account. + * This method mimics parts of + * {@link String#regionMatches(boolean, int, String, int, int)} but takes + * case-sensitivity into account. * - * @param str the string to check, not null - * @param strStartIndex the index to start at in str - * @param search the start to search for, not null + * @param str the string to check, not null + * @param strStartIndex the index to start at in str + * @param search the start to search for, not null * @return true if equal using the case rules * @throws NullPointerException if either string is null */ @@ -244,7 +244,7 @@ public enum IOCase { return str.regionMatches(!sensitive, strStartIndex, search, 0, search.length()); } - //----------------------------------------------------------------------- + // ----------------------------------------------------------------------- /** * Gets a string describing the sensitivity. * diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NameFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NameFileFilter.java index 2e14265..599d434 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NameFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NameFileFilter.java @@ -56,8 +56,7 @@ public class NameFileFilter implements FileFilter, Serializable { /** * Constructs a new case-sensitive name file filter for a list of names. * - * @param names - * the names to allow, must not be null + * @param names the names to allow, must not be null */ public NameFileFilter(final List<String> names) { this((IOCase) null, names); @@ -67,10 +66,9 @@ public class NameFileFilter implements FileFilter, Serializable { * Constructs a new name file filter for a list of names specifying * case-sensitivity. * - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive - * @param names - * the names to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive + * @param names the names to allow, must not be null */ public NameFileFilter(final IOCase caseSensitivity, final List<String> names) { if (names == null) { @@ -83,11 +81,10 @@ public class NameFileFilter implements FileFilter, Serializable { /** * Constructs a new case-sensitive name file filter for an array of names. * <p> - * The array is not cloned, so could be changed after constructing the - * instance. This would be inadvisable however. + * The array is not cloned, so could be changed after constructing the instance. + * This would be inadvisable however. * - * @param names - * the names to allow, must not be null + * @param names the names to allow, must not be null */ public NameFileFilter(final String... names) { this((IOCase) null, names); @@ -97,10 +94,9 @@ public class NameFileFilter implements FileFilter, Serializable { * Constructs a new name file filter for an array of names specifying * case-sensitivity. * - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive - * @param names - * the names to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive + * @param names the names to allow, must not be null */ public NameFileFilter(final IOCase caseSensitivity, final String... names) { if (names == null) { @@ -113,8 +109,7 @@ public class NameFileFilter implements FileFilter, Serializable { /** * Checks to see if the filename matches. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return true if the filename matches */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NotFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NotFileFilter.java index ca07c34..748df41 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NotFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/NotFileFilter.java @@ -38,8 +38,7 @@ public class NotFileFilter implements FileFilter, Serializable { /** * Constructs a new file filter that NOTs the result of another filter. * - * @param filter - * the filter, must not be null + * @param filter the filter, must not be null */ public NotFileFilter(final FileFilter filter) { if (filter == null) { @@ -49,11 +48,10 @@ public class NotFileFilter implements FileFilter, Serializable { } /** - * Returns the logical NOT of the underlying filter's return value for the - * same File. + * Returns the logical NOT of the underlying filter's return value for the same + * File. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return {@code true} if the filter returns {@code false} */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/OrFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/OrFileFilter.java index 77e0c20..2a4f3eb 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/OrFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/OrFileFilter.java @@ -52,8 +52,7 @@ public class OrFileFilter implements FileFilter, ConditionalFileFilter, Serializ /** * Constructs a new file filter that ORs the result of other filters. * - * @param filters - * array of filters, must not be null or empty + * @param filters array of filters, must not be null or empty */ public OrFileFilter(final FileFilter... filters) { if (filters == null || filters.length == 0) { @@ -71,8 +70,7 @@ public class OrFileFilter implements FileFilter, ConditionalFileFilter, Serializ * Constructs a new instance of <code>OrFileFilter</code> with the specified * filters. * - * @param fileFilters - * the file filters for this filter, copied, null ignored + * @param fileFilters the file filters for this filter, copied, null ignored */ public OrFileFilter(final List<FileFilter> fileFilters) { if (fileFilters == null) { diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/PrefixFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/PrefixFileFilter.java index 00f0292..130af3b 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/PrefixFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/PrefixFileFilter.java @@ -56,8 +56,7 @@ public class PrefixFileFilter implements FileFilter, Serializable { /** * Constructs a new Prefix file filter for a list of prefixes. * - * @param prefixes - * the prefixes to allow, must not be null + * @param prefixes the prefixes to allow, must not be null */ public PrefixFileFilter(final List<String> prefixes) { this(IOCase.SENSITIVE, prefixes); @@ -67,10 +66,9 @@ public class PrefixFileFilter implements FileFilter, Serializable { * Constructs a new Prefix file filter for a list of prefixes specifying * case-sensitivity. * - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive - * @param prefixes - * the prefixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive + * @param prefixes the prefixes to allow, must not be null */ public PrefixFileFilter(final IOCase caseSensitivity, final List<String> prefixes) { if (prefixes == null) { @@ -83,11 +81,10 @@ public class PrefixFileFilter implements FileFilter, Serializable { /** * Constructs a new Prefix file filter for any of an array of prefixes. * <p> - * The array is not cloned, so could be changed after constructing the - * instance. This would be inadvisable however. + * The array is not cloned, so could be changed after constructing the instance. + * This would be inadvisable however. * - * @param prefixes - * the prefixes to allow, must not be null + * @param prefixes the prefixes to allow, must not be null */ public PrefixFileFilter(final String... prefixes) { this(IOCase.SENSITIVE, prefixes); @@ -97,10 +94,9 @@ public class PrefixFileFilter implements FileFilter, Serializable { * Constructs a new Prefix file filter for any of an array of prefixes * specifying case-sensitivity. * - * @param prefixes - * the prefixes to allow, must not be null - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive + * @param prefixes the prefixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive */ public PrefixFileFilter(final IOCase caseSensitivity, final String... prefixes) { if (prefixes == null) { @@ -113,8 +109,7 @@ public class PrefixFileFilter implements FileFilter, Serializable { /** * Checks to see if the filename starts with the prefix. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return true if the filename starts with one of our prefixes */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/RegexFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/RegexFileFilter.java index e31816b..8c39608 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/RegexFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/RegexFileFilter.java @@ -35,8 +35,7 @@ import org.apache.commons.vfs2.FileSelectInfo; * <pre> * FileSystemManager fsManager = VFS.getManager(); * FileObject dir = fsManager.toFileObject(new File(".")); - * FileObject[] files = dir.findFiles(new FileFilterSelector(new RegexFileFilter( - * "ˆ.*[tT]est(-\\d+)?\\.java$"))); + * FileObject[] files = dir.findFiles(new FileFilterSelector(new RegexFileFilter("ˆ.*[tT]est(-\\d+)?\\.java$"))); * for (int i = 0; i < files.length; i++) { * System.out.println(files[i]); * } @@ -57,11 +56,9 @@ public class RegexFileFilter implements FileFilter, Serializable { private final Pattern pattern; /** - * Construct a new regular expression filter for a compiled regular - * expression. + * Construct a new regular expression filter for a compiled regular expression. * - * @param pattern - * regular expression to match - Cannot be null + * @param pattern regular expression to match - Cannot be null */ public RegexFileFilter(final Pattern pattern) { if (pattern == null) { @@ -74,8 +71,7 @@ public class RegexFileFilter implements FileFilter, Serializable { /** * Construct a new regular expression filter. * - * @param pattern - * regular string expression to match - Cannot be null + * @param pattern regular string expression to match - Cannot be null */ public RegexFileFilter(final String pattern) { if (pattern == null) { @@ -88,10 +84,8 @@ public class RegexFileFilter implements FileFilter, Serializable { /** * Construct a new regular expression filter with the specified flags. * - * @param pattern - * regular string expression to match - * @param flags - * pattern flags - e.g. {@link Pattern#CASE_INSENSITIVE} + * @param pattern regular string expression to match + * @param flags pattern flags - e.g. {@link Pattern#CASE_INSENSITIVE} */ public RegexFileFilter(final String pattern, final int flags) { if (pattern == null) { @@ -104,10 +98,9 @@ public class RegexFileFilter implements FileFilter, Serializable { * Construct a new regular expression filter with the specified flags case * sensitivity. * - * @param pattern - * regular string expression to match - Cannot be null - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive + * @param pattern regular string expression to match - Cannot be null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive */ public RegexFileFilter(final String pattern, final IOCase caseSensitivity) { if (pattern == null) { @@ -123,8 +116,7 @@ public class RegexFileFilter implements FileFilter, Serializable { /** * Checks to see if the filename matches one of the regular expressions. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return true if the file matches one of the regular expressions */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java index 36084d8..68053ea 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeFileFilter.java @@ -56,11 +56,10 @@ public class SizeFileFilter implements FileFilter, Serializable { private final long size; /** - * Constructs a new size file filter for files equal to or larger than a - * certain size. + * Constructs a new size file filter for files equal to or larger than a certain + * size. * - * @param size - * the threshold size of the files - Must be non-negative. + * @param size the threshold size of the files - Must be non-negative. */ public SizeFileFilter(final long size) { this(size, true); @@ -70,11 +69,9 @@ public class SizeFileFilter implements FileFilter, Serializable { * Constructs a new size file filter for files based on a certain size * threshold. * - * @param size - * the threshold size of the files - Must be non-negative. - * @param acceptLarger - * if true, files equal to or larger are accepted, otherwise - * smaller ones (but not equal to) + * @param size the threshold size of the files - Must be non-negative. + * @param acceptLarger if true, files equal to or larger are accepted, otherwise + * smaller ones (but not equal to) */ public SizeFileFilter(final long size, final boolean acceptLarger) { if (size < 0) { @@ -87,14 +84,13 @@ public class SizeFileFilter implements FileFilter, Serializable { /** * Checks to see if the size of the file is favorable. * <p> - * If size equals threshold and smaller files are required, file <b>IS - * NOT</b> selected. If size equals threshold and larger files are required, - * file <b>IS</b> selected. + * If size equals threshold and smaller files are required, file <b>IS NOT</b> + * selected. If size equals threshold and larger files are required, file + * <b>IS</b> selected. * <p> * Non-existing files return always false (will never be accepted). * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return true if the filename matches */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeRangeFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeRangeFileFilter.java index 3115daa..7060ff3 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeRangeFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SizeRangeFileFilter.java @@ -24,6 +24,7 @@ import org.apache.commons.vfs2.FileSelectInfo; /** * Filter that accepts files whose size is >= minimum size and <= maximum * size. + * * @since 2.4 */ public class SizeRangeFileFilter implements FileFilter, Serializable { @@ -35,10 +36,8 @@ public class SizeRangeFileFilter implements FileFilter, Serializable { /** * Constructor with sizes. * - * @param minSizeInclusive - * the minimum file size (inclusive) - * @param maxSizeInclusive - * the maximum file size (inclusive) + * @param minSizeInclusive the minimum file size (inclusive) + * @param maxSizeInclusive the maximum file size (inclusive) */ public SizeRangeFileFilter(final long minSizeInclusive, final long maxSizeInclusive) { final FileFilter minimumFilter = new SizeFileFilter(minSizeInclusive, true); diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SuffixFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SuffixFileFilter.java index 4f1a6b4..e366319 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SuffixFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/SuffixFileFilter.java @@ -57,8 +57,7 @@ public class SuffixFileFilter implements FileFilter, Serializable { /** * Constructs a new Suffix file filter for a list of suffixes. * - * @param suffixes - * the suffixes to allow, must not be null + * @param suffixes the suffixes to allow, must not be null */ public SuffixFileFilter(final List<String> suffixes) { this(IOCase.SENSITIVE, suffixes); @@ -68,10 +67,9 @@ public class SuffixFileFilter implements FileFilter, Serializable { * Constructs a new Suffix file filter for a list of suffixes specifying * case-sensitivity. * - * @param suffixes - * the suffixes to allow, must not be null - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive + * @param suffixes the suffixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive */ public SuffixFileFilter(final IOCase caseSensitivity, final List<String> suffixes) { if (suffixes == null) { @@ -84,8 +82,7 @@ public class SuffixFileFilter implements FileFilter, Serializable { /** * Constructs a new Suffix file filter for an array of suffixes. * - * @param suffixes - * the suffixes to allow, must not be null + * @param suffixes the suffixes to allow, must not be null */ public SuffixFileFilter(final String... suffixes) { this(IOCase.SENSITIVE, suffixes); @@ -95,10 +92,9 @@ public class SuffixFileFilter implements FileFilter, Serializable { * Constructs a new Suffix file filter for an array of suffixs specifying * case-sensitivity. * - * @param suffixes - * the suffixes to allow, must not be null - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive + * @param suffixes the suffixes to allow, must not be null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive */ public SuffixFileFilter(final IOCase caseSensitivity, final String... suffixes) { if (suffixes == null) { @@ -111,8 +107,7 @@ public class SuffixFileFilter implements FileFilter, Serializable { /** * Checks to see if the filename ends with the suffix. * - * @param fileInfo - * the File to check + * @param fileInfo the File to check * * @return true if the filename ends with one of our suffixes */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/TrueFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/TrueFileFilter.java index 12db49f..b1a6ad8 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/TrueFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/TrueFileFilter.java @@ -46,8 +46,7 @@ public class TrueFileFilter implements FileFilter, Serializable { /** * Returns true. * - * @param fileInfo - * the file to check (ignored) + * @param fileInfo the file to check (ignored) * * @return Always {@code true} */ diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java index b282f9f..3ffe31a 100644 --- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java +++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/filter/WildcardFileFilter.java @@ -66,8 +66,7 @@ public class WildcardFileFilter implements FileFilter, Serializable { /** * Construct a new case-sensitive wildcard filter for a list of wildcards. * - * @param wildcards - * the list of wildcards to match, not null + * @param wildcards the list of wildcards to match, not null */ public WildcardFileFilter(final List<String> wildcards) { this((IOCase) null, wildcards); @@ -77,10 +76,9 @@ public class WildcardFileFilter implements FileFilter, Serializable { * Construct a new wildcard filter for a list of wildcards specifying * case-sensitivity. * - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive - * @param wildcards - * the list of wildcards to match, not null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive + * @param wildcards the list of wildcards to match, not null */ public WildcardFileFilter(final IOCase caseSensitivity, final List<String> wildcards) { if (wildcards == null) { @@ -93,11 +91,10 @@ public class WildcardFileFilter implements FileFilter, Serializable { /** * Construct a new case-sensitive wildcard filter for an array of wildcards. * <p> - * The array is not cloned, so could be changed after constructing the - * instance. This would be inadvisable however. + * The array is not cloned, so could be changed after constructing the instance. + * This would be inadvisable however. * - * @param wildcards - * the array of wildcards to match + * @param wildcards the array of wildcards to match */ public WildcardFileFilter(final String... wildcards) { this((IOCase) null, wildcards); @@ -107,10 +104,9 @@ public class WildcardFileFilter implements FileFilter, Serializable { * Construct a new wildcard filter for an array of wildcards specifying * case-sensitivity. * - * @param caseSensitivity - * how to handle case sensitivity, null means case-sensitive - * @param wildcards - * the array of wildcards to match, not null + * @param caseSensitivity how to handle case sensitivity, null means + * case-sensitive + * @param wildcards the array of wildcards to match, not null */ public WildcardFileFilter(final IOCase caseSensitivity, final String... wildcards) { if (wildcards == null) { @@ -123,8 +119,7 @@ public class WildcardFileFilter implements FileFilter, Serializable { /** * Checks to see if the filename matches one of the wildcards. * - * @param fileInfo - * the file to check + * @param fileInfo the file to check * * @return true if the filename matches one of the wildcards */ @@ -162,12 +157,10 @@ public class WildcardFileFilter implements FileFilter, Serializable { } /** - * Splits a string into a number of tokens. The text is split by '?' and - * '*'. Where multiple '*' occur consecutively they are collapsed into a - * single '*'. + * Splits a string into a number of tokens. The text is split by '?' and '*'. + * Where multiple '*' occur consecutively they are collapsed into a single '*'. * - * @param text - * the text to split + * @param text the text to split * @return the array of tokens, never null */ // CHECKSTYLE:OFF Cyclomatic complexity of 12 is OK here @@ -210,22 +203,19 @@ public class WildcardFileFilter implements FileFilter, Serializable { * Checks a filename to see if it matches the specified wildcard matcher * allowing control over case-sensitivity. * <p> - * The wildcard matcher uses the characters '?' and '*' to represent a - * single or multiple (zero or more) wildcard characters. N.B. the sequence - * "*?" does not work properly at present in match strings. + * The wildcard matcher uses the characters '?' and '*' to represent a single or + * multiple (zero or more) wildcard characters. N.B. the sequence "*?" does not + * work properly at present in match strings. * - * @param filename - * the filename to match on - * @param wildcardMatcher - * the wildcard string to match against - * @param caseSensitivity - * what case sensitivity rule to use, null means case-sensitive + * @param filename the filename to match on + * @param wildcardMatcher the wildcard string to match against + * @param caseSensitivity what case sensitivity rule to use, null means + * case-sensitive * * @return true if the filename matches the wilcard string */ // CHECKSTYLE:OFF TODO xxx Cyclomatic complexity of 19 should be refactored - static boolean wildcardMatch(final String filename, final String wildcardMatcher, - IOCase caseSensitivity) { + static boolean wildcardMatch(final String filename, final String wildcardMatcher, IOCase caseSensitivity) { if (filename == null && wildcardMatcher == null) { return true; } @@ -277,8 +267,7 @@ public class WildcardFileFilter implements FileFilter, Serializable { // token not found break; } - final int repeat = caseSensitivity.checkIndexOf(filename, textIdx + 1, - wcs[wcsIdx]); + final int repeat = caseSensitivity.checkIndexOf(filename, textIdx + 1, wcs[wcsIdx]); if (repeat >= 0) { backtrack.push(new int[] { wcsIdx, repeat }); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AgeFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AgeFileFilterTest.java index 114b2d6..9b82da0 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AgeFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AgeFileFilterTest.java @@ -70,23 +70,22 @@ public class AgeFileFilterTest extends BaseFilterTest { oldFile = new File(testDir, "old.txt"); FileUtils.touch(oldFile); oldFile.setLastModified(TWO_DAYS_AGO); - oldFileInfo = createFSI(oldFile); + oldFileInfo = createFileSelectInfo(oldFile); // Reference file currentFile = new File(testDir, "current.txt"); FileUtils.touch(currentFile); currentFile.setLastModified(NOW); - currentFileInfo = createFSI(currentFile); + currentFileInfo = createFileSelectInfo(currentFile); // Set the file's time stamp two days into the future newFile = new File(testDir, "new.txt"); FileUtils.touch(newFile); newFile.setLastModified(TWO_DAYS_LATER); - newFileInfo = createFSI(newFile); + newFileInfo = createFileSelectInfo(newFile); // Zip the test directory - zipFile = new File(getTempDir(), AgeFileFilterTest.class.getName() - + ".zip"); + zipFile = new File(getTempDir(), AgeFileFilterTest.class.getName() + ".zip"); zipDir(testDir, "", zipFile); zipFileObj = getZipFileObject(zipFile); @@ -193,13 +192,11 @@ public class AgeFileFilterTest extends BaseFilterTest { // Same test with ZIP file FileObject[] files; - files = zipFileObj.findFiles(new FileFilterSelector(new AgeFileFilter( - NOW, true))); + files = zipFileObj.findFiles(new FileFilterSelector(new AgeFileFilter(NOW, true))); assertContains(files, oldFile.getName(), currentFile.getName()); Assert.assertEquals(2, files.length); - files = zipFileObj.findFiles(new FileFilterSelector(new AgeFileFilter( - NOW, false))); + files = zipFileObj.findFiles(new FileFilterSelector(new AgeFileFilter(NOW, false))); assertContains(files, newFile.getName()); Assert.assertEquals(1, files.length); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AndFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AndFileFilterTest.java index e943eb1..683f6f0 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AndFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/AndFileFilterTest.java @@ -124,7 +124,7 @@ public class AndFileFilterTest extends BaseFilterTest { @Test public void testAccept() { - final FileSelectInfo any = createFSI(new File("anyfile")); + final FileSelectInfo any = createFileSelectInfo(new File("anyfile")); // Empty Assert.assertFalse(new AndFileFilter().accept(any)); @@ -135,12 +135,9 @@ public class AndFileFilterTest extends BaseFilterTest { // False Assert.assertFalse(new AndFileFilter(new False()).accept(any)); - Assert.assertFalse(new AndFileFilter(new False(), new False()) - .accept(any)); - Assert.assertFalse(new AndFileFilter(new False(), new True()) - .accept(any)); - Assert.assertFalse(new AndFileFilter(new True(), new False()) - .accept(any)); + Assert.assertFalse(new AndFileFilter(new False(), new False()).accept(any)); + Assert.assertFalse(new AndFileFilter(new False(), new True()).accept(any)); + Assert.assertFalse(new AndFileFilter(new True(), new False()).accept(any)); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java index ac0763c..2886fef 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/BaseFilterTest.java @@ -46,12 +46,11 @@ public abstract class BaseFilterTest { /** * Creates a file select info object for the given file. * - * @param file - * File to create an info for. + * @param file File to create an info for. * * @return File selct info. */ - protected static FileSelectInfo createFSI(final File file) { + protected static FileSelectInfo createFileSelectInfo(final File file) { try { final FileSystemManager fsManager = VFS.getManager(); final FileObject fileObject = fsManager.toFileObject(file); @@ -83,16 +82,13 @@ public abstract class BaseFilterTest { /** * Returns a ZIP file object. * - * @param file - * File to resolve. + * @param file File to resolve. * * @return File object. * - * @throws FileSystemException - * Error resolving the file. + * @throws FileSystemException Error resolving the file. */ - protected static FileObject getZipFileObject(final File file) - throws FileSystemException { + protected static FileObject getZipFileObject(final File file) throws FileSystemException { final FileSystemManager fsManager = VFS.getManager(); return fsManager.resolveFile("zip:" + file.toURI()); } @@ -100,17 +96,13 @@ public abstract class BaseFilterTest { /** * Asserts that the array contains the given file names. * - * @param files - * Array to check. - * @param filenames - * File names to find. + * @param files Array to check. + * @param filenames File names to find. */ - protected void assertContains(final FileObject[] files, - final String... filenames) { + protected void assertContains(final FileObject[] files, final String... filenames) { for (final String filename : filenames) { if (!find(files, filename)) { - fail("File '" + filename + "' not found in: " - + Arrays.asList(files)); + fail("File '" + filename + "' not found in: " + Arrays.asList(files)); } } } @@ -137,8 +129,7 @@ public abstract class BaseFilterTest { /** * Returns a sub directory of the temporary directory. * - * @param name - * Name of the sub directory. + * @param name Name of the sub directory. * * @return Sub directory of java.io.tmpdir. */ @@ -149,32 +140,24 @@ public abstract class BaseFilterTest { /** * Verifies at least all given objects are in the list. * - * @param list - * List to use. - * @param objects - * Objects to find. + * @param list List to use. + * @param objects Objects to find. */ protected static void assertContains(final List<?> list, final Object... objects) { for (final Object obj : objects) { - Assert.assertTrue( - "Couldn't find " + obj + " in " + Arrays.asList(objects), - list.indexOf(obj) > -1); + Assert.assertTrue("Couldn't find " + obj + " in " + Arrays.asList(objects), list.indexOf(obj) > -1); } } /** * Verifies only the given objects are in the list. * - * @param list - * List to scan. - * @param objects - * Objects to find. + * @param list List to scan. + * @param objects Objects to find. */ protected static void assertContainsOnly(final List<?> list, final Object... objects) { for (final Object obj : objects) { - Assert.assertTrue( - "Couldn't find " + obj + " in " + Arrays.asList(objects), - list.indexOf(obj) > -1); + Assert.assertTrue("Couldn't find " + obj + " in " + Arrays.asList(objects), list.indexOf(obj) > -1); } Assert.assertEquals(objects.length, list.size()); } @@ -182,25 +165,18 @@ public abstract class BaseFilterTest { /** * Adds a file to a ZIP output stream. * - * @param srcFile - * File to add - Cannot be <code>null</code>. - * @param destPath - * Path to use for the file - May be <code>null</code> or empty. - * @param out - * Destination stream - Cannot be <code>null</code>. + * @param srcFile File to add - Cannot be <code>null</code>. + * @param destPath Path to use for the file - May be <code>null</code> or empty. + * @param out Destination stream - Cannot be <code>null</code>. * - * @throws IOException - * Error writing to the output stream. + * @throws IOException Error writing to the output stream. */ - private static void zipFile(final File srcFile, final String destPath, - final ZipOutputStream out) throws IOException { + private static void zipFile(final File srcFile, final String destPath, final ZipOutputStream out) + throws IOException { final byte[] buf = new byte[1024]; - final InputStream in = new BufferedInputStream(new FileInputStream( - srcFile)); - try { - final ZipEntry zipEntry = new ZipEntry(concatPathAndFilename( - destPath, srcFile.getName(), File.separator)); + try (final InputStream in = new BufferedInputStream(new FileInputStream(srcFile))) { + final ZipEntry zipEntry = new ZipEntry(concatPathAndFilename(destPath, srcFile.getName(), File.separator)); zipEntry.setTime(srcFile.lastModified()); out.putNextEntry(zipEntry); int len; @@ -208,39 +184,28 @@ public abstract class BaseFilterTest { out.write(buf, 0, len); } out.closeEntry(); - } finally { - in.close(); } } /** * Add a directory to a ZIP output stream. * - * @param srcDir - * Directory to add - Cannot be <code>null</code> and must be a - * valid directory. - * @param filter - * Filter or <code>null</code> for all files. - * @param destPath - * Path to use for the ZIP archive - May be <code>null</code> or - * an empyt string. - * @param out - * Destination stream - Cannot be <code>null</code>. + * @param srcDir Directory to add - Cannot be <code>null</code> and must be a + * valid directory. + * @param filter Filter or <code>null</code> for all files. + * @param destPath Path to use for the ZIP archive - May be <code>null</code> or + * an empyt string. + * @param out Destination stream - Cannot be <code>null</code>. * - * @throws IOException - * Error writing to the output stream. + * @throws IOException Error writing to the output stream. */ - private static void zipDir(final File srcDir, final FileFilter filter, - final String destPath, final ZipOutputStream out) - throws IOException { + private static void zipDir(final File srcDir, final FileFilter filter, final String destPath, + final ZipOutputStream out) throws IOException { final File[] files = listFiles(srcDir, filter); for (final File file : files) { if (file.isDirectory()) { - zipDir(file, - filter, - concatPathAndFilename(destPath, file.getName(), - File.separator), out); + zipDir(file, filter, concatPathAndFilename(destPath, file.getName(), File.separator), out); } else { zipFile(file, destPath, out); } @@ -250,25 +215,20 @@ public abstract class BaseFilterTest { /** * Creates a ZIP file and adds all files in a directory and all it's sub - * directories to the archive. Only entries are added that comply to the - * file filter. + * directories to the archive. Only entries are added that comply to the file + * filter. * - * @param srcDir - * Directory to add - Cannot be <code>null</code> and must be a - * valid directory. - * @param filter - * Filter or <code>null</code> for all files/directories. - * @param destPath - * Path to use for the ZIP archive - May be <code>null</code> or - * an empyt string. - * @param destFile - * Target ZIP file - Cannot be <code>null</code>. + * @param srcDir Directory to add - Cannot be <code>null</code> and must be a + * valid directory. + * @param filter Filter or <code>null</code> for all files/directories. + * @param destPath Path to use for the ZIP archive - May be <code>null</code> or + * an empyt string. + * @param destFile Target ZIP file - Cannot be <code>null</code>. * - * @throws IOException - * Error writing to the output stream. + * @throws IOException Error writing to the output stream. */ - public static void zipDir(final File srcDir, final FileFilter filter, - final String destPath, final File destFile) throws IOException { + public static void zipDir(final File srcDir, final FileFilter filter, final String destPath, final File destFile) + throws IOException { if (srcDir == null) { throw new IllegalArgumentException("srcDir cannot be null"); @@ -283,12 +243,8 @@ public abstract class BaseFilterTest { throw new IllegalArgumentException("destFile cannot be null"); } - final ZipOutputStream out = new ZipOutputStream( - new BufferedOutputStream(new FileOutputStream(destFile))); - try { + try (final ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destFile)));) { zipDir(srcDir, filter, destPath, out); - } finally { - out.close(); } } @@ -297,41 +253,32 @@ public abstract class BaseFilterTest { * Creates a ZIP file and adds all files in a directory and all it's sub * directories to the archive. * - * @param srcDir - * Directory to add - Cannot be <code>null</code> and must be a - * valid directory. - * @param destPath - * Path to use for the ZIP archive - May be <code>null</code> or - * an empyt string. - * @param destFile - * Target ZIP file - Cannot be <code>null</code>. + * @param srcDir Directory to add - Cannot be <code>null</code> and must be a + * valid directory. + * @param destPath Path to use for the ZIP archive - May be <code>null</code> or + * an empyt string. + * @param destFile Target ZIP file - Cannot be <code>null</code>. * - * @throws IOException - * Error writing to the output stream. + * @throws IOException Error writing to the output stream. */ - public static void zipDir(final File srcDir, final String destPath, - final File destFile) throws IOException { + public static void zipDir(final File srcDir, final String destPath, final File destFile) throws IOException { zipDir(srcDir, null, destPath, destFile); } /** - * Concatenate a path and a filename taking <code>null</code> and empty - * string values into account. + * Concatenate a path and a filename taking <code>null</code> and empty string + * values into account. * - * @param path - * Path - Can be <code>null</code> or an empty string. - * @param filename - * Filename - Cannot be <code>null</code>. - * @param separator - * Separator for directories - Can be <code>null</code> or an - * empty string. + * @param path Path - Can be <code>null</code> or an empty string. + * @param filename Filename - Cannot be <code>null</code>. + * @param separator Separator for directories - Can be <code>null</code> or an + * empty string. * * @return Path and filename divided by the separator. */ - public static String concatPathAndFilename(final String path, - final String filename, final String separator) { + public static String concatPathAndFilename(final String path, final String filename, final String separator) { if (filename == null) { throw new IllegalArgumentException("filename cannot be null"); @@ -364,11 +311,9 @@ public abstract class BaseFilterTest { /** * List all files for a directory. * - * @param srcDir - * Directory to list the files for - Cannot be <code>null</code> - * and must be a valid directory. - * @param filter - * Filter or <code>null</code> for all files. + * @param srcDir Directory to list the files for - Cannot be <code>null</code> + * and must be a valid directory. + * @param filter Filter or <code>null</code> for all files. * * @return List of child entries of the directory. */ diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanExecuteFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanExecuteFileFilterTest.java new file mode 100644 index 0000000..cc51c25 --- /dev/null +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanExecuteFileFilterTest.java @@ -0,0 +1,122 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.commons.vfs2.filter; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.vfs2.FileFilterSelector; +import org.apache.commons.vfs2.FileObject; +import org.apache.commons.vfs2.FileSelectInfo; +import org.apache.commons.vfs2.FileSystemException; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test for {@link CanExecuteFileFilter}. + */ +// CHECKSTYLE:OFF Test code +public class CanExecuteFileFilterTest extends BaseFilterTest { + + private static final String EXECUTABLE = "executable.txt"; + + private static final String NOT_EXECUTABLE = "notexecutable.txt"; + + private static File testDir; + + private static File executableFile; + + private static FileSelectInfo executableFileInfo; + + private static File notExecutableFile; + + private static FileSelectInfo notExecutableFileInfo; + + private static File notExistingFile; + + private static FileSelectInfo notExistingFileInfo; + + private static File zipFile; + + private static FileObject zipFileObj; + + @BeforeClass + public static void beforeClass() throws IOException { + + testDir = getTestDir(CanExecuteFileFilterTest.class.getName()); + + executableFile = new File(testDir, EXECUTABLE); + executableFileInfo = createFileSelectInfo(executableFile); + FileUtils.touch(executableFile); + executableFile.setExecutable(true); + + notExecutableFile = new File(testDir, NOT_EXECUTABLE); + notExecutableFileInfo = createFileSelectInfo(notExecutableFile); + FileUtils.touch(notExecutableFile); + notExecutableFile.setExecutable(false); + + notExistingFile = new File(testDir, "not-existing-file.txt"); + notExistingFileInfo = createFileSelectInfo(notExistingFile); + + zipFile = new File(getTempDir(), CanExecuteFileFilterTest.class.getName() + ".zip"); + zipDir(testDir, "", zipFile); + zipFileObj = getZipFileObject(zipFile); + + } + + @AfterClass + public static void afterClass() throws IOException { + + executableFileInfo = null; + executableFile.delete(); + executableFile = null; + + notExecutableFileInfo = null; + notExecutableFile.delete(); + notExecutableFile = null; + + notExistingFileInfo = null; + notExistingFile = null; + + zipFileObj.close(); + FileUtils.deleteQuietly(zipFile); + zipFile = null; + + FileUtils.deleteDirectory(testDir); + testDir = null; + + } + + @Test + public void testAcceptCanExecute() { + Assert.assertTrue(CanExecuteFileFilter.CAN_EXECUTE.accept(executableFileInfo)); + Assert.assertTrue(CanExecuteFileFilter.CAN_EXECUTE.accept(notExecutableFileInfo)); + Assert.assertFalse(CanExecuteFileFilter.CAN_EXECUTE.accept(notExistingFileInfo)); + } + + @Test + public void testAcceptCannotExecute() { + Assert.assertFalse(CanExecuteFileFilter.CANNOT_EXECUTE.accept(executableFileInfo)); + Assert.assertFalse(CanExecuteFileFilter.CANNOT_EXECUTE.accept(notExecutableFileInfo)); + Assert.assertTrue(CanExecuteFileFilter.CANNOT_EXECUTE.accept(notExistingFileInfo)); + } + +} +// CHECKSTYLE:ON diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanReadFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanReadFileFilterTest.java index 5ca78a9..68878d0 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanReadFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanReadFileFilterTest.java @@ -63,20 +63,19 @@ public class CanReadFileFilterTest extends BaseFilterTest { testDir = getTestDir(CanReadFileFilterTest.class.getName()); writeableFile = new File(testDir, WRITEABLE); - writeableFileInfo = createFSI(writeableFile); + writeableFileInfo = createFileSelectInfo(writeableFile); FileUtils.touch(writeableFile); readOnlyFile = new File(testDir, READONLY); - readOnlyFileInfo = createFSI(readOnlyFile); + readOnlyFileInfo = createFileSelectInfo(readOnlyFile); FileUtils.touch(readOnlyFile); readOnlyFile.setReadable(true); readOnlyFile.setWritable(false); notExistingFile = new File(testDir, "not-existing-file.txt"); - notExistingFileInfo = createFSI(notExistingFile); + notExistingFileInfo = createFileSelectInfo(notExistingFile); - zipFile = new File(getTempDir(), CanReadFileFilterTest.class.getName() - + ".zip"); + zipFile = new File(getTempDir(), CanReadFileFilterTest.class.getName() + ".zip"); zipDir(testDir, "", zipFile); zipFileObj = getZipFileObject(zipFile); @@ -110,31 +109,25 @@ public class CanReadFileFilterTest extends BaseFilterTest { Assert.assertTrue(CanReadFileFilter.CAN_READ.accept(writeableFileInfo)); Assert.assertTrue(CanReadFileFilter.CAN_READ.accept(readOnlyFileInfo)); - Assert.assertFalse(CanReadFileFilter.CAN_READ - .accept(notExistingFileInfo)); + Assert.assertFalse(CanReadFileFilter.CAN_READ.accept(notExistingFileInfo)); } @Test public void testAcceptCannotRead() { - Assert.assertFalse(CanReadFileFilter.CANNOT_READ - .accept(writeableFileInfo)); - Assert.assertFalse(CanReadFileFilter.CANNOT_READ - .accept(readOnlyFileInfo)); - Assert.assertTrue(CanReadFileFilter.CANNOT_READ - .accept(notExistingFileInfo)); + Assert.assertFalse(CanReadFileFilter.CANNOT_READ.accept(writeableFileInfo)); + Assert.assertFalse(CanReadFileFilter.CANNOT_READ.accept(readOnlyFileInfo)); + Assert.assertTrue(CanReadFileFilter.CANNOT_READ.accept(notExistingFileInfo)); } @Test public void testAcceptReadOnly() { - Assert.assertFalse(CanReadFileFilter.READ_ONLY - .accept(writeableFileInfo)); + Assert.assertFalse(CanReadFileFilter.READ_ONLY.accept(writeableFileInfo)); Assert.assertTrue(CanReadFileFilter.READ_ONLY.accept(readOnlyFileInfo)); - Assert.assertFalse(CanReadFileFilter.READ_ONLY - .accept(notExistingFileInfo)); + Assert.assertFalse(CanReadFileFilter.READ_ONLY.accept(notExistingFileInfo)); } @@ -144,19 +137,16 @@ public class CanReadFileFilterTest extends BaseFilterTest { FileObject[] files; // CAN_READ Filter - files = zipFileObj.findFiles(new FileFilterSelector( - CanReadFileFilter.CAN_READ)); + files = zipFileObj.findFiles(new FileFilterSelector(CanReadFileFilter.CAN_READ)); assertContains(files, READONLY, WRITEABLE); Assert.assertEquals(2, files.length); // CANNOT_READ Filter - files = zipFileObj.findFiles(new FileFilterSelector( - CanReadFileFilter.CANNOT_READ)); + files = zipFileObj.findFiles(new FileFilterSelector(CanReadFileFilter.CANNOT_READ)); Assert.assertTrue(files == null || files.length == 0); // READ_ONLY Filter - files = zipFileObj.findFiles(new FileFilterSelector( - CanReadFileFilter.READ_ONLY)); + files = zipFileObj.findFiles(new FileFilterSelector(CanReadFileFilter.READ_ONLY)); assertContains(files, READONLY, WRITEABLE); Assert.assertEquals(2, files.length); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanWriteFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanWriteFileFilterTest.java index 5eb6462..360d504 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanWriteFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/CanWriteFileFilterTest.java @@ -63,20 +63,19 @@ public class CanWriteFileFilterTest extends BaseFilterTest { testDir = getTestDir(CanWriteFileFilterTest.class.getName()); writeableFile = new File(testDir, WRITEABLE); - writeableFileInfo = createFSI(writeableFile); + writeableFileInfo = createFileSelectInfo(writeableFile); FileUtils.touch(writeableFile); readOnlyFile = new File(testDir, READONLY); - readOnlyFileInfo = createFSI(readOnlyFile); + readOnlyFileInfo = createFileSelectInfo(readOnlyFile); FileUtils.touch(readOnlyFile); readOnlyFile.setReadable(true); readOnlyFile.setWritable(false); notExistingFile = new File(testDir, "not-existing-file.txt"); - notExistingFileInfo = createFSI(notExistingFile); + notExistingFileInfo = createFileSelectInfo(notExistingFile); - zipFile = new File(getTempDir(), CanWriteFileFilterTest.class.getName() - + ".zip"); + zipFile = new File(getTempDir(), CanWriteFileFilterTest.class.getName() + ".zip"); zipDir(testDir, "", zipFile); zipFileObj = getZipFileObject(zipFile); @@ -108,24 +107,18 @@ public class CanWriteFileFilterTest extends BaseFilterTest { @Test public void testAcceptCanWrite() { - Assert.assertTrue(CanWriteFileFilter.CAN_WRITE - .accept(writeableFileInfo)); - Assert.assertFalse(CanWriteFileFilter.CAN_WRITE - .accept(readOnlyFileInfo)); - Assert.assertTrue(CanWriteFileFilter.CAN_WRITE - .accept(notExistingFileInfo)); + Assert.assertTrue(CanWriteFileFilter.CAN_WRITE.accept(writeableFileInfo)); + Assert.assertFalse(CanWriteFileFilter.CAN_WRITE.accept(readOnlyFileInfo)); + Assert.assertTrue(CanWriteFileFilter.CAN_WRITE.accept(notExistingFileInfo)); } @Test public void testAcceptCannotWrite() { - Assert.assertFalse(CanWriteFileFilter.CANNOT_WRITE - .accept(writeableFileInfo)); - Assert.assertTrue(CanWriteFileFilter.CANNOT_WRITE - .accept(readOnlyFileInfo)); - Assert.assertFalse(CanWriteFileFilter.CANNOT_WRITE - .accept(notExistingFileInfo)); + Assert.assertFalse(CanWriteFileFilter.CANNOT_WRITE.accept(writeableFileInfo)); + Assert.assertTrue(CanWriteFileFilter.CANNOT_WRITE.accept(readOnlyFileInfo)); + Assert.assertFalse(CanWriteFileFilter.CANNOT_WRITE.accept(notExistingFileInfo)); } @@ -135,13 +128,11 @@ public class CanWriteFileFilterTest extends BaseFilterTest { FileObject[] files; // CAN_WRITE Filter - files = zipFileObj.findFiles(new FileFilterSelector( - CanWriteFileFilter.CAN_WRITE)); + files = zipFileObj.findFiles(new FileFilterSelector(CanWriteFileFilter.CAN_WRITE)); Assert.assertTrue(files == null || files.length == 0); // CANNOT_WRITE Filter - files = zipFileObj.findFiles(new FileFilterSelector( - CanWriteFileFilter.CANNOT_WRITE)); + files = zipFileObj.findFiles(new FileFilterSelector(CanWriteFileFilter.CANNOT_WRITE)); assertContains(files, READONLY, WRITEABLE); Assert.assertEquals(2, files.length); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/DirectoryAndFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/DirectoryAndFileFilterTest.java index 797eb66..bc0bb91 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/DirectoryAndFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/DirectoryAndFileFilterTest.java @@ -67,17 +67,16 @@ public class DirectoryAndFileFilterTest extends BaseFilterTest { dir = new File(testDir, DIR); dir.mkdir(); - dirInfo = createFSI(dir); + dirInfo = createFileSelectInfo(dir); file = new File(dir, FILE); FileUtils.touch(file); - fileInfo = createFSI(file); + fileInfo = createFileSelectInfo(file); notExistingFile = new File(testDir, "not-existing-file.txt"); - notExistingFileInfo = createFSI(notExistingFile); + notExistingFileInfo = createFileSelectInfo(notExistingFile); - zipFile = new File(getTempDir(), - DirectoryAndFileFilterTest.class.getName() + ".zip"); + zipFile = new File(getTempDir(), DirectoryAndFileFilterTest.class.getName() + ".zip"); zipDir(testDir, "", zipFile); zipFileObj = getZipFileObject(zipFile); @@ -135,14 +134,12 @@ public class DirectoryAndFileFilterTest extends BaseFilterTest { // FILE Filter files = zipFileObj.findFiles(new FileSelector() { @Override - public boolean traverseDescendents(final FileSelectInfo fileInfo) - throws Exception { + public boolean traverseDescendents(final FileSelectInfo fileInfo) throws Exception { return true; } @Override - public boolean includeFile(final FileSelectInfo fileInfo) - throws Exception { + public boolean includeFile(final FileSelectInfo fileInfo) throws Exception { return FileFileFilter.FILE.accept(fileInfo); } }); @@ -150,8 +147,7 @@ public class DirectoryAndFileFilterTest extends BaseFilterTest { Assert.assertEquals(1, files.length); // DIRECTORY Filter - files = zipFileObj.findFiles(new FileFilterSelector( - DirectoryFileFilter.DIRECTORY)); + files = zipFileObj.findFiles(new FileFilterSelector(DirectoryFileFilter.DIRECTORY)); assertContains(files, DIR); Assert.assertEquals(1, files.length); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/EmptyFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/EmptyFileFilterTest.java index 7b5176b..11ae15c 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/EmptyFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/EmptyFileFilterTest.java @@ -69,27 +69,26 @@ public class EmptyFileFilterTest extends BaseFilterTest { notEmptyFile = new File(testDir, "full.txt"); FileUtils.write(notEmptyFile, "whatever"); - notEmptyFileInfo = createFSI(notEmptyFile); + notEmptyFileInfo = createFileSelectInfo(notEmptyFile); emptyFile = new File(testDir, "empty.txt"); FileUtils.touch(emptyFile); - emptyFileInfo = createFSI(emptyFile); + emptyFileInfo = createFileSelectInfo(emptyFile); notEmptyDir = new File(testDir, "full-dir"); notEmptyDir.mkdir(); - notEmptyDirInfo = createFSI(notEmptyDir); + notEmptyDirInfo = createFileSelectInfo(notEmptyDir); FileUtils.touch(new File(notEmptyDir, "foobar.txt")); emptyDir = new File(testDir, "empty-dir"); emptyDir.mkdir(); - emptyDirInfo = createFSI(emptyDir); + emptyDirInfo = createFileSelectInfo(emptyDir); notExistingFile = new File(testDir, "not-existing-file.txt"); - notExistingFileInfo = createFSI(notExistingFile); + notExistingFileInfo = createFileSelectInfo(notExistingFile); // Zip the test directory - zipFile = new File(getTempDir(), EmptyFileFilterTest.class.getName() - + ".zip"); + zipFile = new File(getTempDir(), EmptyFileFilterTest.class.getName() + ".zip"); zipDir(testDir, "", zipFile); zipFileObj = getZipFileObject(zipFile); @@ -149,13 +148,11 @@ public class EmptyFileFilterTest extends BaseFilterTest { // Same test with ZIP file FileObject[] files; - files = zipFileObj.findFiles(new FileFilterSelector( - EmptyFileFilter.EMPTY)); + files = zipFileObj.findFiles(new FileFilterSelector(EmptyFileFilter.EMPTY)); assertContains(files, emptyFile.getName()); Assert.assertEquals(1, files.length); - files = zipFileObj.findFiles(new FileFilterSelector( - EmptyFileFilter.NOT_EMPTY)); + files = zipFileObj.findFiles(new FileFilterSelector(EmptyFileFilter.NOT_EMPTY)); assertContains(files, notEmptyFile.getName(), notEmptyDir.getName()); Assert.assertEquals(2, files.length); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/HiddenFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/HiddenFileFilterTest.java index eafbfba..540d6b9 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/HiddenFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/HiddenFileFilterTest.java @@ -61,19 +61,18 @@ public class HiddenFileFilterTest extends BaseFilterTest { visibleFile = new File(testDir, "visible.txt"); FileUtils.touch(visibleFile); - visibleFileInfo = createFSI(visibleFile); + visibleFileInfo = createFileSelectInfo(visibleFile); hiddenFile = new File(testDir, "hidden.txt"); // TODO xxx In Java 6 there is no way to hide a file // hiddenFile.setVisible(false); - hiddenFileInfo = createFSI(hiddenFile); + hiddenFileInfo = createFileSelectInfo(hiddenFile); notExistingFile = new File(testDir, "not-existing-file.txt"); - notExistingFileInfo = createFSI(notExistingFile); + notExistingFileInfo = createFileSelectInfo(notExistingFile); // Zip the test directory - zipFile = new File(getTempDir(), HiddenFileFilterTest.class.getName() - + ".zip"); + zipFile = new File(getTempDir(), HiddenFileFilterTest.class.getName() + ".zip"); zipDir(testDir, "", zipFile); zipFileObj = getZipFileObject(zipFile); @@ -133,8 +132,7 @@ public class HiddenFileFilterTest extends BaseFilterTest { // assertContains(files, hiddenFile.getName()); // assertThat(files).hasSize(1); - files = zipFileObj.findFiles(new FileFilterSelector( - HiddenFileFilter.VISIBLE)); + files = zipFileObj.findFiles(new FileFilterSelector(HiddenFileFilter.VISIBLE)); assertContains(files, visibleFile.getName()); Assert.assertEquals(1, files.length); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NameFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NameFileFilterTest.java index 9384037..bd4d987 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NameFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NameFileFilterTest.java @@ -39,10 +39,10 @@ public class NameFileFilterTest extends BaseFilterTest { final NameFileFilter filter = new NameFileFilter(list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -56,10 +56,10 @@ public class NameFileFilterTest extends BaseFilterTest { final NameFileFilter filter = new NameFileFilter(IOCase.INSENSITIVE, list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("TEST1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -73,10 +73,10 @@ public class NameFileFilterTest extends BaseFilterTest { final NameFileFilter filter = new NameFileFilter(IOCase.SENSITIVE, list); // TEST - Assert.assertFalse(filter.accept(createFSI(new File("TEST1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -87,10 +87,10 @@ public class NameFileFilterTest extends BaseFilterTest { final NameFileFilter filter = new NameFileFilter("test1.txt"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -98,14 +98,13 @@ public class NameFileFilterTest extends BaseFilterTest { public void testAcceptStringIOCaseInsensitive() { // PREPARE - final NameFileFilter filter = new NameFileFilter(IOCase.INSENSITIVE, - "test2.txt"); + final NameFileFilter filter = new NameFileFilter(IOCase.INSENSITIVE, "test2.txt"); // TEST - Assert.assertFalse(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -113,14 +112,13 @@ public class NameFileFilterTest extends BaseFilterTest { public void testAcceptStringIOCaseSensitive() { // PREPARE - final NameFileFilter filter = new NameFileFilter(IOCase.SENSITIVE, - "test2.txt"); + final NameFileFilter filter = new NameFileFilter(IOCase.SENSITIVE, "test2.txt"); // TEST - Assert.assertFalse(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NotFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NotFileFilterTest.java index cca5fe6..eceec40 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NotFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/NotFileFilterTest.java @@ -31,7 +31,7 @@ public class NotFileFilterTest extends BaseFilterTest { @Test public void testAccept() { - final FileSelectInfo any = createFSI(new File("test1.txt")); + final FileSelectInfo any = createFileSelectInfo(new File("test1.txt")); Assert.assertFalse(new NotFileFilter(TrueFileFilter.TRUE).accept(any)); Assert.assertTrue(new NotFileFilter(FalseFileFilter.FALSE).accept(any)); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/OrFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/OrFileFilterTest.java index cc708f6..e5a191f 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/OrFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/OrFileFilterTest.java @@ -124,7 +124,7 @@ public class OrFileFilterTest extends BaseFilterTest { @Test public void testAccept() { - final FileSelectInfo any = createFSI(new File("anyfile")); + final FileSelectInfo any = createFileSelectInfo(new File("anyfile")); // Empty Assert.assertFalse(new OrFileFilter().accept(any)); @@ -137,8 +137,7 @@ public class OrFileFilterTest extends BaseFilterTest { // False Assert.assertFalse(new OrFileFilter(new False()).accept(any)); - Assert.assertFalse(new OrFileFilter(new False(), new False()) - .accept(any)); + Assert.assertFalse(new OrFileFilter(new False(), new False()).accept(any)); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/PrefixFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/PrefixFileFilterTest.java index d9f1451..1d120e8 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/PrefixFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/PrefixFileFilterTest.java @@ -39,10 +39,10 @@ public class PrefixFileFilterTest extends BaseFilterTest { final PrefixFileFilter filter = new PrefixFileFilter(list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -56,10 +56,10 @@ public class PrefixFileFilterTest extends BaseFilterTest { final PrefixFileFilter filter = new PrefixFileFilter(IOCase.INSENSITIVE, list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("TEST1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -73,10 +73,10 @@ public class PrefixFileFilterTest extends BaseFilterTest { final PrefixFileFilter filter = new PrefixFileFilter(IOCase.SENSITIVE, list); // TEST - Assert.assertFalse(filter.accept(createFSI(new File("TEST1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -87,10 +87,10 @@ public class PrefixFileFilterTest extends BaseFilterTest { final PrefixFileFilter filter = new PrefixFileFilter("test"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -98,14 +98,13 @@ public class PrefixFileFilterTest extends BaseFilterTest { public void testAcceptStringIOCaseInsensitive() { // PREPARE - final PrefixFileFilter filter = new PrefixFileFilter(IOCase.INSENSITIVE, - "test"); + final PrefixFileFilter filter = new PrefixFileFilter(IOCase.INSENSITIVE, "test"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -116,10 +115,10 @@ public class PrefixFileFilterTest extends BaseFilterTest { final PrefixFileFilter filter = new PrefixFileFilter(IOCase.SENSITIVE, "test"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("Test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("Test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/RegexFileFilterTestCase.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/RegexFileFilterTestCase.java index 5b52657..cab20ff 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/RegexFileFilterTestCase.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/RegexFileFilterTestCase.java @@ -37,30 +37,29 @@ public class RegexFileFilterTestCase extends BaseFilterTest { FileFilter filter; filter = new RegexFileFilter("^.*[tT]est(-\\d+)?\\.java$"); - Assert.assertTrue(filter.accept(createFSI(new File("Test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("test-10.java")))); - Assert.assertFalse(filter.accept(createFSI(new File("test-.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test-10.java")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test-.java")))); filter = new RegexFileFilter("^[Tt]est.java$"); - Assert.assertTrue(filter.accept(createFSI(new File("Test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.java")))); - Assert.assertFalse(filter.accept(createFSI(new File("tEST.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.java")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("tEST.java")))); - filter = new RegexFileFilter(Pattern.compile("^test.java$", - Pattern.CASE_INSENSITIVE)); - Assert.assertTrue(filter.accept(createFSI(new File("Test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("tEST.java")))); + filter = new RegexFileFilter(Pattern.compile("^test.java$", Pattern.CASE_INSENSITIVE)); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("tEST.java")))); filter = new RegexFileFilter("^test.java$", Pattern.CASE_INSENSITIVE); - Assert.assertTrue(filter.accept(createFSI(new File("Test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("tEST.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("tEST.java")))); filter = new RegexFileFilter("^test.java$", IOCase.INSENSITIVE); - Assert.assertTrue(filter.accept(createFSI(new File("Test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.java")))); - Assert.assertTrue(filter.accept(createFSI(new File("tEST.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("Test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.java")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("tEST.java")))); } @@ -70,8 +69,7 @@ public class RegexFileFilterTestCase extends BaseFilterTest { new RegexFileFilter((String) null); fail(); } catch (final IllegalArgumentException ex) { - Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, - ex.getMessage()); + Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, ex.getMessage()); } } @@ -81,8 +79,7 @@ public class RegexFileFilterTestCase extends BaseFilterTest { new RegexFileFilter((Pattern) null); fail(); } catch (final IllegalArgumentException ex) { - Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, - ex.getMessage()); + Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, ex.getMessage()); } } @@ -92,8 +89,7 @@ public class RegexFileFilterTestCase extends BaseFilterTest { new RegexFileFilter((String) null, Pattern.CASE_INSENSITIVE); fail(); } catch (final IllegalArgumentException ex) { - Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, - ex.getMessage()); + Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, ex.getMessage()); } } @@ -103,8 +99,7 @@ public class RegexFileFilterTestCase extends BaseFilterTest { new RegexFileFilter((String) null, IOCase.INSENSITIVE); fail(); } catch (final IllegalArgumentException ex) { - Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, - ex.getMessage()); + Assert.assertEquals(RegexFileFilter.PATTERN_IS_MISSING, ex.getMessage()); } } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SizeFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SizeFileFilterTest.java index 7bf58f3..954e05e 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SizeFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SizeFileFilterTest.java @@ -60,21 +60,20 @@ public class SizeFileFilterTest extends BaseFilterTest { // 2 characters minFile = new File(testDir, "min.txt"); FileUtils.write(minFile, "12"); - minFileInfo = createFSI(minFile); + minFileInfo = createFileSelectInfo(minFile); // 4 characters optFile = new File(testDir, "opt.txt"); FileUtils.write(optFile, "1234"); - optFileInfo = createFSI(optFile); + optFileInfo = createFileSelectInfo(optFile); // 6 characters maxFile = new File(testDir, "max.txt"); FileUtils.write(maxFile, "123456"); - maxFileInfo = createFSI(maxFile); + maxFileInfo = createFileSelectInfo(maxFile); // Zip the test directory - zipFile = new File(getTempDir(), SizeFileFilterTest.class.getName() - + ".zip"); + zipFile = new File(getTempDir(), SizeFileFilterTest.class.getName() + ".zip"); zipDir(testDir, "", zipFile); zipFileObj = getZipFileObject(zipFile); @@ -165,39 +164,31 @@ public class SizeFileFilterTest extends BaseFilterTest { // Same test with ZIP file FileObject[] files; - files = zipFileObj.findFiles(new FileFilterSelector(new SizeFileFilter( - 4, true))); + files = zipFileObj.findFiles(new FileFilterSelector(new SizeFileFilter(4, true))); assertContains(files, optFile.getName(), maxFile.getName()); Assert.assertEquals(2, files.length); - files = zipFileObj.findFiles(new FileFilterSelector(new SizeFileFilter( - 4, false))); + files = zipFileObj.findFiles(new FileFilterSelector(new SizeFileFilter(4, false))); assertContains(files, minFile.getName()); Assert.assertEquals(1, files.length); - files = zipFileObj.findFiles(new FileFilterSelector( - new SizeRangeFileFilter(2, 6))); - assertContains(files, minFile.getName(), optFile.getName(), - maxFile.getName()); + files = zipFileObj.findFiles(new FileFilterSelector(new SizeRangeFileFilter(2, 6))); + assertContains(files, minFile.getName(), optFile.getName(), maxFile.getName()); Assert.assertEquals(3, files.length); - files = zipFileObj.findFiles(new FileFilterSelector( - new SizeRangeFileFilter(3, 6))); + files = zipFileObj.findFiles(new FileFilterSelector(new SizeRangeFileFilter(3, 6))); assertContains(files, optFile.getName(), maxFile.getName()); Assert.assertEquals(2, files.length); - files = zipFileObj.findFiles(new FileFilterSelector( - new SizeRangeFileFilter(2, 5))); + files = zipFileObj.findFiles(new FileFilterSelector(new SizeRangeFileFilter(2, 5))); assertContains(files, minFile.getName(), optFile.getName()); Assert.assertEquals(2, files.length); - files = zipFileObj.findFiles(new FileFilterSelector( - new SizeRangeFileFilter(3, 5))); + files = zipFileObj.findFiles(new FileFilterSelector(new SizeRangeFileFilter(3, 5))); assertContains(files, optFile.getName()); Assert.assertEquals(1, files.length); - files = zipFileObj.findFiles(new FileFilterSelector( - new SizeRangeFileFilter(4, 4))); + files = zipFileObj.findFiles(new FileFilterSelector(new SizeRangeFileFilter(4, 4))); assertContains(files, optFile.getName()); Assert.assertEquals(1, files.length); diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SuffixFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SuffixFileFilterTest.java index f202727..5b1543c 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SuffixFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/SuffixFileFilterTest.java @@ -39,10 +39,10 @@ public class SuffixFileFilterTest extends BaseFilterTest { final SuffixFileFilter filter = new SuffixFileFilter(list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.bin")))); - Assert.assertFalse(filter.accept(createFSI(new File("test2.BIN")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.bin")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.BIN")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -56,10 +56,10 @@ public class SuffixFileFilterTest extends BaseFilterTest { final SuffixFileFilter filter = new SuffixFileFilter(IOCase.INSENSITIVE, list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("TEST1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.bin")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.TXT")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("TEST1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.bin")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.TXT")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -73,10 +73,10 @@ public class SuffixFileFilterTest extends BaseFilterTest { final SuffixFileFilter filter = new SuffixFileFilter(IOCase.SENSITIVE, list); // TEST - Assert.assertFalse(filter.accept(createFSI(new File("test1.Txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test2.BIN")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test1.Txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.BIN")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -87,10 +87,10 @@ public class SuffixFileFilterTest extends BaseFilterTest { final SuffixFileFilter filter = new SuffixFileFilter(".txt", ".xxx"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test2.TXT")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.TXT")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -98,14 +98,13 @@ public class SuffixFileFilterTest extends BaseFilterTest { public void testAcceptStringIOCaseInsensitive() { // PREPARE - final SuffixFileFilter filter = new SuffixFileFilter(IOCase.INSENSITIVE, - ".txt", ".xxx"); + final SuffixFileFilter filter = new SuffixFileFilter(IOCase.INSENSITIVE, ".txt", ".xxx"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.TXT")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.TXT")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -113,14 +112,13 @@ public class SuffixFileFilterTest extends BaseFilterTest { public void testAcceptStringIOCaseSensitive() { // PREPARE - final SuffixFileFilter filter = new SuffixFileFilter(IOCase.SENSITIVE, - ".txt", ".xxx"); + final SuffixFileFilter filter = new SuffixFileFilter(IOCase.SENSITIVE, ".txt", ".xxx"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test2.TXT")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test2.TXT")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.xxx")))); } diff --git a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/WildcardFileFilterTest.java b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/WildcardFileFilterTest.java index 90cf27e..e1e169a 100644 --- a/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/WildcardFileFilterTest.java +++ b/commons-vfs2/src/test/java/org/apache/commons/vfs2/filter/WildcardFileFilterTest.java @@ -39,17 +39,17 @@ public class WildcardFileFilterTest extends BaseFilterTest { final WildcardFileFilter filter = new WildcardFileFilter(list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.a")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ab")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.abc")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ABC")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aaa")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.Aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aAA")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.abcd")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.a")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ab")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.abc")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ABC")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aaa")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.Aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aAA")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.abcd")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -60,21 +60,20 @@ public class WildcardFileFilterTest extends BaseFilterTest { final List<String> list = new ArrayList<>(); list.add("*.txt"); list.add("*.a??"); - final WildcardFileFilter filter = new WildcardFileFilter(IOCase.INSENSITIVE, - list); + final WildcardFileFilter filter = new WildcardFileFilter(IOCase.INSENSITIVE, list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.a")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ab")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.abc")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.ABC")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.Aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aAA")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.abcd")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.a")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ab")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.abc")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.ABC")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.Aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aAA")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.abcd")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -85,21 +84,20 @@ public class WildcardFileFilterTest extends BaseFilterTest { final List<String> list = new ArrayList<>(); list.add("*.txt"); list.add("*.a??"); - final WildcardFileFilter filter = new WildcardFileFilter(IOCase.SENSITIVE, - list); + final WildcardFileFilter filter = new WildcardFileFilter(IOCase.SENSITIVE, list); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.a")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ab")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.abc")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ABC")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aaa")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.Aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aAA")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.abcd")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.a")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ab")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.abc")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ABC")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aaa")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.Aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aAA")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.abcd")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -110,17 +108,17 @@ public class WildcardFileFilterTest extends BaseFilterTest { final WildcardFileFilter filter = new WildcardFileFilter("*.txt", "*.a??"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.a")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ab")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.abc")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ABC")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aaa")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.Aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aAA")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.abcd")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.a")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ab")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.abc")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ABC")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aaa")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.Aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aAA")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.abcd")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -128,21 +126,20 @@ public class WildcardFileFilterTest extends BaseFilterTest { public void testAcceptStringIOCaseInsensitive() { // PREPARE - final WildcardFileFilter filter = new WildcardFileFilter(IOCase.INSENSITIVE, - "*.txt", "*.a??"); + final WildcardFileFilter filter = new WildcardFileFilter(IOCase.INSENSITIVE, "*.txt", "*.a??"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.a")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ab")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.abc")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.ABC")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.Aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aAA")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.abcd")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.a")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ab")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.abc")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.ABC")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.Aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aAA")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.abcd")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); } @@ -150,21 +147,20 @@ public class WildcardFileFilterTest extends BaseFilterTest { public void testAcceptStringIOCaseSensitive() { // PREPARE - final WildcardFileFilter filter = new WildcardFileFilter(IOCase.SENSITIVE, - "*.txt", "*.a??"); + final WildcardFileFilter filter = new WildcardFileFilter(IOCase.SENSITIVE, "*.txt", "*.a??"); // TEST - Assert.assertTrue(filter.accept(createFSI(new File("test1.txt")))); - Assert.assertTrue(filter.accept(createFSI(new File("test2.txt")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.a")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ab")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.abc")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.ABC")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aaa")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.Aaa")))); - Assert.assertTrue(filter.accept(createFSI(new File("test.aAA")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.abcd")))); - Assert.assertFalse(filter.accept(createFSI(new File("test.xxx")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test1.txt")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test2.txt")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.a")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ab")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.abc")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.ABC")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aaa")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.Aaa")))); + Assert.assertTrue(filter.accept(createFileSelectInfo(new File("test.aAA")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.abcd")))); + Assert.assertFalse(filter.accept(createFileSelectInfo(new File("test.xxx")))); }