Migrate ModifiedClassPath tests to JUnit 5

Migrate the remaining JUnit 4 tests to JUnit 5, making use of the
new `ModifiedClassPathExtension`.

See gh-17491
This commit is contained in:
dreis2211
2019-07-14 16:54:16 +01:00
committed by Phillip Webb
parent 2a4c48cb91
commit 0f0278e69b
38 changed files with 396 additions and 411 deletions

View File

@@ -16,13 +16,14 @@
package org.springframework.boot.test.json;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.system.OutputCaptureRule;
import org.springframework.boot.testsupport.runner.classpath.ClassPathOverrides;
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathExtension;
import org.springframework.boot.testsupport.system.CapturedOutput;
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
import static org.assertj.core.api.Assertions.assertThat;
@@ -31,15 +32,20 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Andy Wilkinson
*/
@RunWith(ModifiedClassPathRunner.class)
@ExtendWith(ModifiedClassPathExtension.class)
@ExtendWith(OutputCaptureExtension.class)
@ClassPathOverrides("org.json:json:20140107")
public class DuplicateJsonObjectContextCustomizerFactoryTests {
class DuplicateJsonObjectContextCustomizerFactoryTests {
@Rule
public OutputCaptureRule output = new OutputCaptureRule();
private CapturedOutput output;
@BeforeEach
void setup(CapturedOutput output) {
this.output = output;
}
@Test
public void warningForMultipleVersions() {
void warningForMultipleVersions() {
new DuplicateJsonObjectContextCustomizerFactory().createContextCustomizer(null, null).customizeContext(null,
null);
assertThat(this.output).contains("Found multiple occurrences of org.json.JSONObject on the class path:");