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   
8   import javax.xml.namespace.QName;
9   import javax.xml.transform.stream.StreamSource;
10  import java.io.FileInputStream;
11  import java.io.InputStream;
12  /*
13   * Copyright 2004,2007 The Apache Software Foundation.
14   *
15   * Licensed under the Apache License, Version 2.0 (the "License");
16   * you may not use this file except in compliance with the License.
17   * You may obtain a copy of the License at
18   *
19   *      http://www.apache.org/licenses/LICENSE-2.0
20   *
21   * Unless required by applicable law or agreed to in writing, software
22   * distributed under the License is distributed on an "AS IS" BASIS,
23   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24   * See the License for the specific language governing permissions and
25   * limitations under the License.
26   */
27  
28  public class BlockTest extends TestCase {
29      public void testMixedContent() throws Exception {
30          QName ELEMENT_QNAME = new QName("http://soapinterop.org/xsd",
31                                          "complexElt");
32  
33  
34          InputStream is = new FileInputStream(Resources.asURI("block.xsd"));
35          XmlSchemaCollection schema = new XmlSchemaCollection();
36          XmlSchema s = schema.read(new StreamSource(is), null);
37  
38          XmlSchemaElement elementByName = s.getElementByName(ELEMENT_QNAME);
39          assertNotNull(elementByName);
40  
41          String value = elementByName.getBlock().getValue();
42          assertEquals("restriction",value);
43  
44      }
45  }