KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.File JavaDoc;
19 import java.io.FileInputStream JavaDoc;
20
21 import junit.framework.TestCase;
22
23 import org.apache.ws.jaxme.xs.XSComplexType;
24 import org.apache.ws.jaxme.xs.XSElement;
25 import org.apache.ws.jaxme.xs.XSGroup;
26 import org.apache.ws.jaxme.xs.XSParser;
27 import org.apache.ws.jaxme.xs.XSParticle;
28 import org.apache.ws.jaxme.xs.XSSchema;
29 import org.apache.ws.jaxme.xs.XSType;
30 import org.apache.ws.jaxme.xs.xml.XsQName;
31 import org.xml.sax.InputSource JavaDoc;
32
33 public class ClaesLarssonTest extends TestCase {
34   public ClaesLarssonTest(String JavaDoc pName) {
35     super(pName);
36   }
37
38   public void testParse() throws Exception JavaDoc {
39     XSParser xsp = new XSParser();
40     xsp.setValidating(false);
41
42     String JavaDoc xmlFileName = "examples/xs/Claes_Larsson/schema.xsd";
43     java.net.URL JavaDoc xmlSystemId = new File JavaDoc(xmlFileName).toURL();
44
45     InputSource JavaDoc isource = new InputSource JavaDoc(new FileInputStream JavaDoc(xmlFileName));
46     isource.setSystemId(xmlSystemId.toString());
47     XSSchema schema = xsp.parse(isource);
48
49     // Print the names of all global elements:
50
XSElement[] elements = schema.getElements();
51     assertEquals(154, elements.length);
52
53     XSElement localTransformationElement = schema.getElement(new XsQName((String JavaDoc) null, "local_transformation"));
54     assertNotNull(localTransformationElement);
55     XSType localTransformationType = localTransformationElement.getType();
56     assertTrue(!localTransformationType.isSimple());
57     XSComplexType localTransformationComplexType = localTransformationType.getComplexType();
58     assertTrue(!localTransformationComplexType.hasSimpleContent());
59     XSParticle localTransformationParticle = localTransformationComplexType.getParticle();
60     XSGroup localTransformationGroup = localTransformationParticle.getGroup();
61     XSParticle[] particles = localTransformationGroup.getParticles();
62     assertEquals(0, particles[0].getMinOccurs());
63     assertEquals(1, particles[0].getMaxOccurs());
64   }
65 }
Popular Tags