diff --git a/build.gradle b/build.gradle
index d01d0d701bab42a55672f9848e907b4de7043812..b2e7af70c622aa0ea0f6e77fdac2b0204a07a454 100644
--- a/build.gradle
+++ b/build.gradle
@@ -110,7 +110,7 @@ configure(allprojects.findAll{it.name in ["spring", "spring-jms", "spring-orm",
}
}
-configure(subprojects) { subproject ->
+configure(subprojects - project(":spring-build-junit")) { subproject ->
apply plugin: "merge"
apply from: "${gradleScriptDir}/publish-maven.gradle"
@@ -159,6 +159,34 @@ configure(subprojects) { subproject ->
}
}
+configure(allprojects - project(":spring-build-junit")) {
+ dependencies {
+ testCompile(project(":spring-build-junit"))
+ }
+
+ eclipse.classpath.file.whenMerged { classpath ->
+ classpath.entries.find{it.path == "/spring-build-junit"}.exported = false
+ }
+
+ test.systemProperties.put("testGroups", properties.get("testGroups"))
+}
+
+project("spring-build-junit") {
+ description = "Build-time JUnit dependencies and utilities"
+
+ // NOTE: This is an internal project and is not published.
+
+ dependencies {
+ compile("commons-logging:commons-logging:1.1.1")
+ compile("junit:junit:${junitVersion}")
+ compile("org.hamcrest:hamcrest-all:1.3")
+ compile("org.easymock:easymock:${easymockVersion}")
+ }
+
+ // Don't actually generate any artifacts
+ configurations.archives.artifacts.clear()
+}
+
project("spring-core") {
description = "Spring Core"
diff --git a/settings.gradle b/settings.gradle
index 11ce95641fb68efa56b87ffcb5a46875121f1ed5..8d4e147bccbb4a446474dcb24ca6f00d04a5cd02 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -22,3 +22,4 @@ include "spring-web"
include "spring-webmvc"
include "spring-webmvc-portlet"
include "spring-webmvc-tiles3"
+include "spring-build-junit"
diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
index 930c530961ef7d3dfc964d96896a6fe72ee1d827..7da971041766b637954eaacaae0343328d179b53 100644
--- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java
@@ -49,6 +49,8 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.beans.support.DerivedFromProtectedBaseBean;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultConversionService;
@@ -1139,10 +1141,8 @@ public final class BeanWrapperTests {
@Test
public void testLargeMatchingPrimitiveArray() {
- if (LogFactory.getLog(BeanWrapperTests.class).isTraceEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(LogFactory.getLog(BeanWrapperTests.class));
PrimitiveArrayBean tb = new PrimitiveArrayBean();
BeanWrapper bw = new BeanWrapperImpl(tb);
diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
index bc9f1ffba106a58452b0148d46693be03a1f38a7..35f3420ca04f78fed31f867bdc8ab119d6da2772 100644
--- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
+++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java
@@ -72,6 +72,8 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ConstructorDependenciesBean;
import org.springframework.beans.factory.xml.DependenciesBean;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.core.MethodParameter;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.DefaultConversionService;
@@ -1693,10 +1695,8 @@ public class DefaultListableBeanFactoryTests {
@Test
public void testPrototypeCreationIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1713,10 +1713,8 @@ public class DefaultListableBeanFactoryTests {
@Test
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1759,10 +1757,8 @@ public class DefaultListableBeanFactoryTests {
@Test
@Ignore // TODO re-enable when ConstructorResolver TODO sorted out
public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1809,10 +1805,8 @@ public class DefaultListableBeanFactoryTests {
@Test
public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1833,10 +1827,8 @@ public class DefaultListableBeanFactoryTests {
@Test
public void testPrototypeCreationWithPropertiesIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -1882,10 +1874,8 @@ public class DefaultListableBeanFactoryTests {
*/
@Test
public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
DefaultListableBeanFactory lbf = new DefaultListableBeanFactory();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2200,6 +2190,7 @@ public class DefaultListableBeanFactoryTests {
*/
@Test(timeout=1000)
public void testByTypeLookupIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
for (int i = 0; i < 1000; i++) {
diff --git a/spring-build-junit/src/main/java/org/springframework/build/junit/Assume.java b/spring-build-junit/src/main/java/org/springframework/build/junit/Assume.java
new file mode 100644
index 0000000000000000000000000000000000000000..7b916d0b59c76e4b5bd61d49861679b4a2db4907
--- /dev/null
+++ b/spring-build-junit/src/main/java/org/springframework/build/junit/Assume.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed 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.springframework.build.junit;
+
+import static org.junit.Assume.assumeFalse;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.junit.internal.AssumptionViolatedException;
+
+/**
+ * Provides utility methods that allow JUnit tests to {@link Assume} certain conditions
+ * hold {@code true}. If the assumption fails, it means the test should be skipped.
+ *
+ *
For example, if a set of tests require at least JDK 1.7 it can use
+ * {@code Assume#atLeast(JdkVersion.JAVA_17)} as shown below:
+ *
+ *
+ * public void MyTests {
+ *
+ * @BeforeClass
+ * public static assumptions() {
+ * Assume.atLeast(JdkVersion.JAVA_17);
+ * }
+ *
+ * // ... all the test methods that require at least JDK 1.7
+ * }
+ *
+ *
+ * If only a single test requires at least JDK 1.7 it can use the
+ * {@code Assume#atLeast(JdkVersion.JAVA_17)} as shown below:
+ *
+ *
+ * public void MyTests {
+ *
+ * @Test
+ * public void requiresJdk17 {
+ * Assume.atLeast(JdkVersion.JAVA_17);
+ * // ... perform the actual test
+ * }
+ * }
+ *
+ *
+ * In addition to assumptions based on the JDK version, tests can be categorized into
+ * {@link TestGroup}s. Active groups are enabled using the 'testGroups' system property,
+ * usually activated from the gradle command line:
+ *
+ * gradle test -PtestGroups="performance"
+ *
+ *
+ * Groups can be specified as a comma separated list of values, or using the pseudo group
+ * 'all'. See {@link TestGroup} for a list of valid groups.
+ *
+ * @author Rob Winch
+ * @author Phillip Webb
+ * @since 3.2
+ * @see #atLeast(JavaVersion)
+ * @see #group(TestGroup)
+ */
+public abstract class Assume {
+
+
+ private static final Set GROUPS = TestGroup.parse(System.getProperty("testGroups"));
+
+
+ /**
+ * Assume a minimum {@link JavaVersion} is running.
+ * @param version the minimum version for the test to run
+ */
+ public static void atLeast(JavaVersion version) {
+ if (!JavaVersion.runningVersion().isAtLeast(version)) {
+ throw new AssumptionViolatedException("Requires JDK " + version + " but running "
+ + JavaVersion.runningVersion());
+ }
+ }
+
+ /**
+ * Assume that a particular {@link TestGroup} has been specified.
+ * @param group the group that must be specified.
+ */
+ public static void group(TestGroup group) {
+ if (!GROUPS.contains(group)) {
+ throw new AssumptionViolatedException("Requires unspecified group " + group
+ + " from " + GROUPS);
+ }
+ }
+
+ /**
+ * Assume that the specified log is not set to Trace or Debug.
+ * @param log the log to test
+ */
+ public static void notLogging(Log log) {
+ assumeFalse(log.isTraceEnabled());
+ assumeFalse(log.isDebugEnabled());
+ }
+}
diff --git a/spring-build-junit/src/main/java/org/springframework/build/junit/JavaVersion.java b/spring-build-junit/src/main/java/org/springframework/build/junit/JavaVersion.java
new file mode 100644
index 0000000000000000000000000000000000000000..db9fee370f086f23895ca10d81d4b05c9263ac10
--- /dev/null
+++ b/spring-build-junit/src/main/java/org/springframework/build/junit/JavaVersion.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed 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.springframework.build.junit;
+
+/**
+ * Enumeration of known JDK versions.
+ *
+ * @author Phillip Webb
+ * @see #runningVersion()
+ */
+public enum JavaVersion {
+
+
+ /**
+ * Java 1.5
+ */
+ JAVA_15("1.5", 15),
+
+ /**
+ * Java 1.6
+ */
+ JAVA_16("1.6", 16),
+
+ /**
+ * Java 1.7
+ */
+ JAVA_17("1.7", 17),
+
+ /**
+ * Java 1.8
+ */
+ JAVA_18("1.8", 18);
+
+
+ private static final JavaVersion runningVersion = findRunningVersion();
+
+ private static JavaVersion findRunningVersion() {
+ String version = System.getProperty("java.version");
+ for (JavaVersion candidate : values()) {
+ if (version.startsWith(candidate.version)) {
+ return candidate;
+ }
+ }
+ return JavaVersion.JAVA_15;
+ }
+
+
+ private String version;
+
+ private int value;
+
+
+ private JavaVersion(String version, int value) {
+ this.version = version;
+ this.value = value;
+ }
+
+
+ @Override
+ public String toString() {
+ return version;
+ }
+
+ /**
+ * Determines if the specified version is the same as or greater than this version.
+ * @param version the version to check
+ * @return {@code true} if the specified version is at least this version
+ */
+ public boolean isAtLeast(JavaVersion version) {
+ return this.value >= version.value;
+ }
+
+
+ /**
+ * Returns the current running JDK version. If the current version cannot be
+ * determined {@link #JAVA_15} will be returned.
+ * @return the JDK version
+ */
+ public static JavaVersion runningVersion() {
+ return runningVersion;
+ }
+}
diff --git a/spring-build-junit/src/main/java/org/springframework/build/junit/TestGroup.java b/spring-build-junit/src/main/java/org/springframework/build/junit/TestGroup.java
new file mode 100644
index 0000000000000000000000000000000000000000..3be8b83514b01e66d71d29007107dc26d5b28a74
--- /dev/null
+++ b/spring-build-junit/src/main/java/org/springframework/build/junit/TestGroup.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed 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.springframework.build.junit;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A test group used to limit when certain tests are run.
+ *
+ * @see Assume#group(TestGroup)
+ * @author Phillip Webb
+ */
+public enum TestGroup {
+
+
+ /**
+ * Performance related tests that may take a considerable time to run.
+ */
+ PERFORMANCE;
+
+
+ /**
+ * Parse the specified comma separates string of groups.
+ * @param value the comma separated string of groups
+ * @return a set of groups
+ */
+ public static Set parse(String value) {
+ if (value == null || "".equals(value)) {
+ return Collections.emptySet();
+ }
+ if("ALL".equalsIgnoreCase(value)) {
+ return EnumSet.allOf(TestGroup.class);
+ }
+ Set groups = new HashSet();
+ for (String group : value.split(",")) {
+ try {
+ groups.add(valueOf(group.trim().toUpperCase()));
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException("Unable to find test group '" + group.trim()
+ + "' when parsing '" + value + "'");
+ }
+ }
+ return groups;
+ }
+}
diff --git a/spring-build-junit/src/test/java/org/springframework/build/junit/JavaVersionTest.java b/spring-build-junit/src/test/java/org/springframework/build/junit/JavaVersionTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..1600d4ca195ee36e7468f569a95e216c1a18ddb8
--- /dev/null
+++ b/spring-build-junit/src/test/java/org/springframework/build/junit/JavaVersionTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed 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.springframework.build.junit;
+
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Tests for {@link JavaVersion}.
+ *
+ * @author Phillip Webb
+ */
+public class JavaVersionTest {
+
+ @Test
+ public void runningVersion() {
+ assertNotNull(JavaVersion.runningVersion());
+ assertThat(System.getProperty("java.version"), startsWith(JavaVersion.runningVersion().toString()));
+ }
+
+ @Test
+ public void isAtLeast() throws Exception {
+ assertTrue(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_15));
+ assertTrue(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_16));
+ assertFalse(JavaVersion.JAVA_16.isAtLeast(JavaVersion.JAVA_17));
+ }
+}
diff --git a/spring-build-junit/src/test/java/org/springframework/build/junit/TestGroupTest.java b/spring-build-junit/src/test/java/org/springframework/build/junit/TestGroupTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..2b30f299310c8b12a8908a9473ec7f976bfd71e5
--- /dev/null
+++ b/spring-build-junit/src/test/java/org/springframework/build/junit/TestGroupTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2002-2012 the original author or authors.
+ *
+ * Licensed 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.springframework.build.junit;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Set;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Tests for {@link TestGroup}.
+ *
+ * @author Phillip Webb
+ */
+public class TestGroupTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Test
+ public void parseNull() throws Exception {
+ assertThat(TestGroup.parse(null), is(Collections. emptySet()));
+ }
+
+ @Test
+ public void parseEmptyString() throws Exception {
+ assertThat(TestGroup.parse(""), is(Collections. emptySet()));
+ }
+
+ @Test
+ public void parseWithSpaces() throws Exception {
+ assertThat(TestGroup.parse("PERFORMANCE, PERFORMANCE"),
+ is((Set) EnumSet.of(TestGroup.PERFORMANCE)));
+ }
+
+ @Test
+ public void parseInMixedCase() throws Exception {
+ assertThat(TestGroup.parse("performance, PERFormaNCE"),
+ is((Set) EnumSet.of(TestGroup.PERFORMANCE)));
+ }
+
+ @Test
+ public void parseMissing() throws Exception {
+ thrown.expect(IllegalArgumentException.class);
+ thrown.expectMessage("Unable to find test group 'missing' when parsing 'performance, missing'");
+ TestGroup.parse("performance, missing");
+ }
+
+ @Test
+ public void parseAll() throws Exception {
+ assertThat(TestGroup.parse("all"), is((Set)EnumSet.allOf(TestGroup.class)));
+ }
+}
diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
index 66aa6e0e579f4ac762829548b41fee83eab88db4..0c2927961dc55ca89e145970bf7664d0e35ba267 100644
--- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
+++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assume.assumeFalse;
import java.lang.reflect.Method;
@@ -50,6 +51,8 @@ import org.springframework.beans.factory.config.MethodInvokingFactoryBean;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
@@ -112,10 +115,8 @@ public final class AspectJAutoProxyCreatorTests {
@Test
public void testAspectsAndAdvisorAppliedToPrototypeIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
StopWatch sw = new StopWatch();
sw.start("Prototype Creation");
@@ -134,10 +135,8 @@ public final class AspectJAutoProxyCreatorTests {
@Test
public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
StopWatch sw = new StopWatch();
sw.start("Prototype Creation");
@@ -156,10 +155,8 @@ public final class AspectJAutoProxyCreatorTests {
@Test
public void testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
GenericApplicationContext ac = new GenericApplicationContext();
new XmlBeanDefinitionReader(ac).loadBeanDefinitions(new ClassPathResource(qName("aspectsPlusAdvisor.xml"),
getClass()));
diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java
index e225b5cfe995963f813774ebccdfa00f103d4996..12b0a100b719f1f4d5ac458d9e45abd33dcdb9fc 100644
--- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java
+++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java
@@ -17,6 +17,7 @@
package org.springframework.context.annotation;
import static org.junit.Assert.*;
+import static org.junit.Assume.assumeFalse;
import javax.annotation.Resource;
@@ -30,6 +31,8 @@ import org.springframework.beans.factory.annotation.Required;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.util.StopWatch;
@@ -44,10 +47,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithResourcePropertiesIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
@@ -70,10 +71,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithOverriddenResourcePropertiesIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
@@ -97,10 +96,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithAutowiredPropertiesIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
@@ -123,10 +120,8 @@ public class AnnotationProcessorPerformanceTests {
@Test
public void testPrototypeCreationWithOverriddenAutowiredPropertiesIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
GenericApplicationContext ctx = new GenericApplicationContext();
AnnotationConfigUtils.registerAnnotationConfigProcessors(ctx);
ctx.refresh();
diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java
index 16eccd8d33ebea56337b16ccdbeb8d52799c3783..b23b68611623f93695eaf6c369c059c5f913e1a1 100644
--- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java
+++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java
@@ -38,6 +38,8 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.util.SerializationTestUtils;
@@ -218,10 +220,8 @@ public class ApplicationContextExpressionTests {
@Test
public void prototypeCreationIsFastEnough() {
- if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
- // Skip this test: Trace logging blows the time limit.
- return;
- }
+ Assume.group(TestGroup.PERFORMANCE);
+ Assume.notLogging(factoryLog);
GenericApplicationContext ac = new GenericApplicationContext();
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java
index 349c6ec3870208f890698cf651443cce99d400c3..d4be14d47b6ff270fb986cea6083563fa3524e61 100644
--- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java
+++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java
@@ -19,8 +19,11 @@ package org.springframework.scheduling.annotation;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.Before;
import org.junit.Test;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -43,6 +46,11 @@ import static org.junit.Assert.*;
*/
public class EnableSchedulingTests {
+ @Before
+ public void setUp() {
+ Assume.group(TestGroup.PERFORMANCE);
+ }
+
@Test
public void withFixedRateTask() throws InterruptedException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java
index 41333498ba9188449cae5656df915e79db7e33cd..fadd6933a78955c08b127c65dce8c660e86616b1 100644
--- a/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/convert/support/GenericConversionServiceTests.java
@@ -35,6 +35,8 @@ import java.util.UUID;
import org.junit.Test;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.ConverterNotFoundException;
import org.springframework.core.convert.TypeDescriptor;
@@ -398,6 +400,7 @@ public class GenericConversionServiceTests {
@Test
public void testPerformance1() {
+ Assume.group(TestGroup.PERFORMANCE);
GenericConversionService conversionService = new DefaultConversionService();
StopWatch watch = new StopWatch("integer->string conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
@@ -415,6 +418,7 @@ public class GenericConversionServiceTests {
@Test
public void testPerformance2() throws Exception {
+ Assume.group(TestGroup.PERFORMANCE);
GenericConversionService conversionService = new DefaultConversionService();
StopWatch watch = new StopWatch("list -> list conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
@@ -442,6 +446,7 @@ public class GenericConversionServiceTests {
@Test
public void testPerformance3() throws Exception {
+ Assume.group(TestGroup.PERFORMANCE);
GenericConversionService conversionService = new DefaultConversionService();
StopWatch watch = new StopWatch("map -> map conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java
index 231a3adff0f7f82d65eed3c8855c2dc7a6ad58b0..0d3efa95ddb60f02f078d88fa7a5bb4688299df9 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java
@@ -19,6 +19,8 @@ package org.springframework.expression.spel;
import junit.framework.Assert;
import org.junit.Test;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
@@ -43,6 +45,8 @@ public class PerformanceTests {
@Test
public void testPerformanceOfPropertyAccess() throws Exception {
+ Assume.group(TestGroup.PERFORMANCE);
+
long starttime = 0;
long endtime = 0;
@@ -89,7 +93,10 @@ public class PerformanceTests {
}
}
+ @Test
public void testPerformanceOfMethodAccess() throws Exception {
+ Assume.group(TestGroup.PERFORMANCE);
+
long starttime = 0;
long endtime = 0;
diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java
index 51e2f501d804e0016840352f7494ffc78cfa0c99..cba2d487f2391018eae03a68df8992db4db1adc1 100644
--- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java
+++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java
@@ -19,6 +19,8 @@ package org.springframework.web.bind;
import static org.junit.Assert.*;
import org.junit.Test;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.util.StopWatch;
@@ -399,6 +401,7 @@ public class ServletRequestUtilsTests {
@Test
public void testGetLongParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockHttpServletRequest request = new MockHttpServletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -412,6 +415,7 @@ public class ServletRequestUtilsTests {
@Test
public void testGetFloatParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockHttpServletRequest request = new MockHttpServletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -425,6 +429,7 @@ public class ServletRequestUtilsTests {
@Test
public void testGetDoubleParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockHttpServletRequest request = new MockHttpServletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -438,6 +443,7 @@ public class ServletRequestUtilsTests {
@Test
public void testGetBooleanParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockHttpServletRequest request = new MockHttpServletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -451,6 +457,7 @@ public class ServletRequestUtilsTests {
@Test
public void testGetStringParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockHttpServletRequest request = new MockHttpServletRequest();
StopWatch sw = new StopWatch();
sw.start();
diff --git a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/bind/PortletRequestUtilsTests.java b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/bind/PortletRequestUtilsTests.java
index 3730a69e12b355e217628e0678a79b31332e813d..c903e01a663763956c6690d19c8a49e08536b42c 100644
--- a/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/bind/PortletRequestUtilsTests.java
+++ b/spring-webmvc-portlet/src/test/java/org/springframework/web/portlet/bind/PortletRequestUtilsTests.java
@@ -18,6 +18,9 @@ package org.springframework.web.portlet.bind;
import junit.framework.TestCase;
+import org.junit.Test;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.mock.web.portlet.MockPortletRequest;
import org.springframework.util.StopWatch;
@@ -28,8 +31,9 @@ import static org.junit.Assert.*;
* @author Juergen Hoeller
* @author Mark Fisher
*/
-public class PortletRequestUtilsTests extends TestCase {
+public class PortletRequestUtilsTests {
+ @Test
public void testIntParameter() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param1", "5");
@@ -68,6 +72,7 @@ public class PortletRequestUtilsTests extends TestCase {
}
}
+ @Test
public void testIntParameters() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param", new String[] {"1", "2", "3"});
@@ -90,9 +95,9 @@ public class PortletRequestUtilsTests extends TestCase {
catch (PortletRequestBindingException ex) {
// expected
}
-
}
+ @Test
public void testLongParameter() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param1", "5");
@@ -131,6 +136,7 @@ public class PortletRequestUtilsTests extends TestCase {
}
}
+ @Test
public void testLongParameters() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.setParameter("param", new String[] {"1", "2", "3"});
@@ -162,6 +168,7 @@ public class PortletRequestUtilsTests extends TestCase {
assertEquals(2, values[1]);
}
+ @Test
public void testFloatParameter() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param1", "5.5");
@@ -200,6 +207,7 @@ public class PortletRequestUtilsTests extends TestCase {
}
}
+ @Test
public void testFloatParameters() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param", new String[] {"1.5", "2.5", "3"});
@@ -224,6 +232,7 @@ public class PortletRequestUtilsTests extends TestCase {
}
}
+ @Test
public void testDoubleParameter() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param1", "5.5");
@@ -262,6 +271,7 @@ public class PortletRequestUtilsTests extends TestCase {
}
}
+ @Test
public void testDoubleParameters() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param", new String[] {"1.5", "2.5", "3"});
@@ -286,6 +296,7 @@ public class PortletRequestUtilsTests extends TestCase {
}
}
+ @Test
public void testBooleanParameter() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param1", "true");
@@ -319,6 +330,7 @@ public class PortletRequestUtilsTests extends TestCase {
assertFalse(PortletRequestUtils.getRequiredBooleanParameter(request, "paramEmpty"));
}
+ @Test
public void testBooleanParameters() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param", new String[] {"true", "yes", "off", "1", "bogus"});
@@ -342,6 +354,7 @@ public class PortletRequestUtilsTests extends TestCase {
}
}
+ @Test
public void testStringParameter() throws PortletRequestBindingException {
MockPortletRequest request = new MockPortletRequest();
request.addParameter("param1", "str");
@@ -365,7 +378,9 @@ public class PortletRequestUtilsTests extends TestCase {
assertEquals("", PortletRequestUtils.getRequiredStringParameter(request, "paramEmpty"));
}
+ @Test
public void testGetIntParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockPortletRequest request = new MockPortletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -376,7 +391,9 @@ public class PortletRequestUtilsTests extends TestCase {
assertThat(sw.getTotalTimeMillis(), lessThan(250L));
}
+ @Test
public void testGetLongParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockPortletRequest request = new MockPortletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -387,7 +404,9 @@ public class PortletRequestUtilsTests extends TestCase {
assertThat(sw.getTotalTimeMillis(), lessThan(250L));
}
+ @Test
public void testGetFloatParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockPortletRequest request = new MockPortletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -398,7 +417,9 @@ public class PortletRequestUtilsTests extends TestCase {
assertThat(sw.getTotalTimeMillis(), lessThan(350L));
}
+ @Test
public void testGetDoubleParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockPortletRequest request = new MockPortletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -409,7 +430,9 @@ public class PortletRequestUtilsTests extends TestCase {
assertThat(sw.getTotalTimeMillis(), lessThan(250L));
}
+ @Test
public void testGetBooleanParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockPortletRequest request = new MockPortletRequest();
StopWatch sw = new StopWatch();
sw.start();
@@ -420,7 +443,9 @@ public class PortletRequestUtilsTests extends TestCase {
assertThat(sw.getTotalTimeMillis(), lessThan(250L));
}
+ @Test
public void testGetStringParameterWithDefaultValueHandlingIsFastEnough() {
+ Assume.group(TestGroup.PERFORMANCE);
MockPortletRequest request = new MockPortletRequest();
StopWatch sw = new StopWatch();
sw.start();
diff --git a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java
index eb715261ea04da47d338633dc04e9d063da12484..b2fbd959d265ae92e7f2dfc75f5070e7aa1a2893 100644
--- a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java
+++ b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java
@@ -18,10 +18,13 @@ package org.springframework.scheduling.annotation;
import java.util.concurrent.atomic.AtomicInteger;
+import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanCreationException;
+import org.springframework.build.junit.Assume;
+import org.springframework.build.junit.TestGroup;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -48,6 +51,11 @@ import static org.junit.Assert.*;
*/
public class ScheduledAndTransactionalAnnotationIntegrationTests {
+ @Before
+ public void setUp() {
+ Assume.group(TestGroup.PERFORMANCE);
+ }
+
@Test
public void failsWhenJdkProxyAndScheduledMethodNotPresentOnInterface() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();