Migrate Mockito-effected test classes to JUnit 5
This commit is contained in:
@@ -22,8 +22,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
@@ -38,10 +37,10 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -49,8 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class HeaderEnricherTests {
|
||||
|
||||
@Autowired
|
||||
@@ -252,10 +250,13 @@ public class HeaderEnricherTests {
|
||||
assertThat(result.getHeaders().get("testHeader")).isEqualTo("testBeanForInnerBeanWithMethod");
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
@Test
|
||||
public void testFailConfigUnexpectedSubElement() {
|
||||
new ClassPathXmlApplicationContext("HeaderEnricherWithUnexpectedSubElementForHeader-fail-context.xml",
|
||||
this.getClass()).close();
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() ->
|
||||
new ClassPathXmlApplicationContext(
|
||||
"HeaderEnricherWithUnexpectedSubElementForHeader-fail-context.xml",
|
||||
getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,8 +22,7 @@ import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.function.BiPredicate;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -43,19 +42,19 @@ import org.springframework.integration.metadata.MetadataStore;
|
||||
import org.springframework.integration.selector.MetadataStoreSelector;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.fail;
|
||||
import static org.springframework.integration.test.util.TestUtils.getPropertyValue;
|
||||
|
||||
/**
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class IdempotentReceiverParserTests {
|
||||
|
||||
@@ -158,111 +157,72 @@ public class IdempotentReceiverParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithoutEndpoint() throws Exception {
|
||||
try {
|
||||
bootStrap("without-endpoint");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage()).contains("he 'endpoint' attribute is required");
|
||||
}
|
||||
public void testWithoutEndpoint() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("without-endpoint"))
|
||||
.withMessageContaining("The 'endpoint' attribute is required");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectorAndStore() throws Exception {
|
||||
try {
|
||||
bootStrap("selector-and-store");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
public void testSelectorAndStore() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("selector-and-store"))
|
||||
.withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectorAndKeyStrategy() throws Exception {
|
||||
try {
|
||||
bootStrap("selector-and-key-strategy");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
public void testSelectorAndKeyStrategy() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("selector-and-key-strategy"))
|
||||
.withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectorAndKeyExpression() throws Exception {
|
||||
try {
|
||||
bootStrap("selector-and-key-expression");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
public void testSelectorAndKeyExpression() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("selector-and-key-expression"))
|
||||
.withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectorAndValueStrategy() throws Exception {
|
||||
try {
|
||||
bootStrap("selector-and-value-strategy");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
public void testSelectorAndValueStrategy() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("selector-and-value-strategy"))
|
||||
.withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectorAndValueExpression() throws Exception {
|
||||
try {
|
||||
bootStrap("selector-and-value-expression");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
public void testSelectorAndValueExpression() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("selector-and-value-expression"))
|
||||
.withMessageContaining("The 'selector' attribute is mutually exclusive with 'metadata-store', " +
|
||||
"'key-strategy', 'key-expression', 'value-strategy', 'value-expression', and "
|
||||
+ "'compare-values'");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeyStrategyAndKeyExpression() throws Exception {
|
||||
try {
|
||||
bootStrap("key-strategy-and-key-expression");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("The 'key-strategy' and 'key-expression' attributes are mutually exclusive");
|
||||
}
|
||||
public void testKeyStrategyAndKeyExpression() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("key-strategy-and-key-expression"))
|
||||
.withMessageContaining("The 'key-strategy' and 'key-expression' attributes are mutually exclusive");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValueStrategyAndValueExpression() throws Exception {
|
||||
try {
|
||||
bootStrap("value-strategy-and-value-expression");
|
||||
fail("BeanDefinitionParsingException expected");
|
||||
}
|
||||
catch (BeanDefinitionParsingException e) {
|
||||
assertThat(e.getMessage())
|
||||
.contains("The 'value-strategy' and 'value-expression' attributes are mutually exclusive");
|
||||
}
|
||||
public void testValueStrategyAndValueExpression() {
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> bootStrap("value-strategy-and-value-expression"))
|
||||
.withMessageContaining("The 'value-strategy' and 'value-expression' attributes are mutually exclusive");
|
||||
}
|
||||
|
||||
private ApplicationContext bootStrap(String configProperty) throws Exception {
|
||||
private static ApplicationContext bootStrap(String configProperty) throws Exception {
|
||||
PropertiesFactoryBean pfb = new PropertiesFactoryBean();
|
||||
pfb.setLocation(new ClassPathResource(
|
||||
"org/springframework/integration/config/xml/idempotent-receiver-configs.properties"));
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<int:channel id="input"/>
|
||||
|
||||
<bean id="locker" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.locking.AbstractFileLockerFilter"/>
|
||||
<constructor-arg value="org.springframework.integration.file.locking.AbstractFileLockerFilter"
|
||||
type="java.lang.Class"/>
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
@@ -16,27 +16,25 @@
|
||||
|
||||
package org.springframework.integration.file.config;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.file.locking.NioFileLocker;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class InboundAdapterWithLockersTests {
|
||||
@Autowired(required = true)
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
@@ -45,9 +43,9 @@ public class InboundAdapterWithLockersTests {
|
||||
.isEqualTo(context.getBean("locker"));
|
||||
assertThat(TestUtils.getPropertyValue(context.getBean("inputWithLockerB"), "source.scanner.locker"))
|
||||
.isEqualTo(context.getBean("locker"));
|
||||
assertThat(TestUtils.getPropertyValue(context.getBean("inputWithLockerC"), "source.scanner.locker")
|
||||
instanceof NioFileLocker).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(context.getBean("inputWithLockerD"), "source.scanner.locker")
|
||||
instanceof NioFileLocker).isTrue();
|
||||
assertThat(TestUtils.getPropertyValue(context.getBean("inputWithLockerC"), "source.scanner.locker"))
|
||||
.isInstanceOf(NioFileLocker.class);
|
||||
assertThat(TestUtils.getPropertyValue(context.getBean("inputWithLockerD"), "source.scanner.locker"))
|
||||
.isInstanceOf(NioFileLocker.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@
|
||||
|
||||
package org.springframework.integration.jpa.config.xml;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
@@ -30,7 +29,7 @@ import org.springframework.integration.jpa.core.JpaOperations;
|
||||
import org.springframework.integration.jpa.support.parametersource.ParameterSource;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -42,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @since 2.2
|
||||
*
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class JpaInboundChannelAdapterParserTests {
|
||||
|
||||
@@ -84,7 +83,7 @@ public class JpaInboundChannelAdapterParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJpaInboundChannelAdapterParserWithMaxResults() throws Exception {
|
||||
public void testJpaInboundChannelAdapterParserWithMaxResults() {
|
||||
AbstractMessageChannel outputChannel =
|
||||
TestUtils.getPropertyValue(this.jpaInboundChannelAdapter2, "outputChannel", AbstractMessageChannel.class);
|
||||
|
||||
@@ -114,7 +113,7 @@ public class JpaInboundChannelAdapterParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJpaInboundChannelAdapterParserWithMaxResultsExpression() throws Exception {
|
||||
public void testJpaInboundChannelAdapterParserWithMaxResultsExpression() {
|
||||
AbstractMessageChannel outputChannel =
|
||||
TestUtils.getPropertyValue(this.jpaInboundChannelAdapter3, "outputChannel", AbstractMessageChannel.class);
|
||||
|
||||
@@ -142,7 +141,7 @@ public class JpaInboundChannelAdapterParserTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void testJpaExecutorBeanIdNaming() throws Exception {
|
||||
public void testJpaExecutorBeanIdNaming() {
|
||||
JpaExecutor jpaExecutor1 = this.context.getBean("jpaInboundChannelAdapter1.jpaExecutor", JpaExecutor.class);
|
||||
JpaExecutor jpaExecutor2 = this.context.getBean("jpaInboundChannelAdapter2.jpaExecutor", JpaExecutor.class);
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
http://www.springframework.org/schema/integration/sftp https://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd">
|
||||
|
||||
<bean id="sf" class="org.mockito.Mockito" factory-method="mock">
|
||||
<constructor-arg value="org.springframework.integration.file.remote.session.SessionFactory"/>
|
||||
<constructor-arg value="org.springframework.integration.file.remote.session.SessionFactory"
|
||||
type="java.lang.Class"/>
|
||||
</bean>
|
||||
|
||||
<bean id="csf" class="org.springframework.integration.file.remote.session.CachingSessionFactory">
|
||||
|
||||
@@ -18,8 +18,7 @@ package org.springframework.integration.ws.config;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@@ -29,8 +28,7 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -40,8 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class WebServiceHeaderEnricherTests {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user