1 /***
2 * Redistribution and use of this software and associated documentation
3 * ("Software"), with or without modification, are permitted provided
4 * that the following conditions are met:
5 *
6 * 1. Redistributions of source code must retain copyright
7 * statements and notices. Redistributions must also contain a
8 * copy of this document.
9 *
10 * 2. Redistributions in binary form must reproduce the
11 * above copyright notice, this list of conditions and the
12 * following disclaimer in the documentation and/or other
13 * materials provided with the distribution.
14 *
15 * 3. The name "Exolab" must not be used to endorse or promote
16 * products derived from this Software without prior written
17 * permission of Exoffice Technologies. For written permission,
18 * please contact tma@netspace.net.au.
19 *
20 * 4. Products derived from this Software may not be called "Exolab"
21 * nor may "Exolab" appear in their names without prior written
22 * permission of Exoffice Technologies. Exolab is a registered
23 * trademark of Exoffice Technologies.
24 *
25 * 5. Due credit should be given to the Exolab Project
26 * (http://www.exolab.org/).
27 *
28 * THIS SOFTWARE IS PROVIDED BY EXOFFICE TECHNOLOGIES AND CONTRIBUTORS
29 * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
30 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
31 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
32 * EXOFFICE TECHNOLOGIES OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
33 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
35 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
37 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
39 * OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Copyright 2001-2004 (C) Exoffice Technologies Inc. All Rights Reserved.
42 *
43 * $Id: JMSTestRunner.java,v 1.7 2004/01/31 13:44:24 tanderson Exp $
44 */
45 package org.exolab.jmscts.core;
46
47 import junit.framework.Test;
48 import junit.framework.TestResult;
49
50 import org.apache.log4j.Category;
51
52 import org.exolab.jmscts.report.CoverageReport;
53 import org.exolab.jmscts.requirements.Requirements;
54 import org.exolab.jmscts.requirements.RequirementsLoader;
55 import org.exolab.jmscts.provider.ProviderLoader;
56
57
58 /***
59 * This class enables test cases to be run against different JMS providers
60 * <p>
61 * The provider configuration file path is passed at construction. This
62 * contains a list of providers to run the tests against.
63 * <p>
64 * <h3>Parameters</h3>
65 * <table border="1" cellpadding="2" cellspacing="0">
66 * <tr>
67 * <td valign="top"><b>Argument</b></td>
68 * <td valign="top"><b>Description</b></td>
69 * <td align="center" valign="top"><b>Required</b></td>
70 * </tr>
71 * <tr>
72 * <td valign="top">config</td>
73 * <td valign="top">the provider configuration file path</td>
74 * <td valign="top" align="center">No</td>
75 * </tr>
76 * <tr>
77 * <td valign="top">output</td>
78 * <td valign="top">the coverage report output directory</td>
79 * <td valign="top" align="center">No</td>
80 * </tr>
81 * <tr>
82 * <td valign="top">filter</td>
83 * <td valign="top">the test filter configuration file path</td>
84 * <td valign="top" align="center">No</td>
85 * </tr>
86 * <tr>
87 * <td valign="top">port</td>
88 * <td valign="top">the registry port</td>
89 * <td valign="top" align="center">No</td>
90 * </tr>
91 * </table>
92 *
93 * @version $Revision: 1.7 $ $Date: 2004/01/31 13:44:24 $
94 * @author <a href="mailto:tma@netspace.net.au">Tim Anderson</a>
95 */
96 public class JMSTestRunner extends AbstractTestRunner {
97
98 /***
99 * The requirements
100 */
101 private Requirements _requirements;
102
103 /***
104 * Tracks the test suite's coverage of requirements
105 */
106 private TestCoverage _coverage;
107
108 /***
109 * The logger
110 */
111 private static final Category log =
112 Category.getInstance(JMSTestRunner.class.getName());
113
114
115 /***
116 * Construct an instance using the class of the test case, and the list
117 * of arguments to configure the test suite
118 *
119 * @param test a class implementing the {@link ConnectionFactoryTestCase}
120 * and {@link junit.framework.Test} interfaces
121 * @param args command line arguments
122 */
123 public JMSTestRunner(Class test, String[] args) {
124 super(test, args);
125 }
126
127 /***
128 * Construct an instance with the test to run, and the list of arguments
129 * to configure the test suite
130 *
131 * @param test the test to run
132 * @param args command line arguments
133 */
134 public JMSTestRunner(Test test, String[] args) {
135 super(test, args);
136 }
137
138 /***
139 * Generate a coverage report, writing it out to the specified
140 * path
141 *
142 * @param path the path to write the report
143 * @throws Exception if the report can't be written, or the test
144 * isn't running
145 */
146 public void report(String path) throws Exception {
147 ProviderLoader provider = getProvider();
148 if (_coverage != null && provider != null) {
149 CoverageReport report = new CoverageReport(
150 getHome(), _coverage, provider);
151 report.report(path);
152 } else {
153 throw new Exception("The test is not running");
154 }
155 }
156
157 /***
158 * Runs the test case against each provider
159 *
160 * @param result the instance to collect results in
161 */
162 public void basicRun(TestResult result) {
163 // set up the handler to record test coverage of requirements
164 TestCoverageListener listener = new TestCoverageListener(_coverage);
165 result.addListener(listener);
166 super.basicRun(result);
167 }
168
169 /***
170 * Creates a test context
171 *
172 * @return a new test context
173 */
174 public TestContext createContext() {
175 return new TestContext(_coverage);
176 }
177
178 /***
179 * Reads the provider configuration
180 *
181 * @throws Exception if the configuration cannot be initialised
182 */
183 protected void setUp() throws Exception {
184 // load the requirements
185 _requirements = RequirementsLoader.load();
186 _coverage = new TestCoverage(_requirements);
187
188 super.setUp();
189 }
190
191 }
This page was automatically generated by Maven