File tree 4 files changed +64
-3
lines changed
spring-restdocs-asciidoctor/src/test
java/org/springframework/restdocs/asciidoctor
4 files changed +64
-3
lines changed Original file line number Diff line number Diff line change 35
35
import org .asciidoctor .Options ;
36
36
import org .asciidoctor .OptionsBuilder ;
37
37
import org .asciidoctor .SafeMode ;
38
+ import org .junit .After ;
38
39
import org .junit .Before ;
39
40
import org .junit .Rule ;
40
41
import org .junit .Test ;
@@ -64,6 +65,12 @@ public void setUp() throws IOException {
64
65
prepareOperationSnippets (getBuildOutputLocation ());
65
66
this .options = OptionsBuilder .options ().safe (SafeMode .UNSAFE ).baseDir (getSourceLocation ()).get ();
66
67
this .options .setAttributes (getAttributes ());
68
+ CapturingLogHandler .clear ();
69
+ }
70
+
71
+ @ After
72
+ public void verifyLogging () {
73
+ assertThat (CapturingLogHandler .getLogRecords ()).isEmpty ();
67
74
}
68
75
69
76
public void prepareOperationSnippets (File buildOutputLocation ) throws IOException {
@@ -110,7 +117,8 @@ public void tableSnippetIncludeWithPdfBackend() throws Exception {
110
117
111
118
@ Test
112
119
public void includeSnippetInSection () throws Exception {
113
- String result = this .asciidoctor .convert ("== Section\n " + "operation::some-operation[snippets='curl-request']" ,
120
+ String result = this .asciidoctor .convert (
121
+ "= A\n \n Alpha\n \n == B\n \n Bravo\n \n " + "operation::some-operation[snippets='curl-request']" ,
114
122
this .options );
115
123
assertThat (result ).isEqualTo (getExpectedContentFromFile ("snippet-in-section" ));
116
124
}
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 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 .restdocs .asciidoctor ;
18
+
19
+ import java .util .ArrayList ;
20
+ import java .util .List ;
21
+
22
+ import org .asciidoctor .log .LogHandler ;
23
+ import org .asciidoctor .log .LogRecord ;
24
+
25
+ public class CapturingLogHandler implements LogHandler {
26
+
27
+ private static final List <LogRecord > logRecords = new ArrayList <LogRecord >();
28
+
29
+ @ Override
30
+ public void log (LogRecord logRecord ) {
31
+ logRecords .add (logRecord );
32
+ }
33
+
34
+ static List <LogRecord > getLogRecords () {
35
+ return logRecords ;
36
+ }
37
+
38
+ static void clear () {
39
+ logRecords .clear ();
40
+ }
41
+
42
+ }
Original file line number Diff line number Diff line change
1
+ org.springframework.restdocs.asciidoctor.CapturingLogHandler
Original file line number Diff line number Diff line change
1
+ < div id ="preamble ">
2
+ < div class ="sectionbody ">
3
+ < div class ="paragraph ">
4
+ < p > Alpha</ p >
5
+ </ div >
6
+ </ div >
7
+ </ div >
1
8
< div class ="sect1 ">
2
- < h2 id ="_section " > Section </ h2 >
9
+ < h2 id ="_b " > B </ h2 >
3
10
< div class ="sectionbody ">
11
+ < div class ="paragraph ">
12
+ < p > Bravo</ p >
13
+ </ div >
4
14
< div class ="sect2 ">
5
- < h3 id ="_section_curl_request "> Curl request</ h3 >
15
+ < h3 id ="_b_curl_request "> Curl request</ h3 >
6
16
< div class ="listingblock ">
7
17
< div class ="content ">
8
18
< pre class ="highlight "> < code class ="language-bash " data-lang ="bash "> $ curl 'http://localhost:8080/' -i</ code > </ pre >
You can’t perform that action at this time.
0 commit comments