Added test to ensure that invalid refs log messages are not created when  mode is not set
@@ -9,10 +9,12 @@ import org.asciidoctor.log.TestLogHandlerService;
import org.asciidoctor.util.ClasspathResources;
import org.junit.After;
import org.junit.Before;
+import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.junit.runners.MethodSorters;
import java.io.File;
import java.io.IOException;
@@ -31,6 +33,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class WhenAsciidoctorLogsToConsole {
@Rule
@@ -123,7 +126,6 @@ public class WhenAsciidoctorLogsToConsole {
}
@Test
- @Ignore("Until invalid refs are logged by default")
public void shouldLogInvalidRefs() throws Exception {
final List<LogRecord> logRecords = new ArrayList<>();
@@ -155,6 +157,32 @@ public class WhenAsciidoctorLogsToConsole {
assertThat(cursor, is(nullValue()));
}
+ @Test
+ public void shouldNotLogInvalidRefsWithoutVerbose() throws Exception {
+
+ final List<LogRecord> logRecords = new ArrayList<>();
+
+ final LogHandler logHandler = new LogHandler() {
+ @Override
+ public void log(LogRecord logRecord) {
+ logRecords.add(logRecord);
+ }
+ };
+ asciidoctor.registerLogHandler(logHandler);
+
+ File inputFile = classpath.getResource("documentwithinvalidrefs.adoc");
+ String renderContent = asciidoctor.renderFile(inputFile,
+ options()
+ .inPlace(true)
+ .safe(SafeMode.SERVER)
+ .toFile(false)
+ .attributes(
+ AttributesBuilder.attributes().allowUriRead(true))
+ .asMap());
+
+ assertThat(logRecords, hasSize(0));
+ }
+
@Test
public void shouldOnlyNotifyFromRegisteredAsciidoctor() throws Exception {
