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 | fcd5aa1d233bfade137eb6a4b30401fac9efce7b (patch) | |
| tree | 2104cc916311cb2f6fcba550dcba09daf113894d /qpid/java/client/src/test | |
| parent | 57e5c24a68c69080e7556e8fc53e0c5e7264a2d4 (diff) | |
| download | qpid-python-fcd5aa1d233bfade137eb6a4b30401fac9efce7b.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@641232 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/client/src/test')
| -rw-r--r-- | qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java b/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java index 4a8d74ff87..d89180e640 100644 --- a/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidTestCase.java +++ b/qpid/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 { |
