1 17 package org.apache.ws.jaxme.xs.junit; 18 19 import java.io.File ; 20 import java.io.FileInputStream ; 21 import java.io.IOException ; 22 23 import javax.xml.parsers.ParserConfigurationException ; 24 25 import junit.framework.TestCase; 26 import org.apache.ws.jaxme.xs.XSParser; 27 import org.xml.sax.InputSource ; 28 import org.xml.sax.SAXException ; 29 30 31 34 public class SyntaxTest extends TestCase { 35 public SyntaxTest(String pName) { 36 super(pName); 37 } 38 39 protected void parseSyntax(File f) throws IOException , SAXException , ParserConfigurationException { 40 XSParser xsp = new XSParser(); 41 InputSource isource = new InputSource (new FileInputStream (f)); 42 isource.setSystemId(f.toURL().toString()); 43 xsp.parseSyntax(isource); 44 } 45 46 protected void parseLogical(File f) throws IOException , SAXException , ParserConfigurationException { 47 XSParser xsp = new XSParser(); 48 InputSource isource = new InputSource (new FileInputStream (f)); 49 isource.setSystemId(f.toURL().toString()); 50 xsp.parse(isource); 51 } 52 53 protected void parseSyntax(String s) throws IOException , SAXException , ParserConfigurationException { 54 parseSyntax(new File (s)); 55 } 56 57 protected void parseLogical(String s) throws IOException , SAXException , ParserConfigurationException { 58 parseLogical(new File (s)); 59 } 60 61 public void testStructureSyntax() throws Exception { 62 parseSyntax("examples/xs/structures.xsd"); 63 } 64 65 public void testDatatypesSyntax() throws Exception { 66 parseSyntax("examples/xs/datatypes.xsd"); 67 } 68 69 public void testXmlSyntax() throws Exception { 70 parseSyntax("examples/xs/xml.xsd"); 71 } 72 73 public void testStructureLogical() throws Exception { 74 parseLogical("examples/xs/structures.xsd"); 75 } 76 } 77 | Popular Tags |