Fixing checkstyle

This commit is contained in:
Ryan Baxter
2025-06-03 11:09:35 -04:00
parent f649e995fb
commit 03b0f4ecfe
3 changed files with 18 additions and 20 deletions

View File

@@ -33,8 +33,8 @@ import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContrib
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions;
import org.springframework.cloud.gateway.server.mvc.filter.FilterAutoConfiguration;
import org.springframework.cloud.gateway.server.mvc.filter.FilterFunctions;
import org.springframework.cloud.gateway.server.mvc.predicate.PredicateAutoConfiguration;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AssignableTypeFilter;

View File

@@ -40,7 +40,6 @@ import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import org.assertj.core.api.Assertions;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -154,9 +153,6 @@ import static org.springframework.web.servlet.function.RequestPredicates.path;
@ExtendWith(OutputCaptureExtension.class)
public class ServerMvcIntegrationTests {
public static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType(APPLICATION_FORM_URLENCODED,
StandardCharsets.UTF_8);
static {
// if set type to autodetect above
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
@@ -171,12 +167,6 @@ public class ServerMvcIntegrationTests {
@Autowired
TestRestClient restClient;
private static boolean isPNG(byte[] bytes) {
byte[] pngSignature = { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
byte[] header = Arrays.copyOf(bytes, pngSignature.length);
return Arrays.equals(pngSignature, header);
}
@Test
public void nonGatewayRouterFunctionWorks() {
restClient.get().uri("/hello").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello");
@@ -603,6 +593,9 @@ public class ServerMvcIntegrationTests {
.isOk();
}
private static final MediaType FORM_URL_ENCODED_CONTENT_TYPE = new MediaType(APPLICATION_FORM_URLENCODED,
StandardCharsets.UTF_8);
@Test
void formUrlencodedWorks() {
LinkedMultiValueMap<String, String> formData = new LinkedMultiValueMap<>();
@@ -683,6 +676,12 @@ public class ServerMvcIntegrationTests {
}
}
private static boolean isPNG(byte[] bytes) {
byte[] pngSignature = { (byte) 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A };
byte[] header = Arrays.copyOf(bytes, pngSignature.length);
return Arrays.equals(pngSignature, header);
}
@Test
public void removeRequestHeaderWorks() {
restClient.get()
@@ -1056,10 +1055,10 @@ public class ServerMvcIntegrationTests {
@Bean
@Lazy
@Override
public @NotNull HandlerMappingIntrospector mvcHandlerMappingIntrospector() {
public HandlerMappingIntrospector mvcHandlerMappingIntrospector() {
return new HandlerMappingIntrospector() {
@Override
public @NotNull Filter createCacheFilter() {
public Filter createCacheFilter() {
return (request, response, chain) -> {
chain.doFilter(request, response);
};
@@ -1691,12 +1690,6 @@ public class ServerMvcIntegrationTests {
private static class MyFilter implements Filter, Ordered {
static boolean isFormPost(HttpServletRequest request) {
String contentType = request.getContentType();
return (contentType != null && contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
&& HttpMethod.POST.matches(request.getMethod()));
}
@Override
public int getOrder() {
return FormFilter.FORM_FILTER_ORDER - 1;
@@ -1719,6 +1712,12 @@ public class ServerMvcIntegrationTests {
}
}
static boolean isFormPost(HttpServletRequest request) {
String contentType = request.getContentType();
return (contentType != null && contentType.contains(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
&& HttpMethod.POST.matches(request.getMethod()));
}
}
protected record Hello(String message) {

View File

@@ -27,7 +27,6 @@ import org.springframework.cloud.gateway.server.mvc.test.HttpbinTestcontainers;
import org.springframework.cloud.gateway.server.mvc.test.TestAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.http.HttpHeaders;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClientManager;
import org.springframework.security.oauth2.core.OAuth2AccessToken;