1 2 4 package org.xmlpull.v1.tests; 5 6 import junit.framework.TestCase; 7 import junit.framework.TestSuite; 8 9 import org.xmlpull.v1.XmlPullParser; 10 import org.xmlpull.v1.XmlPullParserFactory; 11 12 17 public class TestFactory extends UtilTestCase { 18 19 public TestFactory(String name) { 20 super(name); 21 } 22 23 public void testFactory() throws Exception { 24 XmlPullParserFactory factory = factoryNewInstance(); 25 XmlPullParser xpp = factory.newPullParser(); 27 PackageTests.addNote("* default parser "+xpp.getClass()+"\n"); 28 assertEquals(false, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES)); 29 factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); 30 xpp = factory.newPullParser(); 31 assertEquals(true, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES)); 32 33 factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); 35 36 assertEquals(false, factory.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES)); 38 xpp = factory.newPullParser(); 39 assertEquals(false, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES)); 40 41 factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); 43 assertEquals(true, factory.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES)); 45 xpp = factory.newPullParser(); 46 assertEquals(true, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES)); 47 PackageTests.addNote("* namespace enabled parser "+xpp.getClass()+"\n"); 48 49 } 50 51 public static void main (String [] args) { 52 junit.textui.TestRunner.run (new TestSuite(TestFactory.class)); 53 } 54 } 55 56 | Popular Tags |