KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cactus > internal > server > runner > WebappTestRunner


1 /*
2  * ========================================================================
3  *
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * ========================================================================
19  */

20 package org.apache.cactus.internal.server.runner;
21
22 import junit.framework.AssertionFailedError;
23 import junit.framework.Test;
24 import junit.runner.BaseTestRunner;
25 import junit.runner.TestSuiteLoader;
26
27 /**
28  * JUnit Test Runner that can load test cases that are in the classpath of
29  * a webapp. This test runner is supposed to be executed from within the
30  * webapp.
31  *
32  * @version $Id: WebappTestRunner.java,v 1.1 2004/05/22 11:34:46 vmassol Exp $
33  */

34 public class WebappTestRunner extends BaseTestRunner
35 {
36     /**
37      * Error message if the suite failed to load.
38      */

39     private String JavaDoc errorMessage;
40
41     /**
42      * Overridden from BaseTestRunner in order to use either the context
43      * class loader or the webapp one.
44      *
45      * @return a loader that loads classes using the context class loader or
46      * the webapp class loader.
47      */

48     public TestSuiteLoader getLoader()
49     {
50         return new WebappTestSuiteLoader();
51     }
52
53     /**
54      * Event called by the base test runner when it fails to load a test suite.
55      *
56      * @param theMessage the message of the failure
57      */

58     protected void runFailed(String JavaDoc theMessage)
59     {
60         this.errorMessage = theMessage;
61     }
62
63     /**
64      * @return the error message provided by <code>BaseTestRunner</code> if it
65      * failed to load the test suite
66      */

67     public String JavaDoc getErrorMessage()
68     {
69         return this.errorMessage;
70     }
71
72     /**
73      * Event called by the base test runner when the test ends.
74      *
75      * @param theTestName the test case name
76      */

77     public void testEnded(String JavaDoc theTestName)
78     {
79         // not used
80
}
81
82     /**
83      * Event called by the base test runner when the test fails.
84      *
85      * @param theStatus the status code of the error
86      * @param theTest the test object that failed
87      * @param theThrowable the exception that was thrown
88      */

89     public void testFailed(int theStatus, Test theTest, Throwable JavaDoc theThrowable)
90     {
91         // not used
92
}
93
94     /**
95      * Event called by the base test runner when the test starts.
96      *
97      * @param theTestName the test case name
98      */

99     public void testStarted(String JavaDoc theTestName)
100     {
101         // not used
102
}
103
104     /**
105      * @see BaseTestRunner#addError(Test, Throwable)
106      */

107     public void addError(Test theTest, Throwable JavaDoc theThrowable)
108     {
109         // not used
110
}
111
112     /**
113      * @see BaseTestRunner#addFailure(Test, AssertionFailedError)
114      */

115     public void addFailure(Test theTest,
116         AssertionFailedError theAssertionFailedError)
117     {
118         // not used
119
}
120
121     /**
122      * @see BaseTestRunner#endTest(Test)
123      */

124     public void endTest(Test theTest)
125     {
126         // not used
127
}
128
129     /**
130      * @see BaseTestRunner#startTest(Test)
131      */

132     public void startTest(Test theTest)
133     {
134         // not used
135
}
136 }
137
Popular Tags