From 1174cc933de08ef7e8d2527b043d966f5611e92d Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Fri, 6 Aug 2010 14:26:48 +0000 Subject: QPID-2787: Move QpidTestCase to Common test module so that any test can inherit from it, allowing exclusions to be applied. Add ability to gather the class name of the message store associated with the test profile in use. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@982986 13f79535-47bb-0310-9956-ffa450edef68 --- java/broker-plugins/experimental/info/build.xml | 2 +- .../qpid/server/util/InternalBrokerBaseCase.java | 4 +- .../org/apache/qpid/test/utils/QpidTestCase.java | 130 +++++++++++++++++++++ java/integrationtests/build.xml | 2 +- java/module.xml | 1 + java/perftests/build.xml | 2 +- .../org/apache/qpid/test/utils/QpidTestCase.java | 120 ------------------- java/test-profiles/default.testprofile | 3 +- java/test-profiles/java-derby.0.10.testprofile | 1 + java/test-profiles/java-derby.testprofile | 1 + 10 files changed, 140 insertions(+), 126 deletions(-) create mode 100644 java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java delete mode 100644 java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java (limited to 'java') diff --git a/java/broker-plugins/experimental/info/build.xml b/java/broker-plugins/experimental/info/build.xml index caf4b138a4..c5881aa839 100644 --- a/java/broker-plugins/experimental/info/build.xml +++ b/java/broker-plugins/experimental/info/build.xml @@ -21,7 +21,7 @@ nn - or more contributor license agreements. See the NOTICE file - + diff --git a/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java b/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java index f731988a8e..99053ca45a 100644 --- a/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java +++ b/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java @@ -20,7 +20,6 @@ */ package org.apache.qpid.server.util; -import junit.framework.TestCase; import org.apache.commons.configuration.XMLConfiguration; import org.apache.qpid.AMQException; import org.apache.qpid.common.AMQPFilterTypes; @@ -44,10 +43,11 @@ import org.apache.qpid.server.registry.IApplicationRegistry; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.TestableMemoryMessageStore; import org.apache.qpid.server.virtualhost.VirtualHost; +import org.apache.qpid.test.utils.QpidTestCase; import org.apache.qpid.util.MockChannel; -public class InternalBrokerBaseCase extends TestCase +public class InternalBrokerBaseCase extends QpidTestCase { protected IApplicationRegistry _registry; protected MessageStore _messageStore; diff --git a/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java b/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java new file mode 100644 index 0000000000..8b470d555e --- /dev/null +++ b/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java @@ -0,0 +1,130 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.qpid.test.utils; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; +import junit.framework.TestResult; + +import org.apache.log4j.Logger; + +public class QpidTestCase extends TestCase +{ + protected static final Logger _logger = Logger.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.exclude")) + { + _logger.info("Some tests should be excluded, building the exclude list"); + String exclusionListURIs = System.getProperties().getProperty("test.excludefiles", ""); + String exclusionListString = System.getProperties().getProperty("test.excludelist", ""); + List exclusionList = new ArrayList(); + + for (String uri : exclusionListURIs.split("\\s+")) + { + File file = new File(uri); + if (file.exists()) + { + _logger.info("Using exclude file: " + uri); + 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); + } + } + } + + if (!exclusionListString.equals("")) + { + _logger.info("Using excludeslist: " + exclusionListString); + for (String test : exclusionListString.split("\\s+")) + { + exclusionList.add(test); + } + } + + _exclusionList = exclusionList; + } + } + + protected static final String MS_CLASS_NAME_KEY = "messagestore.class.name"; + protected static final String MEMORY_STORE_CLASS_NAME = "org.apache.qpid.server.store.MemoryMessageStore"; + + private static List _exclusionList; + + public QpidTestCase() + { + this("QpidTestCase"); + } + + public QpidTestCase(String name) + { + super(name); + } + + public void run(TestResult testResult) + { + if (_exclusionList != null && (_exclusionList.contains(getClass().getPackage().getName() + ".*") || + _exclusionList.contains(getClass().getName() + "#*") || + _exclusionList.contains(getClass().getName() + "#" + getName()))) + { + _logger.info("Test: " + getName() + " is excluded"); + testResult.endTest(this); + } + else + { + super.run(testResult); + } + } + + public String getTestProfileMessageStoreClassName() + { + String storeClass = System.getProperty(MS_CLASS_NAME_KEY); + + return storeClass != null ? storeClass : MEMORY_STORE_CLASS_NAME ; + } +} diff --git a/java/integrationtests/build.xml b/java/integrationtests/build.xml index 29d066edb7..ae870c5675 100644 --- a/java/integrationtests/build.xml +++ b/java/integrationtests/build.xml @@ -20,7 +20,7 @@ --> - + diff --git a/java/module.xml b/java/module.xml index 228f2fd722..d4007e067c 100644 --- a/java/module.xml +++ b/java/module.xml @@ -324,6 +324,7 @@ + diff --git a/java/perftests/build.xml b/java/perftests/build.xml index 19cccb34a5..497bfc8035 100644 --- a/java/perftests/build.xml +++ b/java/perftests/build.xml @@ -20,7 +20,7 @@ --> - + diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java b/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java deleted file mode 100644 index d5b87be5d1..0000000000 --- a/java/systests/src/main/java/org/apache/qpid/test/utils/QpidTestCase.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.test.utils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import junit.framework.TestCase; -import junit.framework.TestResult; - -import org.apache.log4j.Logger; - -public class QpidTestCase extends TestCase -{ - protected static final Logger _logger = Logger.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.exclude")) - { - _logger.info("Some tests should be excluded, building the exclude list"); - String exclusionListURIs = System.getProperties().getProperty("test.excludefiles", ""); - String exclusionListString = System.getProperties().getProperty("test.excludelist", ""); - List exclusionList = new ArrayList(); - - for (String uri : exclusionListURIs.split("\\s+")) - { - File file = new File(uri); - if (file.exists()) - { - _logger.info("Using exclude file: " + uri); - 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); - } - } - } - - if (!exclusionListString.equals("")) - { - _logger.info("Using excludeslist: " + exclusionListString); - for (String test : exclusionListString.split("\\s+")) - { - exclusionList.add(test); - } - } - - _exclusionList = exclusionList; - } - } - - private static List _exclusionList; - - public void run(TestResult testResult) - { - if (_exclusionList != null && (_exclusionList.contains(getClass().getPackage().getName() + ".*") || - _exclusionList.contains(getClass().getName() + "#*") || - _exclusionList.contains(getClass().getName() + "#" + getName()))) - { - _logger.info("Test: " + getName() + " is excluded"); - testResult.endTest(this); - } - else - { - super.run(testResult); - } - } - - public QpidTestCase(String name) - { - super(name); - } - - public QpidTestCase() - { - this("QpidTestCase"); - } -} diff --git a/java/test-profiles/default.testprofile b/java/test-profiles/default.testprofile index 4ab1f484d9..ebab069af9 100644 --- a/java/test-profiles/default.testprofile +++ b/java/test-profiles/default.testprofile @@ -5,9 +5,10 @@ broker.version=0-8 broker=vm broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=Listening on TCP port -broker.config=${project.root}/build/etc/config-systests.xml broker.start=${test.profiles}/start-broker broker.kill=${test.profiles}/kill-broker +broker.config=${project.root}/build/etc/config-systests.xml +messagestore.class.name=org.apache.qpid.server.store.MemoryMessageStore max_prefetch=1000 qpid.dest_syntax=BURL diff --git a/java/test-profiles/java-derby.0.10.testprofile b/java/test-profiles/java-derby.0.10.testprofile index 511e51ec1d..8c53a9423a 100644 --- a/java/test-profiles/java-derby.0.10.testprofile +++ b/java/test-profiles/java-derby.0.10.testprofile @@ -5,6 +5,7 @@ broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=BRK-1004 broker.stopped=Exception broker.config=${project.root}/build/etc/config-systests-derby.xml +messagestore.class.name=org.apache.qpid.server.store.DerbyMessageStore profile.excludes=JavaStandaloneExcludes JavaPersistentExcludes Java010Excludes broker.clean.between.tests=true broker.persistent=true diff --git a/java/test-profiles/java-derby.testprofile b/java/test-profiles/java-derby.testprofile index 742af29ffa..a88f2d852d 100644 --- a/java/test-profiles/java-derby.testprofile +++ b/java/test-profiles/java-derby.testprofile @@ -4,6 +4,7 @@ broker.clean=${test.profiles}/clean-dir ${build.data} ${project.root}/build/work broker.ready=BRK-1004 broker.stopped=Exception broker.config=${project.root}/build/etc/config-systests-derby.xml +messagestore.class.name=org.apache.qpid.server.store.DerbyMessageStore profile.excludes=JavaStandaloneExcludes JavaPersistentExcludes 08StandaloneExcludes broker.clean.between.tests=true broker.persistent=true -- cgit v1.2.1