Polish data buffer allocation tests
This commit is contained in:
parent
48c8d3a551
commit
402046f3c7
|
@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
|
||||
/**
|
||||
* Base class for tests that read or write data buffers with a rule to check
|
||||
* Base class for tests that read or write data buffers with an extension to check
|
||||
* that allocated buffers have been released.
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
|
@ -56,7 +56,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments;
|
|||
public abstract class AbstractDataBufferAllocatingTests {
|
||||
|
||||
@RegisterExtension
|
||||
AfterEachCallback leakDetector = context -> verifyAllocations();
|
||||
AfterEachCallback leakDetector = context -> waitForDataBufferRelease(Duration.ofSeconds(2));
|
||||
|
||||
protected DataBufferFactory bufferFactory;
|
||||
|
||||
|
@ -94,7 +94,7 @@ public abstract class AbstractDataBufferAllocatingTests {
|
|||
/**
|
||||
* Wait until allocations are at 0, or the given duration elapses.
|
||||
*/
|
||||
protected void waitForDataBufferRelease(Duration duration) throws InterruptedException {
|
||||
private void waitForDataBufferRelease(Duration duration) throws InterruptedException {
|
||||
Instant start = Instant.now();
|
||||
while (true) {
|
||||
try {
|
||||
|
|
|
@ -49,7 +49,7 @@ import static org.springframework.core.ResolvableType.forClass;
|
|||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocatingTests {
|
||||
class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAllocatingTests {
|
||||
|
||||
private static final Map<String, Object> HINTS = Collections.emptyMap();
|
||||
|
||||
|
@ -58,7 +58,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
public void canWrite(String displayName, DataBufferFactory bufferFactory) {
|
||||
void canWrite(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
assertThat(this.messageWriter.canWrite(forClass(Object.class), null)).isTrue();
|
||||
|
@ -73,7 +73,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
public void writeServerSentEvent(String displayName, DataBufferFactory bufferFactory) {
|
||||
void writeServerSentEvent(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
ServerSentEvent<?> event = ServerSentEvent.builder().data("bar").id("c42").event("foo")
|
||||
|
@ -91,7 +91,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
public void writeString(String displayName, DataBufferFactory bufferFactory) {
|
||||
void writeString(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||
|
@ -106,7 +106,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
public void writeMultiLineString(String displayName, DataBufferFactory bufferFactory) {
|
||||
void writeMultiLineString(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||
|
@ -121,7 +121,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest // SPR-16516
|
||||
public void writeStringWithCustomCharset(String displayName, DataBufferFactory bufferFactory) {
|
||||
void writeStringWithCustomCharset(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||
|
@ -142,7 +142,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
public void writePojo(String displayName, DataBufferFactory bufferFactory) {
|
||||
void writePojo(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||
|
@ -157,7 +157,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest // SPR-14899
|
||||
public void writePojoWithPrettyPrint(String displayName, DataBufferFactory bufferFactory) {
|
||||
void writePojoWithPrettyPrint(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().indentOutput(true).build();
|
||||
|
@ -179,7 +179,7 @@ public class ServerSentEventHttpMessageWriterTests extends AbstractDataBufferAll
|
|||
}
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest // SPR-16516, SPR-16539
|
||||
public void writePojoWithCustomEncoding(String displayName, DataBufferFactory bufferFactory) {
|
||||
void writePojoWithCustomEncoding(String displayName, DataBufferFactory bufferFactory) {
|
||||
super.bufferFactory = bufferFactory;
|
||||
|
||||
MockServerHttpResponse outputMessage = new MockServerHttpResponse(super.bufferFactory);
|
||||
|
|
|
@ -26,7 +26,6 @@ import io.netty.channel.ChannelOption;
|
|||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
@ -95,11 +94,6 @@ class WebClientDataBufferAllocatingTests extends AbstractDataBufferAllocatingTes
|
|||
}
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void shutDown() throws InterruptedException {
|
||||
waitForDataBufferRelease(Duration.ofSeconds(2));
|
||||
}
|
||||
|
||||
|
||||
@ParameterizedDataBufferAllocatingTest
|
||||
void bodyToMonoVoid(String displayName, DataBufferFactory bufferFactory) {
|
||||
|
|
Loading…
Reference in New Issue