KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xmlpull > v1 > tests > TestFactory


1 /* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/
2 // for license see accompanying LICENSE_TESTS.txt file (available also at http://www.xmlpull.org)
3

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 /**
13  * Simple test ot verify pull parser factory
14  *
15  * @author <a HREF="http://www.extreme.indiana.edu/~aslom/">Aleksander Slominski</a>
16  */

17 public class TestFactory extends UtilTestCase {
18
19     public TestFactory(String JavaDoc name) {
20         super(name);
21     }
22
23     public void testFactory() throws Exception JavaDoc {
24         XmlPullParserFactory factory = factoryNewInstance();
25         //System.out.println("factory = "+factory);
26
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.setNamespaceAware(false);
34
factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
35
36         //assertEquals(false, factory.isNamespaceAware());
37
assertEquals(false, factory.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES));
38         xpp = factory.newPullParser();
39         assertEquals(false, xpp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES));
40
41         //factory.setNamespaceAware(true);
42
factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
43         //assertEquals(true, factory.isNamespaceAware());
44
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 JavaDoc[] args) {
52         junit.textui.TestRunner.run (new TestSuite(TestFactory.class));
53     }
54 }
55
56
Popular Tags