Enforces static imports for JUnit 4 assertions and assumptions
This commit configures Checkstyle to enforces static imports for JUnit 4 assertions and assumptions. See gh-22932
This commit is contained in:
@@ -29,7 +29,6 @@ import java.util.Optional;
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import io.netty.buffer.PooledByteBufAllocator;
|
||||
import io.netty.util.IllegalReferenceCountException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -67,6 +66,7 @@ import org.springframework.util.MultiValueMap;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
|
||||
|
||||
/**
|
||||
@@ -436,7 +436,7 @@ public class BodyExtractorsTests {
|
||||
assertTrue(throwable instanceof UnsupportedMediaTypeException);
|
||||
try {
|
||||
buffer.release();
|
||||
Assert.fail("releasing the buffer should have failed");
|
||||
fail("releasing the buffer should have failed");
|
||||
}
|
||||
catch (IllegalReferenceCountException exc) {
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -71,6 +70,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.springframework.http.codec.json.Jackson2CodecSupport.JSON_VIEW_HINT;
|
||||
|
||||
/**
|
||||
@@ -127,7 +127,7 @@ public class BodyInsertersTests {
|
||||
StepVerifier.create(response.getBody())
|
||||
.consumeNextWith(buf -> {
|
||||
String actual = DataBufferTestUtils.dumpString(buf, UTF_8);
|
||||
Assert.assertEquals("foo", actual);
|
||||
assertEquals("foo", actual);
|
||||
})
|
||||
.expectComplete()
|
||||
.verify();
|
||||
@@ -173,7 +173,7 @@ public class BodyInsertersTests {
|
||||
StepVerifier.create(response.getBody())
|
||||
.consumeNextWith(buf -> {
|
||||
String actual = DataBufferTestUtils.dumpString(buf, UTF_8);
|
||||
Assert.assertEquals("foo", actual);
|
||||
assertEquals("foo", actual);
|
||||
})
|
||||
.expectComplete()
|
||||
.verify();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -36,6 +35,9 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
import org.springframework.web.reactive.protobuf.Msg;
|
||||
import org.springframework.web.reactive.protobuf.SecondMsg;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
||||
/**
|
||||
* Integration tests for Protobuf support.
|
||||
*
|
||||
@@ -71,9 +73,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
|
||||
.uri("/message")
|
||||
.exchange()
|
||||
.doOnNext(response -> {
|
||||
Assert.assertFalse(response.headers().contentType().get().getParameters().containsKey("delimited"));
|
||||
Assert.assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
|
||||
Assert.assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
|
||||
assertFalse(response.headers().contentType().get().getParameters().containsKey("delimited"));
|
||||
assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
|
||||
assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
|
||||
})
|
||||
.flatMap(response -> response.bodyToMono(Msg.class));
|
||||
|
||||
@@ -88,9 +90,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
|
||||
.uri("/messages")
|
||||
.exchange()
|
||||
.doOnNext(response -> {
|
||||
Assert.assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
|
||||
Assert.assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
|
||||
Assert.assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
|
||||
assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
|
||||
assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
|
||||
assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
|
||||
})
|
||||
.flatMapMany(response -> response.bodyToFlux(Msg.class));
|
||||
|
||||
@@ -107,9 +109,9 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT
|
||||
.uri("/message-stream")
|
||||
.exchange()
|
||||
.doOnNext(response -> {
|
||||
Assert.assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
|
||||
Assert.assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
|
||||
Assert.assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
|
||||
assertEquals("true", response.headers().contentType().get().getParameters().get("delimited"));
|
||||
assertEquals("sample.proto", response.headers().header("X-Protobuf-Schema").get(0));
|
||||
assertEquals("Msg", response.headers().header("X-Protobuf-Message").get(0));
|
||||
})
|
||||
.flatMapMany(response -> response.bodyToFlux(Msg.class));
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.web.reactive.result.method.annotation;
|
||||
import java.io.File;
|
||||
import java.time.Duration;
|
||||
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@@ -136,7 +135,7 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
|
||||
@Test
|
||||
public void sseAsEvent() {
|
||||
|
||||
Assume.assumeTrue(server instanceof JettyHttpServer);
|
||||
assumeTrue(server instanceof JettyHttpServer);
|
||||
|
||||
Flux<ServerSentEvent<Person>> result = this.webClient.get()
|
||||
.uri("/event")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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,11 +16,12 @@
|
||||
|
||||
package org.springframework.web.reactive.result.view.script;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link ScriptTemplateViewResolver}.
|
||||
*
|
||||
@@ -31,10 +32,10 @@ public class ScriptTemplateViewResolverTests {
|
||||
@Test
|
||||
public void viewClass() throws Exception {
|
||||
ScriptTemplateViewResolver resolver = new ScriptTemplateViewResolver();
|
||||
Assert.assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
|
||||
assertEquals(ScriptTemplateView.class, resolver.requiredViewClass());
|
||||
DirectFieldAccessor viewAccessor = new DirectFieldAccessor(resolver);
|
||||
Class<?> viewClass = (Class<?>) viewAccessor.getPropertyValue("viewClass");
|
||||
Assert.assertEquals(ScriptTemplateView.class, viewClass);
|
||||
assertEquals(ScriptTemplateView.class, viewClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user