Merge branch '5.3.x'
This commit is contained in:
@@ -200,12 +200,9 @@ class JmsTemplateTests {
|
||||
JmsTemplate template = createTemplate();
|
||||
template.setConnectionFactory(this.connectionFactory);
|
||||
|
||||
template.execute(new SessionCallback<Void>() {
|
||||
@Override
|
||||
public Void doInJms(Session session) throws JMSException {
|
||||
session.getTransacted();
|
||||
return null;
|
||||
}
|
||||
template.execute((SessionCallback<Void>) session -> {
|
||||
session.getTransacted();
|
||||
return null;
|
||||
});
|
||||
|
||||
verify(this.session).close();
|
||||
@@ -220,19 +217,13 @@ class JmsTemplateTests {
|
||||
|
||||
TransactionSynchronizationManager.initSynchronization();
|
||||
try {
|
||||
template.execute(new SessionCallback<Void>() {
|
||||
@Override
|
||||
public Void doInJms(Session session) throws JMSException {
|
||||
session.getTransacted();
|
||||
return null;
|
||||
}
|
||||
template.execute((SessionCallback<Void>) session -> {
|
||||
session.getTransacted();
|
||||
return null;
|
||||
});
|
||||
template.execute(new SessionCallback<Void>() {
|
||||
@Override
|
||||
public Void doInJms(Session session) throws JMSException {
|
||||
session.getTransacted();
|
||||
return null;
|
||||
}
|
||||
template.execute((SessionCallback<Void>) session -> {
|
||||
session.getTransacted();
|
||||
return null;
|
||||
});
|
||||
|
||||
assertThat(ConnectionFactoryUtils.getTransactionalSession(scf, null, false)).isSameAs(this.session);
|
||||
@@ -374,29 +365,14 @@ class JmsTemplateTests {
|
||||
}
|
||||
|
||||
if (useDefaultDestination) {
|
||||
template.send(new MessageCreator() {
|
||||
@Override
|
||||
public Message createMessage(Session session) throws JMSException {
|
||||
return session.createTextMessage("just testing");
|
||||
}
|
||||
});
|
||||
template.send(session -> session.createTextMessage("just testing"));
|
||||
}
|
||||
else {
|
||||
if (explicitDestination) {
|
||||
template.send(this.queue, new MessageCreator() {
|
||||
@Override
|
||||
public Message createMessage(Session session) throws JMSException {
|
||||
return session.createTextMessage("just testing");
|
||||
}
|
||||
});
|
||||
template.send(this.queue, (MessageCreator) session -> session.createTextMessage("just testing"));
|
||||
}
|
||||
else {
|
||||
template.send(destinationName, new MessageCreator() {
|
||||
@Override
|
||||
public Message createMessage(Session session) throws JMSException {
|
||||
return session.createTextMessage("just testing");
|
||||
}
|
||||
});
|
||||
template.send(destinationName, (MessageCreator) session -> session.createTextMessage("just testing"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import jakarta.jms.Session;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.jms.StubQueue;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -182,16 +181,13 @@ public class SimpleMessageListenerContainerTests {
|
||||
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
this.container.setDestinationName(DESTINATION_NAME);
|
||||
this.container.setMessageListener(new SessionAwareMessageListener<Message>() {
|
||||
@Override
|
||||
public void onMessage(Message message, @Nullable Session sess) {
|
||||
try {
|
||||
// Check correct Session passed into SessionAwareMessageListener.
|
||||
assertThat(session).isSameAs(sess);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
failure.add("MessageListener execution failed: " + ex);
|
||||
}
|
||||
this.container.setMessageListener((SessionAwareMessageListener<Message>) (Message message, @Nullable Session sess) -> {
|
||||
try {
|
||||
// Check correct Session passed into SessionAwareMessageListener.
|
||||
assertThat(session).isSameAs(sess);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
failure.add("MessageListener execution failed: " + ex);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -231,14 +227,11 @@ public class SimpleMessageListenerContainerTests {
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
this.container.setDestinationName(DESTINATION_NAME);
|
||||
this.container.setMessageListener(listener);
|
||||
this.container.setTaskExecutor(new TaskExecutor() {
|
||||
@Override
|
||||
public void execute(Runnable task) {
|
||||
listener.executorInvoked = true;
|
||||
assertThat(listener.listenerInvoked).isFalse();
|
||||
task.run();
|
||||
assertThat(listener.listenerInvoked).isTrue();
|
||||
}
|
||||
this.container.setTaskExecutor(task -> {
|
||||
listener.executorInvoked = true;
|
||||
assertThat(listener.listenerInvoked).isFalse();
|
||||
task.run();
|
||||
assertThat(listener.listenerInvoked).isTrue();
|
||||
});
|
||||
this.container.afterPropertiesSet();
|
||||
this.container.start();
|
||||
@@ -278,11 +271,8 @@ public class SimpleMessageListenerContainerTests {
|
||||
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
this.container.setDestinationName(DESTINATION_NAME);
|
||||
this.container.setMessageListener(new SessionAwareMessageListener<Message>() {
|
||||
@Override
|
||||
public void onMessage(Message message, @Nullable Session session) throws JMSException {
|
||||
throw theException;
|
||||
}
|
||||
this.container.setMessageListener((SessionAwareMessageListener<Message>) (Message message, @Nullable Session session1) -> {
|
||||
throw theException;
|
||||
});
|
||||
|
||||
ExceptionListener exceptionListener = mock(ExceptionListener.class);
|
||||
@@ -328,11 +318,8 @@ public class SimpleMessageListenerContainerTests {
|
||||
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
this.container.setDestinationName(DESTINATION_NAME);
|
||||
this.container.setMessageListener(new SessionAwareMessageListener<Message>() {
|
||||
@Override
|
||||
public void onMessage(Message message, @Nullable Session session) throws JMSException {
|
||||
throw theException;
|
||||
}
|
||||
this.container.setMessageListener((SessionAwareMessageListener<Message>) (Message message, @Nullable Session session1) -> {
|
||||
throw theException;
|
||||
});
|
||||
|
||||
ErrorHandler errorHandler = mock(ErrorHandler.class);
|
||||
@@ -374,11 +361,8 @@ public class SimpleMessageListenerContainerTests {
|
||||
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
this.container.setDestinationName(DESTINATION_NAME);
|
||||
this.container.setMessageListener(new MessageListener() {
|
||||
@Override
|
||||
public void onMessage(Message message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
this.container.setMessageListener((MessageListener) message -> {
|
||||
throw new UnsupportedOperationException();
|
||||
});
|
||||
this.container.afterPropertiesSet();
|
||||
this.container.start();
|
||||
@@ -418,11 +402,8 @@ public class SimpleMessageListenerContainerTests {
|
||||
|
||||
this.container.setConnectionFactory(connectionFactory);
|
||||
this.container.setDestinationName(DESTINATION_NAME);
|
||||
this.container.setMessageListener(new MessageListener() {
|
||||
@Override
|
||||
public void onMessage(Message message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
this.container.setMessageListener((MessageListener) message -> {
|
||||
throw new UnsupportedOperationException();
|
||||
});
|
||||
this.container.afterPropertiesSet();
|
||||
this.container.start();
|
||||
|
||||
@@ -431,8 +431,8 @@ public class MessagingMessageListenerAdapterTests {
|
||||
}
|
||||
}
|
||||
|
||||
interface Summary {};
|
||||
interface Full extends Summary {};
|
||||
interface Summary {}
|
||||
interface Full extends Summary {}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class SampleResponse {
|
||||
|
||||
@@ -29,8 +29,6 @@ import jakarta.jms.ObjectMessage;
|
||||
import jakarta.jms.Session;
|
||||
import jakarta.jms.TextMessage;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.springframework.jms.support.converter.MessageConversionException;
|
||||
import org.springframework.jms.support.converter.SimpleMessageConverter;
|
||||
@@ -76,12 +74,7 @@ public class SimpleMessageConverterTests {
|
||||
|
||||
given(session.createBytesMessage()).willReturn(message);
|
||||
given(message.getBodyLength()).willReturn((long) content.length);
|
||||
given(message.readBytes(any(byte[].class))).willAnswer(new Answer<Integer>() {
|
||||
@Override
|
||||
public Integer answer(InvocationOnMock invocation) throws Throwable {
|
||||
return byteArrayInputStream.read((byte[]) invocation.getArguments()[0]);
|
||||
}
|
||||
});
|
||||
given(message.readBytes(any(byte[].class))).willAnswer(invocation -> byteArrayInputStream.read((byte[]) invocation.getArguments()[0]));
|
||||
|
||||
SimpleMessageConverter converter = new SimpleMessageConverter();
|
||||
Message msg = converter.toMessage(content, session);
|
||||
|
||||
@@ -299,9 +299,9 @@ class MappingJackson2MessageConverterTests {
|
||||
}
|
||||
|
||||
|
||||
private interface Summary {};
|
||||
private interface Summary {}
|
||||
|
||||
private interface Full extends Summary {};
|
||||
private interface Full extends Summary {}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
Reference in New Issue
Block a user