Skip to content

Commit 8ba6ba0

Browse files
committed
Add tests specific to the new Util.toXml method
1 parent 874b410 commit 8ba6ba0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

core/src/test/java/com/onelogin/saml2/test/util/UtilsTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,4 +2146,27 @@ public void testQuery() throws XPathExpressionException, URISyntaxException, IOE
21462146
assertEquals("saml2:Assertion", assertion_2.getNodeName());
21472147
}
21482148

2149+
/**
2150+
* Tests the toXml method
2151+
*
2152+
* @see com.onelogin.saml2.util.Util#toXml(String)
2153+
*/
2154+
@Test
2155+
public void testToXml() {
2156+
assertEquals("", Util.toXml(""));
2157+
assertEquals("No escape", Util.toXml("No escape"));
2158+
assertEquals("&amp;&quot;&lt;&gt;&apos;", Util.toXml("&\"<>'"));
2159+
}
2160+
2161+
/**
2162+
* Tests the toXml method
2163+
* <p>
2164+
* Case: the input is <code>null</code>.
2165+
*
2166+
* @see com.onelogin.saml2.util.Util#toXml(String)
2167+
*/
2168+
@Test
2169+
public void testToXmlNull() {
2170+
assertNull(Util.toXml(null));
2171+
}
21492172
}

0 commit comments

Comments
 (0)