diff options
| author | Arnaud Simon <arnaudsimon@apache.org> | 2008-03-26 10:03:56 +0000 |
|---|---|---|
| committer | Arnaud Simon <arnaudsimon@apache.org> | 2008-03-26 10:03:56 +0000 |
| commit | 81b9ca9afea383a4295f1bc8916b8a5ab684d9bf (patch) | |
| tree | 9d130b9ce667aedc09bc31c5b544fb6fa2e33f2f /java/client/src/test | |
| parent | 4338fb589c1874555c2381e7a63e8fa7ead93f66 (diff) | |
| download | qpid-python-81b9ca9afea383a4295f1bc8916b8a5ab684d9bf.tar.gz | |
Qpid-860: provides support for specifying a list of test to be excluded
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@641232 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/client/src/test')
| -rw-r--r-- | java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java b/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java index 4a8d74ff87..d89180e640 100644 --- a/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java +++ b/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java @@ -18,11 +18,14 @@ package org.apache.qpid.testutil; import junit.framework.TestCase; +import junit.framework.TestResult; import javax.jms.Connection; import javax.naming.InitialContext; -import java.io.InputStream; -import java.io.IOException; +import java.io.*; +import java.util.List; +import java.util.ArrayList; +import java.util.StringTokenizer; import org.apache.qpid.client.transport.TransportConnection; import org.apache.qpid.client.AMQConnection; @@ -41,6 +44,63 @@ public class QpidTestCase extends TestCase private static final Logger _logger = LoggerFactory.getLogger(QpidTestCase.class); + /** + * Some tests are excluded when the property test.excludes is set to true. + * An exclusion list is either a file (prop test.excludesfile) which contains one test name + * to be excluded per line or a String (prop test.excludeslist) where tests to be excluded are + * separated by " ". Excluded tests are specified following the format: + * className#testName where className is the class of the test to be + * excluded and testName is the name of the test to be excluded. + * className#* excludes all the tests of the specified class. + */ + static + { + if (Boolean.getBoolean("test.excludes")) + { + _logger.info("Some tests should be excluded, building the exclude list"); + String exclusionListURI = System.getProperties().getProperty("test.excludesfile", ""); + String exclusionListString = System.getProperties().getProperty("test.excludeslist", ""); + File file=new File(exclusionListURI); + List<String> exclusionList = new ArrayList<String>(); + if (file.exists()) + { + _logger.info("Using exclude file: " + exclusionListURI); + try + { + BufferedReader in = new BufferedReader(new FileReader(file)); + String excludedTest = in.readLine(); + do + { + exclusionList.add(excludedTest); + excludedTest = in.readLine(); + } + while (excludedTest != null); + } + catch (IOException e) + { + _logger.warn("Exception when reading exclusion list", e); + } + } + else if( ! exclusionListString.equals("")) + { + _logger.info("Using excludeslist: " + exclusionListString); + // the exclusion list may be specified as a string + StringTokenizer t = new StringTokenizer(exclusionListString, " "); + while (t.hasMoreTokens()) + { + exclusionList.add(t.nextToken()); + } + } + else + { + throw new RuntimeException("Aborting test: Cannot find excludes file nor excludes list"); + } + _exclusionList = exclusionList; + } + } + + private static List<String> _exclusionList; + // system properties private static final String BROKER = "broker"; private static final String BROKER_CLEAN = "broker.clean"; @@ -84,6 +144,21 @@ public class QpidTestCase extends TestCase } } + public void run(TestResult testResult) + { + if( _exclusionList != null && _exclusionList.contains( getClass().getName() + "#*") || + _exclusionList.contains( getClass().getName() + "#" + getName())) + { + _logger.info("Test: " + getName() + " is excluded"); + testResult.endTest(this); + } + else + { + super.run(testResult); + } + } + + private static final class Piper extends Thread { |
