Polishing

This commit is contained in:
Juergen Hoeller
2016-04-04 20:51:30 +02:00
parent d554229981
commit 26378cd604
6 changed files with 46 additions and 41 deletions

View File

@@ -187,7 +187,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@SuppressWarnings("resource")
public void unknownFactory() {
thrown.expect(BeanCreationException.class);
thrown.expectMessage("customFactory"); // Not found
thrown.expectMessage("customFactory"); // not found
new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class);
}
@@ -199,11 +199,11 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
assertEquals(0, defaultFactory.getListenerContainers().size());
context.getBean(LazyBean.class); // trigger lazy resolution
context.getBean(LazyBean.class); // trigger lazy resolution
assertEquals(1, defaultFactory.getListenerContainers().size());
MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0);
assertTrue("Should have been started " + container, container.isStarted());
context.close(); // Close and stop the listeners
context.close(); // close and stop the listeners
assertTrue("Should have been stopped " + container, container.isStopped());
}
@@ -339,6 +339,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
}
@Configuration
@EnableJms
static class EnableJmsAutoStartupFalseConfig implements JmsListenerConfigurer {
@@ -378,6 +379,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
String concurrency() default "";
}
@JmsListener(destination = "billingQueue")
@Retention(RetentionPolicy.RUNTIME)
private @interface BillingQueueListener {
@@ -389,6 +391,7 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
String concurrency() default "";
}
@Component
static class ComposedJmsListenersBean {

View File

@@ -31,10 +31,12 @@ public class JmsListenerContainerTestFactory implements JmsListenerContainerFact
private final Map<String, MessageListenerTestContainer> listenerContainers =
new LinkedHashMap<>();
public void setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup;
}
public List<MessageListenerTestContainer> getListenerContainers() {
return new ArrayList<>(this.listenerContainers.values());
}

View File

@@ -26,8 +26,7 @@ import org.springframework.jms.support.destination.DestinationResolver;
/**
* @author Stephane Nicoll
*/
public class MessageListenerTestContainer
implements MessageListenerContainer, InitializingBean, DisposableBean {
public class MessageListenerTestContainer implements MessageListenerContainer, InitializingBean, DisposableBean {
private final JmsListenerEndpoint endpoint;
@@ -41,10 +40,12 @@ public class MessageListenerTestContainer
private boolean destroyInvoked;
MessageListenerTestContainer(JmsListenerEndpoint endpoint) {
this.endpoint = endpoint;
}
public void setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup;
}
@@ -133,8 +134,7 @@ public class MessageListenerTestContainer
@Override
public void destroy() {
if (!stopInvoked) {
throw new IllegalStateException("Stop should have been invoked before " +
"destroy on " + this);
throw new IllegalStateException("Stop should have been invoked before " + "destroy on " + this);
}
destroyInvoked = true;
}
@@ -150,4 +150,5 @@ public class MessageListenerTestContainer
sb.append('}');
return sb.toString();
}
}