View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package tests;
21  
22  import junit.framework.TestCase;
23  import org.apache.ws.commons.schema.XmlSchemaCollection;
24  
25  import javax.xml.transform.stream.StreamSource;
26  import java.io.ByteArrayInputStream;
27  
28  /**
29   * TestElementForm
30   */
31  public class TestLocalUnnamedSimpleType extends TestCase {
32      String schemaXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
33               "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"\n" +
34               "targetNamespace=\"http://finance.example.com/CreditCardFaults/xsd\"\n" +
35               "xmlns:tns=\"http://finance.example.com/CreditCardFaults/xsd\"\n" +
36               "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
37               "xsi:schemaLocation=\"http://www.w3.org/2001/XMLSchema\n" +
38               "              http://www.w3.org/2001/XMLSchema.xsd\">\n" +
39               "\n" +
40               "<element name=\"tns:CreditCardNumber\" type=\"string\"></element>\n" +
41               "\n" +
42               "<element name=\"tns:CreditCardType\">\n" +
43               "<simpleType>\n" +
44               "<restriction base=\"string\">\n" +
45               "<enumeration value=\"AMEX\" />\n" +
46               "<enumeration value=\"MASTERCARD\" />\n" +
47               "<enumeration value=\"VISA\" />\n" +
48               "</restriction>\n" +
49               "</simpleType>\n" +
50               "</element>\n" +
51               "</schema> ";
52  
53      public void testLocalUnnamedSimpleType() throws Exception {
54          XmlSchemaCollection schema = new XmlSchemaCollection();
55          schema.read(new StreamSource(new ByteArrayInputStream(schemaXML.getBytes())), null);
56      }
57  }