|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
WebappTestRunner.java | - | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* ====================================================================
|
|
3 |
*
|
|
4 |
* The Apache Software License, Version 1.1
|
|
5 |
*
|
|
6 |
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
|
|
7 |
* reserved.
|
|
8 |
*
|
|
9 |
* Redistribution and use in source and binary forms, with or without
|
|
10 |
* modification, are permitted provided that the following conditions
|
|
11 |
* are met:
|
|
12 |
*
|
|
13 |
* 1. Redistributions of source code must retain the above copyright
|
|
14 |
* notice, this list of conditions and the following disclaimer.
|
|
15 |
*
|
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17 |
* notice, this list of conditions and the following disclaimer in
|
|
18 |
* the documentation and/or other materials provided with the
|
|
19 |
* distribution.
|
|
20 |
*
|
|
21 |
* 3. The end-user documentation included with the redistribution, if
|
|
22 |
* any, must include the following acknowlegement:
|
|
23 |
* "This product includes software developed by the
|
|
24 |
* Apache Software Foundation (http://www.apache.org/)."
|
|
25 |
* Alternately, this acknowlegement may appear in the software itself,
|
|
26 |
* if and wherever such third-party acknowlegements normally appear.
|
|
27 |
*
|
|
28 |
* 4. The names "The Jakarta Project", "Cactus" and "Apache Software
|
|
29 |
* Foundation" must not be used to endorse or promote products
|
|
30 |
* derived from this software without prior written permission. For
|
|
31 |
* written permission, please contact apache@apache.org.
|
|
32 |
*
|
|
33 |
* 5. Products derived from this software may not be called "Apache"
|
|
34 |
* nor may "Apache" appear in their names without prior written
|
|
35 |
* permission of the Apache Group.
|
|
36 |
*
|
|
37 |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
38 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
39 |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
40 |
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
|
41 |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
42 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
43 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
44 |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
45 |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
46 |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
47 |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
48 |
* SUCH DAMAGE.
|
|
49 |
* ====================================================================
|
|
50 |
*
|
|
51 |
* This software consists of voluntary contributions made by many
|
|
52 |
* individuals on behalf of the Apache Software Foundation. For more
|
|
53 |
* information on the Apache Software Foundation, please see
|
|
54 |
* <http://www.apache.org/>.
|
|
55 |
*
|
|
56 |
*/
|
|
57 |
package org.apache.cactus.server.runner;
|
|
58 |
|
|
59 |
import junit.framework.AssertionFailedError;
|
|
60 |
import junit.framework.Test;
|
|
61 |
import junit.runner.BaseTestRunner;
|
|
62 |
import junit.runner.TestSuiteLoader;
|
|
63 |
|
|
64 |
/**
|
|
65 |
* JUnit Test Runner that can load test cases that are in the classpath of
|
|
66 |
* a webapp. This test runner is supposed to be executed from within the
|
|
67 |
* webapp.
|
|
68 |
*
|
|
69 |
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
|
70 |
*
|
|
71 |
* @version $Id: WebappTestRunner.java,v 1.5 2003/05/26 11:45:24 cmlenz Exp $
|
|
72 |
*/
|
|
73 |
public class WebappTestRunner extends BaseTestRunner |
|
74 |
{ |
|
75 |
/**
|
|
76 |
* Error message if the suite failed to load.
|
|
77 |
*/
|
|
78 |
private String errorMessage;
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Overridden from BaseTestRunner in order to use either the context
|
|
82 |
* class loader or the webapp one.
|
|
83 |
*
|
|
84 |
* @return a loader that loads classes using the context class loader or
|
|
85 |
* the webapp class loader.
|
|
86 |
*/
|
|
87 | 0 |
public TestSuiteLoader getLoader()
|
88 |
{ |
|
89 | 0 |
return new WebappTestSuiteLoader(); |
90 |
} |
|
91 |
|
|
92 |
/**
|
|
93 |
* Event called by the base test runner when it fails to load a test suite.
|
|
94 |
*
|
|
95 |
* @param theMessage the message of the failure
|
|
96 |
*/
|
|
97 | 0 |
protected void runFailed(String theMessage) |
98 |
{ |
|
99 | 0 |
this.errorMessage = theMessage;
|
100 |
} |
|
101 |
|
|
102 |
/**
|
|
103 |
* @return the error message provided by <code>BaseTestRunner</code> if it
|
|
104 |
* failed to load the test suite
|
|
105 |
*/
|
|
106 | 0 |
public String getErrorMessage()
|
107 |
{ |
|
108 | 0 |
return this.errorMessage; |
109 |
} |
|
110 |
|
|
111 |
/**
|
|
112 |
* Event called by the base test runner when the test ends.
|
|
113 |
*
|
|
114 |
* @param theTestName the test case name
|
|
115 |
*/
|
|
116 | 0 |
public void testEnded(String theTestName) |
117 |
{ |
|
118 |
// not used
|
|
119 |
} |
|
120 |
|
|
121 |
/**
|
|
122 |
* Event called by the base test runner when the test fails.
|
|
123 |
*
|
|
124 |
* @param theStatus the status code of the error
|
|
125 |
* @param theTest the test object that failed
|
|
126 |
* @param theThrowable the exception that was thrown
|
|
127 |
*/
|
|
128 | 0 |
public void testFailed(int theStatus, Test theTest, Throwable theThrowable) |
129 |
{ |
|
130 |
// not used
|
|
131 |
} |
|
132 |
|
|
133 |
/**
|
|
134 |
* Event called by the base test runner when the test starts.
|
|
135 |
*
|
|
136 |
* @param theTestName the test case name
|
|
137 |
*/
|
|
138 | 0 |
public void testStarted(String theTestName) |
139 |
{ |
|
140 |
// not used
|
|
141 |
} |
|
142 |
|
|
143 |
/**
|
|
144 |
* @see BaseTestRunner#addError(Test, Throwable)
|
|
145 |
*/
|
|
146 | 0 |
public void addError(Test theTest, Throwable theThrowable) |
147 |
{ |
|
148 |
// not used
|
|
149 |
} |
|
150 |
|
|
151 |
/**
|
|
152 |
* @see BaseTestRunner#addFailure(Test, AssertionFailedError)
|
|
153 |
*/
|
|
154 | 0 |
public void addFailure(Test theTest, |
155 |
AssertionFailedError theAssertionFailedError) |
|
156 |
{ |
|
157 |
// not used
|
|
158 |
} |
|
159 |
|
|
160 |
/**
|
|
161 |
* @see BaseTestRunner#endTest(Test)
|
|
162 |
*/
|
|
163 | 0 |
public void endTest(Test theTest) |
164 |
{ |
|
165 |
// not used
|
|
166 |
} |
|
167 |
|
|
168 |
/**
|
|
169 |
* @see BaseTestRunner#startTest(Test)
|
|
170 |
*/
|
|
171 | 0 |
public void startTest(Test theTest) |
172 |
{ |
|
173 |
// not used
|
|
174 |
} |
|
175 |
} |
|
176 |
|
|