1 package org.apache.maven;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import javax.xml.parsers.DocumentBuilder;
22 import javax.xml.parsers.DocumentBuilderFactory;
23 import javax.xml.parsers.SAXParser;
24 import javax.xml.parsers.SAXParserFactory;
25
26 import junit.framework.TestCase;
27
28 import org.xml.sax.XMLReader;
29 import org.xml.sax.helpers.XMLReaderFactory;
30
31 /**
32 * Tests to check JAXP is correctly configured and classes are being loaded
33 */
34 public class JAXPTest
35 extends TestCase
36 {
37
38 /**
39 * Constructor for JAXPTest.
40 * @param name test name
41 */
42 public JAXPTest( String name )
43 {
44 super( name );
45 }
46
47 /**
48 * test the jaxp property for the sax parser (org.xml.sax.parser)
49 * returns the piccolo parser
50 * @throws Exception if any problems occur
51 */
52 public void testSAXParser()
53 throws Exception
54 {
55
56 SAXParserFactory factory = SAXParserFactory.newInstance();
57 factory.setNamespaceAware( true );
58 SAXParser parser = factory.newSAXParser();
59 assertTrue( "Wrong sax parser", parser.getClass().getName().startsWith( "com.bluecast.xml." ) );
60 }
61
62 /**
63 * test the jaxp property for the XML Reader (org.xml.sax.driver)
64 * returns the correct XMLReader
65 * @throws Exception if any problems occur
66 */
67 public void testXMLReader()
68 throws Exception
69 {
70 XMLReader reader = XMLReaderFactory.createXMLReader();
71 assertTrue( "Wrong xml reader", reader.getClass().getName().startsWith( "com.bluecast.xml." ) );
72 }
73
74 /**
75 * Test that the DocumentBuilderFactory comes from Xerces
76 */
77 public void testDocumentBuilderFactory()
78 throws Exception
79 {
80 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
81 factory.setNamespaceAware( true );
82 DocumentBuilder builder = factory.newDocumentBuilder();
83 assertTrue( "Wrong document builder", builder.getClass().getName().startsWith( "org.apache.xerces.jaxp." ) );
84 }
85 }