This commit is contained in:
Stéphane Nicoll 2023-12-27 12:51:58 +01:00
parent 699f93fed7
commit 70f31dee45
40 changed files with 322 additions and 339 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2023 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.
@ -16,9 +16,7 @@
package org.springframework.jca;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.InvalidPropertyException;
import jakarta.resource.spi.ResourceAdapter;
/**
@ -27,7 +25,7 @@ import jakarta.resource.spi.ResourceAdapter;
public class StubActivationSpec implements ActivationSpec {
@Override
public void validate() throws InvalidPropertyException {
public void validate() {
}
@Override
@ -36,7 +34,7 @@ public class StubActivationSpec implements ActivationSpec {
}
@Override
public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
public void setResourceAdapter(ResourceAdapter resourceAdapter) {
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2023 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.
@ -18,11 +18,9 @@ package org.springframework.jca;
import javax.transaction.xa.XAResource;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.BootstrapContext;
import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterInternalException;
import jakarta.resource.spi.endpoint.MessageEndpointFactory;
/**
@ -31,7 +29,7 @@ import jakarta.resource.spi.endpoint.MessageEndpointFactory;
public class StubResourceAdapter implements ResourceAdapter {
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
public void start(BootstrapContext bootstrapContext) {
}
@Override
@ -39,7 +37,7 @@ public class StubResourceAdapter implements ResourceAdapter {
}
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
}
@Override
@ -47,7 +45,7 @@ public class StubResourceAdapter implements ResourceAdapter {
}
@Override
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException {
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) {
return null;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2023 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.
@ -19,7 +19,6 @@ package org.springframework.jms;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSException;
/**
* A stub implementation of the JMS ConnectionFactory for testing.
@ -29,12 +28,12 @@ import jakarta.jms.JMSException;
public class StubConnectionFactory implements ConnectionFactory {
@Override
public Connection createConnection() throws JMSException {
public Connection createConnection() {
return null;
}
@Override
public Connection createConnection(String username, String password) throws JMSException {
public Connection createConnection(String username, String password) {
return null;
}

View File

@ -67,56 +67,56 @@ public class StubTextMessage implements TextMessage {
@Override
public String getText() throws JMSException {
public String getText() {
return this.text;
}
@Override
public void setText(String text) throws JMSException {
public void setText(String text) {
this.text = text;
}
@Override
public void acknowledge() throws JMSException {
public void acknowledge() {
throw new UnsupportedOperationException();
}
@Override
public void clearBody() throws JMSException {
public void clearBody() {
this.text = null;
}
@Override
public void clearProperties() throws JMSException {
public void clearProperties() {
this.properties.clear();
}
@Override
public boolean getBooleanProperty(String name) throws JMSException {
public boolean getBooleanProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof Boolean b) ? b : false;
}
@Override
public byte getByteProperty(String name) throws JMSException {
public byte getByteProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof Byte b) ? b : 0;
}
@Override
public double getDoubleProperty(String name) throws JMSException {
public double getDoubleProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof Double d) ? d : 0;
}
@Override
public float getFloatProperty(String name) throws JMSException {
public float getFloatProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof Float f) ? f : 0;
}
@Override
public int getIntProperty(String name) throws JMSException {
public int getIntProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof Integer i) ? i : 0;
}
@ -127,7 +127,7 @@ public class StubTextMessage implements TextMessage {
}
@Override
public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
public byte[] getJMSCorrelationIDAsBytes() {
return this.correlationId.getBytes();
}
@ -177,12 +177,12 @@ public class StubTextMessage implements TextMessage {
}
@Override
public long getJMSDeliveryTime() throws JMSException {
public long getJMSDeliveryTime() {
return this.deliveryTime;
}
@Override
public long getLongProperty(String name) throws JMSException {
public long getLongProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof Long l) ? l : 0;
}
@ -193,49 +193,49 @@ public class StubTextMessage implements TextMessage {
}
@Override
public Enumeration<?> getPropertyNames() throws JMSException {
public Enumeration<?> getPropertyNames() {
return this.properties.keys();
}
@Override
public short getShortProperty(String name) throws JMSException {
public short getShortProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof Short s) ? s : 0;
}
@Override
public String getStringProperty(String name) throws JMSException {
public String getStringProperty(String name) {
Object value = this.properties.get(name);
return (value instanceof String text) ? text : null;
}
@Override
public boolean propertyExists(String name) throws JMSException {
public boolean propertyExists(String name) {
return this.properties.containsKey(name);
}
@Override
public void setBooleanProperty(String name, boolean value) throws JMSException {
public void setBooleanProperty(String name, boolean value) {
this.properties.put(name, value);
}
@Override
public void setByteProperty(String name, byte value) throws JMSException {
public void setByteProperty(String name, byte value) {
this.properties.put(name, value);
}
@Override
public void setDoubleProperty(String name, double value) throws JMSException {
public void setDoubleProperty(String name, double value) {
this.properties.put(name, value);
}
@Override
public void setFloatProperty(String name, float value) throws JMSException {
public void setFloatProperty(String name, float value) {
this.properties.put(name, value);
}
@Override
public void setIntProperty(String name, int value) throws JMSException {
public void setIntProperty(String name, int value) {
this.properties.put(name, value);
}
@ -245,37 +245,37 @@ public class StubTextMessage implements TextMessage {
}
@Override
public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException {
public void setJMSCorrelationIDAsBytes(byte[] correlationID) {
this.correlationId = new String(correlationID);
}
@Override
public void setJMSDeliveryMode(int deliveryMode) throws JMSException {
public void setJMSDeliveryMode(int deliveryMode) {
this.deliveryMode = deliveryMode;
}
@Override
public void setJMSDestination(Destination destination) throws JMSException {
public void setJMSDestination(Destination destination) {
this.destination = destination;
}
@Override
public void setJMSExpiration(long expiration) throws JMSException {
public void setJMSExpiration(long expiration) {
this.expiration = expiration;
}
@Override
public void setJMSMessageID(String id) throws JMSException {
public void setJMSMessageID(String id) {
this.messageId = id;
}
@Override
public void setJMSPriority(int priority) throws JMSException {
public void setJMSPriority(int priority) {
this.priority = priority;
}
@Override
public void setJMSRedelivered(boolean redelivered) throws JMSException {
public void setJMSRedelivered(boolean redelivered) {
this.redelivered = redelivered;
}
@ -285,7 +285,7 @@ public class StubTextMessage implements TextMessage {
}
@Override
public void setJMSTimestamp(long timestamp) throws JMSException {
public void setJMSTimestamp(long timestamp) {
this.timestamp = timestamp;
}
@ -295,12 +295,12 @@ public class StubTextMessage implements TextMessage {
}
@Override
public void setJMSDeliveryTime(long deliveryTime) throws JMSException {
public void setJMSDeliveryTime(long deliveryTime) {
this.deliveryTime = deliveryTime;
}
@Override
public void setLongProperty(String name, long value) throws JMSException {
public void setLongProperty(String name, long value) {
this.properties.put(name, value);
}
@ -310,23 +310,22 @@ public class StubTextMessage implements TextMessage {
}
@Override
public void setShortProperty(String name, short value) throws JMSException {
public void setShortProperty(String name, short value) {
this.properties.put(name, value);
}
@Override
public void setStringProperty(String name, String value) throws JMSException {
public void setStringProperty(String name, String value) {
this.properties.put(name, value);
}
@Override
public <T> T getBody(Class<T> c) throws JMSException {
public <T> T getBody(Class<T> c) {
return null;
}
@Override
@SuppressWarnings("rawtypes")
public boolean isBodyAssignableTo(Class c) throws JMSException {
public boolean isBodyAssignableTo(Class c) {
return false;
}

View File

@ -65,7 +65,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
abstract void defaultContainerFactory();
@Test
abstract void jmsHandlerMethodFactoryConfiguration() throws JMSException;
abstract void jmsHandlerMethodFactoryConfiguration();
@Test
abstract void jmsListenerIsRepeatable();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 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.
@ -16,7 +16,6 @@
package org.springframework.jms.annotation;
import jakarta.jms.JMSException;
import jakarta.jms.MessageListener;
import org.junit.jupiter.api.Test;
@ -85,7 +84,7 @@ class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenTests {
@Override
@Test
void jmsHandlerMethodFactoryConfiguration() throws JMSException {
void jmsHandlerMethodFactoryConfiguration() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-custom-handler-method-factory.xml", getClass());

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -19,7 +19,6 @@ package org.springframework.jms.annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import jakarta.jms.JMSException;
import jakarta.jms.MessageListener;
import org.junit.jupiter.api.Test;
@ -103,7 +102,6 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
@Test
@SuppressWarnings("resource")
void containerAreStartedByDefault() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class);
@ -115,7 +113,6 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
@Test
@SuppressWarnings("resource")
void containerCanBeStarterViaTheRegistry() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsAutoStartupFalseConfig.class, DefaultBean.class);
@ -131,7 +128,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override
@Test
void jmsHandlerMethodFactoryConfiguration() throws JMSException {
void jmsHandlerMethodFactoryConfiguration() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class);
@ -179,7 +176,6 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
}
@Test
@SuppressWarnings("resource")
void unknownFactory() {
// not found
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->

View File

@ -141,7 +141,6 @@ class JmsListenerAnnotationBeanPostProcessorTests {
}
@Test
@SuppressWarnings("resource")
void invalidProxy() {
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
new AnnotationConfigApplicationContext(Config.class, ProxyConfig.class, InvalidProxyTestBean.class))

View File

@ -47,7 +47,7 @@ import static org.mockito.Mockito.mock;
/**
* @author Stephane Nicoll
*/
public class JmsListenerContainerFactoryIntegrationTests {
class JmsListenerContainerFactoryIntegrationTests {
private final DefaultJmsListenerContainerFactory containerFactory = new DefaultJmsListenerContainerFactory();
@ -59,19 +59,19 @@ public class JmsListenerContainerFactoryIntegrationTests {
@BeforeEach
public void setup() {
void setup() {
initializeFactory(factory);
}
@Test
public void messageConverterUsedIfSet() throws JMSException {
void messageConverterUsedIfSet() throws JMSException {
this.containerFactory.setMessageConverter(new UpperCaseMessageConverter());
testMessageConverterIsUsed();
}
@Test
public void messagingMessageConverterCanBeUsed() throws JMSException {
void messagingMessageConverterCanBeUsed() throws JMSException {
MessagingMessageConverter converter = new MessagingMessageConverter();
converter.setPayloadConverter(new UpperCaseMessageConverter());
this.containerFactory.setMessageConverter(converter);
@ -89,7 +89,7 @@ public class JmsListenerContainerFactoryIntegrationTests {
}
@Test
public void parameterAnnotationWithJdkProxy() throws JMSException {
void parameterAnnotationWithJdkProxy() throws JMSException {
ProxyFactory pf = new ProxyFactory(sample);
listener = (JmsEndpointSampleInterface) pf.getProxy();
@ -105,7 +105,7 @@ public class JmsListenerContainerFactoryIntegrationTests {
}
@Test
public void parameterAnnotationWithCglibProxy() throws JMSException {
void parameterAnnotationWithCglibProxy() throws JMSException {
ProxyFactory pf = new ProxyFactory(sample);
pf.setProxyTargetClass(true);
listener = (JmsEndpointSampleBean) pf.getProxy();
@ -178,7 +178,7 @@ public class JmsListenerContainerFactoryIntegrationTests {
private static class UpperCaseMessageConverter implements MessageConverter {
@Override
public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException {
public Message toMessage(Object object, Session session) throws MessageConversionException {
return new StubTextMessage(object.toString().toUpperCase());
}

View File

@ -47,7 +47,7 @@ import static org.mockito.Mockito.mock;
/**
* @author Stephane Nicoll
*/
public class JmsListenerContainerFactoryTests {
class JmsListenerContainerFactoryTests {
private final ConnectionFactory connectionFactory = new StubConnectionFactory();
@ -59,7 +59,7 @@ public class JmsListenerContainerFactoryTests {
@Test
public void createSimpleContainer() {
void createSimpleContainer() {
SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
setDefaultJmsConfig(factory);
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
@ -76,7 +76,7 @@ public class JmsListenerContainerFactoryTests {
}
@Test
public void createJmsContainerFullConfig() {
void createJmsContainerFullConfig() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
TestObservationRegistry testObservationRegistry = TestObservationRegistry.create();
setDefaultJmsConfig(factory);
@ -103,7 +103,7 @@ public class JmsListenerContainerFactoryTests {
}
@Test
public void createJcaContainerFullConfig() {
void createJcaContainerFullConfig() {
DefaultJcaListenerContainerFactory factory = new DefaultJcaListenerContainerFactory();
setDefaultJcaConfig(factory);
factory.setConcurrency("10");
@ -121,7 +121,7 @@ public class JmsListenerContainerFactoryTests {
}
@Test
public void jcaExclusiveProperties() {
void jcaExclusiveProperties() {
DefaultJcaListenerContainerFactory factory = new DefaultJcaListenerContainerFactory();
factory.setDestinationResolver(this.destinationResolver);
factory.setActivationSpecFactory(new StubJmsActivationSpecFactory());
@ -133,7 +133,7 @@ public class JmsListenerContainerFactoryTests {
}
@Test
public void backOffOverridesRecoveryInterval() {
void backOffOverridesRecoveryInterval() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
BackOff backOff = new FixedBackOff();
factory.setBackOff(backOff);
@ -149,7 +149,7 @@ public class JmsListenerContainerFactoryTests {
}
@Test
public void endpointConcurrencyTakesPrecedence() {
void endpointConcurrencyTakesPrecedence() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConcurrency("2-10");

View File

@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* @author Stephane Nicoll
*/
public class JmsListenerEndpointRegistrarTests {
class JmsListenerEndpointRegistrarTests {
private final JmsListenerEndpointRegistrar registrar = new JmsListenerEndpointRegistrar();
@ -38,26 +38,26 @@ public class JmsListenerEndpointRegistrarTests {
@BeforeEach
public void setup() {
void setup() {
this.registrar.setEndpointRegistry(this.registry);
this.registrar.setBeanFactory(new StaticListableBeanFactory());
}
@Test
public void registerNullEndpoint() {
void registerNullEndpoint() {
assertThatIllegalArgumentException().isThrownBy(() ->
this.registrar.registerEndpoint(null, this.containerFactory));
}
@Test
public void registerNullEndpointId() {
void registerNullEndpointId() {
assertThatIllegalArgumentException().isThrownBy(() ->
this.registrar.registerEndpoint(new SimpleJmsListenerEndpoint(), this.containerFactory));
}
@Test
public void registerEmptyEndpointId() {
void registerEmptyEndpointId() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId("");
@ -66,7 +66,7 @@ public class JmsListenerEndpointRegistrarTests {
}
@Test
public void registerNullContainerFactoryIsAllowed() throws Exception {
void registerNullContainerFactoryIsAllowed() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId("some id");
this.registrar.setContainerFactory(this.containerFactory);
@ -74,11 +74,11 @@ public class JmsListenerEndpointRegistrarTests {
this.registrar.afterPropertiesSet();
assertThat(this.registry.getListenerContainer("some id")).as("Container not created").isNotNull();
assertThat(this.registry.getListenerContainers()).hasSize(1);
assertThat(this.registry.getListenerContainerIds()).element(0).isEqualTo("some id");
assertThat(this.registry.getListenerContainerIds()).containsOnly("some id");
}
@Test
public void registerNullContainerFactoryWithNoDefault() throws Exception {
void registerNullContainerFactoryWithNoDefault() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId("some id");
this.registrar.registerEndpoint(endpoint, null);
@ -89,7 +89,7 @@ public class JmsListenerEndpointRegistrarTests {
}
@Test
public void registerContainerWithoutFactory() throws Exception {
void registerContainerWithoutFactory() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId("myEndpoint");
this.registrar.setContainerFactory(this.containerFactory);
@ -97,7 +97,7 @@ public class JmsListenerEndpointRegistrarTests {
this.registrar.afterPropertiesSet();
assertThat(this.registry.getListenerContainer("myEndpoint")).as("Container not created").isNotNull();
assertThat(this.registry.getListenerContainers()).hasSize(1);
assertThat(this.registry.getListenerContainerIds()).element(0).isEqualTo("myEndpoint");
assertThat(this.registry.getListenerContainerIds()).containsOnly("myEndpoint");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 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.
@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* @author Stephane Nicoll
*/
public class JmsListenerEndpointRegistryTests {
class JmsListenerEndpointRegistryTests {
private final JmsListenerEndpointRegistry registry = new JmsListenerEndpointRegistry();
@ -32,25 +32,25 @@ public class JmsListenerEndpointRegistryTests {
@Test
public void createWithNullEndpoint() {
void createWithNullEndpoint() {
assertThatIllegalArgumentException().isThrownBy(() ->
registry.registerListenerContainer(null, containerFactory));
}
@Test
public void createWithNullEndpointId() {
void createWithNullEndpointId() {
assertThatIllegalArgumentException().isThrownBy(() ->
registry.registerListenerContainer(new SimpleJmsListenerEndpoint(), containerFactory));
}
@Test
public void createWithNullContainerFactory() {
void createWithNullContainerFactory() {
assertThatIllegalArgumentException().isThrownBy(() ->
registry.registerListenerContainer(createEndpoint("foo", "myDestination"), null));
}
@Test
public void createWithDuplicateEndpointId() {
void createWithDuplicateEndpointId() {
registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory);
assertThatIllegalStateException().isThrownBy(() ->

View File

@ -35,10 +35,10 @@ import static org.mockito.Mockito.mock;
/**
* @author Stephane Nicoll
*/
public class JmsListenerEndpointTests {
class JmsListenerEndpointTests {
@Test
public void setupJmsMessageContainerFullConfig() {
void setupJmsMessageContainerFullConfig() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
MessageListener messageListener = new MessageListenerAdapter();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
@ -58,7 +58,7 @@ public class JmsListenerEndpointTests {
}
@Test
public void setupJcaMessageContainerFullConfig() {
void setupJcaMessageContainerFullConfig() {
JmsMessageEndpointManager container = new JmsMessageEndpointManager();
MessageListener messageListener = new MessageListenerAdapter();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
@ -78,7 +78,7 @@ public class JmsListenerEndpointTests {
}
@Test
public void setupConcurrencySimpleContainer() {
void setupConcurrencySimpleContainer() {
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
MessageListener messageListener = new MessageListenerAdapter();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
@ -90,7 +90,7 @@ public class JmsListenerEndpointTests {
}
@Test
public void setupMessageContainerNoListener() {
void setupMessageContainerNoListener() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
@ -99,7 +99,7 @@ public class JmsListenerEndpointTests {
}
@Test
public void setupMessageContainerUnsupportedContainer() {
void setupMessageContainerUnsupportedContainer() {
MessageListenerContainer container = mock();
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setMessageListener(new MessageListenerAdapter());

View File

@ -58,7 +58,7 @@ import static org.mockito.Mockito.mock;
* @author Christian Dupuis
* @author Stephane Nicoll
*/
public class JmsNamespaceHandlerTests {
class JmsNamespaceHandlerTests {
private static final String DEFAULT_CONNECTION_FACTORY = "connectionFactory";
@ -68,18 +68,18 @@ public class JmsNamespaceHandlerTests {
@BeforeEach
public void setup() {
void setup() {
this.context = new ToolingTestApplicationContext("jmsNamespaceHandlerTests.xml", getClass());
}
@AfterEach
public void shutdown() {
void shutdown() {
this.context.close();
}
@Test
public void testBeansCreated() {
void testBeansCreated() {
Map<String, ?> containers = context.getBeansOfType(DefaultMessageListenerContainer.class);
assertThat(containers).as("Context should contain 3 JMS listener containers").hasSize(3);
@ -91,7 +91,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testContainerConfiguration() {
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);
@ -113,7 +113,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testJcaContainerConfiguration() {
void testJcaContainerConfiguration() {
Map<String, JmsMessageEndpointManager> containers = context.getBeansOfType(JmsMessageEndpointManager.class);
assertThat(containers.containsKey("listener3")).as("listener3 not found").isTrue();
@ -133,7 +133,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testJmsContainerFactoryConfiguration() {
void testJmsContainerFactoryConfiguration() {
Map<String, DefaultJmsListenerContainerFactory> containers =
context.getBeansOfType(DefaultJmsListenerContainerFactory.class);
DefaultJmsListenerContainerFactory factory = containers.get("testJmsFactory");
@ -155,7 +155,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testJcaContainerFactoryConfiguration() {
void testJcaContainerFactoryConfiguration() {
Map<String, DefaultJcaListenerContainerFactory> containers =
context.getBeansOfType(DefaultJcaListenerContainerFactory.class);
DefaultJcaListenerContainerFactory factory = containers.get("testJcaFactory");
@ -172,7 +172,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testListeners() throws Exception {
void testListeners() throws Exception {
TestBean testBean1 = context.getBean("testBean1", TestBean.class);
TestBean testBean2 = context.getBean("testBean2", TestBean.class);
TestMessageListener testBean3 = context.getBean("testBean3", TestMessageListener.class);
@ -203,7 +203,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testRecoveryInterval() {
void testRecoveryInterval() {
Object testBackOff = context.getBean("testBackOff");
BackOff backOff1 = getBackOff("listener1");
BackOff backOff2 = getBackOff("listener2");
@ -215,7 +215,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testConcurrency() {
void testConcurrency() {
// JMS
DefaultMessageListenerContainer listener0 = this.context
.getBean(DefaultMessageListenerContainer.class.getName() + "#0", DefaultMessageListenerContainer.class);
@ -241,7 +241,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testResponseDestination() {
void testResponseDestination() {
// JMS
DefaultMessageListenerContainer listener1 = this.context
.getBean("listener1", DefaultMessageListenerContainer.class);
@ -264,7 +264,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testErrorHandlers() {
void testErrorHandlers() {
ErrorHandler expected = this.context.getBean("testErrorHandler", ErrorHandler.class);
ErrorHandler errorHandler1 = getErrorHandler("listener1");
ErrorHandler errorHandler2 = getErrorHandler("listener2");
@ -275,7 +275,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testPhases() {
void testPhases() {
int phase1 = getPhase("listener1");
int phase2 = getPhase("listener2");
int phase3 = getPhase("listener3");
@ -289,7 +289,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testComponentRegistration() {
void testComponentRegistration() {
assertThat(context.containsComponentDefinition("listener1")).as("Parser should have registered a component named 'listener1'").isTrue();
assertThat(context.containsComponentDefinition("listener2")).as("Parser should have registered a component named 'listener2'").isTrue();
assertThat(context.containsComponentDefinition("listener3")).as("Parser should have registered a component named 'listener3'").isTrue();
@ -303,7 +303,7 @@ public class JmsNamespaceHandlerTests {
}
@Test
public void testSourceExtraction() {
void testSourceExtraction() {
Iterator<ComponentDefinition> iterator = context.getRegisteredComponents();
while (iterator.hasNext()) {
ComponentDefinition compDef = iterator.next();

View File

@ -410,7 +410,7 @@ class MethodJmsListenerEndpointTests {
}
@Test
void validatePayloadInvalid() throws JMSException {
void validatePayloadInvalid() {
DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
customFactory.setValidator(testValidator("invalid value"));
@ -427,7 +427,7 @@ class MethodJmsListenerEndpointTests {
// failure scenario
@Test
void invalidPayloadType() throws JMSException {
void invalidPayloadType() {
MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);
Session session = mock();
@ -439,7 +439,7 @@ class MethodJmsListenerEndpointTests {
}
@Test
void invalidMessagePayloadType() throws JMSException {
void invalidMessagePayloadType() {
MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
Session session = mock();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 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.
@ -27,13 +27,13 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Stephane Nicoll
*/
public class SimpleJmsListenerEndpointTests {
class SimpleJmsListenerEndpointTests {
private final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
@Test
public void createListener() {
void createListener() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
MessageListener messageListener = new MessageListenerAdapter();
endpoint.setMessageListener(messageListener);

View File

@ -48,17 +48,17 @@ import static org.mockito.Mockito.verify;
* @author Juergen Hoeller
* @since 26.07.2004
*/
public class JmsTransactionManagerTests {
class JmsTransactionManagerTests {
@AfterEach
public void verifyTransactionSynchronizationManagerState() {
void verifyTransactionSynchronizationManagerState() {
assertThat(TransactionSynchronizationManager.getResourceMap()).isEmpty();
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
}
@Test
public void testTransactionCommit() throws JMSException {
void testTransactionCommit() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
final Session session = mock();
@ -81,7 +81,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testTransactionRollback() throws JMSException {
void testTransactionRollback() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
final Session session = mock();
@ -104,7 +104,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testParticipatingTransactionWithCommit() throws JMSException {
void testParticipatingTransactionWithCommit() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
final Session session = mock();
@ -137,7 +137,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testParticipatingTransactionWithRollbackOnly() throws JMSException {
void testParticipatingTransactionWithRollbackOnly() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
final Session session = mock();
@ -172,7 +172,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testSuspendedTransaction() throws JMSException {
void testSuspendedTransaction() throws JMSException {
final ConnectionFactory cf = mock();
Connection con = mock();
final Session session = mock();
@ -213,7 +213,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testTransactionSuspension() throws JMSException {
void testTransactionSuspension() throws JMSException {
final ConnectionFactory cf = mock();
Connection con = mock();
final Session session = mock();
@ -254,7 +254,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testTransactionCommitWithMessageProducer() throws JMSException {
void testTransactionCommitWithMessageProducer() throws JMSException {
Destination dest = new StubQueue();
ConnectionFactory cf = mock();
@ -282,7 +282,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testLazyTransactionalSession() throws JMSException {
void testLazyTransactionalSession() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
final Session session = mock();
@ -307,7 +307,7 @@ public class JmsTransactionManagerTests {
}
@Test
public void testLazyWithoutSessionAccess() {
void testLazyWithoutSessionAccess() {
ConnectionFactory cf = mock();
JmsTransactionManager tm = new JmsTransactionManager(cf);

View File

@ -46,10 +46,10 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Juergen Hoeller
* @since 26.07.2004
*/
public class SingleConnectionFactoryTests {
class SingleConnectionFactoryTests {
@Test
public void testWithConnection() throws JMSException {
void testWithConnection() throws JMSException {
Connection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -70,7 +70,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithQueueConnection() throws JMSException {
void testWithQueueConnection() throws JMSException {
QueueConnection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -91,7 +91,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithTopicConnection() throws JMSException {
void testWithTopicConnection() throws JMSException {
TopicConnection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -112,7 +112,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactory() throws JMSException {
void testWithConnectionFactory() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
@ -134,7 +134,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithQueueConnectionFactoryAndJms11Usage() throws JMSException {
void testWithQueueConnectionFactoryAndJms11Usage() throws JMSException {
QueueConnectionFactory cf = mock();
QueueConnection con = mock();
@ -156,7 +156,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
void testWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
QueueConnectionFactory cf = mock();
QueueConnection con = mock();
@ -178,7 +178,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithTopicConnectionFactoryAndJms11Usage() throws JMSException {
void testWithTopicConnectionFactoryAndJms11Usage() throws JMSException {
TopicConnectionFactory cf = mock();
TopicConnection con = mock();
@ -200,7 +200,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithTopicConnectionFactoryAndJms102Usage() throws JMSException {
void testWithTopicConnectionFactoryAndJms102Usage() throws JMSException {
TopicConnectionFactory cf = mock();
TopicConnection con = mock();
@ -222,7 +222,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionAggregatedStartStop() throws JMSException {
void testWithConnectionAggregatedStartStop() throws JMSException {
Connection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -254,7 +254,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactoryAndClientId() throws JMSException {
void testWithConnectionFactoryAndClientId() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
given(cf.createConnection()).willReturn(con);
@ -277,7 +277,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactoryAndExceptionListener() throws JMSException {
void testWithConnectionFactoryAndExceptionListener() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
@ -305,7 +305,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactoryAndReconnectOnException() throws JMSException {
void testWithConnectionFactoryAndReconnectOnException() throws JMSException {
ConnectionFactory cf = mock();
TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con);
@ -325,7 +325,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactoryAndExceptionListenerAndReconnectOnException() throws JMSException {
void testWithConnectionFactoryAndExceptionListenerAndReconnectOnException() throws JMSException {
ConnectionFactory cf = mock();
TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con);
@ -348,7 +348,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactoryAndExceptionListenerAndReconnectOnExceptionWithJMSException() throws Exception {
void testWithConnectionFactoryAndExceptionListenerAndReconnectOnExceptionWithJMSException() throws Exception {
// Throws JMSException on setExceptionListener() method, but only at the first time
class FailingTestConnection extends TestConnection {
private int setExceptionListenerInvocationCounter;
@ -447,7 +447,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactoryAndLocalExceptionListenerWithCleanup() throws JMSException {
void testWithConnectionFactoryAndLocalExceptionListenerWithCleanup() throws JMSException {
ConnectionFactory cf = mock();
TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con);
@ -485,7 +485,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testWithConnectionFactoryAndLocalExceptionListenerWithReconnect() throws JMSException {
void testWithConnectionFactoryAndLocalExceptionListenerWithReconnect() throws JMSException {
ConnectionFactory cf = mock();
TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con);
@ -519,7 +519,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testCachingConnectionFactory() throws JMSException {
void testCachingConnectionFactory() throws JMSException {
ConnectionFactory cf = mock();
Connection con = mock();
Session txSession = mock();
@ -559,7 +559,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testCachingConnectionFactoryWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
void testCachingConnectionFactoryWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
QueueConnectionFactory cf = mock();
QueueConnection con = mock();
QueueSession txSession = mock();
@ -599,7 +599,7 @@ public class SingleConnectionFactoryTests {
}
@Test
public void testCachingConnectionFactoryWithTopicConnectionFactoryAndJms102Usage() throws JMSException {
void testCachingConnectionFactoryWithTopicConnectionFactoryAndJms102Usage() throws JMSException {
TopicConnectionFactory cf = mock();
TopicConnection con = mock();
TopicSession txSession = mock();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2023 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.
@ -39,36 +39,36 @@ public class TestConnection implements Connection {
@Override
public Session createSession(boolean b, int i) throws JMSException {
public Session createSession(boolean b, int i) {
return null;
}
@Override
public Session createSession(int sessionMode) throws JMSException {
public Session createSession(int sessionMode) {
return null;
}
@Override
public Session createSession() throws JMSException {
public Session createSession() {
return null;
}
@Override
public String getClientID() throws JMSException {
public String getClientID() {
return null;
}
@Override
public void setClientID(String paramName) throws JMSException {
public void setClientID(String paramName) {
}
@Override
public ConnectionMetaData getMetaData() throws JMSException {
public ConnectionMetaData getMetaData() {
return null;
}
@Override
public ExceptionListener getExceptionListener() throws JMSException {
public ExceptionListener getExceptionListener() {
return exceptionListener;
}
@ -78,36 +78,36 @@ public class TestConnection implements Connection {
}
@Override
public void start() throws JMSException {
public void start() {
this.startCount++;
}
@Override
public void stop() throws JMSException {
public void stop() {
}
@Override
public void close() throws JMSException {
public void close() {
this.closeCount++;
}
@Override
public ConnectionConsumer createConnectionConsumer(Destination destination, String paramName, ServerSessionPool serverSessionPool, int i) throws JMSException {
public ConnectionConsumer createConnectionConsumer(Destination destination, String paramName, ServerSessionPool serverSessionPool, int i) {
return null;
}
@Override
public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String paramName, String paramName1, ServerSessionPool serverSessionPool, int i) throws JMSException {
public ConnectionConsumer createDurableConnectionConsumer(Topic topic, String paramName, String paramName1, ServerSessionPool serverSessionPool, int i) {
return null;
}
@Override
public ConnectionConsumer createSharedConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
public ConnectionConsumer createSharedConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) {
return null;
}
@Override
public ConnectionConsumer createSharedDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) throws JMSException {
public ConnectionConsumer createSharedDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages) {
return null;
}

View File

@ -66,7 +66,7 @@ import static org.mockito.Mockito.verify;
* @author Stephane Nicoll
*/
@ExtendWith(MockitoExtension.class)
public class JmsMessagingTemplateTests {
class JmsMessagingTemplateTests {
@Captor
private ArgumentCaptor<MessageCreator> messageCreator;
@ -78,17 +78,17 @@ public class JmsMessagingTemplateTests {
@BeforeEach
public void setup() {
void setup() {
this.messagingTemplate = new JmsMessagingTemplate(this.jmsTemplate);
}
@Test
public void validateJmsTemplate() {
void validateJmsTemplate() {
assertThat(this.messagingTemplate.getJmsTemplate()).isSameAs(this.jmsTemplate);
}
@Test
public void payloadConverterIsConsistentConstructor() {
void payloadConverterIsConsistentConstructor() {
MessageConverter messageConverter = mock();
given(this.jmsTemplate.getMessageConverter()).willReturn(messageConverter);
JmsMessagingTemplate messagingTemplate = new JmsMessagingTemplate(this.jmsTemplate);
@ -97,7 +97,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void payloadConverterIsConsistentSetter() {
void payloadConverterIsConsistentSetter() {
MessageConverter messageConverter = mock();
given(this.jmsTemplate.getMessageConverter()).willReturn(messageConverter);
JmsMessagingTemplate messagingTemplate = new JmsMessagingTemplate();
@ -107,7 +107,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void customConverterAlwaysTakesPrecedence() {
void customConverterAlwaysTakesPrecedence() {
MessageConverter customMessageConverter = mock();
JmsMessagingTemplate messagingTemplate = new JmsMessagingTemplate();
messagingTemplate.setJmsMessageConverter(
@ -127,7 +127,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void send() {
void send() {
Destination destination = new Destination() {};
Message<String> message = createTextMessage();
@ -137,7 +137,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendName() {
void sendName() {
Message<String> message = createTextMessage();
this.messagingTemplate.send("myQueue", message);
@ -146,7 +146,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendDefaultDestination() {
void sendDefaultDestination() {
Destination destination = new Destination() {};
this.messagingTemplate.setDefaultDestination(destination);
Message<String> message = createTextMessage();
@ -157,7 +157,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendDefaultDestinationName() {
void sendDefaultDestinationName() {
this.messagingTemplate.setDefaultDestinationName("myQueue");
Message<String> message = createTextMessage();
@ -167,7 +167,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendNoDefaultSet() {
void sendNoDefaultSet() {
Message<String> message = createTextMessage();
assertThatIllegalStateException().isThrownBy(() ->
@ -175,7 +175,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendPropertyInjection() {
void sendPropertyInjection() {
JmsMessagingTemplate t = new JmsMessagingTemplate();
t.setJmsTemplate(this.jmsTemplate);
t.setDefaultDestinationName("myQueue");
@ -188,7 +188,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertAndSendPayload() throws JMSException {
void convertAndSendPayload() throws JMSException {
Destination destination = new Destination() {};
this.messagingTemplate.convertAndSend(destination, "my Payload");
@ -198,7 +198,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertAndSendPayloadName() throws JMSException {
void convertAndSendPayloadName() throws JMSException {
this.messagingTemplate.convertAndSend("myQueue", "my Payload");
verify(this.jmsTemplate).send(eq("myQueue"), this.messageCreator.capture());
TextMessage textMessage = createTextMessage(this.messageCreator.getValue());
@ -206,7 +206,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertAndSendDefaultDestination() throws JMSException {
void convertAndSendDefaultDestination() throws JMSException {
Destination destination = new Destination() {};
this.messagingTemplate.setDefaultDestination(destination);
@ -217,7 +217,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertAndSendDefaultDestinationName() throws JMSException {
void convertAndSendDefaultDestinationName() throws JMSException {
this.messagingTemplate.setDefaultDestinationName("myQueue");
this.messagingTemplate.convertAndSend("my Payload");
@ -227,17 +227,17 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertAndSendNoDefaultSet() throws JMSException {
void convertAndSendNoDefaultSet() {
assertThatIllegalStateException().isThrownBy(() ->
this.messagingTemplate.convertAndSend("my Payload"));
}
@Test
public void convertAndSendCustomJmsMessageConverter() throws JMSException {
void convertAndSendCustomJmsMessageConverter() {
this.messagingTemplate.setJmsMessageConverter(new SimpleMessageConverter() {
@Override
public jakarta.jms.Message toMessage(Object object, Session session)
throws JMSException, org.springframework.jms.support.converter.MessageConversionException {
throws org.springframework.jms.support.converter.MessageConversionException {
throw new org.springframework.jms.support.converter.MessageConversionException("Test exception");
}
});
@ -251,7 +251,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertAndSendPayloadAndHeaders() throws JMSException {
void convertAndSendPayloadAndHeaders() {
Destination destination = new Destination() {};
Map<String, Object> headers = new HashMap<>();
headers.put("foo", "bar");
@ -262,7 +262,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertAndSendPayloadAndHeadersName() throws JMSException {
void convertAndSendPayloadAndHeadersName() {
Map<String, Object> headers = new HashMap<>();
headers.put("foo", "bar");
@ -272,7 +272,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receive() {
void receive() {
Destination destination = new Destination() {};
jakarta.jms.Message jmsMessage = createJmsTextMessage();
given(this.jmsTemplate.receive(destination)).willReturn(jmsMessage);
@ -283,7 +283,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveName() {
void receiveName() {
jakarta.jms.Message jmsMessage = createJmsTextMessage();
given(this.jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
@ -293,7 +293,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveDefaultDestination() {
void receiveDefaultDestination() {
Destination destination = new Destination() {};
this.messagingTemplate.setDefaultDestination(destination);
jakarta.jms.Message jmsMessage = createJmsTextMessage();
@ -305,7 +305,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveDefaultDestinationName() {
void receiveDefaultDestinationName() {
this.messagingTemplate.setDefaultDestinationName("myQueue");
jakarta.jms.Message jmsMessage = createJmsTextMessage();
given(this.jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
@ -316,13 +316,13 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveNoDefaultSet() {
void receiveNoDefaultSet() {
assertThatIllegalStateException().isThrownBy(
this.messagingTemplate::receive);
}
@Test
public void receiveAndConvert() {
void receiveAndConvert() {
Destination destination = new Destination() {};
jakarta.jms.Message jmsMessage = createJmsTextMessage("my Payload");
given(this.jmsTemplate.receive(destination)).willReturn(jmsMessage);
@ -333,7 +333,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveAndConvertName() {
void receiveAndConvertName() {
jakarta.jms.Message jmsMessage = createJmsTextMessage("my Payload");
given(this.jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
@ -343,7 +343,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveAndConvertDefaultDestination() {
void receiveAndConvertDefaultDestination() {
Destination destination = new Destination() {};
this.messagingTemplate.setDefaultDestination(destination);
jakarta.jms.Message jmsMessage = createJmsTextMessage("my Payload");
@ -355,7 +355,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveAndConvertDefaultDestinationName() {
void receiveAndConvertDefaultDestinationName() {
this.messagingTemplate.setDefaultDestinationName("myQueue");
jakarta.jms.Message jmsMessage = createJmsTextMessage("my Payload");
given(this.jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
@ -366,7 +366,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveAndConvertWithConversion() {
void receiveAndConvertWithConversion() {
jakarta.jms.Message jmsMessage = createJmsTextMessage("123");
given(this.jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
@ -378,7 +378,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveAndConvertNoConverter() {
void receiveAndConvertNoConverter() {
jakarta.jms.Message jmsMessage = createJmsTextMessage("Hello");
given(this.jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
@ -387,14 +387,14 @@ public class JmsMessagingTemplateTests {
}
@Test
public void receiveAndConvertNoInput() {
void receiveAndConvertNoInput() {
given(this.jmsTemplate.receive("myQueue")).willReturn(null);
assertThat(this.messagingTemplate.receiveAndConvert("myQueue", String.class)).isNull();
}
@Test
public void sendAndReceive() {
void sendAndReceive() {
Destination destination = new Destination() {};
Message<String> request = createTextMessage();
jakarta.jms.Message replyJmsMessage = createJmsTextMessage();
@ -406,7 +406,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendAndReceiveName() {
void sendAndReceiveName() {
Message<String> request = createTextMessage();
jakarta.jms.Message replyJmsMessage = createJmsTextMessage();
given(this.jmsTemplate.sendAndReceive(eq("myQueue"), any())).willReturn(replyJmsMessage);
@ -417,7 +417,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendAndReceiveDefaultDestination() {
void sendAndReceiveDefaultDestination() {
Destination destination = new Destination() {};
this.messagingTemplate.setDefaultDestination(destination);
Message<String> request = createTextMessage();
@ -430,7 +430,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendAndReceiveDefaultDestinationName() {
void sendAndReceiveDefaultDestinationName() {
this.messagingTemplate.setDefaultDestinationName("myQueue");
Message<String> request = createTextMessage();
jakarta.jms.Message replyJmsMessage = createJmsTextMessage();
@ -442,7 +442,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void sendAndReceiveNoDefaultSet() {
void sendAndReceiveNoDefaultSet() {
Message<String> message = createTextMessage();
assertThatIllegalStateException().isThrownBy(() ->
@ -450,7 +450,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertSendAndReceivePayload() throws JMSException {
void convertSendAndReceivePayload() {
Destination destination = new Destination() {};
jakarta.jms.Message replyJmsMessage = createJmsTextMessage("My reply");
given(this.jmsTemplate.sendAndReceive(eq(destination), any())).willReturn(replyJmsMessage);
@ -461,7 +461,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertSendAndReceivePayloadName() throws JMSException {
void convertSendAndReceivePayloadName() {
jakarta.jms.Message replyJmsMessage = createJmsTextMessage("My reply");
given(this.jmsTemplate.sendAndReceive(eq("myQueue"), any())).willReturn(replyJmsMessage);
@ -471,7 +471,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertSendAndReceiveDefaultDestination() throws JMSException {
void convertSendAndReceiveDefaultDestination() {
Destination destination = new Destination() {};
this.messagingTemplate.setDefaultDestination(destination);
jakarta.jms.Message replyJmsMessage = createJmsTextMessage("My reply");
@ -483,7 +483,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertSendAndReceiveDefaultDestinationName() throws JMSException {
void convertSendAndReceiveDefaultDestinationName() {
this.messagingTemplate.setDefaultDestinationName("myQueue");
jakarta.jms.Message replyJmsMessage = createJmsTextMessage("My reply");
given(this.jmsTemplate.sendAndReceive(eq("myQueue"), any())).willReturn(replyJmsMessage);
@ -494,13 +494,13 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertSendAndReceiveNoDefaultSet() throws JMSException {
void convertSendAndReceiveNoDefaultSet() {
assertThatIllegalStateException().isThrownBy(() ->
this.messagingTemplate.convertSendAndReceive("my Payload", String.class));
}
@Test
public void convertMessageConversionExceptionOnSend() throws JMSException {
void convertMessageConversionExceptionOnSend() throws JMSException {
Message<String> message = createTextMessage();
MessageConverter messageConverter = mock();
willThrow(org.springframework.jms.support.converter.MessageConversionException.class)
@ -513,7 +513,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertMessageConversionExceptionOnReceive() throws JMSException {
void convertMessageConversionExceptionOnReceive() throws JMSException {
jakarta.jms.Message message = createJmsTextMessage();
MessageConverter messageConverter = mock();
willThrow(org.springframework.jms.support.converter.MessageConversionException.class)
@ -526,7 +526,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertMessageNotReadableException() throws JMSException {
void convertMessageNotReadableException() {
willThrow(MessageNotReadableException.class).given(this.jmsTemplate).receive("myQueue");
assertThatExceptionOfType(MessagingException.class).isThrownBy(() ->
@ -534,7 +534,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertDestinationResolutionExceptionOnSend() {
void convertDestinationResolutionExceptionOnSend() {
Destination destination = new Destination() {};
willThrow(DestinationResolutionException.class).given(this.jmsTemplate).send(eq(destination), any());
@ -543,7 +543,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertDestinationResolutionExceptionOnReceive() {
void convertDestinationResolutionExceptionOnReceive() {
Destination destination = new Destination() {};
willThrow(DestinationResolutionException.class).given(this.jmsTemplate).receive(destination);
@ -552,7 +552,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertMessageFormatException() throws JMSException {
void convertMessageFormatException() throws JMSException {
Message<String> message = createTextMessage();
MessageConverter messageConverter = mock();
willThrow(MessageFormatException.class).given(messageConverter).toMessage(eq(message), any());
@ -564,7 +564,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertMessageNotWritableException() throws JMSException {
void convertMessageNotWritableException() throws JMSException {
Message<String> message = createTextMessage();
MessageConverter messageConverter = mock();
willThrow(MessageNotWriteableException.class).given(messageConverter).toMessage(eq(message), any());
@ -576,7 +576,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertInvalidDestinationExceptionOnSendAndReceiveWithName() {
void convertInvalidDestinationExceptionOnSendAndReceiveWithName() {
willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq("unknownQueue"), any());
assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
@ -584,7 +584,7 @@ public class JmsMessagingTemplateTests {
}
@Test
public void convertInvalidDestinationExceptionOnSendAndReceive() {
void convertInvalidDestinationExceptionOnSendAndReceive() {
Destination destination = new Destination() {};
willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq(destination), any());
@ -611,14 +611,9 @@ public class JmsMessagingTemplateTests {
}
private jakarta.jms.Message createJmsTextMessage(String payload) {
try {
StubTextMessage jmsMessage = new StubTextMessage(payload);
jmsMessage.setStringProperty("foo", "bar");
return jmsMessage;
}
catch (JMSException e) {
throw new IllegalStateException("Should not happen", e);
}
StubTextMessage jmsMessage = new StubTextMessage(payload);
jmsMessage.setStringProperty("foo", "bar");
return jmsMessage;
}
private jakarta.jms.Message createJmsTextMessage() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2023 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.
@ -20,7 +20,7 @@ package org.springframework.jms.core;
* @author Juergen Hoeller
* @since 06.01.2005
*/
public class JmsTemplateJtaTests extends JmsTemplateTests {
class JmsTemplateJtaTests extends JmsTemplateTests {
@Override
protected boolean useTransactedSession() {

View File

@ -61,7 +61,7 @@ class JmsTemplateObservationTests {
}
@Test
void shouldRecordJmsProcessObservations() throws Exception {
void shouldRecordJmsProcessObservations() {
JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
jmsTemplate.setObservationRegistry(registry);
jmsTemplate.convertAndSend("spring.test.observation", "message content");

View File

@ -254,7 +254,7 @@ class JmsTemplateTests {
/**
* Test sending to a destination using the method
* send(Destination d, MessageCreator messageCreator)
* {@code send(Destination d, MessageCreator messageCreator)}
*/
@Test
void testSendDestination() throws Exception {

View File

@ -34,7 +34,7 @@ import static org.mockito.Mockito.mock;
class JmsGatewaySupportTests {
@Test
void testJmsGatewaySupportWithConnectionFactory() throws Exception {
void testJmsGatewaySupportWithConnectionFactory() {
ConnectionFactory mockConnectionFactory = mock();
final List<String> test = new ArrayList<>(1);
JmsGatewaySupport gateway = new JmsGatewaySupport() {
@ -51,7 +51,7 @@ class JmsGatewaySupportTests {
}
@Test
void testJmsGatewaySupportWithJmsTemplate() throws Exception {
void testJmsGatewaySupportWithJmsTemplate() {
JmsTemplate template = new JmsTemplate();
final List<String> test = new ArrayList<>(1);
JmsGatewaySupport gateway = new JmsGatewaySupport() {

View File

@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify;
* @author Chris Beams
* @author Mark Fisher
*/
public class SimpleMessageListenerContainerTests {
class SimpleMessageListenerContainerTests {
private static final String DESTINATION_NAME = "foo";
@ -59,25 +59,25 @@ public class SimpleMessageListenerContainerTests {
@Test
public void testSettingMessageListenerToANullType() {
void testSettingMessageListenerToANullType() {
this.container.setMessageListener(null);
assertThat(this.container.getMessageListener()).isNull();
}
@Test
public void testSettingMessageListenerToAnUnsupportedType() {
void testSettingMessageListenerToAnUnsupportedType() {
assertThatIllegalArgumentException().isThrownBy(() ->
this.container.setMessageListener("Bingo"));
}
@Test
public void testSessionTransactedModeReallyDoesDefaultToFalse() {
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();
}
@Test
public void testSettingConcurrentConsumersToZeroIsNotAllowed() {
void testSettingConcurrentConsumersToZeroIsNotAllowed() {
assertThatIllegalArgumentException().isThrownBy(() -> {
this.container.setConcurrentConsumers(0);
this.container.afterPropertiesSet();
@ -85,7 +85,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() {
void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() {
assertThatIllegalArgumentException().isThrownBy(() -> {
this.container.setConcurrentConsumers(-198);
this.container.afterPropertiesSet();
@ -93,7 +93,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testContextRefreshedEventDoesNotStartTheConnectionIfAutoStartIsSetToFalse() throws Exception {
void testContextRefreshedEventDoesNotStartTheConnectionIfAutoStartIsSetToFalse() throws Exception {
MessageConsumer messageConsumer = mock();
Session session = mock();
// Queue gets created in order to create MessageConsumer for that Destination...
@ -124,7 +124,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testContextRefreshedEventStartsTheConnectionByDefault() throws Exception {
void testContextRefreshedEventStartsTheConnectionByDefault() throws Exception {
MessageConsumer messageConsumer = mock();
Session session = mock();
// Queue gets created in order to create MessageConsumer for that Destination...
@ -156,7 +156,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testCorrectSessionExposedForSessionAwareMessageListenerInvocation() throws Exception {
void testCorrectSessionExposedForSessionAwareMessageListenerInvocation() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
final Session session = mock();
@ -206,7 +206,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testTaskExecutorCorrectlyInvokedWhenSpecified() throws Exception {
void testTaskExecutorCorrectlyInvokedWhenSpecified() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
final Session session = mock();
@ -247,7 +247,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testRegisteredExceptionListenerIsInvokedOnException() throws Exception {
void testRegisteredExceptionListenerIsInvokedOnException() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
Session session = mock();
@ -294,7 +294,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testRegisteredErrorHandlerIsInvokedOnException() throws Exception {
void testRegisteredErrorHandlerIsInvokedOnException() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
Session session = mock();
@ -339,7 +339,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testNoRollbackOccursIfSessionIsNotTransactedAndThatExceptionsDo_NOT_Propagate() throws Exception {
void testNoRollbackOccursIfSessionIsNotTransactedAndThatExceptionsDo_NOT_Propagate() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
Session session = mock();
@ -378,7 +378,7 @@ public class SimpleMessageListenerContainerTests {
}
@Test
public void testTransactedSessionsGetRollbackLogicAppliedAndThatExceptionsStillDo_NOT_Propagate() throws Exception {
void testTransactedSessionsGetRollbackLogicAppliedAndThatExceptionsStillDo_NOT_Propagate() throws Exception {
this.container.setSessionTransacted(true);
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
@ -414,14 +414,14 @@ public class SimpleMessageListenerContainerTests {
// a Throwable from a MessageListener MUST simply be swallowed...
messageConsumer.sendMessage(message);
// Session is rolled back 'cos it is transacted...
// Session is rolled back because it is transacted...
verify(session).rollback();
verify(connection).setExceptionListener(this.container);
verify(connection).start();
}
@Test
public void testDestroyClosesConsumersSessionsAndConnectionInThatOrder() throws Exception {
void testDestroyClosesConsumersSessionsAndConnectionInThatOrder() throws Exception {
MessageConsumer messageConsumer = mock();
Session session = mock();
// Queue gets created in order to create MessageConsumer for that Destination...

View File

@ -31,17 +31,17 @@ import static org.mockito.Mockito.mock;
/**
* @author Stephane Nicoll
*/
public class JmsResponseTests {
class JmsResponseTests {
@Test
public void destinationDoesNotUseDestinationResolver() throws JMSException {
void destinationDoesNotUseDestinationResolver() throws JMSException {
Destination destination = mock();
Destination actual = JmsResponse.forDestination("foo", destination).resolveDestination(null, null);
assertThat(actual).isSameAs(destination);
}
@Test
public void resolveDestinationForQueue() throws JMSException {
void resolveDestinationForQueue() throws JMSException {
Session session = mock();
DestinationResolver destinationResolver = mock();
Destination destination = mock();
@ -53,25 +53,25 @@ public class JmsResponseTests {
}
@Test
public void createWithNullResponse() {
void createWithNullResponse() {
assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forQueue(null, "myQueue"));
}
@Test
public void createWithNullQueueName() {
void createWithNullQueueName() {
assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forQueue("foo", null));
}
@Test
public void createWithNullTopicName() {
void createWithNullTopicName() {
assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forTopic("foo", null));
}
@Test
public void createWithNulDestination() {
void createWithNulDestination() {
assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forDestination("foo", null));
}

View File

@ -122,7 +122,7 @@ class MessageListenerAdapterTests {
}
@Test
void testWithMessageDelegate() throws Exception {
void testWithMessageDelegate() {
TextMessage textMessage = mock();
MessageDelegate delegate = mock();
@ -159,7 +159,7 @@ class MessageListenerAdapterTests {
}
@Test
void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() throws Exception {
void testThatAnExceptionThrownFromTheHandlingMethodIsSimplySwallowedByDefault() {
final IllegalArgumentException exception = new IllegalArgumentException();
TextMessage textMessage = mock();
@ -184,7 +184,7 @@ class MessageListenerAdapterTests {
}
@Test
void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() throws Exception {
void testThatTheDefaultMessageConverterisIndeedTheSimpleMessageConverter() {
MessageListenerAdapter adapter = new MessageListenerAdapter();
assertThat(adapter.getMessageConverter()).as("The default [MessageConverter] must never be null.").isNotNull();
boolean condition = adapter.getMessageConverter() instanceof SimpleMessageConverter;
@ -192,19 +192,19 @@ class MessageListenerAdapterTests {
}
@Test
void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() throws Exception {
void testThatWhenNoDelegateIsSuppliedTheDelegateIsAssumedToBeTheMessageListenerAdapterItself() {
MessageListenerAdapter adapter = new MessageListenerAdapter();
assertThat(adapter.getDelegate()).isSameAs(adapter);
}
@Test
void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() throws Exception {
void testThatTheDefaultMessageHandlingMethodNameIsTheConstantDefault() {
MessageListenerAdapter adapter = new MessageListenerAdapter();
assertThat(adapter.getDefaultListenerMethod()).isEqualTo(MessageListenerAdapter.ORIGINAL_DEFAULT_LISTENER_METHOD);
}
@Test
void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() throws Exception {
void testWithResponsiveMessageDelegate_DoesNotSendReturnTextMessageIfNoSessionSupplied() {
TextMessage textMessage = mock();
ResponsiveMessageDelegate delegate = mock();
given(delegate.handleMessage(textMessage)).willReturn(TEXT);
@ -349,7 +349,7 @@ class MessageListenerAdapterTests {
}
@Test
void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() throws Exception {
void testWithResponsiveMessageDelegateDoesNotSendReturnTextMessageWhenSessionSupplied_AndListenerMethodThrowsException() {
final TextMessage message = mock();
final QueueSession session = mock();
@ -367,7 +367,7 @@ class MessageListenerAdapterTests {
}
@Test
void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() throws Exception {
void testWithResponsiveMessageDelegateWhenReturnTypeIsNotAJMSMessageAndNoMessageConverterIsSupplied() {
final TextMessage sentTextMessage = mock();
final Session session = mock();
ResponsiveMessageDelegate delegate = mock();

View File

@ -59,7 +59,7 @@ import static org.mockito.Mockito.verify;
/**
* @author Stephane Nicoll
*/
public class MessagingMessageListenerAdapterTests {
class MessagingMessageListenerAdapterTests {
private static final Destination sharedReplyDestination = mock();
@ -69,12 +69,12 @@ public class MessagingMessageListenerAdapterTests {
@BeforeEach
public void setup() {
void setup() {
initializeFactory(factory);
}
@Test
public void buildMessageWithStandardMessage() throws JMSException {
void buildMessageWithStandardMessage() throws JMSException {
Destination replyTo = new Destination() {};
Message<String> result = MessageBuilder.withPayload("Response")
.setHeader("foo", "bar")
@ -96,7 +96,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void exceptionInListener() {
void exceptionInListener() {
jakarta.jms.Message message = new StubTextMessage("foo");
Session session = mock();
MessagingMessageListenerAdapter listener = getSimpleInstance("fail", String.class);
@ -108,7 +108,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void exceptionInInvocation() {
void exceptionInInvocation() {
jakarta.jms.Message message = new StubTextMessage("foo");
Session session = mock();
MessagingMessageListenerAdapter listener = getSimpleInstance("wrongParam", Integer.class);
@ -119,7 +119,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void payloadConversionLazilyInvoked() throws JMSException {
void payloadConversionLazilyInvoked() throws JMSException {
jakarta.jms.Message jmsMessage = mock();
MessageConverter messageConverter = mock();
given(messageConverter.fromMessage(jmsMessage)).willReturn("FooBar");
@ -132,7 +132,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void headerConversionLazilyInvoked() throws JMSException {
void headerConversionLazilyInvoked() throws JMSException {
jakarta.jms.Message jmsMessage = mock();
given(jmsMessage.getPropertyNames()).willThrow(new IllegalArgumentException("Header failure"));
MessagingMessageListenerAdapter listener = getSimpleInstance("simple", Message.class);
@ -145,7 +145,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void incomingMessageUsesMessageConverter() throws JMSException {
void incomingMessageUsesMessageConverter() throws JMSException {
jakarta.jms.Message jmsMessage = mock();
Session session = mock();
MessageConverter messageConverter = mock();
@ -159,7 +159,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyUsesMessageConverterForPayload() throws JMSException {
void replyUsesMessageConverterForPayload() throws JMSException {
Session session = mock();
MessageConverter messageConverter = mock();
given(messageConverter.toMessage("Response", session)).willReturn(new StubTextMessage("Response"));
@ -175,7 +175,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyPayloadToQueue() throws JMSException {
void replyPayloadToQueue() throws JMSException {
Session session = mock();
Queue replyDestination = mock();
given(session.createQueue("queueOut")).willReturn(replyDestination);
@ -195,7 +195,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyWithCustomTimeToLive() throws JMSException {
void replyWithCustomTimeToLive() throws JMSException {
Session session = mock();
Queue replyDestination = mock();
given(session.createQueue("queueOut")).willReturn(replyDestination);
@ -218,7 +218,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyWithFullQoS() throws JMSException {
void replyWithFullQoS() throws JMSException {
Session session = mock();
Queue replyDestination = mock();
given(session.createQueue("queueOut")).willReturn(replyDestination);
@ -239,7 +239,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyPayloadToTopic() throws JMSException {
void replyPayloadToTopic() throws JMSException {
Session session = mock();
Topic replyDestination = mock();
given(session.createTopic("topicOut")).willReturn(replyDestination);
@ -259,7 +259,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyPayloadToDestination() throws JMSException {
void replyPayloadToDestination() throws JMSException {
Session session = mock();
MessageProducer messageProducer = mock();
TextMessage responseMessage = mock();
@ -276,7 +276,7 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyPayloadNoDestination() throws JMSException {
void replyPayloadNoDestination() throws JMSException {
Queue replyDestination = mock();
Session session = mock();
@ -297,21 +297,21 @@ public class MessagingMessageListenerAdapterTests {
}
@Test
public void replyJackson() throws JMSException {
void replyJackson() throws JMSException {
TextMessage reply = testReplyWithJackson("replyJackson",
"{\"counter\":42,\"name\":\"Response\",\"description\":\"lengthy description\"}");
verify(reply).setObjectProperty("foo", "bar");
}
@Test
public void replyJacksonMessageAndJsonView() throws JMSException {
void replyJacksonMessageAndJsonView() throws JMSException {
TextMessage reply = testReplyWithJackson("replyJacksonMessageAndJsonView",
"{\"name\":\"Response\"}");
verify(reply).setObjectProperty("foo", "bar");
}
@Test
public void replyJacksonPojoAndJsonView() throws JMSException {
void replyJacksonPojoAndJsonView() throws JMSException {
TextMessage reply = testReplyWithJackson("replyJacksonPojoAndJsonView",
"{\"name\":\"Response\"}");
verify(reply, never()).setObjectProperty("foo", "bar");

View File

@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock;
* @author Agim Emruli
* @author Juergen Hoeller
*/
public class DefaultJmsActivationSpecFactoryTests {
class DefaultJmsActivationSpecFactoryTests {
private final JmsActivationSpecConfig activationSpecConfig = new JmsActivationSpecConfig() {{
setMaxConcurrency(5);
@ -46,7 +46,7 @@ public class DefaultJmsActivationSpecFactoryTests {
@Test
public void activeMQResourceAdapterSetup() {
void activeMQResourceAdapterSetup() {
activationSpecConfig.setAcknowledgeMode(Session.SESSION_TRANSACTED);
JmsActivationSpecFactory activationSpecFactory = new DefaultJmsActivationSpecFactory();
StubActiveMQActivationSpec spec = (StubActiveMQActivationSpec) activationSpecFactory.createActivationSpec(
@ -58,7 +58,7 @@ public class DefaultJmsActivationSpecFactoryTests {
}
@Test
public void webSphereResourceAdapterSetup() throws Exception {
void webSphereResourceAdapterSetup() throws Exception {
Destination destination = new StubQueue();
DestinationResolver destinationResolver = mock();

View File

@ -50,7 +50,7 @@ class JmsActivationSpecConfigTests {
/**
* This test effectively verifies that the internal 'constants' map is properly
* configured for all acknowledge mode constants constants defined in
* configured for all acknowledge mode constants defined in
* {@link jakarta.jms.Session}.
*/
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -26,10 +26,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/**
* @author Stephane Nicoll
*/
public class JmsMessageEndpointManagerTests {
class JmsMessageEndpointManagerTests {
@Test
public void isPubSubDomainWithQueue() {
void isPubSubDomainWithQueue() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(false);
@ -39,7 +39,7 @@ public class JmsMessageEndpointManagerTests {
}
@Test
public void isPubSubDomainWithTopic() {
void isPubSubDomainWithTopic() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(true);
@ -49,7 +49,7 @@ public class JmsMessageEndpointManagerTests {
}
@Test
public void pubSubDomainCustomForReply() {
void pubSubDomainCustomForReply() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(true);
@ -60,7 +60,7 @@ public class JmsMessageEndpointManagerTests {
}
@Test
public void customReplyQosSettings() {
void customReplyQosSettings() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig();
QosSettings settings = new QosSettings(1, 3, 5);
@ -73,7 +73,7 @@ public class JmsMessageEndpointManagerTests {
}
@Test
public void isPubSubDomainWithNoConfig() {
void isPubSubDomainWithNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
// far from ideal
assertThatIllegalStateException().isThrownBy(
@ -81,7 +81,7 @@ public class JmsMessageEndpointManagerTests {
}
@Test
public void isReplyPubSubDomainWithNoConfig() {
void isReplyPubSubDomainWithNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
// far from ideal
assertThatIllegalStateException().isThrownBy(
@ -89,7 +89,7 @@ public class JmsMessageEndpointManagerTests {
}
@Test
public void getReplyQosSettingsWithNoConfig() {
void getReplyQosSettingsWithNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
// far from ideal
assertThatIllegalStateException().isThrownBy(
@ -97,13 +97,13 @@ public class JmsMessageEndpointManagerTests {
}
@Test
public void getMessageConverterNoConfig() {
void getMessageConverterNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
assertThat(endpoint.getMessageConverter()).isNull();
}
@Test
public void getDestinationResolverNoConfig() {
void getDestinationResolverNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
assertThat(endpoint.getDestinationResolver()).isNull();
}

View File

@ -80,7 +80,7 @@ class JmsAccessorTests {
/**
* This test effectively verifies that the internal 'constants' map is properly
* configured for all acknowledge mode constants constants defined in
* configured for all acknowledge mode constants defined in
* {@link jakarta.jms.Session}.
*/
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -32,10 +32,10 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
public class JmsMessageHeaderAccessorTests {
class JmsMessageHeaderAccessorTests {
@Test
public void validateJmsHeaders() throws JMSException {
void validateJmsHeaders() throws JMSException {
Destination destination = new Destination() {};
Destination replyTo = new Destination() {};

View File

@ -47,10 +47,10 @@ import static org.mockito.Mockito.verify;
* @author Rick Evans
* @since 18.09.2004
*/
public class SimpleMessageConverterTests {
class SimpleMessageConverterTests {
@Test
public void testStringConversion() throws JMSException {
void testStringConversion() throws JMSException {
Session session = mock();
TextMessage message = mock();
@ -65,7 +65,7 @@ public class SimpleMessageConverterTests {
}
@Test
public void testByteArrayConversion() throws JMSException {
void testByteArrayConversion() throws JMSException {
Session session = mock();
BytesMessage message = mock();
@ -84,7 +84,7 @@ public class SimpleMessageConverterTests {
}
@Test
public void testMapConversion() throws JMSException {
void testMapConversion() throws JMSException {
Session session = mock();
MapMessage message = mock();
@ -107,7 +107,7 @@ public class SimpleMessageConverterTests {
}
@Test
public void testSerializableConversion() throws JMSException {
void testSerializableConversion() throws JMSException {
Session session = mock();
ObjectMessage message = mock();
@ -122,19 +122,19 @@ public class SimpleMessageConverterTests {
}
@Test
public void testToMessageThrowsExceptionIfGivenNullObjectToConvert() throws Exception {
void testToMessageThrowsExceptionIfGivenNullObjectToConvert() {
assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
new SimpleMessageConverter().toMessage(null, null));
}
@Test
public void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() throws Exception {
void testToMessageThrowsExceptionIfGivenIncompatibleObjectToConvert() {
assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
new SimpleMessageConverter().toMessage(new Object(), null));
}
@Test
public void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
void testToMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
Session session = mock();
ObjectMessage message = mock();
@ -144,7 +144,7 @@ public class SimpleMessageConverterTests {
}
@Test
public void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
void testFromMessageSimplyReturnsMessageAsIsIfSuppliedWithMessage() throws JMSException {
Message message = mock();
SimpleMessageConverter converter = new SimpleMessageConverter();
@ -153,7 +153,7 @@ public class SimpleMessageConverterTests {
}
@Test
public void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
void testMapConversionWhereMapHasNonStringTypesForKeys() throws JMSException {
MapMessage message = mock();
Session session = mock();
given(session.createMapMessage()).willReturn(message);
@ -167,7 +167,7 @@ public class SimpleMessageConverterTests {
}
@Test
public void testMapConversionWhereMapHasNNullForKey() throws JMSException {
void testMapConversionWhereMapHasNNullForKey() throws JMSException {
MapMessage message = mock();
Session session = mock();
given(session.createMapMessage()).willReturn(message);

View File

@ -56,7 +56,7 @@ class MappingJackson2MessageConverterTests {
@BeforeEach
public void setup() {
void setup() {
converter.setEncodingPropertyName("__encoding__");
converter.setTypeIdPropertyName("__typeid__");
}
@ -195,7 +195,7 @@ class MappingJackson2MessageConverterTests {
}
@Test
void toTextMessageWithReturnTypeAndMultipleJsonViews() throws JMSException, NoSuchMethodException {
void toTextMessageWithReturnTypeAndMultipleJsonViews() throws NoSuchMethodException {
Method method = this.getClass().getDeclaredMethod("invalid");
MethodParameter returnType = new MethodParameter(method, -1);
@ -203,7 +203,7 @@ class MappingJackson2MessageConverterTests {
testToTextMessageWithReturnType(returnType));
}
private void testToTextMessageWithReturnType(MethodParameter returnType) throws JMSException, NoSuchMethodException {
private void testToTextMessageWithReturnType(MethodParameter returnType) throws JMSException {
converter.setTargetType(MessageType.TEXT);
TextMessage textMessageMock = mock();

View File

@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify;
/**
* @author Arjen Poutsma
*/
public class MarshallingMessageConverterTests {
class MarshallingMessageConverterTests {
private Marshaller marshallerMock = mock();
@ -49,7 +49,7 @@ public class MarshallingMessageConverterTests {
@Test
public void toBytesMessage() throws Exception {
void toBytesMessage() throws Exception {
BytesMessage bytesMessageMock = mock();
Object toBeMarshalled = new Object();
given(sessionMock.createBytesMessage()).willReturn(bytesMessageMock);
@ -61,7 +61,7 @@ public class MarshallingMessageConverterTests {
}
@Test
public void fromBytesMessage() throws Exception {
void fromBytesMessage() throws Exception {
BytesMessage bytesMessageMock = mock();
Object unmarshalled = new Object();
@ -74,7 +74,7 @@ public class MarshallingMessageConverterTests {
}
@Test
public void toTextMessage() throws Exception {
void toTextMessage() throws Exception {
converter.setTargetType(MessageType.TEXT);
TextMessage textMessageMock = mock();
Object toBeMarshalled = new Object();
@ -87,7 +87,7 @@ public class MarshallingMessageConverterTests {
}
@Test
public void fromTextMessage() throws Exception {
void fromTextMessage() throws Exception {
TextMessage textMessageMock = mock();
Object unmarshalled = new Object();

View File

@ -37,19 +37,19 @@ import static org.mockito.Mockito.verify;
/**
* @author Stephane Nicoll
*/
public class MessagingMessageConverterTests {
class MessagingMessageConverterTests {
private final MessagingMessageConverter converter = new MessagingMessageConverter();
@Test
public void onlyHandlesMessage() throws JMSException {
void onlyHandlesMessage() {
assertThatIllegalArgumentException().isThrownBy(() ->
this.converter.toMessage(new Object(), mock()));
}
@Test
public void simpleObject() throws Exception {
void simpleObject() throws Exception {
Session session = mock();
Serializable payload = mock();
ObjectMessage jmsMessage = mock();
@ -60,7 +60,7 @@ public class MessagingMessageConverterTests {
}
@Test
public void customPayloadConverter() throws JMSException {
void customPayloadConverter() throws JMSException {
TextMessage jmsMsg = new StubTextMessage("1224");
this.converter.setPayloadConverter(new TestMessageConverter());

View File

@ -35,13 +35,13 @@ import static org.mockito.Mockito.mock;
/**
* @author Rick Evans
*/
public class DynamicDestinationResolverTests {
class DynamicDestinationResolverTests {
private static final String DESTINATION_NAME = "foo";
@Test
public void resolveWithPubSubTopicSession() throws Exception {
void resolveWithPubSubTopicSession() throws Exception {
Topic expectedDestination = new StubTopic();
TopicSession session = mock();
given(session.createTopic(DESTINATION_NAME)).willReturn(expectedDestination);
@ -49,7 +49,7 @@ public class DynamicDestinationResolverTests {
}
@Test
public void resolveWithPubSubVanillaSession() throws Exception {
void resolveWithPubSubVanillaSession() throws Exception {
Topic expectedDestination = new StubTopic();
Session session = mock();
given(session.createTopic(DESTINATION_NAME)).willReturn(expectedDestination);
@ -57,7 +57,7 @@ public class DynamicDestinationResolverTests {
}
@Test
public void resolveWithPointToPointQueueSession() throws Exception {
void resolveWithPointToPointQueueSession() throws Exception {
Queue expectedDestination = new StubQueue();
QueueSession session = mock();
given(session.createQueue(DESTINATION_NAME)).willReturn(expectedDestination);
@ -65,7 +65,7 @@ public class DynamicDestinationResolverTests {
}
@Test
public void resolveWithPointToPointVanillaSession() throws Exception {
void resolveWithPointToPointVanillaSession() throws Exception {
Queue expectedDestination = new StubQueue();
Session session = mock();
given(session.createQueue(DESTINATION_NAME)).willReturn(expectedDestination);

View File

@ -27,10 +27,10 @@ import static org.mockito.Mockito.mock;
* @author Rick Evans
* @author Chris Beams
*/
public class JmsDestinationAccessorTests {
class JmsDestinationAccessorTests {
@Test
public void testChokesIfDestinationResolverIsetToNullExplicitly() throws Exception {
void testChokesIfDestinationResolverIsetToNullExplicitly() {
ConnectionFactory connectionFactory = mock();
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
@ -40,7 +40,7 @@ public class JmsDestinationAccessorTests {
}
@Test
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception {
void testSessionTransactedModeReallyDoesDefaultToFalse() {
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
assertThat(accessor.isPubSubDomain()).as("The [pubSubDomain] property of JmsDestinationAccessor must default to " +
"false (i.e. Queues are used by default). Change this test (and the " +

View File

@ -33,7 +33,7 @@ import static org.mockito.Mockito.mock;
* @author Rick Evans
* @author Chris Beams
*/
public class JndiDestinationResolverTests {
class JndiDestinationResolverTests {
private static final String DESTINATION_NAME = "foo";
@ -41,7 +41,7 @@ public class JndiDestinationResolverTests {
@Test
public void testHitsCacheSecondTimeThrough() throws Exception {
void testHitsCacheSecondTimeThrough() throws Exception {
Session session = mock();
@ -52,7 +52,7 @@ public class JndiDestinationResolverTests {
}
@Test
public void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception {
void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception {
Session session = mock();
@ -71,7 +71,7 @@ public class JndiDestinationResolverTests {
}
@Test
public void testDelegatesToFallbackIfNotResolvedInJndi() throws Exception {
void testDelegatesToFallbackIfNotResolvedInJndi() throws Exception {
Session session = mock();
DestinationResolver dynamicResolver = mock();
@ -93,7 +93,7 @@ public class JndiDestinationResolverTests {
}
@Test
public void testDoesNotDelegateToFallbackIfNotResolvedInJndi() throws Exception {
void testDoesNotDelegateToFallbackIfNotResolvedInJndi() {
final Session session = mock();
DestinationResolver dynamicResolver = mock();
@ -115,7 +115,7 @@ public class JndiDestinationResolverTests {
private boolean called;
@Override
protected <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException {
protected <T> T lookup(String jndiName, Class<T> requiredType) {
assertThat(called).as("delegating to lookup(..) not cache").isFalse();
assertThat(jndiName).isEqualTo(DESTINATION_NAME);
called = true;
@ -132,7 +132,7 @@ public class JndiDestinationResolverTests {
}
@Override
protected <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException {
protected <T> T lookup(String jndiName, Class<T> requiredType) {
++this.callCount;
return requiredType.cast(DESTINATION);
}