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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,9 +16,7 @@
package org.springframework.jca; package org.springframework.jca;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec; import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.InvalidPropertyException;
import jakarta.resource.spi.ResourceAdapter; import jakarta.resource.spi.ResourceAdapter;
/** /**
@ -27,7 +25,7 @@ import jakarta.resource.spi.ResourceAdapter;
public class StubActivationSpec implements ActivationSpec { public class StubActivationSpec implements ActivationSpec {
@Override @Override
public void validate() throws InvalidPropertyException { public void validate() {
} }
@Override @Override
@ -36,7 +34,7 @@ public class StubActivationSpec implements ActivationSpec {
} }
@Override @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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 javax.transaction.xa.XAResource;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec; import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.BootstrapContext; import jakarta.resource.spi.BootstrapContext;
import jakarta.resource.spi.ResourceAdapter; import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterInternalException;
import jakarta.resource.spi.endpoint.MessageEndpointFactory; import jakarta.resource.spi.endpoint.MessageEndpointFactory;
/** /**
@ -31,7 +29,7 @@ import jakarta.resource.spi.endpoint.MessageEndpointFactory;
public class StubResourceAdapter implements ResourceAdapter { public class StubResourceAdapter implements ResourceAdapter {
@Override @Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException { public void start(BootstrapContext bootstrapContext) {
} }
@Override @Override
@ -39,7 +37,7 @@ public class StubResourceAdapter implements ResourceAdapter {
} }
@Override @Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException { public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
} }
@Override @Override
@ -47,7 +45,7 @@ public class StubResourceAdapter implements ResourceAdapter {
} }
@Override @Override
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException { public XAResource[] getXAResources(ActivationSpec[] activationSpecs) {
return null; 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Connection;
import jakarta.jms.ConnectionFactory; import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSContext; import jakarta.jms.JMSContext;
import jakarta.jms.JMSException;
/** /**
* A stub implementation of the JMS ConnectionFactory for testing. * A stub implementation of the JMS ConnectionFactory for testing.
@ -29,12 +28,12 @@ import jakarta.jms.JMSException;
public class StubConnectionFactory implements ConnectionFactory { public class StubConnectionFactory implements ConnectionFactory {
@Override @Override
public Connection createConnection() throws JMSException { public Connection createConnection() {
return null; return null;
} }
@Override @Override
public Connection createConnection(String username, String password) throws JMSException { public Connection createConnection(String username, String password) {
return null; return null;
} }

View File

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

View File

@ -65,7 +65,7 @@ abstract class AbstractJmsAnnotationDrivenTests {
abstract void defaultContainerFactory(); abstract void defaultContainerFactory();
@Test @Test
abstract void jmsHandlerMethodFactoryConfiguration() throws JMSException; abstract void jmsHandlerMethodFactoryConfiguration();
@Test @Test
abstract void jmsListenerIsRepeatable(); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.jms.annotation; package org.springframework.jms.annotation;
import jakarta.jms.JMSException;
import jakarta.jms.MessageListener; import jakarta.jms.MessageListener;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -85,7 +84,7 @@ class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
void jmsHandlerMethodFactoryConfiguration() throws JMSException { void jmsHandlerMethodFactoryConfiguration() {
ApplicationContext context = new ClassPathXmlApplicationContext( ApplicationContext context = new ClassPathXmlApplicationContext(
"annotation-driven-custom-handler-method-factory.xml", getClass()); "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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import jakarta.jms.JMSException;
import jakarta.jms.MessageListener; import jakarta.jms.MessageListener;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -103,7 +102,6 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
} }
@Test @Test
@SuppressWarnings("resource")
void containerAreStartedByDefault() { void containerAreStartedByDefault() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class); EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class);
@ -115,7 +113,6 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
} }
@Test @Test
@SuppressWarnings("resource")
void containerCanBeStarterViaTheRegistry() { void containerCanBeStarterViaTheRegistry() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsAutoStartupFalseConfig.class, DefaultBean.class); EnableJmsAutoStartupFalseConfig.class, DefaultBean.class);
@ -131,7 +128,7 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
@Override @Override
@Test @Test
void jmsHandlerMethodFactoryConfiguration() throws JMSException { void jmsHandlerMethodFactoryConfiguration() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class); EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class);
@ -179,7 +176,6 @@ class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
} }
@Test @Test
@SuppressWarnings("resource")
void unknownFactory() { void unknownFactory() {
// not found // not found
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
/** /**
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
public class JmsListenerEndpointRegistrarTests { class JmsListenerEndpointRegistrarTests {
private final JmsListenerEndpointRegistrar registrar = new JmsListenerEndpointRegistrar(); private final JmsListenerEndpointRegistrar registrar = new JmsListenerEndpointRegistrar();
@ -38,26 +38,26 @@ public class JmsListenerEndpointRegistrarTests {
@BeforeEach @BeforeEach
public void setup() { void setup() {
this.registrar.setEndpointRegistry(this.registry); this.registrar.setEndpointRegistry(this.registry);
this.registrar.setBeanFactory(new StaticListableBeanFactory()); this.registrar.setBeanFactory(new StaticListableBeanFactory());
} }
@Test @Test
public void registerNullEndpoint() { void registerNullEndpoint() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
this.registrar.registerEndpoint(null, this.containerFactory)); this.registrar.registerEndpoint(null, this.containerFactory));
} }
@Test @Test
public void registerNullEndpointId() { void registerNullEndpointId() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
this.registrar.registerEndpoint(new SimpleJmsListenerEndpoint(), this.containerFactory)); this.registrar.registerEndpoint(new SimpleJmsListenerEndpoint(), this.containerFactory));
} }
@Test @Test
public void registerEmptyEndpointId() { void registerEmptyEndpointId() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId(""); endpoint.setId("");
@ -66,7 +66,7 @@ public class JmsListenerEndpointRegistrarTests {
} }
@Test @Test
public void registerNullContainerFactoryIsAllowed() throws Exception { void registerNullContainerFactoryIsAllowed() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId("some id"); endpoint.setId("some id");
this.registrar.setContainerFactory(this.containerFactory); this.registrar.setContainerFactory(this.containerFactory);
@ -74,11 +74,11 @@ public class JmsListenerEndpointRegistrarTests {
this.registrar.afterPropertiesSet(); this.registrar.afterPropertiesSet();
assertThat(this.registry.getListenerContainer("some id")).as("Container not created").isNotNull(); assertThat(this.registry.getListenerContainer("some id")).as("Container not created").isNotNull();
assertThat(this.registry.getListenerContainers()).hasSize(1); assertThat(this.registry.getListenerContainers()).hasSize(1);
assertThat(this.registry.getListenerContainerIds()).element(0).isEqualTo("some id"); assertThat(this.registry.getListenerContainerIds()).containsOnly("some id");
} }
@Test @Test
public void registerNullContainerFactoryWithNoDefault() throws Exception { void registerNullContainerFactoryWithNoDefault() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId("some id"); endpoint.setId("some id");
this.registrar.registerEndpoint(endpoint, null); this.registrar.registerEndpoint(endpoint, null);
@ -89,7 +89,7 @@ public class JmsListenerEndpointRegistrarTests {
} }
@Test @Test
public void registerContainerWithoutFactory() throws Exception { void registerContainerWithoutFactory() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
endpoint.setId("myEndpoint"); endpoint.setId("myEndpoint");
this.registrar.setContainerFactory(this.containerFactory); this.registrar.setContainerFactory(this.containerFactory);
@ -97,7 +97,7 @@ public class JmsListenerEndpointRegistrarTests {
this.registrar.afterPropertiesSet(); this.registrar.afterPropertiesSet();
assertThat(this.registry.getListenerContainer("myEndpoint")).as("Container not created").isNotNull(); assertThat(this.registry.getListenerContainer("myEndpoint")).as("Container not created").isNotNull();
assertThat(this.registry.getListenerContainers()).hasSize(1); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JmsListenerEndpointRegistryTests { class JmsListenerEndpointRegistryTests {
private final JmsListenerEndpointRegistry registry = new JmsListenerEndpointRegistry(); private final JmsListenerEndpointRegistry registry = new JmsListenerEndpointRegistry();
@ -32,25 +32,25 @@ public class JmsListenerEndpointRegistryTests {
@Test @Test
public void createWithNullEndpoint() { void createWithNullEndpoint() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
registry.registerListenerContainer(null, containerFactory)); registry.registerListenerContainer(null, containerFactory));
} }
@Test @Test
public void createWithNullEndpointId() { void createWithNullEndpointId() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
registry.registerListenerContainer(new SimpleJmsListenerEndpoint(), containerFactory)); registry.registerListenerContainer(new SimpleJmsListenerEndpoint(), containerFactory));
} }
@Test @Test
public void createWithNullContainerFactory() { void createWithNullContainerFactory() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
registry.registerListenerContainer(createEndpoint("foo", "myDestination"), null)); registry.registerListenerContainer(createEndpoint("foo", "myDestination"), null));
} }
@Test @Test
public void createWithDuplicateEndpointId() { void createWithDuplicateEndpointId() {
registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory); registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory);
assertThatIllegalStateException().isThrownBy(() -> assertThatIllegalStateException().isThrownBy(() ->

View File

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

View File

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

View File

@ -410,7 +410,7 @@ class MethodJmsListenerEndpointTests {
} }
@Test @Test
void validatePayloadInvalid() throws JMSException { void validatePayloadInvalid() {
DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory(); DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
customFactory.setValidator(testValidator("invalid value")); customFactory.setValidator(testValidator("invalid value"));
@ -427,7 +427,7 @@ class MethodJmsListenerEndpointTests {
// failure scenario // failure scenario
@Test @Test
void invalidPayloadType() throws JMSException { void invalidPayloadType() {
MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class); MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);
Session session = mock(); Session session = mock();
@ -439,7 +439,7 @@ class MethodJmsListenerEndpointTests {
} }
@Test @Test
void invalidMessagePayloadType() throws JMSException { void invalidMessagePayloadType() {
MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class); MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
Session session = mock(); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class SimpleJmsListenerEndpointTests { class SimpleJmsListenerEndpointTests {
private final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); private final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
@Test @Test
public void createListener() { void createListener() {
SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint(); SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
MessageListener messageListener = new MessageListenerAdapter(); MessageListener messageListener = new MessageListenerAdapter();
endpoint.setMessageListener(messageListener); endpoint.setMessageListener(messageListener);

View File

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

View File

@ -46,10 +46,10 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 26.07.2004 * @since 26.07.2004
*/ */
public class SingleConnectionFactoryTests { class SingleConnectionFactoryTests {
@Test @Test
public void testWithConnection() throws JMSException { void testWithConnection() throws JMSException {
Connection con = mock(); Connection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con); SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -70,7 +70,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithQueueConnection() throws JMSException { void testWithQueueConnection() throws JMSException {
QueueConnection con = mock(); QueueConnection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con); SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -91,7 +91,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithTopicConnection() throws JMSException { void testWithTopicConnection() throws JMSException {
TopicConnection con = mock(); TopicConnection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con); SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -112,7 +112,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactory() throws JMSException { void testWithConnectionFactory() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
Connection con = mock(); Connection con = mock();
@ -134,7 +134,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithQueueConnectionFactoryAndJms11Usage() throws JMSException { void testWithQueueConnectionFactoryAndJms11Usage() throws JMSException {
QueueConnectionFactory cf = mock(); QueueConnectionFactory cf = mock();
QueueConnection con = mock(); QueueConnection con = mock();
@ -156,7 +156,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithQueueConnectionFactoryAndJms102Usage() throws JMSException { void testWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
QueueConnectionFactory cf = mock(); QueueConnectionFactory cf = mock();
QueueConnection con = mock(); QueueConnection con = mock();
@ -178,7 +178,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithTopicConnectionFactoryAndJms11Usage() throws JMSException { void testWithTopicConnectionFactoryAndJms11Usage() throws JMSException {
TopicConnectionFactory cf = mock(); TopicConnectionFactory cf = mock();
TopicConnection con = mock(); TopicConnection con = mock();
@ -200,7 +200,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithTopicConnectionFactoryAndJms102Usage() throws JMSException { void testWithTopicConnectionFactoryAndJms102Usage() throws JMSException {
TopicConnectionFactory cf = mock(); TopicConnectionFactory cf = mock();
TopicConnection con = mock(); TopicConnection con = mock();
@ -222,7 +222,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionAggregatedStartStop() throws JMSException { void testWithConnectionAggregatedStartStop() throws JMSException {
Connection con = mock(); Connection con = mock();
SingleConnectionFactory scf = new SingleConnectionFactory(con); SingleConnectionFactory scf = new SingleConnectionFactory(con);
@ -254,7 +254,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactoryAndClientId() throws JMSException { void testWithConnectionFactoryAndClientId() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
Connection con = mock(); Connection con = mock();
given(cf.createConnection()).willReturn(con); given(cf.createConnection()).willReturn(con);
@ -277,7 +277,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactoryAndExceptionListener() throws JMSException { void testWithConnectionFactoryAndExceptionListener() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
Connection con = mock(); Connection con = mock();
@ -305,7 +305,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactoryAndReconnectOnException() throws JMSException { void testWithConnectionFactoryAndReconnectOnException() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
TestConnection con = new TestConnection(); TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con); given(cf.createConnection()).willReturn(con);
@ -325,7 +325,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactoryAndExceptionListenerAndReconnectOnException() throws JMSException { void testWithConnectionFactoryAndExceptionListenerAndReconnectOnException() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
TestConnection con = new TestConnection(); TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con); given(cf.createConnection()).willReturn(con);
@ -348,7 +348,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactoryAndExceptionListenerAndReconnectOnExceptionWithJMSException() throws Exception { void testWithConnectionFactoryAndExceptionListenerAndReconnectOnExceptionWithJMSException() throws Exception {
// Throws JMSException on setExceptionListener() method, but only at the first time // Throws JMSException on setExceptionListener() method, but only at the first time
class FailingTestConnection extends TestConnection { class FailingTestConnection extends TestConnection {
private int setExceptionListenerInvocationCounter; private int setExceptionListenerInvocationCounter;
@ -447,7 +447,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactoryAndLocalExceptionListenerWithCleanup() throws JMSException { void testWithConnectionFactoryAndLocalExceptionListenerWithCleanup() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
TestConnection con = new TestConnection(); TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con); given(cf.createConnection()).willReturn(con);
@ -485,7 +485,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testWithConnectionFactoryAndLocalExceptionListenerWithReconnect() throws JMSException { void testWithConnectionFactoryAndLocalExceptionListenerWithReconnect() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
TestConnection con = new TestConnection(); TestConnection con = new TestConnection();
given(cf.createConnection()).willReturn(con); given(cf.createConnection()).willReturn(con);
@ -519,7 +519,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testCachingConnectionFactory() throws JMSException { void testCachingConnectionFactory() throws JMSException {
ConnectionFactory cf = mock(); ConnectionFactory cf = mock();
Connection con = mock(); Connection con = mock();
Session txSession = mock(); Session txSession = mock();
@ -559,7 +559,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testCachingConnectionFactoryWithQueueConnectionFactoryAndJms102Usage() throws JMSException { void testCachingConnectionFactoryWithQueueConnectionFactoryAndJms102Usage() throws JMSException {
QueueConnectionFactory cf = mock(); QueueConnectionFactory cf = mock();
QueueConnection con = mock(); QueueConnection con = mock();
QueueSession txSession = mock(); QueueSession txSession = mock();
@ -599,7 +599,7 @@ public class SingleConnectionFactoryTests {
} }
@Test @Test
public void testCachingConnectionFactoryWithTopicConnectionFactoryAndJms102Usage() throws JMSException { void testCachingConnectionFactoryWithTopicConnectionFactoryAndJms102Usage() throws JMSException {
TopicConnectionFactory cf = mock(); TopicConnectionFactory cf = mock();
TopicConnection con = mock(); TopicConnection con = mock();
TopicSession txSession = 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,36 +39,36 @@ public class TestConnection implements Connection {
@Override @Override
public Session createSession(boolean b, int i) throws JMSException { public Session createSession(boolean b, int i) {
return null; return null;
} }
@Override @Override
public Session createSession(int sessionMode) throws JMSException { public Session createSession(int sessionMode) {
return null; return null;
} }
@Override @Override
public Session createSession() throws JMSException { public Session createSession() {
return null; return null;
} }
@Override @Override
public String getClientID() throws JMSException { public String getClientID() {
return null; return null;
} }
@Override @Override
public void setClientID(String paramName) throws JMSException { public void setClientID(String paramName) {
} }
@Override @Override
public ConnectionMetaData getMetaData() throws JMSException { public ConnectionMetaData getMetaData() {
return null; return null;
} }
@Override @Override
public ExceptionListener getExceptionListener() throws JMSException { public ExceptionListener getExceptionListener() {
return exceptionListener; return exceptionListener;
} }
@ -78,36 +78,36 @@ public class TestConnection implements Connection {
} }
@Override @Override
public void start() throws JMSException { public void start() {
this.startCount++; this.startCount++;
} }
@Override @Override
public void stop() throws JMSException { public void stop() {
} }
@Override @Override
public void close() throws JMSException { public void close() {
this.closeCount++; this.closeCount++;
} }
@Override @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; return null;
} }
@Override @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; return null;
} }
@Override @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; return null;
} }
@Override @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; return null;
} }

View File

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

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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Juergen Hoeller
* @since 06.01.2005 * @since 06.01.2005
*/ */
public class JmsTemplateJtaTests extends JmsTemplateTests { class JmsTemplateJtaTests extends JmsTemplateTests {
@Override @Override
protected boolean useTransactedSession() { protected boolean useTransactedSession() {

View File

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

View File

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

View File

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

View File

@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify;
* @author Chris Beams * @author Chris Beams
* @author Mark Fisher * @author Mark Fisher
*/ */
public class SimpleMessageListenerContainerTests { class SimpleMessageListenerContainerTests {
private static final String DESTINATION_NAME = "foo"; private static final String DESTINATION_NAME = "foo";
@ -59,25 +59,25 @@ public class SimpleMessageListenerContainerTests {
@Test @Test
public void testSettingMessageListenerToANullType() { void testSettingMessageListenerToANullType() {
this.container.setMessageListener(null); this.container.setMessageListener(null);
assertThat(this.container.getMessageListener()).isNull(); assertThat(this.container.getMessageListener()).isNull();
} }
@Test @Test
public void testSettingMessageListenerToAnUnsupportedType() { void testSettingMessageListenerToAnUnsupportedType() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
this.container.setMessageListener("Bingo")); this.container.setMessageListener("Bingo"));
} }
@Test @Test
public void testSessionTransactedModeReallyDoesDefaultToFalse() { void testSessionTransactedModeReallyDoesDefaultToFalse() {
assertThat(this.container.isPubSubNoLocal()).as("The [pubSubLocal] property of SimpleMessageListenerContainer " + assertThat(this.container.isPubSubNoLocal()).as("The [pubSubLocal] property of SimpleMessageListenerContainer " +
"must default to false. Change this test (and the attendant javadoc) if you have changed the default.").isFalse(); "must default to false. Change this test (and the attendant javadoc) if you have changed the default.").isFalse();
} }
@Test @Test
public void testSettingConcurrentConsumersToZeroIsNotAllowed() { void testSettingConcurrentConsumersToZeroIsNotAllowed() {
assertThatIllegalArgumentException().isThrownBy(() -> { assertThatIllegalArgumentException().isThrownBy(() -> {
this.container.setConcurrentConsumers(0); this.container.setConcurrentConsumers(0);
this.container.afterPropertiesSet(); this.container.afterPropertiesSet();
@ -85,7 +85,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() { void testSettingConcurrentConsumersToANegativeValueIsNotAllowed() {
assertThatIllegalArgumentException().isThrownBy(() -> { assertThatIllegalArgumentException().isThrownBy(() -> {
this.container.setConcurrentConsumers(-198); this.container.setConcurrentConsumers(-198);
this.container.afterPropertiesSet(); this.container.afterPropertiesSet();
@ -93,7 +93,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testContextRefreshedEventDoesNotStartTheConnectionIfAutoStartIsSetToFalse() throws Exception { void testContextRefreshedEventDoesNotStartTheConnectionIfAutoStartIsSetToFalse() throws Exception {
MessageConsumer messageConsumer = mock(); MessageConsumer messageConsumer = mock();
Session session = mock(); Session session = mock();
// Queue gets created in order to create MessageConsumer for that Destination... // Queue gets created in order to create MessageConsumer for that Destination...
@ -124,7 +124,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testContextRefreshedEventStartsTheConnectionByDefault() throws Exception { void testContextRefreshedEventStartsTheConnectionByDefault() throws Exception {
MessageConsumer messageConsumer = mock(); MessageConsumer messageConsumer = mock();
Session session = mock(); Session session = mock();
// Queue gets created in order to create MessageConsumer for that Destination... // Queue gets created in order to create MessageConsumer for that Destination...
@ -156,7 +156,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testCorrectSessionExposedForSessionAwareMessageListenerInvocation() throws Exception { void testCorrectSessionExposedForSessionAwareMessageListenerInvocation() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer(); final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
final Session session = mock(); final Session session = mock();
@ -206,7 +206,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testTaskExecutorCorrectlyInvokedWhenSpecified() throws Exception { void testTaskExecutorCorrectlyInvokedWhenSpecified() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer(); final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
final Session session = mock(); final Session session = mock();
@ -247,7 +247,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testRegisteredExceptionListenerIsInvokedOnException() throws Exception { void testRegisteredExceptionListenerIsInvokedOnException() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer(); final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
Session session = mock(); Session session = mock();
@ -294,7 +294,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testRegisteredErrorHandlerIsInvokedOnException() throws Exception { void testRegisteredErrorHandlerIsInvokedOnException() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer(); final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
Session session = mock(); Session session = mock();
@ -339,7 +339,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testNoRollbackOccursIfSessionIsNotTransactedAndThatExceptionsDo_NOT_Propagate() throws Exception { void testNoRollbackOccursIfSessionIsNotTransactedAndThatExceptionsDo_NOT_Propagate() throws Exception {
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer(); final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
Session session = mock(); Session session = mock();
@ -378,7 +378,7 @@ public class SimpleMessageListenerContainerTests {
} }
@Test @Test
public void testTransactedSessionsGetRollbackLogicAppliedAndThatExceptionsStillDo_NOT_Propagate() throws Exception { void testTransactedSessionsGetRollbackLogicAppliedAndThatExceptionsStillDo_NOT_Propagate() throws Exception {
this.container.setSessionTransacted(true); this.container.setSessionTransacted(true);
final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer(); final SimpleMessageConsumer messageConsumer = new SimpleMessageConsumer();
@ -414,14 +414,14 @@ public class SimpleMessageListenerContainerTests {
// a Throwable from a MessageListener MUST simply be swallowed... // a Throwable from a MessageListener MUST simply be swallowed...
messageConsumer.sendMessage(message); messageConsumer.sendMessage(message);
// Session is rolled back 'cos it is transacted... // Session is rolled back because it is transacted...
verify(session).rollback(); verify(session).rollback();
verify(connection).setExceptionListener(this.container); verify(connection).setExceptionListener(this.container);
verify(connection).start(); verify(connection).start();
} }
@Test @Test
public void testDestroyClosesConsumersSessionsAndConnectionInThatOrder() throws Exception { void testDestroyClosesConsumersSessionsAndConnectionInThatOrder() throws Exception {
MessageConsumer messageConsumer = mock(); MessageConsumer messageConsumer = mock();
Session session = mock(); Session session = mock();
// Queue gets created in order to create MessageConsumer for that Destination... // 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 * @author Stephane Nicoll
*/ */
public class JmsResponseTests { class JmsResponseTests {
@Test @Test
public void destinationDoesNotUseDestinationResolver() throws JMSException { void destinationDoesNotUseDestinationResolver() throws JMSException {
Destination destination = mock(); Destination destination = mock();
Destination actual = JmsResponse.forDestination("foo", destination).resolveDestination(null, null); Destination actual = JmsResponse.forDestination("foo", destination).resolveDestination(null, null);
assertThat(actual).isSameAs(destination); assertThat(actual).isSameAs(destination);
} }
@Test @Test
public void resolveDestinationForQueue() throws JMSException { void resolveDestinationForQueue() throws JMSException {
Session session = mock(); Session session = mock();
DestinationResolver destinationResolver = mock(); DestinationResolver destinationResolver = mock();
Destination destination = mock(); Destination destination = mock();
@ -53,25 +53,25 @@ public class JmsResponseTests {
} }
@Test @Test
public void createWithNullResponse() { void createWithNullResponse() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forQueue(null, "myQueue")); JmsResponse.forQueue(null, "myQueue"));
} }
@Test @Test
public void createWithNullQueueName() { void createWithNullQueueName() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forQueue("foo", null)); JmsResponse.forQueue("foo", null));
} }
@Test @Test
public void createWithNullTopicName() { void createWithNullTopicName() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forTopic("foo", null)); JmsResponse.forTopic("foo", null));
} }
@Test @Test
public void createWithNulDestination() { void createWithNulDestination() {
assertThatIllegalArgumentException().isThrownBy(() -> assertThatIllegalArgumentException().isThrownBy(() ->
JmsResponse.forDestination("foo", null)); JmsResponse.forDestination("foo", null));
} }

View File

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

View File

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

View File

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

View File

@ -50,7 +50,7 @@ class JmsActivationSpecConfigTests {
/** /**
* This test effectively verifies that the internal 'constants' map is properly * 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}. * {@link jakarta.jms.Session}.
*/ */
@Test @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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JmsMessageEndpointManagerTests { class JmsMessageEndpointManagerTests {
@Test @Test
public void isPubSubDomainWithQueue() { void isPubSubDomainWithQueue() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig(); JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(false); config.setPubSubDomain(false);
@ -39,7 +39,7 @@ public class JmsMessageEndpointManagerTests {
} }
@Test @Test
public void isPubSubDomainWithTopic() { void isPubSubDomainWithTopic() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig(); JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(true); config.setPubSubDomain(true);
@ -49,7 +49,7 @@ public class JmsMessageEndpointManagerTests {
} }
@Test @Test
public void pubSubDomainCustomForReply() { void pubSubDomainCustomForReply() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig(); JmsActivationSpecConfig config = new JmsActivationSpecConfig();
config.setPubSubDomain(true); config.setPubSubDomain(true);
@ -60,7 +60,7 @@ public class JmsMessageEndpointManagerTests {
} }
@Test @Test
public void customReplyQosSettings() { void customReplyQosSettings() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
JmsActivationSpecConfig config = new JmsActivationSpecConfig(); JmsActivationSpecConfig config = new JmsActivationSpecConfig();
QosSettings settings = new QosSettings(1, 3, 5); QosSettings settings = new QosSettings(1, 3, 5);
@ -73,7 +73,7 @@ public class JmsMessageEndpointManagerTests {
} }
@Test @Test
public void isPubSubDomainWithNoConfig() { void isPubSubDomainWithNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
// far from ideal // far from ideal
assertThatIllegalStateException().isThrownBy( assertThatIllegalStateException().isThrownBy(
@ -81,7 +81,7 @@ public class JmsMessageEndpointManagerTests {
} }
@Test @Test
public void isReplyPubSubDomainWithNoConfig() { void isReplyPubSubDomainWithNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
// far from ideal // far from ideal
assertThatIllegalStateException().isThrownBy( assertThatIllegalStateException().isThrownBy(
@ -89,7 +89,7 @@ public class JmsMessageEndpointManagerTests {
} }
@Test @Test
public void getReplyQosSettingsWithNoConfig() { void getReplyQosSettingsWithNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
// far from ideal // far from ideal
assertThatIllegalStateException().isThrownBy( assertThatIllegalStateException().isThrownBy(
@ -97,13 +97,13 @@ public class JmsMessageEndpointManagerTests {
} }
@Test @Test
public void getMessageConverterNoConfig() { void getMessageConverterNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
assertThat(endpoint.getMessageConverter()).isNull(); assertThat(endpoint.getMessageConverter()).isNull();
} }
@Test @Test
public void getDestinationResolverNoConfig() { void getDestinationResolverNoConfig() {
JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager(); JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
assertThat(endpoint.getDestinationResolver()).isNull(); assertThat(endpoint.getDestinationResolver()).isNull();
} }

View File

@ -80,7 +80,7 @@ class JmsAccessorTests {
/** /**
* This test effectively verifies that the internal 'constants' map is properly * 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}. * {@link jakarta.jms.Session}.
*/ */
@Test @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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 * @author Stephane Nicoll
*/ */
public class JmsMessageHeaderAccessorTests { class JmsMessageHeaderAccessorTests {
@Test @Test
public void validateJmsHeaders() throws JMSException { void validateJmsHeaders() throws JMSException {
Destination destination = new Destination() {}; Destination destination = new Destination() {};
Destination replyTo = new Destination() {}; Destination replyTo = new Destination() {};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,10 +27,10 @@ import static org.mockito.Mockito.mock;
* @author Rick Evans * @author Rick Evans
* @author Chris Beams * @author Chris Beams
*/ */
public class JmsDestinationAccessorTests { class JmsDestinationAccessorTests {
@Test @Test
public void testChokesIfDestinationResolverIsetToNullExplicitly() throws Exception { void testChokesIfDestinationResolverIsetToNullExplicitly() {
ConnectionFactory connectionFactory = mock(); ConnectionFactory connectionFactory = mock();
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor(); JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
@ -40,7 +40,7 @@ public class JmsDestinationAccessorTests {
} }
@Test @Test
public void testSessionTransactedModeReallyDoesDefaultToFalse() throws Exception { void testSessionTransactedModeReallyDoesDefaultToFalse() {
JmsDestinationAccessor accessor = new StubJmsDestinationAccessor(); JmsDestinationAccessor accessor = new StubJmsDestinationAccessor();
assertThat(accessor.isPubSubDomain()).as("The [pubSubDomain] property of JmsDestinationAccessor must default to " + 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 " + "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 Rick Evans
* @author Chris Beams * @author Chris Beams
*/ */
public class JndiDestinationResolverTests { class JndiDestinationResolverTests {
private static final String DESTINATION_NAME = "foo"; private static final String DESTINATION_NAME = "foo";
@ -41,7 +41,7 @@ public class JndiDestinationResolverTests {
@Test @Test
public void testHitsCacheSecondTimeThrough() throws Exception { void testHitsCacheSecondTimeThrough() throws Exception {
Session session = mock(); Session session = mock();
@ -52,7 +52,7 @@ public class JndiDestinationResolverTests {
} }
@Test @Test
public void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception { void testDoesNotUseCacheIfCachingIsTurnedOff() throws Exception {
Session session = mock(); Session session = mock();
@ -71,7 +71,7 @@ public class JndiDestinationResolverTests {
} }
@Test @Test
public void testDelegatesToFallbackIfNotResolvedInJndi() throws Exception { void testDelegatesToFallbackIfNotResolvedInJndi() throws Exception {
Session session = mock(); Session session = mock();
DestinationResolver dynamicResolver = mock(); DestinationResolver dynamicResolver = mock();
@ -93,7 +93,7 @@ public class JndiDestinationResolverTests {
} }
@Test @Test
public void testDoesNotDelegateToFallbackIfNotResolvedInJndi() throws Exception { void testDoesNotDelegateToFallbackIfNotResolvedInJndi() {
final Session session = mock(); final Session session = mock();
DestinationResolver dynamicResolver = mock(); DestinationResolver dynamicResolver = mock();
@ -115,7 +115,7 @@ public class JndiDestinationResolverTests {
private boolean called; private boolean called;
@Override @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(called).as("delegating to lookup(..) not cache").isFalse();
assertThat(jndiName).isEqualTo(DESTINATION_NAME); assertThat(jndiName).isEqualTo(DESTINATION_NAME);
called = true; called = true;
@ -132,7 +132,7 @@ public class JndiDestinationResolverTests {
} }
@Override @Override
protected <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException { protected <T> T lookup(String jndiName, Class<T> requiredType) {
++this.callCount; ++this.callCount;
return requiredType.cast(DESTINATION); return requiredType.cast(DESTINATION);
} }