Re-enable shadowed, overridden @Test methods

Due to a bug (or "unintentional feature") in JUnit 4, overridden test
methods not annotated with @Test are still executed as test methods;
however, JUnit Jupiter does not support that. Thus, prior to this
commit, some overridden test methods in spring-core were no longer
executed after the migration from JUnit 4 to JUnit Jupiter.

This commit addresses this issue for such known use cases, but there
are likely other such use cases within Spring's test suite.

See gh-23451
This commit is contained in:
Sam Brannen 2019-08-20 14:47:23 +02:00
parent fab96cad67
commit aa6e762dcf
8 changed files with 15 additions and 0 deletions

View File

@ -55,6 +55,7 @@ class ByteArrayEncoderTests extends AbstractEncoderTestCase<ByteArrayEncoder> {
}
@Override
@Test
public void encode() {
Flux<byte[]> input = Flux.just(this.fooBytes, this.barBytes);
@ -63,4 +64,5 @@ class ByteArrayEncoderTests extends AbstractEncoderTestCase<ByteArrayEncoder> {
.consumeNextWith(expectBytes(this.barBytes))
.verifyComplete());
}
}

View File

@ -46,6 +46,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTestCase<CharSequenceEncod
@Override
@Test
public void canEncode() throws Exception {
assertThat(this.encoder.canEncode(ResolvableType.forClass(String.class),
MimeTypeUtils.TEXT_PLAIN)).isTrue();
@ -63,6 +64,7 @@ class CharSequenceEncoderTests extends AbstractEncoderTestCase<CharSequenceEncod
}
@Override
@Test
public void encode() {
Flux<CharSequence> input = Flux.just(this.foo, this.bar);

View File

@ -55,6 +55,7 @@ class DataBufferDecoderTests extends AbstractDecoderTestCase<DataBufferDecoder>
}
@Override
@Test
public void decode() {
Flux<DataBuffer> input = Flux.just(
this.bufferFactory.wrap(this.fooBytes),
@ -67,6 +68,7 @@ class DataBufferDecoderTests extends AbstractDecoderTestCase<DataBufferDecoder>
}
@Override
@Test
public void decodeToMono() throws Exception {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),

View File

@ -57,6 +57,7 @@ class DataBufferEncoderTests extends AbstractEncoderTestCase<DataBufferEncoder>
}
@Override
@Test
public void encode() throws Exception {
Flux<DataBuffer> input = Flux.just(this.fooBytes, this.barBytes)
.flatMap(bytes -> Mono.defer(() -> {

View File

@ -79,6 +79,7 @@ class ResourceDecoderTests extends AbstractDecoderTestCase<ResourceDecoder> {
}
@Override
@Test
public void decodeToMono() {
Flux<DataBuffer> input = Flux.concat(
dataBuffer(this.fooBytes),

View File

@ -64,6 +64,7 @@ class ResourceEncoderTests extends AbstractEncoderTestCase<ResourceEncoder> {
}
@Override
@Test
public void encode() {
Flux<Resource> input = Flux.just(new ByteArrayResource(this.bytes));

View File

@ -19,6 +19,8 @@ package org.springframework.core.type.classreading;
import java.io.BufferedInputStream;
import java.io.InputStream;
import org.junit.jupiter.api.Test;
import org.springframework.asm.ClassReader;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
@ -61,6 +63,7 @@ class AnnotationMetadataReadingVisitorTests extends AbstractAnnotationMetadataTe
}
@Override
@Test
public void getAnnotationsReturnsDirectAnnotations() {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
super::getAnnotationsReturnsDirectAnnotations);

View File

@ -19,6 +19,8 @@ package org.springframework.core.type.classreading;
import java.io.BufferedInputStream;
import java.io.InputStream;
import org.junit.jupiter.api.Test;
import org.springframework.asm.ClassReader;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
@ -61,6 +63,7 @@ class MethodMetadataReadingVisitorTests extends AbstractMethodMetadataTests {
}
@Override
@Test
public void getAnnotationsReturnsDirectAnnotations() {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
super::getAnnotationsReturnsDirectAnnotations);