001: package jdepend.framework;
002:
003: import java.io.File;
004: import java.io.IOException;
005:
006: /**
007: * @author <b>Mike Clark</b>
008: * @author Clarkware Consulting, Inc.
009: */
010:
011: public class FileManagerTest extends JDependTestCase {
012:
013: private FileManager fileManager;
014:
015: public FileManagerTest(String name) {
016: super (name);
017: }
018:
019: protected void setUp() {
020: super .setUp();
021: fileManager = new FileManager();
022: fileManager.acceptInnerClasses(false);
023: }
024:
025: protected void tearDown() {
026: super .tearDown();
027: }
028:
029: public void testEmptyFileManager() {
030: assertEquals(0, fileManager.extractFiles().size());
031: }
032:
033: public void testBuildDirectory() throws IOException {
034: fileManager.addDirectory(getBuildDir());
035: assertEquals(39, fileManager.extractFiles().size());
036: }
037:
038: public void testNonExistentDirectory() {
039:
040: try {
041:
042: fileManager.addDirectory(getBuildDir() + "junk");
043: fail("Non-existent directory: Should raise IOException");
044:
045: } catch (IOException expected) {
046: assertTrue(true);
047: }
048: }
049:
050: public void testInvalidDirectory() {
051:
052: String file = getTestDir() + getPackageSubDir()
053: + "ExampleTest.java";
054:
055: try {
056:
057: fileManager.addDirectory(file);
058: fail("Invalid directory: Should raise IOException");
059:
060: } catch (IOException expected) {
061: assertTrue(true);
062: }
063: }
064:
065: public void testClassFile() throws IOException {
066:
067: File f = new File(getBuildDir() + getPackageSubDir()
068: + "JDepend.class");
069:
070: assertEquals(true, new FileManager().acceptClassFile(f));
071: }
072:
073: public void testNonExistentClassFile() {
074: File f = new File(getBuildDir() + "JDepend.class");
075: assertEquals(false, new FileManager().acceptClassFile(f));
076: }
077:
078: public void testInvalidClassFile() {
079: File f = new File(getHomeDir() + "build.xml");
080: assertEquals(false, new FileManager().acceptClassFile(f));
081: }
082:
083: public void testJar() throws IOException {
084: File f = File.createTempFile("bogus", ".jar", new File(
085: getTestDataDir()));
086: fileManager.addDirectory(f.getPath());
087: f.deleteOnExit();
088: }
089:
090: public void testZip() throws IOException {
091: File f = File.createTempFile("bogus", ".zip", new File(
092: getTestDataDir()));
093: fileManager.addDirectory(f.getPath());
094: f.deleteOnExit();
095: }
096:
097: public void testWar() throws IOException {
098: File f = File.createTempFile("bogus", ".war", new File(
099: getTestDataDir()));
100: fileManager.addDirectory(f.getPath());
101: f.deleteOnExit();
102: }
103: }
|