Skip to content

Commit

Permalink
Polishing (backported from master)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Mar 12, 2021
1 parent ae27118 commit 215514f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -198,9 +198,9 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe

private int registeredWithDestination = 0;

private volatile boolean recovering = false;
private volatile boolean recovering;

private volatile boolean interrupted = false;
private volatile boolean interrupted;

@Nullable
private Runnable stopCallback;
Expand Down Expand Up @@ -963,11 +963,8 @@ protected void refreshConnectionUntilSuccessful() {
}
}
if (!applyBackOffTime(execution)) {
StringBuilder msg = new StringBuilder();
msg.append("Stopping container for destination '")
.append(getDestinationDescription())
.append("': back-off policy does not allow ").append("for further attempts.");
logger.error(msg.toString());
logger.error("Stopping container for destination '" + getDestinationDescription() +
"': back-off policy does not allow for further attempts.");
stop();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -69,12 +69,12 @@ public class JmsNamespaceHandlerTests {


@BeforeEach
public void setUp() throws Exception {
public void setup() {
this.context = new ToolingTestApplicationContext("jmsNamespaceHandlerTests.xml", getClass());
}

@AfterEach
public void tearDown() throws Exception {
public void shutdown() {
this.context.close();
}

Expand All @@ -87,13 +87,12 @@ public void testBeansCreated() {
containers = context.getBeansOfType(GenericMessageEndpointManager.class);
assertThat(containers.size()).as("Context should contain 3 JCA endpoint containers").isEqualTo(3);

Map<String, JmsListenerContainerFactory> containerFactories =
context.getBeansOfType(JmsListenerContainerFactory.class);
assertThat(containerFactories.size()).as("Context should contain 3 JmsListenerContainerFactory instances").isEqualTo(3);
assertThat(context.getBeansOfType(JmsListenerContainerFactory.class))
.as("Context should contain 3 JmsListenerContainerFactory instances").hasSize(3);
}

@Test
public void testContainerConfiguration() throws Exception {
public void testContainerConfiguration() {
Map<String, DefaultMessageListenerContainer> containers = context.getBeansOfType(DefaultMessageListenerContainer.class);
ConnectionFactory defaultConnectionFactory = context.getBean(DEFAULT_CONNECTION_FACTORY, ConnectionFactory.class);
ConnectionFactory explicitConnectionFactory = context.getBean(EXPLICIT_CONNECTION_FACTORY, ConnectionFactory.class);
Expand All @@ -115,7 +114,7 @@ else if (container.getConnectionFactory().equals(explicitConnectionFactory)) {
}

@Test
public void testJcaContainerConfiguration() throws Exception {
public void testJcaContainerConfiguration() {
Map<String, JmsMessageEndpointManager> containers = context.getBeansOfType(JmsMessageEndpointManager.class);

assertThat(containers.containsKey("listener3")).as("listener3 not found").isTrue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -75,8 +75,7 @@ public void testSettingMessageListenerToAnUnsupportedType() {
@Test
public void testSessionTransactedModeReallyDoesDefaultToFalse() {
assertThat(this.container.isPubSubNoLocal()).as("The [pubSubLocal] property of SimpleMessageListenerContainer " +
"must default to false. Change this test (and the " +
"attendant Javadoc) if you have changed the default.").isFalse();
"must default to false. Change this test (and the attendant javadoc) if you have changed the default.").isFalse();
}

@Test
Expand Down Expand Up @@ -121,6 +120,7 @@ public void testContextRefreshedEventDoesNotStartTheConnectionIfAutoStartIsSetTo
GenericApplicationContext context = new GenericApplicationContext();
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
context.refresh();
context.close();

verify(connection).setExceptionListener(this.container);
}
Expand Down Expand Up @@ -151,6 +151,7 @@ public void testContextRefreshedEventStartsTheConnectionByDefault() throws Excep
GenericApplicationContext context = new GenericApplicationContext();
context.getBeanFactory().registerSingleton("messageListenerContainer", this.container);
context.refresh();
context.close();

verify(connection).setExceptionListener(this.container);
verify(connection).start();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -58,7 +58,7 @@ public class ReactorNettyTcpStompClientTests {


@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
public void setup(TestInfo testInfo) throws Exception {
logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'");

int port = SocketUtils.findAvailableTcpPort(61613);
Expand All @@ -81,7 +81,7 @@ public void setUp(TestInfo testInfo) throws Exception {
}

@AfterEach
public void tearDown() throws Exception {
public void shutdown() throws Exception {
try {
this.client.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
Expand Down Expand Up @@ -75,19 +75,19 @@ public class StompBrokerRelayMessageHandlerIntegrationTests {


@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
public void setup(TestInfo testInfo) throws Exception {
logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'");

this.port = SocketUtils.findAvailableTcpPort(61613);
this.responseChannel = new ExecutorSubscribableChannel();
this.responseHandler = new TestMessageHandler();
this.responseChannel.subscribe(this.responseHandler);
this.eventPublisher = new TestEventPublisher();
startActiveMqBroker();
startActiveMQBroker();
createAndStartRelay();
}

private void startActiveMqBroker() throws Exception {
private void startActiveMQBroker() throws Exception {
this.activeMQBroker = new BrokerService();
this.activeMQBroker.addConnector("stomp://localhost:" + this.port);
this.activeMQBroker.setStartAsync(false);
Expand Down Expand Up @@ -217,7 +217,7 @@ public void relayReconnectsIfBrokerComesBackUp() throws Exception {

this.eventPublisher.expectBrokerAvailabilityEvent(false);

startActiveMqBroker();
startActiveMQBroker();
this.eventPublisher.expectBrokerAvailabilityEvent(true);
}

Expand Down Expand Up @@ -274,8 +274,7 @@ public void handleMessage(Message<?> message) throws MessagingException {
}

public void expectMessages(MessageExchange... messageExchanges) throws InterruptedException {
List<MessageExchange> expectedMessages =
new ArrayList<>(Arrays.<MessageExchange>asList(messageExchanges));
List<MessageExchange> expectedMessages = new ArrayList<>(Arrays.asList(messageExchanges));
while (expectedMessages.size() > 0) {
Message<?> message = this.queue.poll(10000, TimeUnit.MILLISECONDS);
assertThat(message).as("Timed out waiting for messages, expected [" + expectedMessages + "]").isNotNull();
Expand Down Expand Up @@ -451,7 +450,7 @@ public StompFrameMessageMatcher(StompCommand command, String sessionId) {
@Override
public final boolean match(Message<?> message) {
StompHeaderAccessor headers = StompHeaderAccessor.wrap(message);
if (!this.command.equals(headers.getCommand()) || (this.sessionId != headers.getSessionId())) {
if (!this.command.equals(headers.getCommand()) || !this.sessionId.equals(headers.getSessionId())) {
return false;
}
return matchInternal(headers, message.getPayload());
Expand Down

0 comments on commit 215514f

Please sign in to comment.