Segregate add'l long-running and performance tests

- Add TestGroup#LONG_RUNNING to distinguish from #PERFORMANCE, the
   former being tests that simply take a long time vs the latter being
   tests that are actually dependent on certain actions happening within
   a given time window and are thefore CPU-dependent.

Issue: SPR-9984
This commit is contained in:
Chris Beams
2013-01-03 12:14:17 +01:00
parent acd86a1fd7
commit 68e3b7773c
19 changed files with 217 additions and 58 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -16,8 +16,6 @@
package org.springframework.aop.aspectj;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.framework.Advised;
@@ -26,9 +24,13 @@ import org.springframework.beans.ITestBean;
import org.springframework.beans.TestBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import test.mixin.Lockable;
import static org.junit.Assert.*;
/**
* @author Rod Johnson
* @author Chris Beams
@@ -63,6 +65,8 @@ public final class DeclareParentsTests {
// on the introduction, in which case this would not be a problem.
@Test
public void testLockingWorks() {
Assume.group(TestGroup.LONG_RUNNING);
Object introductionObject = ctx.getBean("introduction");
assertFalse("Introduction should not be proxied", AopUtils.isAopProxy(introductionObject));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -19,7 +19,6 @@ package org.springframework.context.support;
import java.util.concurrent.CopyOnWriteArrayList;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -27,6 +26,8 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.Lifecycle;
import org.springframework.context.LifecycleProcessor;
import org.springframework.context.SmartLifecycle;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
@@ -251,6 +252,8 @@ public class DefaultLifecycleProcessorTests {
@Test
public void smartLifecycleGroupShutdown() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<Lifecycle>();
TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 300, stoppedBeans);
TestSmartLifecycleBean bean2 = TestSmartLifecycleBean.forShutdownTests(3, 100, stoppedBeans);
@@ -280,6 +283,8 @@ public class DefaultLifecycleProcessorTests {
@Test
public void singleSmartLifecycleShutdown() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<Lifecycle>();
TestSmartLifecycleBean bean = TestSmartLifecycleBean.forShutdownTests(99, 300, stoppedBeans);
StaticApplicationContext context = new StaticApplicationContext();
@@ -386,6 +391,8 @@ public class DefaultLifecycleProcessorTests {
@Test
public void dependentShutdownFirstEvenIfItsPhaseIsLower() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<Lifecycle>();
TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forShutdownTests(Integer.MIN_VALUE, 100, stoppedBeans);
TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 200, stoppedBeans);
@@ -458,6 +465,8 @@ public class DefaultLifecycleProcessorTests {
@Test
public void dependentShutdownFirstAndIsSmartLifecycle() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<Lifecycle>();
TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forShutdownTests(Integer.MIN_VALUE, 400, stoppedBeans);
TestSmartLifecycleBean beanNegative = TestSmartLifecycleBean.forShutdownTests(-99, 100, stoppedBeans);
@@ -521,6 +530,8 @@ public class DefaultLifecycleProcessorTests {
@Test
public void dependentShutdownFirstButNotSmartLifecycle() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<Lifecycle>();
TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 200, stoppedBeans);
TestLifecycleBean simpleBean = TestLifecycleBean.forShutdownTests(stoppedBeans);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -20,6 +20,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.concurrent.Future;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
@@ -28,6 +29,8 @@ import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
@@ -43,6 +46,10 @@ public class AsyncExecutionTests {
private static int listenerConstructed = 0;
@Before
public void setUp() {
Assume.group(TestGroup.PERFORMANCE);
}
@Test
public void asyncMethods() throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Properties;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -37,6 +36,8 @@ import org.springframework.scheduling.config.CronTask;
import org.springframework.scheduling.config.IntervalTask;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.ScheduledMethodRunnable;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
@@ -130,6 +131,8 @@ public class ScheduledAnnotationBeanPostProcessorTests {
@Test
public void cronTask() throws InterruptedException {
Assume.group(TestGroup.LONG_RUNNING);
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
BeanDefinition targetDefinition = new RootBeanDefinition(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -16,15 +16,6 @@
package org.springframework.scheduling.concurrent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.mockito.BDDMockito.willThrow;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
@@ -32,6 +23,12 @@ import java.util.concurrent.ThreadFactory;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.core.task.NoOpRunnable;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;
import static org.mockito.Mockito.*;
/**
* @author Rick Evans
@@ -97,6 +94,8 @@ public class ScheduledExecutorFactoryBeanTests {
@Test
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
Runnable runnable = mock(Runnable.class);
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
@@ -112,6 +111,8 @@ public class ScheduledExecutorFactoryBeanTests {
@Test
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
Runnable runnable = mock(Runnable.class);
ScheduledExecutorTask task = new ScheduledExecutorTask(runnable);
@@ -129,6 +130,8 @@ public class ScheduledExecutorFactoryBeanTests {
@Test
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
Runnable runnable = mock(Runnable.class);
willThrow(new IllegalStateException()).given(runnable).run();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -32,6 +32,7 @@ import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Map;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
@@ -53,6 +54,8 @@ import org.springframework.scripting.ScriptCompilationException;
import org.springframework.scripting.ScriptSource;
import org.springframework.scripting.support.ScriptFactoryPostProcessor;
import org.springframework.stereotype.Component;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
/**
* @author Rob Harrop
@@ -64,6 +67,11 @@ import org.springframework.stereotype.Component;
*/
public class GroovyScriptFactoryTests {
@Before
public void setUp() {
Assume.group(TestGroup.LONG_RUNNING);
}
@Test
public void testStaticScript() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovyContext.xml", getClass());
@@ -396,6 +404,8 @@ public class GroovyScriptFactoryTests {
@Test
public void testAnonymousScriptDetected() throws Exception {
Assume.group(TestGroup.LONG_RUNNING);
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.class);
assertEquals(4, beans.size());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -18,8 +18,8 @@ package org.springframework.scripting.jruby;
import java.util.Map;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.aop.target.dynamic.Refreshable;
import org.springframework.beans.TestBean;
@@ -31,13 +31,18 @@ import org.springframework.scripting.ConfigurableMessenger;
import org.springframework.scripting.Messenger;
import org.springframework.scripting.ScriptCompilationException;
import org.springframework.scripting.TestBeanAwareMessenger;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
/**
* @author Rob Harrop
* @author Rick Evans
* @author Juergen Hoeller
* @author Chris Beams
*/
public class JRubyScriptFactoryTests extends TestCase {
public class JRubyScriptFactoryTests {
private static final String RUBY_SCRIPT_SOURCE_LOCATOR =
"inline:require 'java'\n" +
@@ -45,7 +50,12 @@ public class JRubyScriptFactoryTests extends TestCase {
"end\n" +
"RubyBar.new";
@Before
public void setUp() {
Assume.group(TestGroup.LONG_RUNNING);
}
@Test
public void testStaticScript() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyContext.xml", getClass());
Calculator calc = (Calculator) ctx.getBean("calculator");
@@ -64,6 +74,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals("Message is incorrect", desiredMessage, messenger.getMessage());
}
@Test
public void testNonStaticScript() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyRefreshableContext.xml", getClass());
Messenger messenger = (Messenger) ctx.getBean("messenger");
@@ -81,6 +92,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals("Incorrect refresh count", 2, refreshable.getRefreshCount());
}
@Test
public void testScriptCompilationException() throws Exception {
try {
new ClassPathXmlApplicationContext("jrubyBrokenContext.xml", getClass());
@@ -91,6 +103,7 @@ public class JRubyScriptFactoryTests extends TestCase {
}
}
@Test
public void testCtorWithNullScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory(null, new Class<?>[]{Messenger.class});
@@ -100,6 +113,7 @@ public class JRubyScriptFactoryTests extends TestCase {
}
}
@Test
public void testCtorWithEmptyScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory("", new Class<?>[]{Messenger.class});
@@ -109,6 +123,7 @@ public class JRubyScriptFactoryTests extends TestCase {
}
}
@Test
public void testCtorWithWhitespacedScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory("\n ", new Class<?>[]{Messenger.class});
@@ -118,6 +133,7 @@ public class JRubyScriptFactoryTests extends TestCase {
}
}
@Test
public void testCtorWithNullScriptInterfacesArray() throws Exception {
try {
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR, null);
@@ -127,6 +143,7 @@ public class JRubyScriptFactoryTests extends TestCase {
}
}
@Test
public void testCtorWithEmptyScriptInterfacesArray() throws Exception {
try {
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR, new Class<?>[]{});
@@ -136,6 +153,7 @@ public class JRubyScriptFactoryTests extends TestCase {
}
}
@Test
public void testResourceScriptFromTag() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
TestBean testBean = (TestBean) ctx.getBean("testBean");
@@ -151,6 +169,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals(testBean, messengerByName.getTestBean());
}
@Test
public void testPrototypeScriptFromTag() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
ConfigurableMessenger messenger = (ConfigurableMessenger) ctx.getBean("messengerPrototype");
@@ -166,6 +185,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals("Byebye World!", messenger2.getMessage());
}
@Test
public void testInlineScriptFromTag() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
Calculator calculator = (Calculator) ctx.getBean("calculator");
@@ -173,6 +193,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertFalse(calculator instanceof Refreshable);
}
@Test
public void testRefreshableFromTag() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-with-xsd.xml", getClass());
Messenger messenger = (Messenger) ctx.getBean("refreshableMessenger");
@@ -190,6 +211,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals(0, calc.add(2, -2));
}
@Test
public void testWithComplexArg() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyContext.xml", getClass());
Printer printer = (Printer) ctx.getBean("printer");
@@ -198,6 +220,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals(1, printable.count);
}
@Test
public void testWithPrimitiveArgsInReturnTypeAndParameters() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyContextForPrimitives.xml", getClass());
PrimitiveAdder adder = (PrimitiveAdder) ctx.getBean("adder");
@@ -211,6 +234,7 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals('c', adder.echo('c'));
}
@Test
public void testWithWrapperArgsInReturnTypeAndParameters() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jrubyContextForWrappers.xml", getClass());
WrapperAdder adder = (WrapperAdder) ctx.getBean("adder");
@@ -266,6 +290,7 @@ public class JRubyScriptFactoryTests extends TestCase {
}
}
@Test
public void testAOP() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("jruby-aop.xml", getClass());
Messenger messenger = (Messenger) ctx.getBean("messenger");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -17,7 +17,9 @@
package org.springframework.scripting.support;
import static org.mockito.Mockito.mock;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.FatalBeanException;
import org.springframework.beans.factory.BeanFactory;
@@ -28,12 +30,17 @@ import org.springframework.context.support.GenericApplicationContext;
import org.springframework.scripting.Messenger;
import org.springframework.scripting.ScriptCompilationException;
import org.springframework.scripting.groovy.GroovyScriptFactory;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import static org.junit.Assert.*;
/**
* @author Rick Evans
* @author Juergen Hoeller
* @author Chris Beams
*/
public class ScriptFactoryPostProcessorTests extends TestCase {
public class ScriptFactoryPostProcessorTests {
private static final String MESSAGE_TEXT = "Bingo";
@@ -69,11 +76,17 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
" }\n" +
"}";
@Before
public void setUp() {
Assume.group(TestGroup.PERFORMANCE);
}
@Test
public void testDoesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() throws Exception {
assertNull(new ScriptFactoryPostProcessor().postProcessBeforeInstantiation(getClass(), "a.bean"));
}
@Test
public void testThrowsExceptionIfGivenNonAbstractBeanFactoryImplementation() throws Exception {
try {
new ScriptFactoryPostProcessor().setBeanFactory(mock(BeanFactory.class));
@@ -83,6 +96,7 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
}
}
@Test
public void testChangeScriptWithRefreshableBeanFunctionality() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
@@ -103,6 +117,7 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
assertEquals(EXPECTED_CHANGED_MESSAGE_TEXT, refreshedMessenger.getMessage());
}
@Test
public void testChangeScriptWithNoRefreshableBeanFunctionality() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(false);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
@@ -123,6 +138,7 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
MESSAGE_TEXT, refreshedMessenger.getMessage());
}
@Test
public void testRefreshedScriptReferencePropagatesToCollaborators() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
@@ -150,6 +166,7 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
assertEquals(EXPECTED_CHANGED_MESSAGE_TEXT, collaborator.getMessage());
}
@Test
public void testReferencesAcrossAContainerHierarchy() throws Exception {
GenericApplicationContext businessContext = new GenericApplicationContext();
businessContext.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());
@@ -165,11 +182,13 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
presentationCtx.refresh();
}
@Test
public void testScriptHavingAReferenceToAnotherBean() throws Exception {
// just tests that the (singleton) script-backed bean is able to be instantiated with references to its collaborators
new ClassPathXmlApplicationContext("org/springframework/scripting/support/groovyReferences.xml");
}
@Test
public void testForRefreshedScriptHavingErrorPickedUpOnFirstCall() throws Exception {
BeanDefinition processorBeanDefinition = createScriptFactoryPostProcessor(true);
BeanDefinition scriptedBeanDefinition = createScriptedGroovyBean();
@@ -200,6 +219,7 @@ public class ScriptFactoryPostProcessorTests extends TestCase {
}
}
@Test
public void testPrototypeScriptedBean() throws Exception {
GenericApplicationContext ctx = new GenericApplicationContext();
ctx.registerBeanDefinition("messenger", BeanDefinitionBuilder.rootBeanDefinition(StubMessenger.class).getBeanDefinition());