Remove dumpString from DataBufferTestUtils

See gh-24786
This commit is contained in:
Rossen Stoyanchev
2020-03-26 21:41:45 +00:00
parent 7aa06b8610
commit 3175f0771e
21 changed files with 60 additions and 102 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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.
@@ -24,7 +24,6 @@ import org.springframework.core.MethodParameter;
import org.springframework.core.ReactiveAdapterRegistry;
import org.springframework.core.codec.Encoder;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils;
import org.springframework.messaging.Message;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -50,7 +49,7 @@ public class TestEncoderMethodReturnValueHandler extends AbstractEncoderMethodRe
}
public Flux<String> getContentAsStrings() {
return this.encodedContent.map(buffer -> DataBufferTestUtils.dumpString(buffer, UTF_8));
return this.encodedContent.map(buffer -> buffer.toString(UTF_8));
}
@Override

View File

@@ -33,7 +33,6 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.core.io.buffer.NettyDataBuffer;
import org.springframework.core.io.buffer.NettyDataBufferFactory;
import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils;
import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
@@ -124,7 +123,7 @@ public class MetadataEncoderTests {
.encode()
.block();
assertThat(dumpString(buffer)).isEqualTo("toA");
assertThat(buffer.toString(UTF_8)).isEqualTo("toA");
}
@Test
@@ -135,7 +134,7 @@ public class MetadataEncoderTests {
.encode()
.block();
assertThat(dumpString(buffer)).isEqualTo("a.BBB.C%2EC%2EC.d");
assertThat(buffer.toString(UTF_8)).isEqualTo("a.BBB.C%2EC%2EC.d");
}
@Test
@@ -146,7 +145,7 @@ public class MetadataEncoderTests {
.encode()
.block();
assertThat(dumpString(buffer)).isEqualTo("Raw data");
assertThat(buffer.toString(UTF_8)).isEqualTo("Raw data");
}
@Test
@@ -157,7 +156,7 @@ public class MetadataEncoderTests {
.encode()
.block();
assertThat(dumpString(buffer)).isEqualTo("toA");
assertThat(buffer.toString(UTF_8)).isEqualTo("toA");
}
@Test
@@ -235,8 +234,4 @@ public class MetadataEncoderTests {
assertThat(tags.hasNext()).isFalse();
}
private String dumpString(DataBuffer buffer) {
return DataBufferTestUtils.dumpString(buffer, UTF_8);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2020 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,8 +30,8 @@ import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.core.io.buffer.DefaultDataBuffer;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.core.io.buffer.NettyDataBuffer;
import org.springframework.core.testfixture.io.buffer.DataBufferTestUtils;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -99,8 +99,8 @@ public class PayloadUtilsTests {
Payload payload = PayloadUtils.createPayload(data, metadata);
assertThat(payload).isInstanceOf(DefaultPayload.class);
assertThat(payload.getDataUtf8()).isEqualTo(dataBufferToString(data));
assertThat(payload.getMetadataUtf8()).isEqualTo(dataBufferToString(metadata));
assertThat(payload.getDataUtf8()).isEqualTo(data.toString(UTF_8));
assertThat(payload.getMetadataUtf8()).isEqualTo(metadata.toString(UTF_8));
}
@Test
@@ -111,7 +111,7 @@ public class PayloadUtilsTests {
try {
assertThat(payload).isInstanceOf(ByteBufPayload.class);
assertThat(payload.data()).isSameAs(data.getNativeBuffer());
assertThat(payload.getMetadataUtf8()).isEqualTo(dataBufferToString(metadata));
assertThat(payload.getMetadataUtf8()).isEqualTo(metadata.toString(UTF_8));
}
finally {
payload.release();
@@ -125,7 +125,7 @@ public class PayloadUtilsTests {
Payload payload = PayloadUtils.createPayload(data, metadata);
try {
assertThat(payload).isInstanceOf(ByteBufPayload.class);
assertThat(payload.getDataUtf8()).isEqualTo(dataBufferToString(data));
assertThat(payload.getDataUtf8()).isEqualTo(data.toString(UTF_8));
assertThat(payload.metadata()).isSameAs(metadata.getNativeBuffer());
}
finally {
@@ -152,7 +152,7 @@ public class PayloadUtilsTests {
Payload payload = PayloadUtils.createPayload(data);
assertThat(payload).isInstanceOf(DefaultPayload.class);
assertThat(payload.getDataUtf8()).isEqualTo(dataBufferToString(data));
assertThat(payload.getDataUtf8()).isEqualTo(data.toString(UTF_8));
}
@@ -168,8 +168,4 @@ public class PayloadUtilsTests {
return buffer;
}
private String dataBufferToString(DataBuffer metadata) {
return DataBufferTestUtils.dumpString(metadata, StandardCharsets.UTF_8);
}
}