Skip to content

Commit 0ec666a

Browse files
committed
More tests added to FileFilter, Demux fixed to use right package names.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140332 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8386997 commit 0ec666a

3 files changed

Lines changed: 45 additions & 14 deletions

File tree

src/test/org/apache/commons/io/DemuxTestCase.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/DemuxTestCase.java,v 1.4 2002/11/12 07:57:46 bayard Exp $
3-
* $Revision: 1.4 $
4-
* $Date: 2002/11/12 07:57:46 $
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/DemuxTestCase.java,v 1.5 2002/12/07 20:27:39 bayard Exp $
3+
* $Revision: 1.5 $
4+
* $Date: 2002/12/07 20:27:39 $
55
*
66
* ====================================================================
77
*
@@ -71,6 +71,9 @@
7171
import java.util.Random;
7272
import junit.framework.TestCase;
7373

74+
import org.apache.commons.io.output.DemuxOutputStream;
75+
import org.apache.commons.io.input.DemuxInputStream;
76+
7477
/**
7578
* Basic unit tests for the multiplexing streams.
7679
*

src/test/org/apache/commons/io/IOTestSuite.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/Attic/IOTestSuite.java,v 1.1 2002/07/08 22:19:10 nicolaken Exp $
3-
* $Revision: 1.1 $
4-
* $Date: 2002/07/08 22:19:10 $
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/Attic/IOTestSuite.java,v 1.2 2002/12/07 20:27:39 bayard Exp $
3+
* $Revision: 1.2 $
4+
* $Date: 2002/12/07 20:27:39 $
55
*
66
* ====================================================================
77
*
@@ -72,7 +72,7 @@ public class IOTestSuite
7272
public static Test suite()
7373
{
7474
final TestSuite suite = new TestSuite( "IO Utilities" );
75-
suite.addTest( new TestSuite( FileUtilTestCase.class ) );
75+
suite.addTest( new TestSuite( FileUtilsTestCase.class ) );
7676
suite.addTest( new TestSuite( IOUtilTestCase.class ) );
7777
return suite;
7878
}

src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
2-
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java,v 1.1 2002/11/12 08:05:12 bayard Exp $
3-
* $Revision: 1.1 $
4-
* $Date: 2002/11/12 08:05:12 $
2+
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//io/src/test/org/apache/commons/io/filefilter/FileFilterTestCase.java,v 1.2 2002/12/07 20:27:39 bayard Exp $
3+
* $Revision: 1.2 $
4+
* $Date: 2002/12/07 20:27:39 $
55
*
66
* ====================================================================
77
*
@@ -89,11 +89,19 @@ public FileFilterTestCase( String name )
8989
public void assertFiltering(FileFilter filter, File file, boolean expected)
9090
throws Exception
9191
{
92+
// Note. This only tests the (File, String) version if the parent of
93+
// the File passed in is not null
9294
assertTrue(
93-
"Filter "+filter.getClass().getName()+" not "+expected+" for "+file,
95+
"Filter(File) "+filter.getClass().getName()+" not "+expected+" for "+file,
9496
(filter.accept(file) == expected)
95-
&& (filter.accept(file.getParentFile(), file.getName()) == expected)
96-
);
97+
);
98+
99+
if(file.getParentFile() != null) {
100+
assertTrue(
101+
"Filter(File, String) "+filter.getClass().getName()+" not "+expected+" for "+file,
102+
(filter.accept(file.getParentFile(), file.getName()) == expected)
103+
);
104+
}
97105
}
98106

99107
public void testExtension() throws Exception {
@@ -108,5 +116,25 @@ public void testExtension() throws Exception {
108116
assertFiltering( filter, new File("fred.test"), true);
109117
}
110118

111-
}
119+
public void testNull() throws Exception {
120+
FileFilter filter = new NullFileFilter();
121+
assertFiltering( filter, new File("foo.test"), true);
122+
assertFiltering( filter, new File("foo"), true);
123+
assertFiltering( filter, new File(""), true);
124+
}
125+
126+
public void testPrefix() throws Exception {
127+
FileFilter filter = new PrefixFileFilter("foo");
128+
assertFiltering( filter, new File("foo.test"), true);
129+
assertFiltering( filter, new File("foo"), true);
130+
assertFiltering( filter, new File("bar"), false);
131+
}
132+
133+
public void testDirectory() throws Exception {
134+
FileFilter filter = new DirectoryFileFilter();
135+
assertFiltering( filter, new File("src/"), true);
136+
assertFiltering( filter, new File("project.xml"), false);
137+
assertFiltering( filter, new File("src/java/"), true);
138+
}
112139

140+
}

0 commit comments

Comments
 (0)