Migrate few modules to Junit Jupiter
including: `spring-integration-amqp`, `spring-integration-file`, 'spring-integration-groovy' Signed-off-by: Jiandong Ma <jiandong.ma.cn@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.http.config;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.PropertiesFactoryBean;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,8 @@
|
||||
|
||||
package org.springframework.integration.http.config;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
@@ -30,12 +29,12 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
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 org.springframework.test.web.client.MockRestServiceServer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
|
||||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
|
||||
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
|
||||
@@ -44,8 +43,7 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@SpringJUnitConfig
|
||||
@DirtiesContext
|
||||
public class HttpOutboundGatewayWithMethodExpressionTests {
|
||||
|
||||
@@ -63,7 +61,7 @@ public class HttpOutboundGatewayWithMethodExpressionTests {
|
||||
|
||||
private MockRestServiceServer mockServer;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.mockServer = MockRestServiceServer.createServer(this.restTemplate);
|
||||
}
|
||||
@@ -96,11 +94,11 @@ public class HttpOutboundGatewayWithMethodExpressionTests {
|
||||
this.mockServer.verify();
|
||||
}
|
||||
|
||||
@Test(expected = BeanDefinitionParsingException.class)
|
||||
@Test
|
||||
public void testMutuallyExclusivityInMethodAndMethodExpression() {
|
||||
new ClassPathXmlApplicationContext(
|
||||
"http-outbound-gateway-with-httpmethod-expression-fail.xml", getClass())
|
||||
.close();
|
||||
assertThatExceptionOfType(BeanDefinitionParsingException.class)
|
||||
.isThrownBy(() -> new ClassPathXmlApplicationContext(
|
||||
"http-outbound-gateway-with-httpmethod-expression-fail.xml", getClass()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,8 +29,8 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -42,6 +42,8 @@ import org.springframework.util.MimeType;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -55,14 +57,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class DefaultHttpHeaderMapperFromMessageOutboundTests {
|
||||
|
||||
// ACCEPT tests
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void validateAcceptHeaderWithNoSlash() {
|
||||
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
|
||||
Map<String, Object> messageHeaders = new HashMap<>();
|
||||
messageHeaders.put("Accept", "bar");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
|
||||
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -158,13 +162,15 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
|
||||
|
||||
// ACCEPT_CHARSET tests
|
||||
|
||||
@Test(expected = UnsupportedCharsetException.class)
|
||||
@Test
|
||||
public void validateAcceptCharsetHeaderWithWrongCharset() {
|
||||
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
|
||||
Map<String, Object> messageHeaders = new HashMap<>();
|
||||
messageHeaders.put("Accept-Charset", "foo");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
|
||||
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
|
||||
assertThatExceptionOfType(UnsupportedCharsetException.class)
|
||||
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -298,26 +304,30 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
|
||||
assertThat(headers.getContentLength()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test(expected = NumberFormatException.class)
|
||||
@Test
|
||||
public void validateContentLengthAsNonNumericString() {
|
||||
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
|
||||
Map<String, Object> messageHeaders = new HashMap<>();
|
||||
messageHeaders.put("Content-Length", "foo");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
|
||||
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
|
||||
assertThatExceptionOfType(NumberFormatException.class)
|
||||
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
|
||||
}
|
||||
|
||||
// Content-Type test
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void validateContentTypeWrongValue() {
|
||||
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
|
||||
Map<String, Object> messageHeaders = new HashMap<>();
|
||||
messageHeaders.put(MessageHeaders.CONTENT_TYPE, "foo");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
|
||||
MessageHeaders messageHeadersObj = new MessageHeaders(messageHeaders);
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> mapper.fromHeaders(messageHeadersObj, headers));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -542,7 +552,7 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@Disabled
|
||||
public void perf() {
|
||||
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user