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  package tests.ext;
20  
21  import junit.framework.TestCase;
22  
23  import javax.xml.parsers.DocumentBuilderFactory;
24  
25  import org.w3c.dom.Document;
26  import org.apache.ws.commons.schema.XmlSchemaCollection;
27  import org.apache.ws.commons.schema.XmlSchema;
28  import org.apache.ws.commons.schema.XmlSchemaElement;
29  import tests.Resources;
30  
31  import java.util.Iterator;
32  import java.util.Map;
33  import java.io.ByteArrayOutputStream;
34  
35  /**
36   * try writing the schemas after they are built
37   */
38  public class PlainExtensionSerializerTest extends TestCase {
39  
40       public void testSerialization() throws Exception {
41  
42             //create a DOM document
43             DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
44             documentBuilderFactory.setNamespaceAware(true);
45             Document doc = documentBuilderFactory.newDocumentBuilder().
46                     parse(Resources.asURI("/external/externalAnnotations.xsd"));
47  
48             XmlSchemaCollection schemaCol = new XmlSchemaCollection();
49             XmlSchema schema = schemaCol.read(doc,null);
50             assertNotNull(schema);
51  
52             schema.write(new ByteArrayOutputStream());
53       }
54  
55  
56      public void testSerialization1() throws Exception {
57  
58             //create a DOM document
59             DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
60             documentBuilderFactory.setNamespaceAware(true);
61             Document doc = documentBuilderFactory.newDocumentBuilder().
62                     parse(Resources.asURI("/external/externalElementAnnotations.xsd"));
63  
64             XmlSchemaCollection schemaCol = new XmlSchemaCollection();
65             XmlSchema schema = schemaCol.read(doc,null);
66             assertNotNull(schema);
67  
68             schema.write(new ByteArrayOutputStream());
69       }
70  }