Add test for Driver.setProperty
Bug: 119393918
Bug: 181670896
Test: atest CtsLibcoreTestCases:libcore.xml.XmlToSax2DriverTest
Change-Id: I552be4d7d8635953571628fb3dd1c607c16f6d04
(cherry picked from commit 1756169d0668621f46875a38508eae07dbcfa4c0)
Merged-In: I552be4d7d8635953571628fb3dd1c607c16f6d04
diff --git a/luni/src/test/java/libcore/xml/XmlToSax2DriverTest.java b/luni/src/test/java/libcore/xml/XmlToSax2DriverTest.java
index 9e4b47c..b8ad8bd 100644
--- a/luni/src/test/java/libcore/xml/XmlToSax2DriverTest.java
+++ b/luni/src/test/java/libcore/xml/XmlToSax2DriverTest.java
@@ -15,6 +15,8 @@
*/
package libcore.xml;
+import static org.junit.Assert.assertThrows;
+
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
@@ -93,6 +95,23 @@
assertEquals(driver.getColumnNumber(), 1);
}
+ public void testSetProperty() throws Exception {
+ assertThrows(SAXNotSupportedException.class , () -> driver.setProperty(
+ "http://xml.org/sax/properties/declaration-handler", // DECLARATION_HANDLER_PROPERTY
+ ""));
+
+ assertThrows(SAXNotSupportedException.class ,() -> driver.setProperty(
+ "http://xml.org/sax/properties/lexical-handler", // LEXICAL_HANDLER_PROPERTY
+ ""));
+
+ // This may be the only key accpeted by the KXmlParser.
+ String key = "http://xmlpull.org/v1/doc/properties.html#location";
+ driver.setProperty(key, "123");
+ assertEquals("123", driver.getProperty(key));
+
+ assertThrows(SAXNotSupportedException.class ,() -> driver.setProperty("abc", ""));
+ }
+
public void testGetSetContentHandler() throws XmlPullParserException {
assertTrue(driver.getContentHandler() instanceof DefaultHandler);