Skip to content

Commit 56c2a52

Browse files
committed
Polish "Fix syntax errors in docs"
Closes gh-17835
1 parent 0bdf2b8 commit 56c2a52

File tree

2 files changed

+46
-18
lines changed

2 files changed

+46
-18
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7933,26 +7933,10 @@ for assertions, as follows:
79337933

79347934
[source,java,indent=0]
79357935
----
7936-
import org.junit.Rule;
7937-
import org.junit.Test;
7938-
import org.springframework.boot.test.rule.OutputCapture;
7939-
7940-
import static org.hamcrest.Matchers.*;
7941-
import static org.junit.Assert.*;
7942-
7943-
public class MyTest {
7944-
7945-
@Rule
7946-
public OutputCapture capture = new OutputCapture();
7936+
include::{test-examples}/test/rule/OutputCaptureTests.java[tag=test]
7937+
----
79477938

7948-
@Test
7949-
public void testName() throws Exception {
7950-
System.out.println("Hello World!");
7951-
assertThat(capture.toString(), containsString("World");
7952-
}
79537939

7954-
}
7955-
----
79567940

79577941
[[boot-features-rest-templates-test-utility]]
79587942
==== TestRestTemplate
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.test.rule;
18+
19+
import org.junit.Rule;
20+
import org.junit.Test;
21+
22+
import org.springframework.boot.test.rule.OutputCapture;
23+
24+
import static org.assertj.core.api.Assertions.assertThat;
25+
26+
/**
27+
* Sample showcasing the use of {@link OutputCapture}.
28+
*
29+
* @author Stephane Nicoll
30+
*/
31+
// tag::test[]
32+
public class OutputCaptureTests {
33+
34+
@Rule
35+
public final OutputCapture capture = new OutputCapture();
36+
37+
@Test
38+
public void testName() {
39+
System.out.println("Hello World!");
40+
assertThat(this.capture.toString()).contains("World");
41+
}
42+
43+
}
44+
// end::test[]

0 commit comments

Comments
 (0)