1   /*
2    * Copyright 2004,2007 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 tests;
18  
19  import junit.framework.TestCase;
20  import org.apache.ws.commons.schema.XmlSchemaCollection;
21  
22  import javax.xml.transform.stream.StreamSource;
23  import java.io.ByteArrayInputStream;
24  
25  /**
26   * TestElementForm
27   */
28  public class TestLocalUnnamedSimpleType extends TestCase {
29      String schemaXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
30               "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"\n" +
31               "targetNamespace=\"http://finance.example.com/CreditCardFaults/xsd\"\n" +
32               "xmlns:tns=\"http://finance.example.com/CreditCardFaults/xsd\"\n" +
33               "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
34               "xsi:schemaLocation=\"http://www.w3.org/2001/XMLSchema\n" +
35               "              http://www.w3.org/2001/XMLSchema.xsd\">\n" +
36               "\n" +
37               "<element name=\"tns:CreditCardNumber\" type=\"string\"></element>\n" +
38               "\n" +
39               "<element name=\"tns:CreditCardType\">\n" +
40               "<simpleType>\n" +
41               "<restriction base=\"string\">\n" +
42               "<enumeration value=\"AMEX\" />\n" +
43               "<enumeration value=\"MASTERCARD\" />\n" +
44               "<enumeration value=\"VISA\" />\n" +
45               "</restriction>\n" +
46               "</simpleType>\n" +
47               "</element>\n" +
48               "</schema> ";
49  
50      public void testLocalUnnamedSimpleType() throws Exception {
51          XmlSchemaCollection schema = new XmlSchemaCollection();
52          schema.read(new StreamSource(new ByteArrayInputStream(schemaXML.getBytes())), null);
53      }
54  }