Repackage output capture and always use extension declaratively
Closes gh-17029
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -20,7 +20,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.boot.test.rule.OutputCapture;
|
||||
import org.springframework.boot.test.system.OutputCaptureRule;
|
||||
import org.springframework.boot.testsupport.runner.classpath.ClassPathOverrides;
|
||||
import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner;
|
||||
|
||||
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class DuplicateJsonObjectContextCustomizerFactoryTests {
|
||||
|
||||
@Rule
|
||||
public OutputCapture output = new OutputCapture();
|
||||
public OutputCaptureRule output = new OutputCaptureRule();
|
||||
|
||||
@Test
|
||||
public void warningForMultipleVersions() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -26,6 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Roland Weisleder
|
||||
*/
|
||||
@Deprecated
|
||||
public class OutputCaptureTests {
|
||||
|
||||
@Rule
|
||||
|
||||
@@ -13,29 +13,28 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.boot.test.extension;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
package org.springframework.boot.test.system;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link OutputExtension} when used via
|
||||
* {@link RegisterExtension @RegisterExtension}.
|
||||
* Tests for {@link OutputCaptureRule}.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
* @author Roland Weisleder
|
||||
*/
|
||||
class OutputExtensionRegisterExtensionTests {
|
||||
public class OutputCaptureRuleTests {
|
||||
|
||||
@RegisterExtension
|
||||
CapturedOutput output = OutputExtension.capture();
|
||||
@Rule
|
||||
public OutputCaptureRule outputCapture = new OutputCaptureRule();
|
||||
|
||||
@Test
|
||||
void captureShouldReturnAllCapturedOutput() {
|
||||
public void toStringShouldReturnAllCapturedOutput() {
|
||||
System.out.println("Hello World");
|
||||
System.err.println("Error!!!");
|
||||
assertThat(this.output).contains("Hello World").contains("Error!!!");
|
||||
assertThat(this.outputCapture.toString()).contains("Hello World");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.test.extension;
|
||||
package org.springframework.boot.test.system;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
@@ -28,11 +28,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
/**
|
||||
* Tests for {@link CapturedOutput}.
|
||||
* Tests for {@link OutputCapture}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
class CapturedOutputTests {
|
||||
class OutputCaptureTests {
|
||||
|
||||
private PrintStream originalOut;
|
||||
|
||||
@@ -42,7 +42,7 @@ class CapturedOutputTests {
|
||||
|
||||
private TestPrintStream systemErr;
|
||||
|
||||
private CapturedOutput output = new CapturedOutput();
|
||||
private OutputCapture output = new OutputCapture();
|
||||
|
||||
@BeforeEach
|
||||
void replaceSystemStreams() {
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.boot.test.extension;
|
||||
package org.springframework.boot.test.system;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
@@ -23,11 +23,11 @@ import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link OutputExtension} when used via {@link ExtendWith @ExtendWith}.
|
||||
* Tests for {@link OutputCaptureExtension} when used via {@link ExtendWith @ExtendWith}.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@ExtendWith(OutputExtension.class)
|
||||
@ExtendWith(OutputCaptureExtension.class)
|
||||
@ExtendWith(OutputExtensionExtendWithTests.BeforeAllExtension.class)
|
||||
class OutputExtensionExtendWithTests {
|
||||
|
||||
Reference in New Issue
Block a user