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