diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/xml/XmlEntity.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/xml/XmlEntity.java index 2da3aacdf..acad80fa7 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/xml/XmlEntity.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/xml/XmlEntity.java @@ -13,37 +13,12 @@ import java.util.Map; * @author https://stackoverflow.com/users/823393/oldcurmudgeon */ public class XmlEntity { - - /** - * Private constructor for a utility class. - */ - private XmlEntity() { - } - - /** - * Converts a named XML entity into its HTML encoded Unicode code point. - * - * @param s the named entity (note, this should not include the leading '&' - * or trailing ';' - * @return the HTML encoded Unicode code point representation of the named - * entity - */ - public static String fromNamedReference(CharSequence s) { - if (s == null) { - return null; - } - final Integer code = SPECIALS.get(s.toString()); - if (code != null) { - return "&#" + code + ";"; - } - return null; - } - /** * The map of HTML entities. */ private static final Map SPECIALS; + // /** * Create a map HTML Named Entities to their numeric equivalent. Derived * from Wikipedia @@ -306,4 +281,30 @@ public class XmlEntity { map.put("diams", 9830); SPECIALS = Collections.unmodifiableMap(map); } + // + + /** + * Private constructor for a utility class. + */ + private XmlEntity() { + } + + /** + * Converts a named XML entity into its HTML encoded Unicode code point. + * + * @param s the named entity (note, this should not include the leading '&' + * or trailing ';' + * @return the HTML encoded Unicode code point representation of the named + * entity + */ + public static String fromNamedReference(CharSequence s) { + if (s == null) { + return null; + } + final Integer code = SPECIALS.get(s.toString()); + if (code != null) { + return "&#" + code + ";"; + } + return null; + } } diff --git a/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlEntityTest.java b/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlEntityTest.java index 53f2cc3d8..6d143ddd8 100644 --- a/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlEntityTest.java +++ b/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlEntityTest.java @@ -17,10 +17,6 @@ */ package org.owasp.dependencycheck.xml; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; diff --git a/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlInputStreamTest.java b/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlInputStreamTest.java index cd2e44504..f2382f7ab 100644 --- a/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlInputStreamTest.java +++ b/dependency-check-core/src/test/java/org/owasp/dependencycheck/xml/XmlInputStreamTest.java @@ -21,11 +21,6 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; @@ -126,10 +121,12 @@ public class XmlInputStreamTest { InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); XmlInputStream instance = new XmlInputStream(stream); int r = instance.read(); + assertEquals('t', r); String expResult = "[1]-\"t\" ( 74)"; String result = instance.toString(); assertEquals(expResult, result); r = instance.read(); + assertEquals('e', r); expResult = "[2]-\"te\" ( 74 65)"; result = instance.toString(); assertEquals(expResult, result);