Polish "Avoid warnings when parsing AsciiDoc sub-content in Asciidoctor.load"
See gh-628
This commit is contained in:
@@ -35,6 +35,7 @@ import org.asciidoctor.Attributes;
|
||||
import org.asciidoctor.Options;
|
||||
import org.asciidoctor.OptionsBuilder;
|
||||
import org.asciidoctor.SafeMode;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -64,6 +65,12 @@ public abstract class AbstractOperationBlockMacroTests {
|
||||
prepareOperationSnippets(getBuildOutputLocation());
|
||||
this.options = OptionsBuilder.options().safe(SafeMode.UNSAFE).baseDir(getSourceLocation()).get();
|
||||
this.options.setAttributes(getAttributes());
|
||||
CapturingLogHandler.clear();
|
||||
}
|
||||
|
||||
@After
|
||||
public void verifyLogging() {
|
||||
assertThat(CapturingLogHandler.getLogRecords()).isEmpty();
|
||||
}
|
||||
|
||||
public void prepareOperationSnippets(File buildOutputLocation) throws IOException {
|
||||
@@ -110,7 +117,8 @@ public abstract class AbstractOperationBlockMacroTests {
|
||||
|
||||
@Test
|
||||
public void includeSnippetInSection() throws Exception {
|
||||
String result = this.asciidoctor.convert("== Section\n" + "operation::some-operation[snippets='curl-request']",
|
||||
String result = this.asciidoctor.convert(
|
||||
"= A\n\nAlpha\n\n== B\n\nBravo\n\n" + "operation::some-operation[snippets='curl-request']",
|
||||
this.options);
|
||||
assertThat(result).isEqualTo(getExpectedContentFromFile("snippet-in-section"));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.restdocs.asciidoctor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.asciidoctor.log.LogHandler;
|
||||
import org.asciidoctor.log.LogRecord;
|
||||
|
||||
public class CapturingLogHandler implements LogHandler {
|
||||
|
||||
private static final List<LogRecord> logRecords = new ArrayList<LogRecord>();
|
||||
|
||||
@Override
|
||||
public void log(LogRecord logRecord) {
|
||||
logRecords.add(logRecord);
|
||||
}
|
||||
|
||||
static List<LogRecord> getLogRecords() {
|
||||
return logRecords;
|
||||
}
|
||||
|
||||
static void clear() {
|
||||
logRecords.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
org.springframework.restdocs.asciidoctor.CapturingLogHandler
|
||||
@@ -1,8 +1,18 @@
|
||||
<div class="sect1">
|
||||
<h2 id="_section">Section</h2>
|
||||
<div id="preamble">
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Alpha</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sect1">
|
||||
<h2 id="_b">B</h2>
|
||||
<div class="sectionbody">
|
||||
<div class="paragraph">
|
||||
<p>Bravo</p>
|
||||
</div>
|
||||
<div class="sect2">
|
||||
<h3 id="_section_curl_request">Curl request</h3>
|
||||
<h3 id="_b_curl_request">Curl request</h3>
|
||||
<div class="listingblock">
|
||||
<div class="content">
|
||||
<pre class="highlight"><code class="language-bash" data-lang="bash">$ curl 'http://localhost:8080/' -i</code></pre>
|
||||
|
||||
Reference in New Issue
Block a user