Skip to content

Commit

Permalink
Camel-case parameter and internal names
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Oct 19, 2023
1 parent fea0ee8 commit 819cd6e
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public ValidatingObjectInputStream accept(final String... patterns) {
return this;
}

/**
/**
* Checks that the class name conforms to requirements.
*
* @param name The class name
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/apache/commons/io/DirectoryWalkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ protected boolean handleIsCancelled(final File file, final int depth, final Coll
private static final File outputDir = new File(ioDir, "output");
private static final File[] dirs = {orgDir, apacheDir, commonsDir, ioDir, outputDir};
// Files
private static final File filenameUtils = new File(ioDir, "FilenameUtils.java");
private static final File fileNameUtils = new File(ioDir, "FilenameUtils.java");

private static final File ioUtils = new File(ioDir, "IOUtils.java");
private static final File proxyWriter = new File(outputDir, "ProxyWriter.java");
private static final File nullStream = new File(outputDir, "NullOutputStream.java");
private static final File[] ioFiles = {filenameUtils, ioUtils};
private static final File[] ioFiles = {fileNameUtils, ioUtils};
private static final File[] outputFiles = {proxyWriter, nullStream};

// Filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,12 @@ protected boolean handleIsCancelled(final File file, final int depth, final Coll
private static final File outputDir = new File(ioDir, "output");
private static final File[] dirs = {orgDir, apacheDir, commonsDir, ioDir, outputDir};
// Files
private static final File filenameUtils = new File(ioDir, "FilenameUtils.java");
private static final File fileNameUtils = new File(ioDir, "FilenameUtils.java");
private static final File ioUtils = new File(ioDir, "IOUtils.java");

private static final File proxyWriter = new File(outputDir, "ProxyWriter.java");
private static final File nullStream = new File(outputDir, "NullOutputStream.java");
private static final File[] ioFiles = {filenameUtils, ioUtils};
private static final File[] ioFiles = {fileNameUtils, ioUtils};
private static final File[] outputFiles = {proxyWriter, nullStream};
// Filters
private static final IOFileFilter dirsFilter = createNameFilter(dirs);
Expand Down
86 changes: 43 additions & 43 deletions src/test/java/org/apache/commons/io/FileUtilsListFilesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,34 +97,34 @@ public void testIterateFilesByExtension() {

Iterator<File> files = FileUtils.iterateFiles(temporaryFolder, extensions, false);
try {
final Collection<String> filenames = filesToFilenames(files);
assertEquals(1, filenames.size());
assertTrue(filenames.contains("dummy-build.xml"));
assertFalse(filenames.contains("README"));
assertFalse(filenames.contains("dummy-file.txt"));
final Collection<String> fileNames = filesToFilenames(files);
assertEquals(1, fileNames.size());
assertTrue(fileNames.contains("dummy-build.xml"));
assertFalse(fileNames.contains("README"));
assertFalse(fileNames.contains("dummy-file.txt"));
} finally {
// Backstop in case filesToFilenames() failure.
files.forEachRemaining(Consumers.nop());
}

try {
files = FileUtils.iterateFiles(temporaryFolder, extensions, true);
final Collection<String> filenames = filesToFilenames(files);
assertEquals(4, filenames.size());
assertTrue(filenames.contains("dummy-file.txt"));
assertFalse(filenames.contains("dummy-index.html"));
final Collection<String> fileNames = filesToFilenames(files);
assertEquals(4, fileNames.size());
assertTrue(fileNames.contains("dummy-file.txt"));
assertFalse(fileNames.contains("dummy-index.html"));
} finally {
// Backstop in case filesToFilenames() failure.
files.forEachRemaining(Consumers.nop());
}

files = FileUtils.iterateFiles(temporaryFolder, null, false);
try {
final Collection<String> filenames = filesToFilenames(files);
assertEquals(2, filenames.size());
assertTrue(filenames.contains("dummy-build.xml"));
assertTrue(filenames.contains("README"));
assertFalse(filenames.contains("dummy-file.txt"));
final Collection<String> fileNames = filesToFilenames(files);
assertEquals(2, fileNames.size());
assertTrue(fileNames.contains("dummy-build.xml"));
assertTrue(fileNames.contains("README"));
assertFalse(fileNames.contains("dummy-file.txt"));
} finally {
// Backstop in case filesToFilenames() failure.
files.forEachRemaining(Consumers.nop());
Expand All @@ -134,45 +134,45 @@ public void testIterateFilesByExtension() {
@Test
public void testListFiles() {
Collection<File> files;
Collection<String> filenames;
Collection<String> fileNames;
IOFileFilter fileFilter;
IOFileFilter dirFilter;

// First, find non-recursively
fileFilter = FileFilterUtils.trueFileFilter();
files = FileUtils.listFiles(temporaryFolder, fileFilter, null);
filenames = filesToFilenames(files);
assertTrue(filenames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertFalse(filenames.contains("dummy-index.html"), "'dummy-index.html' shouldn't be found");
assertFalse(filenames.contains("Entries"), "'Entries' shouldn't be found");
fileNames = filesToFilenames(files);
assertTrue(fileNames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertFalse(fileNames.contains("dummy-index.html"), "'dummy-index.html' shouldn't be found");
assertFalse(fileNames.contains("Entries"), "'Entries' shouldn't be found");

// Second, find recursively
fileFilter = FileFilterUtils.trueFileFilter();
dirFilter = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("CVS"));
files = FileUtils.listFiles(temporaryFolder, fileFilter, dirFilter);
filenames = filesToFilenames(files);
assertTrue(filenames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertTrue(filenames.contains("dummy-index.html"), "'dummy-index.html' is missing");
assertFalse(filenames.contains("Entries"), "'Entries' shouldn't be found");
fileNames = filesToFilenames(files);
assertTrue(fileNames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertTrue(fileNames.contains("dummy-index.html"), "'dummy-index.html' is missing");
assertFalse(fileNames.contains("Entries"), "'Entries' shouldn't be found");

// Do the same as above but now with the filter coming from FileFilterUtils
fileFilter = FileFilterUtils.trueFileFilter();
dirFilter = FileFilterUtils.makeCVSAware(null);
files = FileUtils.listFiles(temporaryFolder, fileFilter, dirFilter);
filenames = filesToFilenames(files);
assertTrue(filenames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertTrue(filenames.contains("dummy-index.html"), "'dummy-index.html' is missing");
assertFalse(filenames.contains("Entries"), "'Entries' shouldn't be found");
fileNames = filesToFilenames(files);
assertTrue(fileNames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertTrue(fileNames.contains("dummy-index.html"), "'dummy-index.html' is missing");
assertFalse(fileNames.contains("Entries"), "'Entries' shouldn't be found");

// Again with the CVS filter but now with a non-null parameter
fileFilter = FileFilterUtils.trueFileFilter();
dirFilter = FileFilterUtils.prefixFileFilter("sub");
dirFilter = FileFilterUtils.makeCVSAware(dirFilter);
files = FileUtils.listFiles(temporaryFolder, fileFilter, dirFilter);
filenames = filesToFilenames(files);
assertTrue(filenames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertTrue(filenames.contains("dummy-index.html"), "'dummy-index.html' is missing");
assertFalse(filenames.contains("Entries"), "'Entries' shouldn't be found");
fileNames = filesToFilenames(files);
assertTrue(fileNames.contains("dummy-build.xml"), "'dummy-build.xml' is missing");
assertTrue(fileNames.contains("dummy-index.html"), "'dummy-index.html' is missing");
assertFalse(fileNames.contains("Entries"), "'Entries' shouldn't be found");

assertThrows(NullPointerException.class, () -> FileUtils.listFiles(temporaryFolder, null, null));
}
Expand All @@ -183,23 +183,23 @@ public void testListFilesByExtension() {

Collection<File> files = FileUtils.listFiles(temporaryFolder, extensions, false);
assertEquals(1, files.size());
Collection<String> filenames = filesToFilenames(files);
assertTrue(filenames.contains("dummy-build.xml"));
assertFalse(filenames.contains("README"));
assertFalse(filenames.contains("dummy-file.txt"));
Collection<String> fileNames = filesToFilenames(files);
assertTrue(fileNames.contains("dummy-build.xml"));
assertFalse(fileNames.contains("README"));
assertFalse(fileNames.contains("dummy-file.txt"));

files = FileUtils.listFiles(temporaryFolder, extensions, true);
filenames = filesToFilenames(files);
assertEquals(4, filenames.size());
assertTrue(filenames.contains("dummy-file.txt"));
assertFalse(filenames.contains("dummy-index.html"));
fileNames = filesToFilenames(files);
assertEquals(4, fileNames.size());
assertTrue(fileNames.contains("dummy-file.txt"));
assertFalse(fileNames.contains("dummy-index.html"));

files = FileUtils.listFiles(temporaryFolder, null, false);
assertEquals(2, files.size());
filenames = filesToFilenames(files);
assertTrue(filenames.contains("dummy-build.xml"));
assertTrue(filenames.contains("README"));
assertFalse(filenames.contains("dummy-file.txt"));
fileNames = filesToFilenames(files);
assertTrue(fileNames.contains("dummy-build.xml"));
assertTrue(fileNames.contains("README"));
assertFalse(fileNames.contains("dummy-file.txt"));
}


Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/apache/commons/io/FileUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ public void testDeleteQuietlyNonExistent() {
public void testFileUtils() throws Exception {
// Loads file from classpath
final File file1 = new File(tempDirFile, "test.txt");
final String filename = file1.getAbsolutePath();
final String fileName = file1.getAbsolutePath();

//Create test file on-the-fly (used to be in CVS)
try (OutputStream out = Files.newOutputStream(file1.toPath())) {
Expand All @@ -1445,16 +1445,16 @@ public void testFileUtils() throws Exception {

final File file2 = new File(tempDirFile, "test2.txt");

FileUtils.writeStringToFile(file2, filename, UTF_8);
FileUtils.writeStringToFile(file2, fileName, UTF_8);
assertTrue(file2.exists());
assertTrue(file2.length() > 0);

final String file2contents = FileUtils.readFileToString(file2, UTF_8);
assertEquals(filename, file2contents, "Second file's contents correct");
assertEquals(fileName, file2contents, "Second file's contents correct");

assertTrue(file2.delete());

final String contents = FileUtils.readFileToString(new File(filename), UTF_8);
final String contents = FileUtils.readFileToString(new File(fileName), UTF_8);
assertEquals("This is a test", contents, "FileUtils.fileRead()");

}
Expand Down Expand Up @@ -1629,8 +1629,8 @@ public void testIO300() {
@Test
public void testIO575() throws IOException {
final Path sourceDir = Files.createTempDirectory("source-dir");
final String filename = "some-file";
final Path sourceFile = Files.createFile(sourceDir.resolve(filename));
final String fileName = "some-file";
final Path sourceFile = Files.createFile(sourceDir.resolve(fileName));

assertEquals(SystemUtils.IS_OS_WINDOWS, sourceFile.toFile().canExecute());

Expand All @@ -1642,7 +1642,7 @@ public void testIO575() throws IOException {

FileUtils.copyDirectory(sourceDir.toFile(), destDir.toFile());

final Path destFile = destDir.resolve(filename);
final Path destFile = destDir.resolve(fileName);

assertTrue(destFile.toFile().exists());
assertTrue(destFile.toFile().canExecute());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void testFilterBuiltUsingAdd() {
final boolean[] trueResults = testTrueResults.get(i);
final boolean[] falseResults = testFalseResults.get(i);
final boolean fileResults = testFileResults.get(i);
final boolean filenameResults = testFilenameResults.get(i);
final boolean fileNameResults = testFilenameResults.get(i);

// Test conditional AND filter created by passing filters to the constructor
final IOFileFilter filter = this.buildFilterUsingAdd(filters);
Expand All @@ -116,10 +116,10 @@ public void testFilterBuiltUsingAdd() {
assertTrueFiltersInvoked(i, trueFilters, trueResults);
assertFalseFiltersInvoked(i, falseFilters, falseResults);

// Test as a filename filter
// Test as a file name filter
resetTrueFilters(this.trueFilters);
resetFalseFilters(this.falseFilters);
assertFilenameFiltering(i, filter, this.file, filenameResults);
assertFilenameFiltering(i, filter, this.file, fileNameResults);
assertTrueFiltersInvoked(i, trueFilters, trueResults);
assertFalseFiltersInvoked(i, falseFilters, falseResults);
}
Expand All @@ -138,7 +138,7 @@ public void testFilterBuiltUsingConstructor() {
final boolean[] trueResults = testTrueResults.get(i);
final boolean[] falseResults = testFalseResults.get(i);
final boolean fileResults = testFileResults.get(i);
final boolean filenameResults = testFilenameResults.get(i);
final boolean fileNameResults = testFilenameResults.get(i);

// Test conditional AND filter created by passing filters to the constructor
final IOFileFilter filter = this.buildFilterUsingConstructor(filters);
Expand All @@ -150,10 +150,10 @@ public void testFilterBuiltUsingConstructor() {
assertTrueFiltersInvoked(i, trueFilters, trueResults);
assertFalseFiltersInvoked(i, falseFilters, falseResults);

// Test as a filename filter
// Test as a file name filter
resetTrueFilters(this.trueFilters);
resetFalseFilters(this.falseFilters);
assertFilenameFiltering(i, filter, this.file, filenameResults);
assertFilenameFiltering(i, filter, this.file, fileNameResults);
assertTrueFiltersInvoked(i, trueFilters, trueResults);
assertFalseFiltersInvoked(i, falseFilters, falseResults);
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/apache/commons/io/test/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ public static void generateTestData(final OutputStream out, final long size) thr
}
}

public static File newFile(final File testDirectory, final String filename) throws IOException {
final File destination = new File(testDirectory, filename);
public static File newFile(final File testDirectory, final String fileName) throws IOException {
final File destination = new File(testDirectory, fileName);
/*
assertTrue( filename + "Test output data file shouldn't previously exist",
!destination.exists() );
assertTrue(fileName + "Test output data file shouldn't previously exist",
!destination.exists());
*/
if (destination.exists()) {
FileUtils.forceDelete(destination);
Expand Down

0 comments on commit 819cd6e

Please sign in to comment.