mirror of https://github.com/apache/nifi.git
NIFI-9882 Updated HtmlDocumentationWriter to avoid writing null characters
This closes #5935 Signed-off-by: Mike Thomsen <mthomsen@apache.org>
This commit is contained in:
parent
9c71d83c5c
commit
74a4104259
|
@ -843,16 +843,20 @@ public class HtmlDocumentationWriter implements DocumentationWriter {
|
|||
protected final static void writeSimpleElement(final XMLStreamWriter writer, final String elementName,
|
||||
final String characters, boolean strong, String id) throws XMLStreamException {
|
||||
writer.writeStartElement(elementName);
|
||||
if (id != null) {
|
||||
writer.writeAttribute("id", id);
|
||||
}
|
||||
if (strong) {
|
||||
writer.writeStartElement("strong");
|
||||
}
|
||||
writer.writeCharacters(characters);
|
||||
if (strong) {
|
||||
writer.writeEndElement();
|
||||
|
||||
if (characters != null) {
|
||||
if (id != null) {
|
||||
writer.writeAttribute("id", id);
|
||||
}
|
||||
if (strong) {
|
||||
writer.writeStartElement("strong");
|
||||
}
|
||||
writer.writeCharacters(characters);
|
||||
if (strong) {
|
||||
writer.writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
writer.writeEndElement();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,21 +32,20 @@ import org.apache.nifi.nar.ExtensionManager;
|
|||
import org.apache.nifi.nar.StandardExtensionDiscoveringManager;
|
||||
import org.apache.nifi.reporting.InitializationException;
|
||||
import org.apache.nifi.reporting.ReportingTask;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.apache.nifi.documentation.html.XmlValidator.assertContains;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class HtmlDocumentationWriterTest {
|
||||
|
||||
private ExtensionManager extensionManager;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
extensionManager = new StandardExtensionDiscoveringManager();
|
||||
}
|
||||
|
@ -89,6 +88,9 @@ public class HtmlDocumentationWriterTest {
|
|||
assertContains(results, "PKCS12");
|
||||
assertContains(results, "Sensitive Property: true");
|
||||
|
||||
// property with null default value
|
||||
assertContains(results, "Keystore Password</td><td></td>");
|
||||
|
||||
// restricted
|
||||
assertContains(results, "controller service restriction description");
|
||||
|
||||
|
@ -101,11 +103,11 @@ public class HtmlDocumentationWriterTest {
|
|||
assertContains(results, "Not Specified");
|
||||
|
||||
// verify the right OnRemoved and OnShutdown methods were called
|
||||
Assert.assertEquals(0, controllerService.getOnRemovedArgs());
|
||||
Assert.assertEquals(0, controllerService.getOnRemovedNoArgs());
|
||||
assertEquals(0, controllerService.getOnRemovedArgs());
|
||||
assertEquals(0, controllerService.getOnRemovedNoArgs());
|
||||
|
||||
Assert.assertEquals(1, controllerService.getOnShutdownArgs());
|
||||
Assert.assertEquals(1, controllerService.getOnShutdownNoArgs());
|
||||
assertEquals(1, controllerService.getOnShutdownArgs());
|
||||
assertEquals(1, controllerService.getOnShutdownNoArgs());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -149,11 +151,11 @@ public class HtmlDocumentationWriterTest {
|
|||
assertContains(results, "Not Specified");
|
||||
|
||||
// verify the right OnRemoved and OnShutdown methods were called
|
||||
Assert.assertEquals(0, reportingTask.getOnRemovedArgs());
|
||||
Assert.assertEquals(0, reportingTask.getOnRemovedNoArgs());
|
||||
assertEquals(0, reportingTask.getOnRemovedArgs());
|
||||
assertEquals(0, reportingTask.getOnRemovedNoArgs());
|
||||
|
||||
Assert.assertEquals(1, reportingTask.getOnShutdownArgs());
|
||||
Assert.assertEquals(1, reportingTask.getOnShutdownNoArgs());
|
||||
assertEquals(1, reportingTask.getOnShutdownArgs());
|
||||
assertEquals(1, reportingTask.getOnShutdownNoArgs());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue