Polish
This commit is contained in:
parent
3e3f046dc9
commit
ce3be72e7f
|
|
@ -4777,7 +4777,7 @@ directly. For example:
|
|||
ContextSnapshot snapshot = ContextSnapshot.captureAll();
|
||||
|
||||
// On a different thread: restore ThreadLocal values
|
||||
try (ContextSnapshot.Scope scoped = snapshot.setThreadLocals()) {
|
||||
try (ContextSnapshot.Scope scope = snapshot.setThreadLocals()) {
|
||||
// ...
|
||||
}
|
||||
----
|
||||
|
|
|
|||
|
|
@ -16,10 +16,9 @@
|
|||
|
||||
package org.springframework.context.aot
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito
|
||||
import org.springframework.aot.generate.GenerationContext
|
||||
import org.springframework.aot.hint.MemberCategory
|
||||
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates
|
||||
import org.springframework.aot.test.generate.TestGenerationContext
|
||||
|
|
@ -41,7 +40,7 @@ class KotlinReflectionBeanRegistrationAotProcessorTests {
|
|||
|
||||
@Test
|
||||
fun processorIsRegistered() {
|
||||
Assertions.assertThat(
|
||||
assertThat(
|
||||
AotServices.factories(javaClass.classLoader).load(BeanRegistrationAotProcessor::class.java))
|
||||
.anyMatch(KotlinReflectionBeanRegistrationAotProcessor::class.java::isInstance)
|
||||
}
|
||||
|
|
@ -49,12 +48,12 @@ class KotlinReflectionBeanRegistrationAotProcessorTests {
|
|||
@Test
|
||||
fun shouldProcessKotlinBean() {
|
||||
process(SampleKotlinBean::class.java)
|
||||
Assertions.assertThat(
|
||||
assertThat(
|
||||
RuntimeHintsPredicates.reflection()
|
||||
.onType(SampleKotlinBean::class.java)
|
||||
.withMemberCategory(MemberCategory.INTROSPECT_DECLARED_METHODS)
|
||||
).accepts(generationContext.runtimeHints)
|
||||
Assertions.assertThat(
|
||||
assertThat(
|
||||
RuntimeHintsPredicates.reflection()
|
||||
.onType(BaseKotlinBean::class.java)
|
||||
.withMemberCategory(MemberCategory.INTROSPECT_DECLARED_METHODS)
|
||||
|
|
@ -64,7 +63,7 @@ class KotlinReflectionBeanRegistrationAotProcessorTests {
|
|||
@Test
|
||||
fun shouldNotProcessJavaBean() {
|
||||
process(SampleJavaBean::class.java)
|
||||
Assertions.assertThat(generationContext.runtimeHints.reflection().typeHints()).isEmpty()
|
||||
assertThat(generationContext.runtimeHints.reflection().typeHints()).isEmpty()
|
||||
}
|
||||
|
||||
private fun process(beanClass: Class<*>) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ import jakarta.validation.ValidationException
|
|||
import jakarta.validation.Validator
|
||||
import jakarta.validation.constraints.NotEmpty
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.aop.framework.ProxyFactory
|
||||
import org.springframework.validation.annotation.Validated
|
||||
|
|
@ -41,8 +42,8 @@ class KotlinMethodValidationTests {
|
|||
validator.afterPropertiesSet()
|
||||
proxyFactory.addAdvice(MethodValidationInterceptor(validator as Validator))
|
||||
val proxy = proxyFactory.getProxy() as MyValidBean
|
||||
Assertions.assertThat(proxy.validName("name")).isEqualTo("name")
|
||||
Assertions.assertThatExceptionOfType(ValidationException::class.java).isThrownBy {
|
||||
assertThat(proxy.validName("name")).isEqualTo("name")
|
||||
assertThatExceptionOfType(ValidationException::class.java).isThrownBy {
|
||||
proxy.validName("")
|
||||
}
|
||||
}
|
||||
|
|
@ -55,8 +56,8 @@ class KotlinMethodValidationTests {
|
|||
validator.afterPropertiesSet()
|
||||
proxyFactory.addAdvice(MethodValidationInterceptor(validator as Validator))
|
||||
val proxy = proxyFactory.getProxy() as MyValidCoroutinesBean
|
||||
Assertions.assertThat(proxy.validName("name")).isEqualTo("name")
|
||||
Assertions.assertThatExceptionOfType(ValidationException::class.java).isThrownBy {
|
||||
assertThat(proxy.validName("name")).isEqualTo("name")
|
||||
assertThatExceptionOfType(ValidationException::class.java).isThrownBy {
|
||||
runBlocking {
|
||||
proxy.validName("")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package org.springframework.cglib.core;
|
|||
|
||||
@Deprecated
|
||||
public class TinyBitSet {
|
||||
private static int[] T = new int[256];
|
||||
private static final int[] T = new int[256];
|
||||
private int value = 0;
|
||||
|
||||
private static int gcount(int x) {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ public abstract class RepeatableContainers {
|
|||
|
||||
private static final Object NONE = new Object();
|
||||
|
||||
private static StandardRepeatableContainers INSTANCE = new StandardRepeatableContainers();
|
||||
private static final StandardRepeatableContainers INSTANCE = new StandardRepeatableContainers();
|
||||
|
||||
StandardRepeatableContainers() {
|
||||
super(null);
|
||||
|
|
@ -270,7 +270,7 @@ public abstract class RepeatableContainers {
|
|||
*/
|
||||
private static class NoRepeatableContainers extends RepeatableContainers {
|
||||
|
||||
private static NoRepeatableContainers INSTANCE = new NoRepeatableContainers();
|
||||
private static final NoRepeatableContainers INSTANCE = new NoRepeatableContainers();
|
||||
|
||||
NoRepeatableContainers() {
|
||||
super(null);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import org.springframework.util.MimeTypeUtils;
|
|||
public class ResourceDecoder extends AbstractDataBufferDecoder<Resource> {
|
||||
|
||||
/** Name of hint with a filename for the resource(e.g. from "Content-Disposition" HTTP header). */
|
||||
public static String FILENAME_HINT = ResourceDecoder.class.getName() + ".filename";
|
||||
public static final String FILENAME_HINT = ResourceDecoder.class.getName() + ".filename";
|
||||
|
||||
|
||||
public ResourceDecoder() {
|
||||
|
|
|
|||
|
|
@ -897,9 +897,9 @@ public class PathMatchingResourcePatternResolver implements ResourcePatternResol
|
|||
}
|
||||
|
||||
/**
|
||||
* If it's a "file:" URI, use FileSystemResource to avoid duplicates
|
||||
* for the same path discovered via class-path scanning.
|
||||
*/
|
||||
* If it's a "file:" URI, use FileSystemResource to avoid duplicates
|
||||
* for the same path discovered via class-path scanning.
|
||||
*/
|
||||
private Resource convertModuleSystemURI(URI uri) {
|
||||
return (ResourceUtils.URL_PROTOCOL_FILE.equals(uri.getScheme()) ?
|
||||
new FileSystemResource(uri.getPath()) : UrlResource.from(uri));
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.aot.hint
|
||||
|
||||
/**
|
||||
* Extension for [TypeHint.Builder.onReachableType] providing a `onReachableType<Foo>())`
|
||||
* Extension for [TypeHint.Builder.onReachableType] providing a `onReachableType<Foo>()`
|
||||
* variant.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class ResourceHintsExtensionsTests {
|
|||
private val resourceHints = mockk<ResourceHints>()
|
||||
|
||||
@Test
|
||||
fun `registerType extension with MemberCategory`() {
|
||||
fun `registerType extension`() {
|
||||
every { resourceHints.registerType(any<Class<String>>()) } returns resourceHints
|
||||
resourceHints.registerType<String>()
|
||||
verify { resourceHints.registerType(String::class.java) }
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import io.r2dbc.spi.IsolationLevel;
|
|||
import io.r2dbc.spi.R2dbcBadGrammarException;
|
||||
import io.r2dbc.spi.R2dbcTimeoutException;
|
||||
import io.r2dbc.spi.Statement;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
|
@ -345,7 +344,7 @@ class R2dbcTransactionManagerUnitTests {
|
|||
.doOnNext(connection -> {
|
||||
throw new IllegalStateException("Intentional error to trigger rollback");
|
||||
}).then()).as(StepVerifier::create)
|
||||
.verifyErrorSatisfies(e -> Assertions.assertThat(e)
|
||||
.verifyErrorSatisfies(e -> assertThat(e)
|
||||
.isInstanceOf(BadSqlGrammarException.class)
|
||||
.hasCause(new R2dbcBadGrammarException("Rollback should fail"))
|
||||
);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public final class MockMvcWebConnection implements WebConnection {
|
|||
|
||||
private WebClient webClient;
|
||||
|
||||
private static int MAX_FORWARDS = 100;
|
||||
private static final int MAX_FORWARDS = 100;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -143,7 +143,7 @@ public final class MockMvcWebConnection implements WebConnection {
|
|||
forwards += 1;
|
||||
}
|
||||
if (forwards == MAX_FORWARDS) {
|
||||
throw new IllegalStateException("Forwarded more than " + forwards + " times in a row, potential infinite forward loop");
|
||||
throw new IllegalStateException("Forwarded " + forwards + " times in a row, potential infinite forward loop");
|
||||
}
|
||||
storeCookies(webRequest, httpServletResponse.getCookies());
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class MockMvcWebConnectionTests {
|
|||
public void infiniteForward() {
|
||||
this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient, ""));
|
||||
assertThatIllegalStateException().isThrownBy(() -> this.webClient.getPage("http://localhost/infiniteForward"))
|
||||
.withMessage("Forwarded more than 100 times in a row, potential infinite forward loop");
|
||||
.withMessage("Forwarded 100 times in a row, potential infinite forward loop");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ import org.springframework.util.xml.StaxUtils;
|
|||
*/
|
||||
public class Jackson2ObjectMapperBuilder {
|
||||
|
||||
private static boolean jackson2XmlPresent = ClassUtils.isPresent(
|
||||
private static final boolean jackson2XmlPresent = ClassUtils.isPresent(
|
||||
"com.fasterxml.jackson.dataformat.xml.XmlMapper", Jackson2ObjectMapperBuilder.class.getClassLoader());
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.http;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
|
@ -46,11 +45,8 @@ class ResponseEntityTests {
|
|||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getHeaders().containsKey(headerName)).isTrue();
|
||||
List<String> list = responseEntity.getHeaders().get(headerName);
|
||||
assertThat(list).hasSize(2);
|
||||
assertThat(list.get(0)).isEqualTo(headerValue1);
|
||||
assertThat(list.get(1)).isEqualTo(headerValue2);
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getHeaders().get(headerName)).containsExactly(headerValue1, headerValue2);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -69,7 +65,7 @@ class ResponseEntityTests {
|
|||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -79,7 +75,7 @@ class ResponseEntityTests {
|
|||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -98,7 +94,7 @@ class ResponseEntityTests {
|
|||
|
||||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -270,7 +266,7 @@ class ResponseEntityTests {
|
|||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getHeaders().containsKey(HttpHeaders.CACHE_CONTROL)).isFalse();
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -286,7 +282,7 @@ class ResponseEntityTests {
|
|||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getHeaders().containsKey(HttpHeaders.CACHE_CONTROL)).isTrue();
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
String cacheControlHeader = responseEntity.getHeaders().getCacheControl();
|
||||
assertThat(cacheControlHeader).isEqualTo(
|
||||
"max-age=3600, must-revalidate, private, proxy-revalidate, s-maxage=1800");
|
||||
|
|
@ -304,7 +300,7 @@ class ResponseEntityTests {
|
|||
assertThat(responseEntity).isNotNull();
|
||||
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
assertThat(responseEntity.getHeaders().containsKey(HttpHeaders.CACHE_CONTROL)).isTrue();
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
|
||||
String cacheControlHeader = responseEntity.getHeaders().getCacheControl();
|
||||
assertThat(cacheControlHeader).isEqualTo("no-store");
|
||||
|
|
@ -316,7 +312,7 @@ class ResponseEntityTests {
|
|||
ResponseEntity<Integer> responseEntity = ResponseEntity.status(200).body(entity);
|
||||
|
||||
assertThat(responseEntity.getStatusCode().value()).isEqualTo(200);
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -326,7 +322,7 @@ class ResponseEntityTests {
|
|||
ResponseEntity<Integer> responseEntity = ResponseEntity.status(299).body(entity);
|
||||
|
||||
assertThat(responseEntity.getStatusCodeValue()).isEqualTo(299);
|
||||
assertThat((int) responseEntity.getBody()).isEqualTo((int) entity);
|
||||
assertThat(responseEntity.getBody()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
package org.springframework.web.method.annotation
|
||||
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatThrownBy
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.ArgumentMatchers.*
|
||||
|
|
@ -61,7 +62,7 @@ class ModelAttributeMethodProcessorKotlinTests {
|
|||
val factory = Mockito.mock<WebDataBinderFactory>()
|
||||
BDDMockito.given(factory.createBinder(any(), any(), eq("param")))
|
||||
.willAnswer { WebRequestDataBinder(it.getArgument(1)) }
|
||||
Assertions.assertThat(processor.resolveArgument(this.param, container, requestWithParam, factory)).isEqualTo(Param("b"))
|
||||
assertThat(processor.resolveArgument(this.param, container, requestWithParam, factory)).isEqualTo(Param("b"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -71,7 +72,7 @@ class ModelAttributeMethodProcessorKotlinTests {
|
|||
val factory = Mockito.mock<WebDataBinderFactory>()
|
||||
BDDMockito.given(factory.createBinder(any(), any(), eq("param")))
|
||||
.willAnswer { WebRequestDataBinder(it.getArgument(1)) }
|
||||
Assertions.assertThatThrownBy {
|
||||
assertThatThrownBy {
|
||||
processor.resolveArgument(this.param, container, requestWithParam, factory)
|
||||
}.isInstanceOf(MethodArgumentNotValidException::class.java)
|
||||
.hasMessageContaining("parameter a")
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
|
|||
|
||||
private static final KeyValue URI_NONE = KeyValue.of(LowCardinalityKeyNames.URI, KeyValue.NONE_VALUE);
|
||||
|
||||
private static final KeyValue URI_ROOT = KeyValue.of(LowCardinalityKeyNames.URI, ROOT_PATH);
|
||||
|
||||
private static final KeyValue METHOD_NONE = KeyValue.of(LowCardinalityKeyNames.METHOD, KeyValue.NONE_VALUE);
|
||||
|
||||
private static final KeyValue STATUS_IO_ERROR = KeyValue.of(LowCardinalityKeyNames.STATUS, "IO_ERROR");
|
||||
|
|
@ -101,7 +103,7 @@ public class DefaultClientRequestObservationConvention implements ClientRequestO
|
|||
}
|
||||
ClientRequest request = context.getRequest();
|
||||
if (request != null && ROOT_PATH.equals(request.url().getPath())) {
|
||||
return KeyValue.of(LowCardinalityKeyNames.URI, ROOT_PATH);
|
||||
return URI_ROOT;
|
||||
}
|
||||
return URI_NONE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ package org.springframework.web.reactive.function.client.support
|
|||
import kotlinx.coroutines.runBlocking
|
||||
import okhttp3.mockwebserver.MockResponse
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.assertj.core.api.Assertions
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
|
|
@ -66,7 +66,7 @@ class KotlinWebClientHttpServiceProxyTests {
|
|||
}
|
||||
runBlocking {
|
||||
val greeting = initHttpService().getGreetingSuspending()
|
||||
Assertions.assertThat(greeting).isEqualTo("Hello Spring!")
|
||||
assertThat(greeting).isEqualTo("Hello Spring!")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ class KotlinWebClientHttpServiceProxyTests {
|
|||
).setBody("Hello Spring!")
|
||||
}
|
||||
val greeting = initHttpService().getGreetingBlocking()
|
||||
Assertions.assertThat(greeting).isEqualTo("Hello Spring!")
|
||||
assertThat(greeting).isEqualTo("Hello Spring!")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -115,8 +115,8 @@ class KotlinWebClientHttpServiceProxyTests {
|
|||
val service = initHttpService(webClient)
|
||||
runBlocking {
|
||||
val greeting = service.getGreetingSuspendingWithAttribute("myAttributeValue")
|
||||
Assertions.assertThat(greeting).isEqualTo("Hello Spring!")
|
||||
Assertions.assertThat(attributes).containsEntry("myAttribute", "myAttributeValue")
|
||||
assertThat(greeting).isEqualTo("Hello Spring!")
|
||||
assertThat(attributes).containsEntry("myAttribute", "myAttributeValue")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ class RequestMappingInfoHandlerMappingTests {
|
|||
}
|
||||
|
||||
@PathPatternsParameterizedTest // gh-28062
|
||||
void getHandlerMethodTypeNotSupportedWithParseError(TestRequestMappingInfoHandlerMapping mapping) {
|
||||
void getHandlerMediaTypeNotSupportedWithParseError(TestRequestMappingInfoHandlerMapping mapping) {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/person/1");
|
||||
request.setContentType("This string");
|
||||
assertThatExceptionOfType(HttpMediaTypeNotSupportedException.class)
|
||||
|
|
|
|||
Loading…
Reference in New Issue