1 package tests;
2
3 import junit.framework.TestCase;
4 import org.apache.ws.commons.schema.XmlSchema;
5 import org.apache.ws.commons.schema.XmlSchemaCollection;
6 import org.apache.ws.commons.schema.XmlSchemaElement;
7 import org.apache.ws.commons.schema.XmlSchemaType;
8 import org.w3c.dom.Document;
9
10 import javax.xml.parsers.DocumentBuilderFactory;
11 import java.util.Iterator;
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class AllSimpleTypeTest extends TestCase {
29
30 public void testSimpleTypeSchemaGeneration() throws Exception {
31
32 DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
33 documentBuilderFactory.setNamespaceAware(true);
34 Document doc = documentBuilderFactory.newDocumentBuilder().
35 parse(Resources.asURI("allSimpleTypes.xsd"));
36
37 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
38 XmlSchema schema = schemaCol.read(doc,null);
39 assertNotNull(schema);
40
41
42
43
44 Iterator values = schema.getElements().getValues();
45 while (values.hasNext()) {
46 XmlSchemaElement elt = (XmlSchemaElement) values.next();
47 XmlSchemaType schemaType = elt.getSchemaType();
48 assertNotNull(schemaType);
49
50 }
51
52
53 }
54 }