Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Nov 4, 2024
1 parent 59e6ef7 commit 35ead94
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ pmd_binary(
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="pmd_binary-name"></a>name | The name of the target | none |
| <a id="pmd_binary-main_class"></a>main_class | The main class to use for PMD. | `"net.sourceforge.pmd.PMD"` |
| <a id="pmd_binary-main_class"></a>main_class | The main class to use for PMD. | `"net.sourceforge.pmd.cli.PmdCli"` |
| <a id="pmd_binary-deps"></a>deps | The deps required for compiling this binary. May be omitted. | `None` |
| <a id="pmd_binary-runtime_deps"></a>runtime_deps | The deps required by PMD at runtime. May be omitted. | `None` |
| <a id="pmd_binary-srcs"></a>srcs | If you're compiling your own PMD binary, the sources to use. | `None` |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
package com.github.bazel_contrib.contrib_rules_jvm.junit5;

import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

public class SafeXmlTest {

@Test
public void properlyEscapesCDataSection()
throws XMLStreamException, ParserConfigurationException, IOException, SAXException {
try (Writer writer = new StringWriter()) {
XMLStreamWriter xml = XMLOutputFactory.newDefaultFactory().createXMLStreamWriter(writer);
@Test
public void properlyEscapesCDataSection()
throws XMLStreamException, ParserConfigurationException, IOException, SAXException {
try (Writer writer = new StringWriter()) {
XMLStreamWriter xml = XMLOutputFactory.newDefaultFactory().createXMLStreamWriter(writer);

xml.writeStartDocument("UTF-8", "1.0");
// Output the "end of cdata" marker
SafeXml.writeTextElement(xml, "container", "]]>");
xml.writeEndDocument();
xml.writeStartDocument("UTF-8", "1.0");
// Output the "end of cdata" marker
SafeXml.writeTextElement(xml, "container", "]]>");
xml.writeEndDocument();

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try (Reader reader = new StringReader(writer.toString())) {
builder = factory.newDocumentBuilder();
Document parsed = builder.parse(new InputSource(reader));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder;
try (Reader reader = new StringReader(writer.toString())) {
builder = factory.newDocumentBuilder();
Document parsed = builder.parse(new InputSource(reader));

Node container = parsed.getElementsByTagName("container").item(0);
Node container = parsed.getElementsByTagName("container").item(0);

assertEquals("]]>", container.getTextContent());
}
}
assertEquals("]]>", container.getTextContent());
}
}
}
}
}

0 comments on commit 35ead94

Please sign in to comment.