diff --git a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java index 4397ba95e5..2970b5f0aa 100644 --- a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java +++ b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java @@ -16,17 +16,10 @@ package org.springframework.scheduling.annotation; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.replay; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.util.concurrent.atomic.AtomicInteger; import org.junit.Test; + import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -34,13 +27,17 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.dao.support.PersistenceExceptionTranslator; -import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.stereotype.Repository; import org.springframework.transaction.CallCountingTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.Transactional; +import static org.easymock.EasyMock.*; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + /** * Integration tests cornering bug SPR-8651, which revealed that @Scheduled methods may * not work well with beans that have already been proxied for other reasons such @@ -58,7 +55,8 @@ public class ScheduledAndTransactionalAnnotationIntegrationTests { try { ctx.refresh(); fail("expected exception"); - } catch (BeanCreationException ex) { + } + catch (BeanCreationException ex) { assertTrue(ex.getRootCause().getMessage().startsWith("@Scheduled method 'scheduled' found")); } } @@ -69,7 +67,7 @@ public class ScheduledAndTransactionalAnnotationIntegrationTests { ctx.register(Config.class, SubclassProxyTxConfig.class, RepoConfigA.class); ctx.refresh(); - Thread.sleep(50); // allow @Scheduled method to be called several times + Thread.sleep(100); // allow @Scheduled method to be called several times MyRepository repository = ctx.getBean(MyRepository.class); CallCountingTransactionManager txManager = ctx.getBean(CallCountingTransactionManager.class); @@ -93,6 +91,7 @@ public class ScheduledAndTransactionalAnnotationIntegrationTests { assertThat("no transactions were committed", txManager.commits, greaterThan(0)); } + @Configuration @EnableTransactionManagement static class JdkProxyTxConfig { } @@ -179,5 +178,5 @@ public class ScheduledAndTransactionalAnnotationIntegrationTests { return this.count.get(); } } -} +}