KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ws > jaxme > xs > junit > SyntaxTest


1 /*
2  * Copyright 2003, 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15
16  */

17 package org.apache.ws.jaxme.xs.junit;
18
19 import java.io.File JavaDoc;
20 import java.io.FileInputStream JavaDoc;
21 import java.io.IOException JavaDoc;
22
23 import javax.xml.parsers.ParserConfigurationException JavaDoc;
24
25 import junit.framework.TestCase;
26 import org.apache.ws.jaxme.xs.XSParser;
27 import org.xml.sax.InputSource JavaDoc;
28 import org.xml.sax.SAXException JavaDoc;
29
30
31 /**
32  * @author <a HREF="mailto:joe@ispsoft.de">Jochen Wiedmann</a>
33  */

34 public class SyntaxTest extends TestCase {
35   public SyntaxTest(String JavaDoc pName) {
36     super(pName);
37   }
38
39   protected void parseSyntax(File JavaDoc f) throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
40     XSParser xsp = new XSParser();
41     InputSource JavaDoc isource = new InputSource JavaDoc(new FileInputStream JavaDoc(f));
42     isource.setSystemId(f.toURL().toString());
43     xsp.parseSyntax(isource);
44   }
45
46   protected void parseLogical(File JavaDoc f) throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
47     XSParser xsp = new XSParser();
48     InputSource JavaDoc isource = new InputSource JavaDoc(new FileInputStream JavaDoc(f));
49     isource.setSystemId(f.toURL().toString());
50     xsp.parse(isource);
51   }
52
53   protected void parseSyntax(String JavaDoc s) throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
54     parseSyntax(new File JavaDoc(s));
55   }
56
57   protected void parseLogical(String JavaDoc s) throws IOException JavaDoc, SAXException JavaDoc, ParserConfigurationException JavaDoc {
58     parseLogical(new File JavaDoc(s));
59   }
60
61   public void testStructureSyntax() throws Exception JavaDoc {
62     parseSyntax("examples/xs/structures.xsd");
63   }
64
65   public void testDatatypesSyntax() throws Exception JavaDoc {
66     parseSyntax("examples/xs/datatypes.xsd");
67   }
68
69   public void testXmlSyntax() throws Exception JavaDoc {
70     parseSyntax("examples/xs/xml.xsd");
71   }
72
73   public void testStructureLogical() throws Exception JavaDoc {
74     parseLogical("examples/xs/structures.xsd");
75   }
76 }
77
Popular Tags