aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Chang <vichang@google.com>2022-05-06 16:21:23 +0100
committerVictor Chang <vichang@google.com>2022-05-10 11:30:50 +0000
commitad95ea0a4c2d6962bf71ea48c71bcdb2bd305697 (patch)
treef448771238dad96ddbef4d123e36b2e79bc7584c
parentb80f7478499173b7a801501a5ada09ca5bb90e13 (diff)
downloadlibcore-ad95ea0a4c2d6962bf71ea48c71bcdb2bd305697.tar.gz
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
-rw-r--r--luni/src/test/java/libcore/xml/XmlToSax2DriverTest.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/luni/src/test/java/libcore/xml/XmlToSax2DriverTest.java b/luni/src/test/java/libcore/xml/XmlToSax2DriverTest.java
index 9e4b47c290f..b8ad8bd0b23 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 @@ public class XmlToSax2DriverTest extends TestCase {
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);