Polishing

This commit is contained in:
Sam Brannen 2019-08-22 13:17:07 +02:00
parent 3e2b977d5d
commit a07ce8eb82
8 changed files with 85 additions and 90 deletions

View File

@ -45,7 +45,7 @@ public class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests {
} }
@Override @Override
public void testMultiEvict(CacheableService<?> service) { protected void testMultiEvict(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object r1 = service.multiCache(o1); Object r1 = service.multiCache(o1);

View File

@ -33,12 +33,12 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.tests.Assume; import org.springframework.tests.EnabledForTestGroups;
import org.springframework.tests.TestGroup;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFuture;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.tests.TestGroup.PERFORMANCE;
/** /**
* Unit tests for {@link AnnotationAsyncExecutionAspect}. * Unit tests for {@link AnnotationAsyncExecutionAspect}.
@ -46,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Ramnivas Laddad * @author Ramnivas Laddad
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@EnabledForTestGroups(PERFORMANCE)
public class AnnotationAsyncExecutionAspectTests { public class AnnotationAsyncExecutionAspectTests {
private static final long WAIT_TIME = 1000; //milliseconds private static final long WAIT_TIME = 1000; //milliseconds
@ -57,8 +58,6 @@ public class AnnotationAsyncExecutionAspectTests {
@BeforeEach @BeforeEach
public void setUp() { public void setUp() {
Assume.group(TestGroup.PERFORMANCE);
executor = new CountingExecutor(); executor = new CountingExecutor();
AnnotationAsyncExecutionAspect.aspectOf().setExecutor(executor); AnnotationAsyncExecutionAspect.aspectOf().setExecutor(executor);
} }
@ -96,8 +95,6 @@ public class AnnotationAsyncExecutionAspectTests {
@Test @Test
public void voidMethodInAsyncClassGetsRoutedAsynchronously() { public void voidMethodInAsyncClassGetsRoutedAsynchronously() {
Assume.group(TestGroup.PERFORMANCE);
ClassWithAsyncAnnotation obj = new ClassWithAsyncAnnotation(); ClassWithAsyncAnnotation obj = new ClassWithAsyncAnnotation();
obj.increment(); obj.increment();
executor.waitForCompletion(); executor.waitForCompletion();

View File

@ -21,13 +21,11 @@ import javax.transaction.Transactional;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.tests.transaction.CallCountingTransactionManager; import org.springframework.tests.transaction.CallCountingTransactionManager;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -37,8 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
/** /**
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@ExtendWith(SpringExtension.class) @SpringJUnitConfig(JtaTransactionAspectsTests.Config.class)
@ContextConfiguration(classes = JtaTransactionAspectsTests.Config.class)
public class JtaTransactionAspectsTests { public class JtaTransactionAspectsTests {
@Autowired @Autowired

View File

@ -79,7 +79,7 @@ public abstract class AbstractCacheAnnotationTests {
} }
public void testCacheable(CacheableService<?> service) { protected void testCacheable(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object r1 = service.cache(o1); Object r1 = service.cache(o1);
@ -90,7 +90,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r3).isSameAs(r1); assertThat(r3).isSameAs(r1);
} }
public void testCacheableNull(CacheableService<?> service) { protected void testCacheableNull(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
assertThat(this.cm.getCache("testCache").get(o1)).isNull(); assertThat(this.cm.getCache("testCache").get(o1)).isNull();
@ -105,7 +105,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r3).as("Cached value should be null").isNull(); assertThat(r3).as("Cached value should be null").isNull();
} }
public void testCacheableSync(CacheableService<?> service) { protected void testCacheableSync(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object r1 = service.cacheSync(o1); Object r1 = service.cacheSync(o1);
@ -116,7 +116,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r3).isSameAs(r1); assertThat(r3).isSameAs(r1);
} }
public void testCacheableSyncNull(CacheableService<?> service) { protected void testCacheableSyncNull(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
assertThat(this.cm.getCache("testCache").get(o1)).isNull(); assertThat(this.cm.getCache("testCache").get(o1)).isNull();
@ -131,7 +131,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r3).as("Cached value should be null").isNull(); assertThat(r3).as("Cached value should be null").isNull();
} }
public void testEvict(CacheableService<?> service, boolean successExpected) { protected void testEvict(CacheableService<?> service, boolean successExpected) {
Cache cache = this.cm.getCache("testCache"); Cache cache = this.cm.getCache("testCache");
Object o1 = new Object(); Object o1 = new Object();
@ -155,7 +155,7 @@ public abstract class AbstractCacheAnnotationTests {
} }
} }
public void testEvictEarly(CacheableService<?> service) { protected void testEvictEarly(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache"); Cache cache = this.cm.getCache("testCache");
Object o1 = new Object(); Object o1 = new Object();
@ -174,7 +174,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r2).isNotSameAs(r1); assertThat(r2).isNotSameAs(r1);
} }
public void testEvictException(CacheableService<?> service) { protected void testEvictException(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object r1 = service.cache(o1); Object r1 = service.cache(o1);
@ -189,7 +189,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r2).isSameAs(r1); assertThat(r2).isSameAs(r1);
} }
public void testEvictWithKey(CacheableService<?> service) { protected void testEvictWithKey(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object r1 = service.cache(o1); Object r1 = service.cache(o1);
@ -198,7 +198,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r2).isNotSameAs(r1); assertThat(r2).isNotSameAs(r1);
} }
public void testEvictWithKeyEarly(CacheableService<?> service) { protected void testEvictWithKeyEarly(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object r1 = service.cache(o1); Object r1 = service.cache(o1);
@ -212,7 +212,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r2).isNotSameAs(r1); assertThat(r2).isNotSameAs(r1);
} }
public void testEvictAll(CacheableService<?> service, boolean successExpected) { protected void testEvictAll(CacheableService<?> service, boolean successExpected) {
Cache cache = this.cm.getCache("testCache"); Cache cache = this.cm.getCache("testCache");
Object o1 = new Object(); Object o1 = new Object();
@ -246,7 +246,7 @@ public abstract class AbstractCacheAnnotationTests {
} }
} }
public void testEvictAllEarly(CacheableService<?> service) { protected void testEvictAllEarly(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache"); Cache cache = this.cm.getCache("testCache");
Object o1 = new Object(); Object o1 = new Object();
@ -273,7 +273,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r4).isNotSameAs(r2); assertThat(r4).isNotSameAs(r2);
} }
public void testConditionalExpression(CacheableService<?> service) { protected void testConditionalExpression(CacheableService<?> service) {
Object r1 = service.conditional(4); Object r1 = service.conditional(4);
Object r2 = service.conditional(4); Object r2 = service.conditional(4);
@ -285,7 +285,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r4).isSameAs(r3); assertThat(r4).isSameAs(r3);
} }
public void testConditionalExpressionSync(CacheableService<?> service) { protected void testConditionalExpressionSync(CacheableService<?> service) {
Object r1 = service.conditionalSync(4); Object r1 = service.conditionalSync(4);
Object r2 = service.conditionalSync(4); Object r2 = service.conditionalSync(4);
@ -297,7 +297,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r4).isSameAs(r3); assertThat(r4).isSameAs(r3);
} }
public void testUnlessExpression(CacheableService<?> service) { protected void testUnlessExpression(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache"); Cache cache = this.cm.getCache("testCache");
cache.clear(); cache.clear();
service.unless(10); service.unless(10);
@ -306,7 +306,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(cache.get(11)).isNull(); assertThat(cache.get(11)).isNull();
} }
public void testKeyExpression(CacheableService<?> service) { protected void testKeyExpression(CacheableService<?> service) {
Object r1 = service.key(5, 1); Object r1 = service.key(5, 1);
Object r2 = service.key(5, 2); Object r2 = service.key(5, 2);
@ -318,7 +318,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r4).isNotSameAs(r3); assertThat(r4).isNotSameAs(r3);
} }
public void testVarArgsKey(CacheableService<?> service) { protected void testVarArgsKey(CacheableService<?> service) {
Object r1 = service.varArgsKey(1, 2, 3); Object r1 = service.varArgsKey(1, 2, 3);
Object r2 = service.varArgsKey(1, 2, 3); Object r2 = service.varArgsKey(1, 2, 3);
@ -330,8 +330,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(r4).isNotSameAs(r3); assertThat(r4).isNotSameAs(r3);
} }
protected void testNullValue(CacheableService<?> service) {
public void testNullValue(CacheableService<?> service) {
Object key = new Object(); Object key = new Object();
assertThat(service.nullValue(key)).isNull(); assertThat(service.nullValue(key)).isNull();
int nr = service.nullInvocations().intValue(); int nr = service.nullInvocations().intValue();
@ -341,7 +340,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(service.nullInvocations().intValue()).isEqualTo(nr + 1); assertThat(service.nullInvocations().intValue()).isEqualTo(nr + 1);
} }
public void testMethodName(CacheableService<?> service, String keyName) { protected void testMethodName(CacheableService<?> service, String keyName) {
Object key = new Object(); Object key = new Object();
Object r1 = service.name(key); Object r1 = service.name(key);
assertThat(service.name(key)).isSameAs(r1); assertThat(service.name(key)).isSameAs(r1);
@ -350,7 +349,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(cache.get(keyName)).isNotNull(); assertThat(cache.get(keyName)).isNotNull();
} }
public void testRootVars(CacheableService<?> service) { protected void testRootVars(CacheableService<?> service) {
Object key = new Object(); Object key = new Object();
Object r1 = service.rootVars(key); Object r1 = service.rootVars(key);
assertThat(service.rootVars(key)).isSameAs(r1); assertThat(service.rootVars(key)).isSameAs(r1);
@ -360,38 +359,38 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(cache.get(expectedKey)).isNotNull(); assertThat(cache.get(expectedKey)).isNotNull();
} }
public void testCheckedThrowable(CacheableService<?> service) { protected void testCheckedThrowable(CacheableService<?> service) {
String arg = UUID.randomUUID().toString(); String arg = UUID.randomUUID().toString();
assertThatIOException().isThrownBy(() -> assertThatIOException().isThrownBy(() ->
service.throwChecked(arg)) service.throwChecked(arg))
.withMessage(arg); .withMessage(arg);
} }
public void testUncheckedThrowable(CacheableService<?> service) { protected void testUncheckedThrowable(CacheableService<?> service) {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
service.throwUnchecked(1L)) service.throwUnchecked(1L))
.withMessage("1"); .withMessage("1");
} }
public void testCheckedThrowableSync(CacheableService<?> service) { protected void testCheckedThrowableSync(CacheableService<?> service) {
String arg = UUID.randomUUID().toString(); String arg = UUID.randomUUID().toString();
assertThatIOException().isThrownBy(() -> assertThatIOException().isThrownBy(() ->
service.throwCheckedSync(arg)) service.throwCheckedSync(arg))
.withMessage(arg); .withMessage(arg);
} }
public void testUncheckedThrowableSync(CacheableService<?> service) { protected void testUncheckedThrowableSync(CacheableService<?> service) {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
service.throwUncheckedSync(1L)) service.throwUncheckedSync(1L))
.withMessage("1"); .withMessage("1");
} }
public void testNullArg(CacheableService<?> service) { protected void testNullArg(CacheableService<?> service) {
Object r1 = service.cache(null); Object r1 = service.cache(null);
assertThat(service.cache(null)).isSameAs(r1); assertThat(service.cache(null)).isSameAs(r1);
} }
public void testCacheUpdate(CacheableService<?> service) { protected void testCacheUpdate(CacheableService<?> service) {
Object o = new Object(); Object o = new Object();
Cache cache = this.cm.getCache("testCache"); Cache cache = this.cm.getCache("testCache");
assertThat(cache.get(o)).isNull(); assertThat(cache.get(o)).isNull();
@ -404,7 +403,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(cache.get(o).get()).isSameAs(r2); assertThat(cache.get(o).get()).isSameAs(r2);
} }
public void testConditionalCacheUpdate(CacheableService<?> service) { protected void testConditionalCacheUpdate(CacheableService<?> service) {
Integer one = 1; Integer one = 1;
Integer three = 3; Integer three = 3;
@ -416,7 +415,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat((int) Integer.valueOf(cache.get(three).get().toString())).isEqualTo((int) three); assertThat((int) Integer.valueOf(cache.get(three).get().toString())).isEqualTo((int) three);
} }
public void testMultiCache(CacheableService<?> service) { protected void testMultiCache(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object o2 = new Object(); Object o2 = new Object();
@ -442,7 +441,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(secondary.get(o2).get()).isSameAs(r4); assertThat(secondary.get(o2).get()).isSameAs(r4);
} }
public void testMultiEvict(CacheableService<?> service) { protected void testMultiEvict(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object o2 = o1.toString() + "A"; Object o2 = o1.toString() + "A";
@ -472,7 +471,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(secondary.get(o1).get()).isSameAs(r4); assertThat(secondary.get(o1).get()).isSameAs(r4);
} }
public void testMultiPut(CacheableService<?> service) { protected void testMultiPut(CacheableService<?> service) {
Object o = 1; Object o = 1;
Cache primary = this.cm.getCache("primary"); Cache primary = this.cm.getCache("primary");
@ -492,7 +491,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(secondary.get(o).get()).isSameAs(r2); assertThat(secondary.get(o).get()).isSameAs(r2);
} }
public void testPutRefersToResult(CacheableService<?> service) { protected void testPutRefersToResult(CacheableService<?> service) {
Long id = Long.MIN_VALUE; Long id = Long.MIN_VALUE;
TestEntity entity = new TestEntity(); TestEntity entity = new TestEntity();
Cache primary = this.cm.getCache("primary"); Cache primary = this.cm.getCache("primary");
@ -502,7 +501,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(primary.get(id).get()).isSameAs(entity); assertThat(primary.get(id).get()).isSameAs(entity);
} }
public void testMultiCacheAndEvict(CacheableService<?> service) { protected void testMultiCacheAndEvict(CacheableService<?> service) {
String methodName = "multiCacheAndEvict"; String methodName = "multiCacheAndEvict";
Cache primary = this.cm.getCache("primary"); Cache primary = this.cm.getCache("primary");
@ -523,7 +522,7 @@ public abstract class AbstractCacheAnnotationTests {
assertThat(secondary.get(key)).isNull(); assertThat(secondary.get(key)).isNull();
} }
public void testMultiConditionalCacheAndEvict(CacheableService<?> service) { protected void testMultiConditionalCacheAndEvict(CacheableService<?> service) {
Cache primary = this.cm.getCache("primary"); Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary"); Cache secondary = this.cm.getCache("secondary");
Object key = 1; Object key = 1;

View File

@ -21,6 +21,7 @@ import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.MutablePropertyValues;
@ -64,9 +65,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
@Test @Test
@Override @Override
@Disabled("Do nothing here since super is looking for errorCodes we do NOT have in the Context")
public void messageSource() throws NoSuchMessageException { public void messageSource() throws NoSuchMessageException {
// Do nothing here since super is looking for errorCodes we
// do NOT have in the Context
} }
@Test @Test

View File

@ -43,44 +43,43 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
/** /**
*
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public abstract class AbstractJmsAnnotationDrivenTests { abstract class AbstractJmsAnnotationDrivenTests {
@Test @Test
public abstract void sampleConfiguration(); abstract void sampleConfiguration();
@Test @Test
public abstract void fullConfiguration(); abstract void fullConfiguration();
@Test @Test
public abstract void fullConfigurableConfiguration(); abstract void fullConfigurableConfiguration();
@Test @Test
public abstract void customConfiguration(); abstract void customConfiguration();
@Test @Test
public abstract void explicitContainerFactory(); abstract void explicitContainerFactory();
@Test @Test
public abstract void defaultContainerFactory(); abstract void defaultContainerFactory();
@Test @Test
public abstract void jmsHandlerMethodFactoryConfiguration() throws JMSException; abstract void jmsHandlerMethodFactoryConfiguration() throws JMSException;
@Test @Test
public abstract void jmsListenerIsRepeatable(); abstract void jmsListenerIsRepeatable();
@Test @Test
public abstract void jmsListeners(); abstract void jmsListeners();
/** /**
* Test for {@link SampleBean} discovery. If a factory with the default name * Test for {@link SampleBean} discovery. If a factory with the default name
* is set, an endpoint will use it automatically * is set, an endpoint will use it automatically
*/ */
public void testSampleConfiguration(ApplicationContext context) { protected void testSampleConfiguration(ApplicationContext context) {
JmsListenerContainerTestFactory defaultFactory = JmsListenerContainerTestFactory defaultFactory =
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
JmsListenerContainerTestFactory simpleFactory = JmsListenerContainerTestFactory simpleFactory =
@ -94,7 +93,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
* all endpoints provide a default registry. This shows that the default factory * all endpoints provide a default registry. This shows that the default factory
* is only retrieved if it needs to be. * is only retrieved if it needs to be.
*/ */
public void testFullConfiguration(ApplicationContext context) { protected void testFullConfiguration(ApplicationContext context) {
JmsListenerContainerTestFactory simpleFactory = JmsListenerContainerTestFactory simpleFactory =
context.getBean("simpleFactory", JmsListenerContainerTestFactory.class); context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1); assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1);
@ -117,7 +116,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
* with "myCustomEndpointId". The custom endpoint does not provide * with "myCustomEndpointId". The custom endpoint does not provide
* any factory so it's registered with the default one * any factory so it's registered with the default one
*/ */
public void testCustomConfiguration(ApplicationContext context) { protected void testCustomConfiguration(ApplicationContext context) {
JmsListenerContainerTestFactory defaultFactory = JmsListenerContainerTestFactory defaultFactory =
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
JmsListenerContainerTestFactory customFactory = JmsListenerContainerTestFactory customFactory =
@ -141,7 +140,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
* factory to use as a default is registered with an explicit * factory to use as a default is registered with an explicit
* default. * default.
*/ */
public void testExplicitContainerFactoryConfiguration(ApplicationContext context) { protected void testExplicitContainerFactoryConfiguration(ApplicationContext context) {
JmsListenerContainerTestFactory defaultFactory = JmsListenerContainerTestFactory defaultFactory =
context.getBean("simpleFactory", JmsListenerContainerTestFactory.class); context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1); assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1);
@ -151,7 +150,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
* Test for {@link DefaultBean} that does not define the container * Test for {@link DefaultBean} that does not define the container
* factory to use as a default is registered with the default name. * factory to use as a default is registered with the default name.
*/ */
public void testDefaultContainerFactoryConfiguration(ApplicationContext context) { protected void testDefaultContainerFactoryConfiguration(ApplicationContext context) {
JmsListenerContainerTestFactory defaultFactory = JmsListenerContainerTestFactory defaultFactory =
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1); assertThat(defaultFactory.getListenerContainers().size()).isEqualTo(1);
@ -163,7 +162,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
* *
* The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException}
*/ */
public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { protected void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException {
JmsListenerContainerTestFactory simpleFactory = JmsListenerContainerTestFactory simpleFactory =
context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); context.getBean("defaultFactory", JmsListenerContainerTestFactory.class);
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1); assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(1);
@ -180,7 +179,7 @@ public abstract class AbstractJmsAnnotationDrivenTests {
* Test for {@link JmsListenerRepeatableBean} and {@link JmsListenersBean} that validates that the * Test for {@link JmsListenerRepeatableBean} and {@link JmsListenersBean} that validates that the
* {@code @JmsListener} annotation is repeatable and generate one specific container per annotation. * {@code @JmsListener} annotation is repeatable and generate one specific container per annotation.
*/ */
public void testJmsListenerRepeatable(ApplicationContext context) { protected void testJmsListenerRepeatable(ApplicationContext context) {
JmsListenerContainerTestFactory simpleFactory = JmsListenerContainerTestFactory simpleFactory =
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(2); assertThat(simpleFactory.getListenerContainers().size()).isEqualTo(2);

View File

@ -32,12 +32,13 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
/** /**
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Sam Brannen
*/ */
public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenTests { class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void sampleConfiguration() { void sampleConfiguration() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-sample-config.xml", getClass()); "annotation-driven-sample-config.xml", getClass());
testSampleConfiguration(context); testSampleConfiguration(context);
@ -45,7 +46,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void fullConfiguration() { void fullConfiguration() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-full-config.xml", getClass()); "annotation-driven-full-config.xml", getClass());
testFullConfiguration(context); testFullConfiguration(context);
@ -53,7 +54,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void fullConfigurableConfiguration() { void fullConfigurableConfiguration() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-full-configurable-config.xml", getClass()); "annotation-driven-full-configurable-config.xml", getClass());
testFullConfiguration(context); testFullConfiguration(context);
@ -61,7 +62,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void customConfiguration() { void customConfiguration() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-custom-registry.xml", getClass()); "annotation-driven-custom-registry.xml", getClass());
testCustomConfiguration(context); testCustomConfiguration(context);
@ -69,7 +70,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void explicitContainerFactory() { void explicitContainerFactory() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-custom-container-factory.xml", getClass()); "annotation-driven-custom-container-factory.xml", getClass());
testExplicitContainerFactoryConfiguration(context); testExplicitContainerFactoryConfiguration(context);
@ -77,7 +78,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void defaultContainerFactory() { void defaultContainerFactory() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-default-container-factory.xml", getClass()); "annotation-driven-default-container-factory.xml", getClass());
testDefaultContainerFactoryConfiguration(context); testDefaultContainerFactoryConfiguration(context);
@ -85,7 +86,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void jmsHandlerMethodFactoryConfiguration() throws JMSException { void jmsHandlerMethodFactoryConfiguration() throws JMSException {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-custom-handler-method-factory.xml", getClass()); "annotation-driven-custom-handler-method-factory.xml", getClass());
@ -96,7 +97,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void jmsListenerIsRepeatable() { void jmsListenerIsRepeatable() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-jms-listener-repeatable.xml", getClass()); "annotation-driven-jms-listener-repeatable.xml", getClass());
testJmsListenerRepeatable(context); testJmsListenerRepeatable(context);
@ -104,7 +105,7 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
@Override @Override
@Test @Test
public void jmsListeners() { void jmsListeners() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-jms-listeners.xml", getClass()); "annotation-driven-jms-listeners.xml", getClass());
testJmsListenerRepeatable(context); testJmsListenerRepeatable(context);

View File

@ -52,11 +52,11 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Sam Brannen * @author Sam Brannen
*/ */
public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests { class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void sampleConfiguration() { void sampleConfiguration() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsSampleConfig.class, SampleBean.class); EnableJmsSampleConfig.class, SampleBean.class);
testSampleConfiguration(context); testSampleConfiguration(context);
@ -64,7 +64,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void fullConfiguration() { void fullConfiguration() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsFullConfig.class, FullBean.class); EnableJmsFullConfig.class, FullBean.class);
testFullConfiguration(context); testFullConfiguration(context);
@ -72,7 +72,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void fullConfigurableConfiguration() { void fullConfigurableConfiguration() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsFullConfigurableConfig.class, FullConfigurableBean.class); EnableJmsFullConfigurableConfig.class, FullConfigurableBean.class);
testFullConfiguration(context); testFullConfiguration(context);
@ -80,7 +80,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void customConfiguration() { void customConfiguration() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsCustomConfig.class, CustomBean.class); EnableJmsCustomConfig.class, CustomBean.class);
testCustomConfiguration(context); testCustomConfiguration(context);
@ -88,7 +88,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void explicitContainerFactory() { void explicitContainerFactory() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsCustomContainerFactoryConfig.class, DefaultBean.class); EnableJmsCustomContainerFactoryConfig.class, DefaultBean.class);
testExplicitContainerFactoryConfiguration(context); testExplicitContainerFactoryConfiguration(context);
@ -96,14 +96,15 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void defaultContainerFactory() { void defaultContainerFactory() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class); EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class);
testDefaultContainerFactoryConfiguration(context); testDefaultContainerFactoryConfiguration(context);
} }
@Test @Test
public void containerAreStartedByDefault() { @SuppressWarnings("resource")
void containerAreStartedByDefault() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class); EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class);
JmsListenerContainerTestFactory factory = JmsListenerContainerTestFactory factory =
@ -114,7 +115,8 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
} }
@Test @Test
public void containerCanBeStarterViaTheRegistry() { @SuppressWarnings("resource")
void containerCanBeStarterViaTheRegistry() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsAutoStartupFalseConfig.class, DefaultBean.class); EnableJmsAutoStartupFalseConfig.class, DefaultBean.class);
JmsListenerContainerTestFactory factory = JmsListenerContainerTestFactory factory =
@ -129,7 +131,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void jmsHandlerMethodFactoryConfiguration() throws JMSException { void jmsHandlerMethodFactoryConfiguration() throws JMSException {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class); EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class);
@ -140,7 +142,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void jmsListenerIsRepeatable() { void jmsListenerIsRepeatable() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, JmsListenerRepeatableBean.class); EnableJmsDefaultContainerFactoryConfig.class, JmsListenerRepeatableBean.class);
testJmsListenerRepeatable(context); testJmsListenerRepeatable(context);
@ -148,14 +150,14 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
public void jmsListeners() { void jmsListeners() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, JmsListenersBean.class); EnableJmsDefaultContainerFactoryConfig.class, JmsListenersBean.class);
testJmsListenerRepeatable(context); testJmsListenerRepeatable(context);
} }
@Test @Test
public void composedJmsListeners() { void composedJmsListeners() {
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) { EnableJmsDefaultContainerFactoryConfig.class, ComposedJmsListenersBean.class)) {
JmsListenerContainerTestFactory simpleFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory simpleFactory = context.getBean("jmsListenerContainerFactory",
@ -178,7 +180,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Test @Test
@SuppressWarnings("resource") @SuppressWarnings("resource")
public void unknownFactory() { void unknownFactory() {
// not found // not found
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class)) new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class))
@ -186,7 +188,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
} }
@Test @Test
public void lazyComponent() { void lazyComponent() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class); EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class);
JmsListenerContainerTestFactory defaultFactory = JmsListenerContainerTestFactory defaultFactory =