KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > xml > resolving > impl > xmlcommons > TestXMLCatalogResolver


1 /**
2  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5 package org.exoplatform.services.xml.resolving.impl.xmlcommons;
6
7 import junit.framework.TestCase;
8
9 import java.io.File JavaDoc;
10 import org.exoplatform.container.PortalContainer;
11 import org.exoplatform.services.xml.resolving.XMLCatalogResolvingService;
12 import org.exoplatform.services.xml.resolving.impl.xmlcommons.XMLCommonsResolvingServiceImpl;
13
14 /**
15  * Created by the Exo Development team.
16  */

17 public class TestXMLCatalogResolver extends TestCase {
18
19    public void setUp() throws Exception JavaDoc
20    {
21    }
22
23    public void testConfig() throws Exception JavaDoc
24    {
25        try {
26 // PortalContainer manager = PortalContainer.getInstance();
27
// XMLCatalogResolvingService service = (XMLCatalogResolvingService) manager.
28
// getComponentInstanceOfType(XMLCommonsResolvingServiceImpl.class);
29
XMLCatalogResolvingService service = new XMLCommonsResolvingServiceImpl();
30           assertEquals( "./catalog/exo-catalog.xml", System.getProperty("xml.catalog.files"));
31
32           assertTrue( "File ./catalog/exo-catalog.xml not found!", new File JavaDoc("./catalog/exo-catalog.xml").exists() );
33
34        } catch ( Exception JavaDoc e) {
35
36             fail( "testConfig() ERROR: "+e.toString());
37         }
38
39    }
40
41    public void testWebXmlResolving() throws Exception JavaDoc
42    {
43        try {
44 // PortalContainer manager = PortalContainer.getInstance();
45
// XMLCommonsResolvingServiceImpl service = (XMLCommonsResolvingServiceImpl) manager.
46
// getComponentInstanceOfType(XMLCommonsResolvingServiceImpl.class);
47
XMLCommonsResolvingServiceImpl service = new XMLCommonsResolvingServiceImpl();
48
49           assertTrue("DTD for WEB.XML (publicId=\"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN\") must be in catalog! ",
50                       service.isLocallyResolvable("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN") );
51
52
53       javax.xml.parsers.SAXParserFactory JavaDoc factory=javax.xml.parsers.SAXParserFactory.newInstance();
54       factory.setNamespaceAware( true );
55       javax.xml.parsers.SAXParser JavaDoc jaxpParser=factory.newSAXParser();
56       org.xml.sax.XMLReader JavaDoc reader=jaxpParser.getXMLReader();
57
58           reader.setEntityResolver(service.getEntityResolver());
59           reader.parse("tmp/web.xml");
60
61        } catch ( Exception JavaDoc e) {
62
63             fail( "testWebXmlResolving() ERROR: "+e.toString());
64         }
65
66    }
67
68
69 }
70
Popular Tags