Merge branch '4.1.x'
This commit is contained in:
@@ -47,6 +47,7 @@ dependencies {
|
||||
api("org.aspectj:aspectjrt:1.9.24")
|
||||
api("org.aspectj:aspectjweaver:1.9.24")
|
||||
api("org.assertj:assertj-core:3.27.3")
|
||||
api("org.awaitility:awaitility:4.3.0")
|
||||
api("org.dom4j:dom4j:2.1.4")
|
||||
api("org.easymock:easymock:5.5.0")
|
||||
api("org.eclipse.angus:angus-mail:2.0.3")
|
||||
|
||||
@@ -34,6 +34,7 @@ dependencies {
|
||||
testImplementation("org.apache.logging.log4j:log4j-core")
|
||||
testImplementation("org.apache.logging.log4j:log4j-slf4j2-impl")
|
||||
testImplementation("org.assertj:assertj-core")
|
||||
testImplementation("org.awaitility:awaitility")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testImplementation("org.slf4j:slf4j-api")
|
||||
testImplementation("org.springframework:spring-test")
|
||||
|
||||
@@ -26,11 +26,14 @@ import jakarta.jms.BytesMessage;
|
||||
import jakarta.jms.ConnectionFactory;
|
||||
import jakarta.jms.JMSException;
|
||||
import jakarta.jms.Message;
|
||||
import jakarta.jms.QueueBrowser;
|
||||
import jakarta.jms.Session;
|
||||
import jakarta.jms.TextMessage;
|
||||
import jakarta.xml.soap.MessageFactory;
|
||||
import jakarta.xml.soap.SOAPConstants;
|
||||
import jakarta.xml.soap.SOAPException;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.awaitility.Awaitility;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -40,6 +43,8 @@ import org.springframework.context.annotation.Import;
|
||||
import org.springframework.jms.annotation.EnableJms;
|
||||
import org.springframework.jms.annotation.JmsListener;
|
||||
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
|
||||
import org.springframework.jms.core.BrowserCallback;
|
||||
import org.springframework.jms.core.JmsTemplate;
|
||||
import org.springframework.jms.core.MessagePostProcessor;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
@@ -60,6 +65,9 @@ class JmsMessageSenderIntegrationTests {
|
||||
|
||||
private static final MessageFactory messageFactory = createMessageFactory();
|
||||
|
||||
@Autowired
|
||||
private ConnectionFactory connectionFactory;
|
||||
|
||||
@Autowired
|
||||
private JmsMessageSender messageSender;
|
||||
|
||||
@@ -100,6 +108,7 @@ class JmsMessageSenderIntegrationTests {
|
||||
assertNonEmptyByteMessage(message);
|
||||
return createEmptySoapMessage();
|
||||
});
|
||||
waitForReply(responseQueueName);
|
||||
|
||||
SoapMessage response = (SoapMessage) connection.receive(new SaajSoapMessageFactory(messageFactory));
|
||||
assertThat(response).isNotNull();
|
||||
@@ -203,6 +212,18 @@ class JmsMessageSenderIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
private void waitForReply(String destinationName) {
|
||||
JmsTemplate jmsTemplate = new JmsTemplate(this.connectionFactory);
|
||||
Awaitility.await()
|
||||
.atMost(Duration.ofSeconds(3))
|
||||
.until(() -> jmsTemplate.browse(destinationName, new BrowserCallback<Boolean>() {
|
||||
@Override
|
||||
public Boolean doInJms(Session session, QueueBrowser browser) throws JMSException {
|
||||
return browser.getEnumeration().hasMoreElements();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
static class TestJmsListener {
|
||||
|
||||
private ThrowingFunction<jakarta.jms.Message, Object> messageHandler;
|
||||
@@ -239,7 +260,7 @@ class JmsMessageSenderIntegrationTests {
|
||||
@Bean
|
||||
JmsMessageSender messageSender(ConnectionFactory connectionFactory) {
|
||||
JmsMessageSender messageSender = new JmsMessageSender(connectionFactory);
|
||||
messageSender.setReceiveTimeout(Duration.ofSeconds(2).toMillis());
|
||||
messageSender.setReceiveTimeout(Duration.ofSeconds(1).toMillis());
|
||||
return messageSender;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user