Merge branch '5.3.x'

# Conflicts:
#	spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java
#	spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java
#	spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java
#	spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java
#	spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java
This commit is contained in:
Sam Brannen
2022-05-31 14:15:36 +02:00
42 changed files with 533 additions and 780 deletions

View File

@@ -28,7 +28,7 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.ArgumentMatchers.any;
@@ -69,12 +69,12 @@ public class WebAsyncManagerTests {
public void startAsyncProcessingWithoutAsyncWebRequest() throws Exception {
WebAsyncManager manager = WebAsyncUtils.getAsyncManager(new MockHttpServletRequest());
assertThatIllegalStateException().isThrownBy(() ->
manager.startCallableProcessing(new StubCallable(1)))
assertThatIllegalStateException()
.isThrownBy(() -> manager.startCallableProcessing(new StubCallable(1)))
.withMessage("AsyncWebRequest must not be null");
assertThatIllegalStateException().isThrownBy(() ->
manager.startDeferredResultProcessing(new DeferredResult<String>()))
assertThatIllegalStateException()
.isThrownBy(() -> manager.startDeferredResultProcessing(new DeferredResult<String>()))
.withMessage("AsyncWebRequest must not be null");
}
@@ -93,13 +93,11 @@ public class WebAsyncManagerTests {
@Test
public void setAsyncWebRequestAfterAsyncStarted() {
this.asyncWebRequest.startAsync();
assertThatIllegalArgumentException().isThrownBy(() ->
this.asyncManager.setAsyncWebRequest(null));
assertThatIllegalArgumentException().isThrownBy(() -> this.asyncManager.setAsyncWebRequest(null));
}
@Test
public void startCallableProcessing() throws Exception {
int concurrentResult = 21;
Callable<Object> task = new StubCallable(concurrentResult);
@@ -121,7 +119,6 @@ public class WebAsyncManagerTests {
@Test
public void startCallableProcessingCallableException() throws Exception {
Exception concurrentResult = new Exception();
Callable<Object> task = new StubCallable(concurrentResult);
@@ -151,8 +148,8 @@ public class WebAsyncManagerTests {
this.asyncManager.registerCallableInterceptor("interceptor", interceptor);
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
this.asyncManager.startCallableProcessing(task))
assertThatException()
.isThrownBy(() -> this.asyncManager.startCallableProcessing(task))
.isEqualTo(exception);
assertThat(this.asyncManager.hasConcurrentResult()).isFalse();
@@ -247,8 +244,8 @@ public class WebAsyncManagerTests {
@Test
public void startCallableProcessingNullInput() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
this.asyncManager.startCallableProcessing((Callable<?>) null))
assertThatIllegalArgumentException()
.isThrownBy(() -> this.asyncManager.startCallableProcessing((Callable<?>) null))
.withMessage("Callable must not be null");
}
@@ -284,8 +281,8 @@ public class WebAsyncManagerTests {
this.asyncManager.registerDeferredResultInterceptor("interceptor", interceptor);
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
this.asyncManager.startDeferredResultProcessing(deferredResult))
assertThatException()
.isThrownBy(() -> this.asyncManager.startDeferredResultProcessing(deferredResult))
.isEqualTo(exception);
assertThat(this.asyncManager.hasConcurrentResult()).isFalse();
@@ -297,7 +294,6 @@ public class WebAsyncManagerTests {
@Test
public void startDeferredResultProcessingPreProcessException() throws Exception {
DeferredResult<Integer> deferredResult = new DeferredResult<>();
Exception exception = new Exception();
@@ -339,8 +335,8 @@ public class WebAsyncManagerTests {
@Test
public void startDeferredResultProcessingNullInput() throws Exception {
assertThatIllegalArgumentException().isThrownBy(() ->
this.asyncManager.startDeferredResultProcessing(null))
assertThatIllegalArgumentException()
.isThrownBy(() -> this.asyncManager.startDeferredResultProcessing(null))
.withMessage("DeferredResult must not be null");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -28,7 +28,7 @@ import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
@@ -131,8 +131,7 @@ public class WebArgumentResolverAdapterTests {
public void resolveArgumentThrowsException() throws Exception {
given(adaptee.resolveArgument(parameter, webRequest)).willThrow(new Exception());
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
adapter.resolveArgument(parameter, null, webRequest, null));
assertThatException().isThrownBy(() -> adapter.resolveArgument(parameter, null, webRequest, null));
}
public void handle(int param) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2022 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.
@@ -30,9 +30,11 @@ import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
import org.springframework.web.testfixture.servlet.MockHttpServletResponse;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatException;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatRuntimeException;
/**
* Unit tests for {@link InvocableHandlerMethod}.
@@ -127,23 +129,23 @@ public class InvocableHandlerMethodTests {
@Test
public void invocationTargetException() throws Exception {
RuntimeException runtimeException = new RuntimeException("error");
assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
getInvocable(Throwable.class).invokeForRequest(this.request, null, runtimeException))
assertThatRuntimeException()
.isThrownBy(() -> getInvocable(Throwable.class).invokeForRequest(this.request, null, runtimeException))
.isSameAs(runtimeException);
Error error = new Error("error");
assertThatExceptionOfType(Error.class).isThrownBy(() ->
getInvocable(Throwable.class).invokeForRequest(this.request, null, error))
assertThatExceptionOfType(Error.class)
.isThrownBy(() -> getInvocable(Throwable.class).invokeForRequest(this.request, null, error))
.isSameAs(error);
Exception exception = new Exception("error");
assertThatExceptionOfType(Exception.class).isThrownBy(() ->
getInvocable(Throwable.class).invokeForRequest(this.request, null, exception))
assertThatException()
.isThrownBy(() -> getInvocable(Throwable.class).invokeForRequest(this.request, null, exception))
.isSameAs(exception);
Throwable throwable = new Throwable("error");
assertThatIllegalStateException().isThrownBy(() ->
getInvocable(Throwable.class).invokeForRequest(this.request, null, throwable))
assertThatIllegalStateException()
.isThrownBy(() -> getInvocable(Throwable.class).invokeForRequest(this.request, null, throwable))
.withCause(throwable)
.withMessageContaining("Invocation failure");
}
@@ -151,8 +153,8 @@ public class InvocableHandlerMethodTests {
@Test // SPR-13917
public void invocationErrorMessage() throws Exception {
this.composite.addResolver(new StubArgumentResolver(double.class));
assertThatIllegalStateException().isThrownBy(() ->
getInvocable(double.class).invokeForRequest(this.request, null))
assertThatIllegalStateException()
.isThrownBy(() -> getInvocable(double.class).invokeForRequest(this.request, null))
.withMessageContaining("Illegal argument");
}