Skip to content

Commit 4e21cef

Browse files
author
prepicky
committed
Modified the FileFinderTest class so that it covers the case of a file not existing.
git-svn-id: file:///tmp/test-svn/trunk@2852 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent fb1ec5a commit 4e21cef

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed

dynamicjava/src/koala/Version.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* This file is copied to Version.java by the build process, which also
5454
* fills in the right values of the date and time.
5555
*
56-
* This javadoc corresponds to build drjava-20050129-0346;
56+
* This javadoc corresponds to build drjava-20050131-2103;
5757
*
5858
* @version $Id$
5959
*/
@@ -62,7 +62,7 @@ public abstract class Version {
6262
* This string will be automatically expanded upon "ant commit".
6363
* Do not edit it by hand!
6464
*/
65-
private static final String BUILD_TIME_STRING = "20050129-0346";
65+
private static final String BUILD_TIME_STRING = "20050131-2103";
6666

6767
/** A {@link Date} version of the build time. */
6868
private static final Date BUILD_TIME = _getBuildDate();
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*BEGIN_COPYRIGHT_BLOCK
2+
*
3+
* This file is part of DrJava. Download the current version of this project:
4+
* http://sourceforge.net/projects/drjava/ or http://www.drjava.org/
5+
*
6+
* DrJava Open Source License
7+
*
8+
* Copyright (C) 2001-2003 JavaPLT group at Rice University (javaplt@rice.edu)
9+
* All rights reserved.
10+
*
11+
* Developed by: Java Programming Languages Team
12+
* Rice University
13+
* http://www.cs.rice.edu/~javaplt/
14+
*
15+
* Permission is hereby granted, free of charge, to any person obtaining a
16+
* copy of this software and associated documentation files (the "Software"),
17+
* to deal with the Software without restriction, including without
18+
* limitation the rights to use, copy, modify, merge, publish, distribute,
19+
* sublicense, and/or sell copies of the Software, and to permit persons to
20+
* whom the Software is furnished to do so, subject to the following
21+
* conditions:
22+
*
23+
* - Redistributions of source code must retain the above copyright
24+
* notice, this list of conditions and the following disclaimers.
25+
* - Redistributions in binary form must reproduce the above copyright
26+
* notice, this list of conditions and the following disclaimers in the
27+
* documentation and/or other materials provided with the distribution.
28+
* - Neither the names of DrJava, the JavaPLT, Rice University, nor the
29+
* names of its contributors may be used to endorse or promote products
30+
* derived from this Software without specific prior written permission.
31+
* - Products derived from this software may not be called "DrJava" nor
32+
* use the term "DrJava" as part of their names without prior written
33+
* permission from the JavaPLT group. For permission, write to
34+
* javaplt@rice.edu.
35+
*
36+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
37+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
38+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
39+
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
40+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
41+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
42+
* OTHER DEALINGS WITH THE SOFTWARE.
43+
*
44+
END_COPYRIGHT_BLOCK*/
45+
46+
package koala.dynamicjava.util;
47+
48+
import java.io.*;
49+
import java.util.*;
50+
import junit.framework.TestCase;
51+
52+
/**
53+
* Tests the FileFinder class by attempting to find two files, one that does exist and one that does not exist
54+
*/
55+
public class FileFinderTest extends TestCase
56+
{
57+
private FileFinder ff = new FileFinder();
58+
59+
public FileFinderTest(){}
60+
61+
public void testFindFile()
62+
{
63+
File thisFile;
64+
File noFile;
65+
66+
//When running the ant script for testing this is the relative path to the directory that contains this file
67+
ff.addPath("dynamicjava/util/");
68+
69+
//Try to find a file that does exist, namely this current file
70+
try
71+
{
72+
thisFile = ff.findFile("FileFinderTest.java");
73+
assertTrue("Found This File", thisFile != null);
74+
}
75+
catch(IOException ioe)
76+
{
77+
fail();
78+
}
79+
80+
//Try to find a file that does not exist
81+
try
82+
{
83+
noFile = ff.findFile("file.doesnotexist");
84+
fail();
85+
}
86+
catch(IOException fnf)
87+
{
88+
assertEquals("File Not Found", "File Not Found: file.doesnotexist", fnf.getMessage());
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)