Repository: qpid-jms Updated Branches: refs/heads/master fba50f1c3 -> a5240be50
QPIDJMS-132 Fix test runner name. Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/a5240be5 Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/a5240be5 Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/a5240be5 Branch: refs/heads/master Commit: a5240be50158f2c90a857b00656be33fc9ead1c8 Parents: fba50f1 Author: Timothy Bish <tabish...@gmail.com> Authored: Thu Oct 29 16:58:44 2015 -0400 Committer: Timothy Bish <tabish...@gmail.com> Committed: Thu Oct 29 16:58:44 2015 -0400 ---------------------------------------------------------------------- .../jms/integration/SessionIntegrationTest.java | 4 +- .../apache/qpid/jms/util/QPidJMSTestRunner.java | 116 ------------------- .../apache/qpid/jms/util/QpidJMSTestRunner.java | 116 +++++++++++++++++++ 3 files changed, 118 insertions(+), 118 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a5240be5/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java index 38a2cf7..4d36e8c 100644 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/integration/SessionIntegrationTest.java @@ -77,7 +77,7 @@ import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageAnnotationsSec import org.apache.qpid.jms.test.testpeer.matchers.sections.MessageHeaderSectionMatcher; import org.apache.qpid.jms.test.testpeer.matchers.sections.TransferPayloadCompositeMatcher; import org.apache.qpid.jms.test.testpeer.matchers.types.EncodedAmqpValueMatcher; -import org.apache.qpid.jms.util.QPidJMSTestRunner; +import org.apache.qpid.jms.util.QpidJMSTestRunner; import org.apache.qpid.jms.util.Repeat; import org.apache.qpid.proton.amqp.Binary; import org.apache.qpid.proton.amqp.Symbol; @@ -87,7 +87,7 @@ import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -@RunWith(QPidJMSTestRunner.class) +@RunWith(QpidJMSTestRunner.class) public class SessionIntegrationTest extends QpidJmsTestCase { private static final Logger LOG = LoggerFactory.getLogger(SessionIntegrationTest.class); http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a5240be5/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QPidJMSTestRunner.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QPidJMSTestRunner.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QPidJMSTestRunner.java deleted file mode 100644 index d7d110f..0000000 --- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QPidJMSTestRunner.java +++ /dev/null @@ -1,116 +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.jms.util; - -import java.util.concurrent.TimeUnit; - -import org.junit.Test; -import org.junit.internal.runners.statements.FailOnTimeout; -import org.junit.runners.BlockJUnit4ClassRunner; -import org.junit.runners.model.FrameworkMethod; -import org.junit.runners.model.InitializationError; -import org.junit.runners.model.Statement; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A Custom JUnit test runner for customizing JUnit tests run in QPid JMS. - */ -public class QPidJMSTestRunner extends BlockJUnit4ClassRunner { - - private static final Logger LOG = LoggerFactory.getLogger(QPidJMSTestRunner.class); - - public QPidJMSTestRunner(Class<?> klass) throws InitializationError { - super(klass); - } - - @Override - protected Statement methodBlock(final FrameworkMethod method) { - Statement statement = super.methodBlock(method); - - // Check for repeats needed - statement = withPotentialRepeat(method, statement); - - return statement; - } - - /** - * Perform the same logic as - * {@link BlockJUnit4ClassRunner#withPotentialTimeout(FrameworkMethod, Object, Statement)} - * but with additional support for changing the coded timeout with an extended value. - * - * @return either a {@link FailOnTimeout}, or the supplied {@link Statement} as appropriate. - */ - @SuppressWarnings("deprecation") - @Override - protected Statement withPotentialTimeout(FrameworkMethod frameworkMethod, Object testInstance, Statement next) { - long testTimeout = getOriginalTimeout(frameworkMethod); - - if (testTimeout > 0) { - String multiplierString = System.getProperty("org.apache.qpid.jms.testTimeoutMultiplier"); - double multiplier = 0.0; - - try { - multiplier = Double.parseDouble(multiplierString); - } catch (NullPointerException npe) { - } catch (NumberFormatException nfe) { - LOG.warn("Ignoring testTimeoutMultiplier not set to a valid value: " + multiplierString); - } - - if (multiplier > 0.0) { - LOG.info("Test timeout multiple {} applied to test timeout {}ms: new timeout = {}", - multiplier, testTimeout, (long) (testTimeout * multiplier)); - testTimeout = (long) (testTimeout * multiplier); - } - - next = FailOnTimeout.builder(). - withTimeout(testTimeout, TimeUnit.MILLISECONDS).build(next); - } else { - next = super.withPotentialTimeout(frameworkMethod, testInstance, next); - } - - return next; - } - - /** - * Check for the presence of a {@link Repeat} annotation and return a {@link RepeatStatement} - * to handle executing the test repeated or the original value if not repeating. - * - * @return either a {@link RepeatStatement}, or the supplied {@link Statement} as appropriate. - */ - protected Statement withPotentialRepeat(FrameworkMethod frameworkMethod, Statement next) { - - Repeat repeatAnnotation = frameworkMethod.getAnnotation(Repeat.class); - - if (repeatAnnotation != null) { - next = RepeatStatement.builder().build(repeatAnnotation, next); - } - - return next; - } - - /** - * Retrieve the original JUnit {@code timeout} from the {@link Test @Test} - * annotation on the incoming {@linkplain FrameworkMethod test method}. - * - * @return the timeout, or {@code 0} if none was specified - */ - protected long getOriginalTimeout(FrameworkMethod frameworkMethod) { - Test test = frameworkMethod.getAnnotation(Test.class); - return (test != null && test.timeout() > 0 ? test.timeout() : 0); - } -} http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/a5240be5/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QpidJMSTestRunner.java ---------------------------------------------------------------------- diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QpidJMSTestRunner.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QpidJMSTestRunner.java new file mode 100644 index 0000000..4a572c6 --- /dev/null +++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/util/QpidJMSTestRunner.java @@ -0,0 +1,116 @@ +/* + * 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.jms.util; + +import java.util.concurrent.TimeUnit; + +import org.junit.Test; +import org.junit.internal.runners.statements.FailOnTimeout; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A Custom JUnit test runner for customizing JUnit tests run in QPid JMS. + */ +public class QpidJMSTestRunner extends BlockJUnit4ClassRunner { + + private static final Logger LOG = LoggerFactory.getLogger(QpidJMSTestRunner.class); + + public QpidJMSTestRunner(Class<?> klass) throws InitializationError { + super(klass); + } + + @Override + protected Statement methodBlock(final FrameworkMethod method) { + Statement statement = super.methodBlock(method); + + // Check for repeats needed + statement = withPotentialRepeat(method, statement); + + return statement; + } + + /** + * Perform the same logic as + * {@link BlockJUnit4ClassRunner#withPotentialTimeout(FrameworkMethod, Object, Statement)} + * but with additional support for changing the coded timeout with an extended value. + * + * @return either a {@link FailOnTimeout}, or the supplied {@link Statement} as appropriate. + */ + @SuppressWarnings("deprecation") + @Override + protected Statement withPotentialTimeout(FrameworkMethod frameworkMethod, Object testInstance, Statement next) { + long testTimeout = getOriginalTimeout(frameworkMethod); + + if (testTimeout > 0) { + String multiplierString = System.getProperty("org.apache.qpid.jms.testTimeoutMultiplier"); + double multiplier = 0.0; + + try { + multiplier = Double.parseDouble(multiplierString); + } catch (NullPointerException npe) { + } catch (NumberFormatException nfe) { + LOG.warn("Ignoring testTimeoutMultiplier not set to a valid value: " + multiplierString); + } + + if (multiplier > 0.0) { + LOG.info("Test timeout multiple {} applied to test timeout {}ms: new timeout = {}", + multiplier, testTimeout, (long) (testTimeout * multiplier)); + testTimeout = (long) (testTimeout * multiplier); + } + + next = FailOnTimeout.builder(). + withTimeout(testTimeout, TimeUnit.MILLISECONDS).build(next); + } else { + next = super.withPotentialTimeout(frameworkMethod, testInstance, next); + } + + return next; + } + + /** + * Check for the presence of a {@link Repeat} annotation and return a {@link RepeatStatement} + * to handle executing the test repeated or the original value if not repeating. + * + * @return either a {@link RepeatStatement}, or the supplied {@link Statement} as appropriate. + */ + protected Statement withPotentialRepeat(FrameworkMethod frameworkMethod, Statement next) { + + Repeat repeatAnnotation = frameworkMethod.getAnnotation(Repeat.class); + + if (repeatAnnotation != null) { + next = RepeatStatement.builder().build(repeatAnnotation, next); + } + + return next; + } + + /** + * Retrieve the original JUnit {@code timeout} from the {@link Test @Test} + * annotation on the incoming {@linkplain FrameworkMethod test method}. + * + * @return the timeout, or {@code 0} if none was specified + */ + protected long getOriginalTimeout(FrameworkMethod frameworkMethod) { + Test test = frameworkMethod.getAnnotation(Test.class); + return (test != null && test.timeout() > 0 ? test.timeout() : 0); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org