提交 e7155616 编写于 作者: C Chris Beams

Merge branch 'SPR-9984' into cleanup-3.2.x

* SPR-9984:
  Ignore performance-sensitive tests by default
  Introduce 'spring-build-junit' subproject
......@@ -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"
......
......@@ -22,3 +22,4 @@ include "spring-web"
include "spring-webmvc"
include "spring-webmvc-portlet"
include "spring-webmvc-tiles3"
include "spring-build-junit"
......@@ -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);
......
......@@ -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++) {
......
/*
* 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.
*
* <p>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:
*
* <pre class="code">
* public void MyTests {
*
* &#064;BeforeClass
* public static assumptions() {
* Assume.atLeast(JdkVersion.JAVA_17);
* }
*
* // ... all the test methods that require at least JDK 1.7
* }
* </pre>
*
* If only a single test requires at least JDK 1.7 it can use the
* {@code Assume#atLeast(JdkVersion.JAVA_17)} as shown below:
*
* <pre class="code">
* public void MyTests {
*
* &#064;Test
* public void requiresJdk17 {
* Assume.atLeast(JdkVersion.JAVA_17);
* // ... perform the actual test
* }
* }
* </pre>
*
* 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:
* <pre>
* gradle test -PtestGroups="performance"
* </pre>
*
* 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<TestGroup> 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());
}
}
/*
* 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;
}
}
/*
* 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<TestGroup> parse(String value) {
if (value == null || "".equals(value)) {
return Collections.emptySet();
}
if("ALL".equalsIgnoreCase(value)) {
return EnumSet.allOf(TestGroup.class);
}
Set<TestGroup> groups = new HashSet<TestGroup>();
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;
}
}
/*
* 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));
}
}
/*
* 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.<TestGroup> emptySet()));
}
@Test
public void parseEmptyString() throws Exception {
assertThat(TestGroup.parse(""), is(Collections.<TestGroup> emptySet()));
}
@Test
public void parseWithSpaces() throws Exception {
assertThat(TestGroup.parse("PERFORMANCE, PERFORMANCE"),
is((Set<TestGroup>) EnumSet.of(TestGroup.PERFORMANCE)));
}
@Test
public void parseInMixedCase() throws Exception {
assertThat(TestGroup.parse("performance, PERFormaNCE"),
is((Set<TestGroup>) 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<TestGroup>)EnumSet.allOf(TestGroup.class)));
}
}
......@@ -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()));
......
......@@ -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();
......
......@@ -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);
......
......@@ -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();
......
......@@ -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<string> -> list<integer> 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<string, string> -> map<string, integer> conversionPerformance");
watch.start("convert 4,000,000 with conversion service");
......
......@@ -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;
......
......@@ -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();
......
......@@ -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();
......
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册