1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.jdiagnose.library;
17
18 import org.jdiagnose.DiagnosticUnit;
19
20 /***
21 * Ensures that a particular file is available on the classpath.
22 *
23 * User: jamie
24 * Date: May 31, 2004
25 * Time: 8:38:08 PM
26 */
27 public class ExistsOnClasspathDiagnostic extends DiagnosticUnit {
28
29 private String filename = null;
30
31 /***
32 * Create a new diagnostic with a fqn and a filename to check
33 * @param name the name of this diagnostic
34 * @param filename the filename to look for
35 */
36 public ExistsOnClasspathDiagnostic(String name, String filename) {
37 super(name);
38 this.filename = filename;
39 }
40
41 /***
42 * Default Constructor. Filename property MUST be set.
43 */
44 public ExistsOnClasspathDiagnostic() {
45 super();
46 }
47
48 /***
49 * Constructs a new diagnostic with a filename.
50 * @param filename the filename to look for
51 */
52 public ExistsOnClasspathDiagnostic(String filename) {
53 super();
54 this.filename = filename;
55 }
56
57 /***
58 * Checks for the existence of filename on the classpath.
59 */
60 public void diagnoseExistence() {
61 assertNotNull("filename property should not be null", filename);
62 assertNotNull(filename + " could not be found on the classpath",
63 this.getClass().getResource(filename));
64 }
65
66 /***
67 * @return Returns the filename.
68 */
69 public String getFilename() {
70 return filename;
71 }
72
73 /***
74 * @param filename The filename to set.
75 */
76 public void setFilename(String filename) {
77 this.filename = filename;
78 }
79 }