1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package tests.customext.attrib;
17
18 import junit.framework.TestCase;
19 import org.apache.ws.commons.schema.XmlSchema;
20 import org.apache.ws.commons.schema.XmlSchemaCollection;
21 import org.apache.ws.commons.schema.XmlSchemaElement;
22 import org.apache.ws.commons.schema.constants.Constants;
23 import org.w3c.dom.Document;
24 import tests.Resources;
25
26 import javax.xml.parsers.DocumentBuilderFactory;
27 import java.util.Iterator;
28 import java.util.Map;
29
30
31
32
33 public class CustomExtDeserializerTest extends TestCase {
34
35
36 public void testDeserialization() throws Exception {
37
38 System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY,
39 CustomExtensionRegistry.class.getName());
40
41
42 DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
43 documentBuilderFactory.setNamespaceAware(true);
44 Document doc = documentBuilderFactory.newDocumentBuilder().
45 parse(Resources.asURI("/external/externalAnnotations.xsd"));
46
47 XmlSchemaCollection schemaCol = new XmlSchemaCollection();
48 XmlSchema schema = schemaCol.read(doc,null);
49 assertNotNull(schema);
50
51
52
53 Iterator values = schema.getElements().getValues();
54 while (values.hasNext()) {
55 XmlSchemaElement elt = (XmlSchemaElement) values.next();
56 assertNotNull(elt);
57 Map metaInfoMap = elt.getMetaInfoMap();
58 assertNotNull(metaInfoMap);
59
60 CustomAttribute customAttrib = (CustomAttribute)metaInfoMap.get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
61 assertNotNull(customAttrib);
62
63 }
64
65
66 System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);;
67
68 }
69 }