1 5 package org.exoplatform.services.xml.resolving.impl.xmlcommons; 6 7 import junit.framework.TestCase; 8 9 import java.io.File ; 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 17 public class TestXMLCatalogResolver extends TestCase { 18 19 public void setUp() throws Exception 20 { 21 } 22 23 public void testConfig() throws Exception 24 { 25 try { 26 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 ("./catalog/exo-catalog.xml").exists() ); 33 34 } catch ( Exception e) { 35 36 fail( "testConfig() ERROR: "+e.toString()); 37 } 38 39 } 40 41 public void testWebXmlResolving() throws Exception 42 { 43 try { 44 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 factory=javax.xml.parsers.SAXParserFactory.newInstance(); 54 factory.setNamespaceAware( true ); 55 javax.xml.parsers.SAXParser jaxpParser=factory.newSAXParser(); 56 org.xml.sax.XMLReader reader=jaxpParser.getXMLReader(); 57 58 reader.setEntityResolver(service.getEntityResolver()); 59 reader.parse("tmp/web.xml"); 60 61 } catch ( Exception e) { 62 63 fail( "testWebXmlResolving() ERROR: "+e.toString()); 64 } 65 66 } 67 68 69 } 70 | Popular Tags |