View Javadoc
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 2003-2004 (C) Exoffice Technologies Inc. All Rights Reserved. 42 * 43 * $Id: StressTestRunner.java,v 1.3 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.provider.ProviderLoader; 53 import org.exolab.jmscts.report.StatisticsReport; 54 55 56 /*** 57 * This class enables stress test cases to be run against different JMS 58 * providers 59 * <p> 60 * The provider configuration file path is passed at construction. This 61 * contains a list of providers to run the tests against. 62 * <p> 63 * <h3>Parameters</h3> 64 * <table border="1" cellpadding="2" cellspacing="0"> 65 * <tr> 66 * <td valign="top"><b>Argument</b></td> 67 * <td valign="top"><b>Description</b></td> 68 * <td align="center" valign="top"><b>Required</b></td> 69 * </tr> 70 * <tr> 71 * <td valign="top">config</td> 72 * <td valign="top">the provider configuration file path</td> 73 * <td valign="top" align="center">No</td> 74 * </tr> 75 * <tr> 76 * <td valign="top">output</td> 77 * <td valign="top">the coverage report output directory</td> 78 * <td valign="top" align="center">No</td> 79 * </tr> 80 * <tr> 81 * <td valign="top">filter</td> 82 * <td valign="top">the test filter configuration file path</td> 83 * <td valign="top" align="center">No</td> 84 * </tr> 85 * <tr> 86 * <td valign="top">port</td> 87 * <td valign="top">the registry port</td> 88 * <td valign="top" align="center">No</td> 89 * </tr> 90 * </table> 91 * 92 * @version $Revision: 1.3 $ $Date: 2004/01/31 13:44:24 $ 93 * @author <a href="mailto:tma@netspace.net.au">Tim Anderson</a> 94 */ 95 public class StressTestRunner extends AbstractTestRunner { 96 97 /*** 98 * Stress test statistics 99 */ 100 private final TestStatistics _statistics = new TestStatistics(); 101 102 /*** 103 * The logger 104 */ 105 private static final Category log = 106 Category.getInstance(StressTestRunner.class); 107 108 109 /*** 110 * Construct an instance using the class of the test case, and the list 111 * of arguments to configure the provider 112 * 113 * @param test a class implementing the {@link ConnectionFactoryTestCase} 114 * and {@link junit.framework.Test} interfaces 115 * @param args command line arguments 116 */ 117 public StressTestRunner(Class test, String[] args) { 118 super(test, args); 119 } 120 121 /*** 122 * Construct an instance with the test to run, and the list of arguments 123 * to configure test suite. 124 * 125 * @param test the test to run 126 * @param args command line arguments 127 */ 128 public StressTestRunner(Test test, String[] args) { 129 super(test, args); 130 } 131 132 /*** 133 * Generate a stress test report, writing it out to the specified 134 * path 135 * 136 * @param path the path to write the report 137 * @throws Exception if the report can't be written, or the test 138 * isn't running 139 */ 140 public void report(String path) throws Exception { 141 ProviderLoader provider = getProvider(); 142 if (provider != null) { 143 StatisticsReport report = new StatisticsReport( 144 getHome(), _statistics, provider); 145 report.report(path); 146 } else { 147 throw new Exception("The test is not running"); 148 } 149 } 150 151 /*** 152 * Runs the test cases against each provider 153 * 154 * @param result the instance to collect results in 155 */ 156 public void basicRun(TestResult result) { 157 // set up the handler to record statistics 158 TestStatisticsListener listener = 159 new TestStatisticsListener(_statistics); 160 result.addListener(listener); 161 super.basicRun(result); 162 } 163 164 /*** 165 * Creates a test context 166 * 167 * @return a new test context 168 */ 169 public TestContext createContext() { 170 return new TestContext(_statistics); 171 } 172 173 }

This page was automatically generated by Maven