You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by bi...@apache.org on 2008/12/15 00:18:59 UTC
svn commit: r726576 [9/10] - in
/webservices/commons/trunk/modules/XmlSchema: ./ etc/ etc/eclipse/
src/main/java/org/apache/ws/commons/schema/
src/main/java/org/apache/ws/commons/schema/constants/
src/main/java/org/apache/ws/commons/schema/extensions/ ...
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/RedefineTest.java Sun Dec 14 15:18:54 2008
@@ -52,56 +52,25 @@
/**
* This method will test a complex type redefine.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testComplexTypeRedefine() throws Exception {
/*
- redefine1.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <complexType name="person">
- <sequence>
- <element name="firstname" type="string"/>
- <element name="lastname" type="string"/>
- </sequence>
- </complexType>
-
- <element name="customer" type="tns:person"/>
-
- </schema>
-
-
- redefine2.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <redefine schemaLocation="src/test/test-resources/redefine1.xsd">
- <complexType name="person">
- <complexContent>
- <extension base="tns:person">
- <sequence>
- <element name="id" type="string"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
- </redefine>
-
- <element name="vip" type="tns:person"/>
-
- </schema>
- */
+ * redefine1.xsd ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <complexType name="person"> <sequence> <element
+ * name="firstname" type="string"/> <element name="lastname" type="string"/> </sequence>
+ * </complexType> <element name="customer" type="tns:person"/> </schema> redefine2.xsd
+ * ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <redefine
+ * schemaLocation="src/test/test-resources/redefine1.xsd"> <complexType name="person">
+ * <complexContent> <extension base="tns:person"> <sequence> <element name="id" type="string"/>
+ * </sequence> </extension> </complexContent> </complexType> </redefine> <element name="vip"
+ * type="tns:person"/> </schema>
+ */
InputStream is = new FileInputStream(Resources.asURI("redefine2.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
@@ -111,29 +80,26 @@
assertEquals(1, xsot.getCount());
XmlSchemaElement xse = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xse = (XmlSchemaElement)i.next();
}
assertEquals("vip", xse.getName());
- assertEquals(new QName("http://soapinterop.org/types",
- "person"),
- xse.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "person"), xse.getSchemaTypeName());
XmlSchemaObjectCollection xsoc = schema.getIncludes();
assertEquals(1, xsoc.getCount());
-
+
XmlSchemaRedefine xsr = (XmlSchemaRedefine)xsoc.getItem(0);
xsot = xsr.getSchemaTypes();
assertEquals(1, xsot.getCount());
- for (Iterator i = xsot.getNames(); i.hasNext(); ) {
+ for (Iterator i = xsot.getNames(); i.hasNext();) {
QName qname = (QName)i.next();
- assertEquals(new QName("http://soapinterop.org/types",
- "person"), qname);
+ assertEquals(new QName("http://soapinterop.org/types", "person"), qname);
}
XmlSchemaComplexType xsct = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xsct = (XmlSchemaComplexType)i.next();
}
assertNotNull(xsct);
@@ -141,11 +107,8 @@
XmlSchemaContentModel xscm = xsct.getContentModel();
assertNotNull(xscm);
- XmlSchemaComplexContentExtension xscce =
- (XmlSchemaComplexContentExtension)xscm.getContent();
- assertEquals(new QName("http://soapinterop.org/types",
- "person"),
- xscce.getBaseTypeName());
+ XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension)xscm.getContent();
+ assertEquals(new QName("http://soapinterop.org/types", "person"), xscce.getBaseTypeName());
XmlSchemaSequence xsp = (XmlSchemaSequence)xscce.getParticle();
assertNotNull(xsp);
@@ -158,58 +121,28 @@
xse = (XmlSchemaElement)c.getItem(i);
}
assertEquals("id", xse.getName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
- "string"),
- xse.getSchemaTypeName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"), xse.getSchemaTypeName());
}
/**
* This method will test a simple type redefine.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testSimpleTypeRedefine() throws Exception {
/*
-
- redefine3.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <simpleType name="drinksize">
- <restriction base="integer"/>
- </simpleType>
-
- <element name="size" type="tns:drinksize"/>
-
- </schema>
-
-
- redefine4.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <redefine schemaLocation="test-resources/redefine3.xsd">
- <simpleType name="drinksize">
- <restriction base="tns:drinksize">
- <minInclusive value="1"/>
- <maxInclusive value="3"/>
- </restriction>
- </simpleType>
- </redefine>
-
- <element name="childsizedrink" type="tns:drinksize"/>
-
- </schema>
- */
+ * redefine3.xsd ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <simpleType name="drinksize"> <restriction
+ * base="integer"/> </simpleType> <element name="size" type="tns:drinksize"/> </schema> redefine4.xsd
+ * ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <redefine
+ * schemaLocation="test-resources/redefine3.xsd"> <simpleType name="drinksize"> <restriction
+ * base="tns:drinksize"> <minInclusive value="1"/> <maxInclusive value="3"/> </restriction>
+ * </simpleType> </redefine> <element name="childsizedrink" type="tns:drinksize"/> </schema>
+ */
InputStream is = new FileInputStream(Resources.asURI("redefine4.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
@@ -219,45 +152,39 @@
assertEquals(1, xsot.getCount());
XmlSchemaElement xse = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xse = (XmlSchemaElement)i.next();
}
assertEquals("childsizedrink", xse.getName());
- assertEquals(new QName("http://soapinterop.org/types",
- "drinksize"),
- xse.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "drinksize"), xse.getSchemaTypeName());
XmlSchemaObjectCollection xsoc = schema.getIncludes();
assertEquals(1, xsoc.getCount());
-
+
XmlSchemaRedefine xsr = (XmlSchemaRedefine)xsoc.getItem(0);
xsot = xsr.getSchemaTypes();
assertEquals(1, xsot.getCount());
- for (Iterator i = xsot.getNames(); i.hasNext(); ) {
+ for (Iterator i = xsot.getNames(); i.hasNext();) {
QName qname = (QName)i.next();
- assertEquals(new QName("http://soapinterop.org/types",
- "drinksize"), qname);
+ assertEquals(new QName("http://soapinterop.org/types", "drinksize"), qname);
}
XmlSchemaSimpleType xsst = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xsst = (XmlSchemaSimpleType)i.next();
}
assertNotNull(xsst);
- XmlSchemaSimpleTypeRestriction xsstr =
- (XmlSchemaSimpleTypeRestriction)xsst.getContent();
- assertEquals(new QName("http://soapinterop.org/types",
- "drinksize"),
- xsstr.getBaseTypeName());
+ XmlSchemaSimpleTypeRestriction xsstr = (XmlSchemaSimpleTypeRestriction)xsst.getContent();
+ assertEquals(new QName("http://soapinterop.org/types", "drinksize"), xsstr.getBaseTypeName());
xsoc = xsstr.getFacets();
Set s = new HashSet();
s.add(XmlSchemaMinInclusiveFacet.class.getName());
s.add(XmlSchemaMaxInclusiveFacet.class.getName());
- for (Iterator i = xsoc.getIterator(); i.hasNext(); ) {
+ for (Iterator i = xsoc.getIterator(); i.hasNext();) {
Object o = i.next();
assertTrue(s.remove(o.getClass().getName()));
if (o instanceof XmlSchemaMinInclusiveFacet) {
@@ -265,63 +192,33 @@
} else if (o instanceof XmlSchemaMaxInclusiveFacet) {
assertEquals("3", ((XmlSchemaMaxInclusiveFacet)o).getValue());
} else {
- fail("Unexpected object encountered: "
- + o.getClass().getName());
+ fail("Unexpected object encountered: " + o.getClass().getName());
}
}
- assertTrue("The set should have been empty, but instead contained: "
- + s + ".",
- s.isEmpty());
+ assertTrue("The set should have been empty, but instead contained: " + s + ".", s.isEmpty());
}
/**
* This method will test a group redefine.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testGroupRedefine() throws Exception {
/*
- redefine5.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <group name="PrologGroup">
- <sequence>
- <element name="date" type="string"/>
- <element name="author" type="string"/>
- <element name="defect" type="integer"/>
- </sequence>
- </group>
-
- </schema>
-
-
- redefine6.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <redefine schemaLocation="redefine5.xsd">
- <group name="PrologGroup">
- <sequence>
- <group ref="tns:PrologGroup"/>
- <element name="description" type="string"/>
- </sequence>
- </group>
- </redefine>
-
- </schema>
- */
+ * redefine5.xsd ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <group name="PrologGroup"> <sequence> <element
+ * name="date" type="string"/> <element name="author" type="string"/> <element name="defect"
+ * type="integer"/> </sequence> </group> </schema> redefine6.xsd ----------------- <schema
+ * xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ * xmlns:tns="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/types"> <redefine
+ * schemaLocation="redefine5.xsd"> <group name="PrologGroup"> <sequence> <group
+ * ref="tns:PrologGroup"/> <element name="description" type="string"/> </sequence> </group>
+ * </redefine> </schema>
+ */
InputStream is = new FileInputStream(Resources.asURI("redefine6.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
@@ -329,17 +226,17 @@
XmlSchemaObjectCollection xsoc = schema.getIncludes();
assertEquals(1, xsoc.getCount());
-
+
XmlSchemaRedefine xsr = (XmlSchemaRedefine)xsoc.getItem(0);
XmlSchemaObjectTable xsot = xsr.getGroup();
assertEquals(1, xsot.getCount());
- for (Iterator i = xsot.getNames(); i.hasNext(); ) {
+ for (Iterator i = xsot.getNames(); i.hasNext();) {
assertEquals("PrologGroup", ((QName)i.next()).getLocalPart());
}
XmlSchemaGroup xsg = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xsg = (XmlSchemaGroup)i.next();
}
@@ -347,73 +244,45 @@
xsoc = xss.getItems();
assertEquals(2, xsoc.getCount());
-
+
Set s = new HashSet();
s.add(XmlSchemaGroupRef.class.getName());
s.add(XmlSchemaElement.class.getName());
- for (Iterator i = xsoc.getIterator(); i.hasNext(); ) {
+ for (Iterator i = xsoc.getIterator(); i.hasNext();) {
Object o = i.next();
assertTrue(s.remove(o.getClass().getName()));
if (o instanceof XmlSchemaGroupRef) {
- assertEquals(new QName("http://soapinterop.org/types",
- "PrologGroup"),
- ((XmlSchemaGroupRef)o).getRefName());
+ assertEquals(new QName("http://soapinterop.org/types", "PrologGroup"), ((XmlSchemaGroupRef)o)
+ .getRefName());
} else if (o instanceof XmlSchemaElement) {
assertEquals("description", ((XmlSchemaElement)o).getName());
} else {
- fail("Unexpected object encountered: "
- + o.getClass().getName());
+ fail("Unexpected object encountered: " + o.getClass().getName());
}
}
- assertTrue("The set should have been empty, but instead contained: "
- + s + ".",
- s.isEmpty());
+ assertTrue("The set should have been empty, but instead contained: " + s + ".", s.isEmpty());
}
/**
* This method will test a attribute group redefine.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testAttributeGroupRedefine() throws Exception {
/*
- redefine7.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <attributeGroup name="AttribGroup">
- <attribute name="type" type="string"/>
- <attribute name="units" type="string"/>
- <attribute name="serialId" type="string"/>
- </attributeGroup>
-
- </schema>
-
-
- redefine8.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <redefine schemaLocation="redefine7.xsd">
- <attributeGroup name="AttribGroup">
- <attribute name="type" type="string"/>
- <attribute name="units" type="string"/>
- </attributeGroup>
- </redefine>
-
- </schema>
- */
+ * redefine7.xsd ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <attributeGroup name="AttribGroup"> <attribute
+ * name="type" type="string"/> <attribute name="units" type="string"/> <attribute name="serialId"
+ * type="string"/> </attributeGroup> </schema> redefine8.xsd ----------------- <schema
+ * xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ * xmlns:tns="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/types"> <redefine
+ * schemaLocation="redefine7.xsd"> <attributeGroup name="AttribGroup"> <attribute name="type"
+ * type="string"/> <attribute name="units" type="string"/> </attributeGroup> </redefine> </schema>
+ */
InputStream is = new FileInputStream(Resources.asURI("redefine8.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
@@ -421,123 +290,71 @@
XmlSchemaObjectCollection xsoc = schema.getIncludes();
assertEquals(1, xsoc.getCount());
-
+
XmlSchemaRedefine xsr = (XmlSchemaRedefine)xsoc.getItem(0);
XmlSchemaObjectTable xsot = xsr.getAttributeGroup();
assertEquals(1, xsot.getCount());
- for (Iterator i = xsot.getNames(); i.hasNext(); ) {
+ for (Iterator i = xsot.getNames(); i.hasNext();) {
assertEquals("AttribGroup", ((QName)i.next()).getLocalPart());
}
XmlSchemaAttributeGroup xsag = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xsag = (XmlSchemaAttributeGroup)i.next();
}
assertNotNull(xsag);
- assertEquals("AttribGroup", (xsag.getName()).getLocalPart());
+ assertEquals("AttribGroup", xsag.getName().getLocalPart());
xsoc = xsag.getAttributes();
Set s = new HashSet();
s.add("type");
s.add("units");
- for (Iterator i = xsoc.getIterator(); i.hasNext(); ) {
+ for (Iterator i = xsoc.getIterator(); i.hasNext();) {
XmlSchemaAttribute xsa = (XmlSchemaAttribute)i.next();
assertTrue(s.remove(xsa.getName()));
}
- assertTrue("The set should have been empty, but instead contained: "
- + s + ".",
- s.isEmpty());
-
- }
+ assertTrue("The set should have been empty, but instead contained: " + s + ".", s.isEmpty());
+ }
/**
- * This method will test a complex type redefine. Similar
- * to the first test but now there are multiple layers of includes
- *
+ * This method will test a complex type redefine. Similar to the first test but now there are multiple
+ * layers of includes
+ *
* @throws Exception Any exception encountered
*/
public void testComplexTypeRedefineWithRelativeImports() throws Exception {
- /*
- * redefine-import2.xsd
- *
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <complexType name="person">
- <sequence>
- <element name="firstname" type="string"/>
- <element name="lastname" type="string"/>
- </sequence>
- </complexType>
-
- <element name="customer" type="tns:person"/>
-
- </schema>
- *
- *
- */
-
-
- /*
- * redefine-import1.xsd
- *
- *
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
- <!-- relative import to this location -->
- <xsd:include schemaLocation="redefine-import2.xsd"></xsd:include>
-
- </schema>
- *
- */
/*
- redefine9.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <!-- Relative import -->
- <xsd:include schemaLocation="redefine-include/redefine-import1.xsd"></xsd:include>
-
- </schema>
-
-
- redefine10.xsd
- -----------------
-
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <redefine schemaLocation="src/test/test-resources/redefine9.xsd">
- <complexType name="person">
- <complexContent>
- <extension base="tns:person">
- <sequence>
- <element name="id" type="string"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
- </redefine>
-
- <element name="vip" type="tns:person"/>
-
- </schema>
- */
+ * redefine-import2.xsd <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <complexType name="person"> <sequence> <element
+ * name="firstname" type="string"/> <element name="lastname" type="string"/> </sequence>
+ * </complexType> <element name="customer" type="tns:person"/> </schema>
+ */
+
+ /*
+ * redefine-import1.xsd <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <!-- relative import to this location -->
+ * <xsd:include schemaLocation="redefine-import2.xsd"></xsd:include> </schema>
+ */
+ /*
+ * redefine9.xsd ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <!-- Relative import --> <xsd:include
+ * schemaLocation="redefine-include/redefine-import1.xsd"></xsd:include> </schema> redefine10.xsd
+ * ----------------- <schema xmlns="http://www.w3.org/2001/XMLSchema"
+ * xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://soapinterop.org/types"
+ * targetNamespace="http://soapinterop.org/types"> <redefine
+ * schemaLocation="src/test/test-resources/redefine9.xsd"> <complexType name="person">
+ * <complexContent> <extension base="tns:person"> <sequence> <element name="id" type="string"/>
+ * </sequence> </extension> </complexContent> </complexType> </redefine> <element name="vip"
+ * type="tns:person"/> </schema>
+ */
InputStream is = new FileInputStream(Resources.asURI("redefine10.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
@@ -547,29 +364,26 @@
assertEquals(1, xsot.getCount());
XmlSchemaElement xse = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xse = (XmlSchemaElement)i.next();
}
assertEquals("vip", xse.getName());
- assertEquals(new QName("http://soapinterop.org/types",
- "person"),
- xse.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "person"), xse.getSchemaTypeName());
XmlSchemaObjectCollection xsoc = schema.getIncludes();
assertEquals(1, xsoc.getCount());
-
+
XmlSchemaRedefine xsr = (XmlSchemaRedefine)xsoc.getItem(0);
xsot = xsr.getSchemaTypes();
assertEquals(1, xsot.getCount());
- for (Iterator i = xsot.getNames(); i.hasNext(); ) {
+ for (Iterator i = xsot.getNames(); i.hasNext();) {
QName qname = (QName)i.next();
- assertEquals(new QName("http://soapinterop.org/types",
- "person"), qname);
+ assertEquals(new QName("http://soapinterop.org/types", "person"), qname);
}
XmlSchemaComplexType xsct = null;
- for (Iterator i = xsot.getValues(); i.hasNext(); ) {
+ for (Iterator i = xsot.getValues(); i.hasNext();) {
xsct = (XmlSchemaComplexType)i.next();
}
assertNotNull(xsct);
@@ -577,11 +391,8 @@
XmlSchemaContentModel xscm = xsct.getContentModel();
assertNotNull(xscm);
- XmlSchemaComplexContentExtension xscce =
- (XmlSchemaComplexContentExtension)xscm.getContent();
- assertEquals(new QName("http://soapinterop.org/types",
- "person"),
- xscce.getBaseTypeName());
+ XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension)xscm.getContent();
+ assertEquals(new QName("http://soapinterop.org/types", "person"), xscce.getBaseTypeName());
XmlSchemaSequence xsp = (XmlSchemaSequence)xscce.getParticle();
assertNotNull(xsp);
@@ -594,9 +405,7 @@
xse = (XmlSchemaElement)c.getItem(i);
}
assertEquals("id", xse.getName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema",
- "string"),
- xse.getSchemaTypeName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"), xse.getSchemaTypeName());
}
-}
\ No newline at end of file
+}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SequenceTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SequenceTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SequenceTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SequenceTest.java Sun Dec 14 15:18:54 2008
@@ -53,45 +53,31 @@
/**
* This method will test the sequence - the min and max occurences.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testChoice() throws Exception {
/*
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <element name="computer">
- <complexType>
- <sequence minOccurs="4" maxOccurs="50">
- <element name="desktop" type="string"/>
- <element name="laptop" type="string"/>
- </sequence>
- </complexType>
- </element>
-
- </schema>
- */
-
- QName computerElementQname = new QName("http://soapinterop.org/types",
- "computer");
+ * <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ * xmlns:tns="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/types"> <element
+ * name="computer"> <complexType> <sequence minOccurs="4" maxOccurs="50"> <element name="desktop"
+ * type="string"/> <element name="laptop" type="string"/> </sequence> </complexType> </element>
+ * </schema>
+ */
+ QName computerElementQname = new QName("http://soapinterop.org/types", "computer");
InputStream is = new FileInputStream(Resources.asURI("sequence.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
schemaCol.read(new StreamSource(is), null);
- QName WRONG_QNAME = new QName("http://soapinterop.org/types",
- "machine");
+ QName WRONG_QNAME = new QName("http://soapinterop.org/types", "machine");
XmlSchemaElement elem = schemaCol.getElementByQName(WRONG_QNAME);
assertNull(elem);
elem = schemaCol.getElementByQName(computerElementQname);
assertEquals("computer", elem.getName());
- assertEquals(new QName("http://soapinterop.org/types", "computer"),
- elem.getQName());
+ assertEquals(new QName("http://soapinterop.org/types", "computer"), elem.getQName());
XmlSchemaComplexType cType = (XmlSchemaComplexType)elem.getSchemaType();
assertNotNull(cType);
@@ -99,9 +85,9 @@
XmlSchemaSequence sequence = (XmlSchemaSequence)cType.getParticle();
assertNotNull(sequence);
- //values from the XML file
- assertEquals(sequence.getMinOccurs(),4);
- assertEquals(sequence.getMaxOccurs(),50);
+ // values from the XML file
+ assertEquals(sequence.getMinOccurs(), 4);
+ assertEquals(sequence.getMaxOccurs(), 50);
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentExtensionTest.java Sun Dec 14 15:18:54 2008
@@ -50,35 +50,21 @@
/**
* This method will test the simple content extension.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testSimpleContentExtension() throws Exception {
/*
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types"
- attributeFormDefault="qualified">
-
- <element name="height">
- <complexType>
- <simpleContent>
- <extension base="integer">
- <attribute name="units" type="string" use="required"/>
- <attribute name="id" type="integer" use="required" default="001"/>
- <attribute name="desc" type="decimal" fixed="1.1"/>
- </extension>
- </simpleContent>
- </complexType>
- </element>
+ * <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ * xmlns:tns="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/types"
+ * attributeFormDefault="qualified"> <element name="height"> <complexType> <simpleContent> <extension
+ * base="integer"> <attribute name="units" type="string" use="required"/> <attribute name="id"
+ * type="integer" use="required" default="001"/> <attribute name="desc" type="decimal" fixed="1.1"/>
+ * </extension> </simpleContent> </complexType> </element> </schema>
+ */
- </schema>
- */
-
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
- "height");
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "height");
InputStream is = new FileInputStream(Resources.asURI("simplecontentextension.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
@@ -86,19 +72,16 @@
XmlSchemaElement elem = schema.getElementByName(ELEMENT_QNAME);
assertNotNull(elem);
assertEquals("height", elem.getName());
- assertEquals(new QName("http://soapinterop.org/types", "height"),
- elem.getQName());
+ assertEquals(new QName("http://soapinterop.org/types", "height"), elem.getQName());
XmlSchemaComplexType xsct = (XmlSchemaComplexType)elem.getSchemaType();
assertNotNull(xsct);
XmlSchemaSimpleContent xssc = (XmlSchemaSimpleContent)xsct.getContentModel();
assertNotNull(xssc);
-
- XmlSchemaSimpleContentExtension xssce
- = (XmlSchemaSimpleContentExtension)xssc.getContent();
+
+ XmlSchemaSimpleContentExtension xssce = (XmlSchemaSimpleContentExtension)xssc.getContent();
assertNotNull(xssce);
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
- xssce.getBaseTypeName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"), xssce.getBaseTypeName());
XmlSchemaObjectCollection xsoc = xssce.getAttributes();
assertEquals(3, xsoc.getCount());
@@ -111,26 +94,22 @@
XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.getItem(i);
String name = xsa.getName();
if (name.equals("units")) {
- assertEquals(new QName("http://soapinterop.org/types", "units"),
- xsa.getQName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
- xsa.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "units"), xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"), xsa.getSchemaTypeName());
assertNull(xsa.getDefaultValue());
assertEquals("required", xsa.getUse().getValue());
assertNull(xsa.getFixedValue());
} else if (name.equals("id")) {
- assertEquals(new QName("http://soapinterop.org/types", "id"),
- xsa.getQName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
- xsa.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "id"), xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"), xsa
+ .getSchemaTypeName());
assertEquals("001", xsa.getDefaultValue());
assertEquals("required", xsa.getUse().getValue());
assertNull(xsa.getFixedValue());
} else if (name.equals("desc")) {
- assertEquals(new QName("http://soapinterop.org/types", "desc"),
- xsa.getQName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "decimal"),
- xsa.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "desc"), xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "decimal"), xsa
+ .getSchemaTypeName());
assertEquals("none", xsa.getUse().getValue());
assertEquals("1.1", xsa.getFixedValue());
} else {
@@ -139,10 +118,8 @@
s.remove(name);
}
- assertTrue("The set should have been empty, but instead contained: "
- + s + ".",
- s.isEmpty());
+ assertTrue("The set should have been empty, but instead contained: " + s + ".", s.isEmpty());
}
-}
\ No newline at end of file
+}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/SimpleContentRestrictionTest.java Sun Dec 14 15:18:54 2008
@@ -50,58 +50,36 @@
/**
* This method will test the simple content restriction.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testSimpleContentRestriction() throws Exception {
/*
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types"
- attributeFormDefault="qualified">
-
- <simpleType name="drinksize">
- <restriction base="string">
- <enumeration value="small"/>
- <enumeration value="medium"/>
- <enumeration value="large"/>
- </restriction>
- </simpleType>
-
- <complexType name="dietdrinksize">
- <simpleContent>
- <restriction base="tns:drinksize">
- <enumeration value="small"/>
- <enumeration value="medium"/>
- <attribute name="units" type="string" use="required"/>
- <attribute name="id" type="integer" use="required" default="001"/>
- </restriction>
- </simpleContent>
- </complexType>
-
- </schema>
- */
+ * <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ * xmlns:tns="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/types"
+ * attributeFormDefault="qualified"> <simpleType name="drinksize"> <restriction base="string">
+ * <enumeration value="small"/> <enumeration value="medium"/> <enumeration value="large"/>
+ * </restriction> </simpleType> <complexType name="dietdrinksize"> <simpleContent> <restriction
+ * base="tns:drinksize"> <enumeration value="small"/> <enumeration value="medium"/> <attribute
+ * name="units" type="string" use="required"/> <attribute name="id" type="integer" use="required"
+ * default="001"/> </restriction> </simpleContent> </complexType> </schema>
+ */
- QName TYPE_QNAME = new QName("http://soapinterop.org/types",
- "dietdrinksize");
+ QName TYPE_QNAME = new QName("http://soapinterop.org/types", "dietdrinksize");
InputStream is = new FileInputStream(Resources.asURI("screstriction.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
- XmlSchemaComplexType xsct =
- (XmlSchemaComplexType)schema.getTypeByName(TYPE_QNAME);
+ XmlSchemaComplexType xsct = (XmlSchemaComplexType)schema.getTypeByName(TYPE_QNAME);
assertNotNull(xsct);
XmlSchemaSimpleContent xssc = (XmlSchemaSimpleContent)xsct.getContentModel();
assertNotNull(xssc);
-
- XmlSchemaSimpleContentRestriction xsscr
- = (XmlSchemaSimpleContentRestriction)xssc.getContent();
+
+ XmlSchemaSimpleContentRestriction xsscr = (XmlSchemaSimpleContentRestriction)xssc.getContent();
assertNotNull(xsscr);
- assertEquals(new QName("http://soapinterop.org/types", "drinksize"),
- xsscr.getBaseTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "drinksize"), xsscr.getBaseTypeName());
XmlSchemaObjectCollection xsoc = xsscr.getAttributes();
assertNotNull(xsoc);
assertEquals(2, xsoc.getCount());
@@ -113,18 +91,15 @@
XmlSchemaAttribute xsa = (XmlSchemaAttribute)xsoc.getItem(i);
String name = xsa.getName();
if (name.equals("units")) {
- assertEquals(new QName("http://soapinterop.org/types", "units"),
- xsa.getQName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"),
- xsa.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "units"), xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "string"), xsa.getSchemaTypeName());
assertNull(xsa.getDefaultValue());
assertEquals("required", xsa.getUse().getValue());
assertNull(xsa.getFixedValue());
} else if (name.equals("id")) {
- assertEquals(new QName("http://soapinterop.org/types", "id"),
- xsa.getQName());
- assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"),
- xsa.getSchemaTypeName());
+ assertEquals(new QName("http://soapinterop.org/types", "id"), xsa.getQName());
+ assertEquals(new QName("http://www.w3.org/2001/XMLSchema", "integer"), xsa
+ .getSchemaTypeName());
assertEquals("001", xsa.getDefaultValue());
assertEquals("required", xsa.getUse().getValue());
assertNull(xsa.getFixedValue());
@@ -133,10 +108,8 @@
}
assertTrue(s.remove(name));
}
- assertTrue("The set should have been empty, but instead contained: "
- + s + ".",
- s.isEmpty());
-
+ assertTrue("The set should have been empty, but instead contained: " + s + ".", s.isEmpty());
+
XmlSchemaObjectCollection xsoc2 = xsscr.getFacets();
assertNotNull(xsoc2);
assertEquals(2, xsoc2.getCount());
@@ -145,19 +118,15 @@
s.add("small");
s.add("medium");
for (int i = 0; i < xsoc2.getCount(); i++) {
- XmlSchemaEnumerationFacet xsef =
- (XmlSchemaEnumerationFacet)xsoc2.getItem(i);
+ XmlSchemaEnumerationFacet xsef = (XmlSchemaEnumerationFacet)xsoc2.getItem(i);
String value = (String)xsef.getValue();
if (!(value.equals("small") || value.equals("medium"))) {
- fail("Unexpected enumeration value of \"" + value
- + "\" found.");
+ fail("Unexpected enumeration value of \"" + value + "\" found.");
}
assertTrue(s.remove(value));
}
- assertTrue("The set should have been empty, but instead contained: "
- + s + ".",
- s.isEmpty());
+ assertTrue("The set should have been empty, but instead contained: " + s + ".", s.isEmpty());
}
-}
\ No newline at end of file
+}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestForwardRefs.java Sun Dec 14 15:18:54 2008
@@ -30,10 +30,9 @@
/**
*/
public class TestForwardRefs extends TestCase {
-
+
public void testForwardRefs() throws Exception {
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
- "attrTest");
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "attrTest");
InputStream is = new FileInputStream(Resources.asURI("forwardRef.xsd"));
XmlSchemaCollection schema = new XmlSchemaCollection();
schema.read(new StreamSource(is), null);
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestLocalUnnamedSimpleType.java Sun Dec 14 15:18:54 2008
@@ -29,26 +29,18 @@
* TestElementForm
*/
public class TestLocalUnnamedSimpleType extends TestCase {
- String schemaXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"\n" +
- "targetNamespace=\"http://finance.example.com/CreditCardFaults/xsd\"\n" +
- "xmlns:tns=\"http://finance.example.com/CreditCardFaults/xsd\"\n" +
- "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- "xsi:schemaLocation=\"http://www.w3.org/2001/XMLSchema\n" +
- " http://www.w3.org/2001/XMLSchema.xsd\">\n" +
- "\n" +
- "<element name=\"tns:CreditCardNumber\" type=\"string\"></element>\n" +
- "\n" +
- "<element name=\"tns:CreditCardType\">\n" +
- "<simpleType>\n" +
- "<restriction base=\"string\">\n" +
- "<enumeration value=\"AMEX\" />\n" +
- "<enumeration value=\"MASTERCARD\" />\n" +
- "<enumeration value=\"VISA\" />\n" +
- "</restriction>\n" +
- "</simpleType>\n" +
- "</element>\n" +
- "</schema> ";
+ String schemaXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\"\n"
+ + "targetNamespace=\"http://finance.example.com/CreditCardFaults/xsd\"\n"
+ + "xmlns:tns=\"http://finance.example.com/CreditCardFaults/xsd\"\n"
+ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+ + "xsi:schemaLocation=\"http://www.w3.org/2001/XMLSchema\n"
+ + " http://www.w3.org/2001/XMLSchema.xsd\">\n" + "\n"
+ + "<element name=\"tns:CreditCardNumber\" type=\"string\"></element>\n" + "\n"
+ + "<element name=\"tns:CreditCardType\">\n" + "<simpleType>\n"
+ + "<restriction base=\"string\">\n" + "<enumeration value=\"AMEX\" />\n"
+ + "<enumeration value=\"MASTERCARD\" />\n" + "<enumeration value=\"VISA\" />\n"
+ + "</restriction>\n" + "</simpleType>\n" + "</element>\n" + "</schema> ";
public void testLocalUnnamedSimpleType() throws Exception {
XmlSchemaCollection schema = new XmlSchemaCollection();
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestSimpleRestriction.java Sun Dec 14 15:18:54 2008
@@ -32,10 +32,8 @@
public class TestSimpleRestriction extends TestCase {
public void testSimpleRestriction() throws Exception {
- QName TYPE_QNAME = new QName("http://soapinterop.org/types",
- "layoutComponentType");
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
- "foo");
+ QName TYPE_QNAME = new QName("http://soapinterop.org/types", "layoutComponentType");
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "foo");
InputStream is = new FileInputStream(Resources.asURI("SimpleContentRestriction.xsd"));
XmlSchemaCollection schema = new XmlSchemaCollection();
@@ -52,15 +50,16 @@
}
public void testSimpleTypeRestrictionWithoutNamespace() throws Exception {
- InputStream is = new FileInputStream(Resources.asURI("includedWithoutNamespace.xsd"));
- XmlSchemaCollection schema = new XmlSchemaCollection();
- schema.read(new StreamSource(is), null);
- XmlSchemaType principalId = schema.getTypeByQName(new QName("", "XdwsPrincipalId"));
- assertNotNull(principalId);
- XmlSchemaSimpleType groupId = (XmlSchemaSimpleType)schema.getTypeByQName(new QName("", "XdwsGroupId"));
- assertNotNull(groupId);
- QName baseName = ((XmlSchemaSimpleTypeRestriction)groupId.getContent()).getBaseTypeName();
+ InputStream is = new FileInputStream(Resources.asURI("includedWithoutNamespace.xsd"));
+ XmlSchemaCollection schema = new XmlSchemaCollection();
+ schema.read(new StreamSource(is), null);
+ XmlSchemaType principalId = schema.getTypeByQName(new QName("", "XdwsPrincipalId"));
+ assertNotNull(principalId);
+ XmlSchemaSimpleType groupId = (XmlSchemaSimpleType)schema
+ .getTypeByQName(new QName("", "XdwsGroupId"));
+ assertNotNull(groupId);
+ QName baseName = ((XmlSchemaSimpleTypeRestriction)groupId.getContent()).getBaseTypeName();
- assertEquals(principalId.getQName(), baseName);
+ assertEquals(principalId.getQName(), baseName);
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TestUnqualifiedSchema.java Sun Dec 14 15:18:54 2008
@@ -29,35 +29,32 @@
public class TestUnqualifiedSchema extends TestCase {
-
public void testUnqualifiedSchemas() throws Exception {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
- Document doc = documentBuilderFactory.newDocumentBuilder().
- parse(Resources.asURI("unqualifiedTypes.xsd"));
+ Document doc = documentBuilderFactory.newDocumentBuilder().parse(
+ Resources
+ .asURI("unqualifiedTypes.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema s = schemaCol.read(doc.getDocumentElement());
assertNotNull(s);
- XmlSchemaElement e=s.getElementByName(new QName("http://soapinterop.org/xsd","complexElt") );
- XmlSchemaComplexType t =(XmlSchemaComplexType)e.getSchemaType();
+ XmlSchemaElement e = s.getElementByName(new QName("http://soapinterop.org/xsd", "complexElt"));
+ XmlSchemaComplexType t = (XmlSchemaComplexType)e.getSchemaType();
assertNotNull(t);
XmlSchemaSequence seq = (XmlSchemaSequence)t.getParticle();
XmlSchemaObjectCollection items = seq.getItems();
Iterator iterator = items.getIterator();
while (iterator.hasNext()) {
- XmlSchemaElement elt2 = (XmlSchemaElement) iterator.next();
+ XmlSchemaElement elt2 = (XmlSchemaElement)iterator.next();
System.out.println(elt2.getQName());
XmlSchemaType schemaType2 = elt2.getSchemaType();
assertNotNull(schemaType2);
}
-
-
}
-
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasRefTest.java Sun Dec 14 15:18:54 2008
@@ -32,23 +32,25 @@
public class TwoSchemasRefTest extends TestCase {
- public void testTwoSchemas() throws Exception{
+ public void testTwoSchemas() throws Exception {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
- Document doc = documentBuilderFactory.newDocumentBuilder().
- parse(Resources.asURI("twoSchemas-ref.wsdl"));
+ Document doc = documentBuilderFactory.newDocumentBuilder().parse(
+ Resources
+ .asURI("twoSchemas-ref.wsdl"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- NodeList schemaNodes = doc.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema","schema");
+ NodeList schemaNodes = doc.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "schema");
for (int j = 0; j < schemaNodes.getLength(); j++) {
- Node schemaNode = schemaNodes.item(j);
- if("schema".equals(schemaNode.getLocalName())){
- schemaCol.read((Element)schemaNode);
- }
+ Node schemaNode = schemaNodes.item(j);
+ if ("schema".equals(schemaNode.getLocalName())) {
+ schemaCol.read((Element)schemaNode);
+ }
}
- XmlSchemaElement elementByQName = schemaCol.getElementByQName(new QName("http://tns.demo.org", "elem1"));
+ XmlSchemaElement elementByQName = schemaCol.getElementByQName(new QName("http://tns.demo.org",
+ "elem1"));
assertNotNull(elementByQName);
-
+
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/TwoSchemasTest.java Sun Dec 14 15:18:54 2008
@@ -31,22 +31,21 @@
public class TwoSchemasTest extends TestCase {
- public void testTwoSchemas() throws Exception{
+ public void testTwoSchemas() throws Exception {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
- Document doc = documentBuilderFactory.newDocumentBuilder().
- parse(Resources.asURI("twoSchemas.wsdl"));
+ Document doc = documentBuilderFactory.newDocumentBuilder().parse(Resources.asURI("twoSchemas.wsdl"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- NodeList schemaNodes = doc.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema","schema");
+ NodeList schemaNodes = doc.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "schema");
for (int j = 0; j < schemaNodes.getLength(); j++) {
- Node schemaNode = schemaNodes.item(j);
- if("schema".equals(schemaNode.getLocalName())){
- schemaCol.read((Element)schemaNode);
- }
+ Node schemaNode = schemaNodes.item(j);
+ if ("schema".equals(schemaNode.getLocalName())) {
+ schemaCol.read((Element)schemaNode);
+ }
}
-
- assertNotNull(schemaCol.getElementByQName(new QName("http://tns.demo.org","elem1")));
+
+ assertNotNull(schemaCol.getElementByQName(new QName("http://tns.demo.org", "elem1")));
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/UnionTest.java Sun Dec 14 15:18:54 2008
@@ -50,56 +50,42 @@
/**
* This method will test the union.
- *
+ *
* @throws Exception Any exception encountered
*/
public void testUnion() throws Exception {
/*
- <schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:tns="http://soapinterop.org/types"
- targetNamespace="http://soapinterop.org/types">
-
- <element name="unionTest">
- <simpleType>
- <union memberTypes="float decimal"/>
- </simpleType>
- </element>
+ * <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ * xmlns:tns="http://soapinterop.org/types" targetNamespace="http://soapinterop.org/types"> <element
+ * name="unionTest"> <simpleType> <union memberTypes="float decimal"/> </simpleType> </element>
+ * </schema>
+ */
- </schema>
- */
-
- QName ELEMENT_QNAME = new QName("http://soapinterop.org/types",
- "unionTest");
+ QName ELEMENT_QNAME = new QName("http://soapinterop.org/types", "unionTest");
InputStream is = new FileInputStream(Resources.asURI("union.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
schemaCol.read(new StreamSource(is), null);
-
XmlSchemaElement elem = schemaCol.getElementByQName(ELEMENT_QNAME);
assertNotNull(elem);
assertEquals("unionTest", elem.getName());
- assertEquals(new QName("http://soapinterop.org/types", "unionTest"),
- elem.getQName());
+ assertEquals(new QName("http://soapinterop.org/types", "unionTest"), elem.getQName());
XmlSchemaSimpleType simpleType = (XmlSchemaSimpleType)elem.getSchemaType();
assertNotNull(simpleType);
- XmlSchemaSimpleTypeUnion xsstu =
- (XmlSchemaSimpleTypeUnion)simpleType.getContent();
+ XmlSchemaSimpleTypeUnion xsstu = (XmlSchemaSimpleTypeUnion)simpleType.getContent();
assertNotNull(xsstu);
QName[] qname = xsstu.getMemberTypesQNames();
Set s = new HashSet();
s.add(new QName("http://www.w3.org/2001/XMLSchema", "float"));
s.add(new QName("http://www.w3.org/2001/XMLSchema", "decimal"));
- for (int i = 0; i < qname.length; i++) {
- assertTrue(s.remove(qname[i]));
+ for (QName element : qname) {
+ assertTrue(s.remove(element));
}
- assertTrue("The set should have been empty, but instead contained: "
- + s + ".",
- s.isEmpty());
+ assertTrue("The set should have been empty, but instead contained: " + s + ".", s.isEmpty());
assertEquals("float decimal", xsstu.getMemberTypesSource());
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/WSCOMMONS377Test.java Sun Dec 14 15:18:54 2008
@@ -3,7 +3,6 @@
* (C) Copyright 2003-2008 Alexander Veit
*/
-
package tests;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -17,10 +16,8 @@
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-
/**
- * @author alex
- * $Revision$
+ * @author alex $Revision$
*/
public class WSCOMMONS377Test extends TestCase {
@@ -38,7 +35,8 @@
XmlSchema[] schemas = new XmlSchema[nodesSchema.getLength()];
String systemIdBase = "urn:schemas";
- for (int i = 0; i < nodesSchema.getLength(); i++)
+ for (int i = 0; i < nodesSchema.getLength(); i++) {
schemas[i] = xsColl.read((Element)nodesSchema.item(i), systemIdBase + i);
+ }
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttribute.java Sun Dec 14 15:18:54 2008
@@ -21,15 +21,13 @@
import javax.xml.namespace.QName;
/**
- * Custom Attribute class
- * The is will be with reference to the http://customattrib.org
- * namespace and will have 'customAttrib' as the name and the
- * value will be a prefix and a suffix seperated with a colon
- * see the externalAnnotations.xsd for an example schema.
+ * Custom Attribute class The is will be with reference to the http://customattrib.org namespace and will have
+ * 'customAttrib' as the name and the value will be a prefix and a suffix seperated with a colon see the
+ * externalAnnotations.xsd for an example schema.
*/
public class CustomAttribute {
- public static final QName CUSTOM_ATTRIBUTE_QNAME = new QName("http://customattrib.org","customAttrib");
+ public static final QName CUSTOM_ATTRIBUTE_QNAME = new QName("http://customattrib.org", "customAttrib");
private String prefix;
private String suffix;
@@ -49,5 +47,4 @@
this.suffix = suffix;
}
-
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeDeserializer.java Sun Dec 14 15:18:54 2008
@@ -32,27 +32,26 @@
/**
* deserialize the given element
- *
+ *
* @param schemaObject - Parent schema element
- * @param name - the QName of the element/attribute to be deserialized.
- * in the case where a deserializer is used to handle multiple elements/attributes
- * this may be useful to determine the correct deserialization
- * @param domNode - the raw DOM Node read from the source. This will be the
- * extension element itself if for an element or the extension attribute object if
- * it is an attribute
+ * @param name - the QName of the element/attribute to be deserialized. in the case where a deserializer
+ * is used to handle multiple elements/attributes this may be useful to determine the correct
+ * deserialization
+ * @param domNode - the raw DOM Node read from the source. This will be the extension element itself if
+ * for an element or the extension attribute object if it is an attribute
*/
public void deserialize(XmlSchemaObject schemaObject, QName name, Node domNode) {
- if (CustomAttribute.CUSTOM_ATTRIBUTE_QNAME.equals(name)){
- Attr attrib = (Attr)domNode;
- String value = attrib.getValue();
- //break the attrib into
- CustomAttribute customAttrib = new CustomAttribute();
- String[] strings = value.split(":");
- customAttrib.setPrefix(strings[0]);
- customAttrib.setSuffix(strings[1]);
+ if (CustomAttribute.CUSTOM_ATTRIBUTE_QNAME.equals(name)) {
+ Attr attrib = (Attr)domNode;
+ String value = attrib.getValue();
+ // break the attrib into
+ CustomAttribute customAttrib = new CustomAttribute();
+ String[] strings = value.split(":");
+ customAttrib.setPrefix(strings[0]);
+ customAttrib.setSuffix(strings[1]);
- //put this in the schema object meta info map
- schemaObject.addMetaInfo(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME,customAttrib);
- }
+ // put this in the schema object meta info map
+ schemaObject.addMetaInfo(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME, customAttrib);
+ }
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomAttributeSerializer.java Sun Dec 14 15:18:54 2008
@@ -29,24 +29,26 @@
/**
* serializer for the custom attribute
*/
-public class CustomAttributeSerializer implements ExtensionSerializer {
+public class CustomAttributeSerializer implements ExtensionSerializer {
/**
* serialize the given element
- *
- * @param schemaObject - Parent schema object.contains the extension
- * to be serialized
- * @param classOfType - The class of type to be serialized
- * @param domNode - the parent DOM Node that will ultimately be serialized. The XMLSchema
- * serialization mechanism is to create a DOM tree first and serialize it
+ *
+ * @param schemaObject - Parent schema object.contains the extension to be serialized
+ * @param classOfType - The class of type to be serialized
+ * @param domNode - the parent DOM Node that will ultimately be serialized. The XMLSchema serialization
+ * mechanism is to create a DOM tree first and serialize it
*/
public void serialize(XmlSchemaObject schemaObject, Class classOfType, Node domNode) {
Map metaInfoMap = schemaObject.getMetaInfoMap();
CustomAttribute att = (CustomAttribute)metaInfoMap.get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
Element elt = (Element)domNode;
- Attr att1 = elt.getOwnerDocument().createAttributeNS(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME.getNamespaceURI(),
- CustomAttribute.CUSTOM_ATTRIBUTE_QNAME.getLocalPart());
+ Attr att1 = elt.getOwnerDocument().createAttributeNS(
+ CustomAttribute.CUSTOM_ATTRIBUTE_QNAME
+ .getNamespaceURI(),
+ CustomAttribute.CUSTOM_ATTRIBUTE_QNAME
+ .getLocalPart());
att1.setValue(att.getPrefix() + ":" + att.getSuffix());
elt.setAttributeNodeNS(att1);
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtDeserializerTest.java Sun Dec 14 15:18:54 2008
@@ -35,38 +35,39 @@
*/
public class CustomExtDeserializerTest extends TestCase {
-
public void testDeserialization() throws Exception {
- //set the system property for the custom extension registry
- System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY,
- CustomExtensionRegistry.class.getName());
-
- //create a DOM document
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true);
- Document doc = documentBuilderFactory.newDocumentBuilder().
- parse(Resources.asURI("/external/externalAnnotations.xsd"));
-
- XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(doc,null);
- assertNotNull(schema);
-
- // get the elements and check whether their annotations are properly
- // populated
- Iterator values = schema.getElements().getValues();
- while (values.hasNext()) {
- XmlSchemaElement elt = (XmlSchemaElement) values.next();
- assertNotNull(elt);
- Map metaInfoMap = elt.getMetaInfoMap();
- assertNotNull(metaInfoMap);
-
- CustomAttribute customAttrib = (CustomAttribute)metaInfoMap.get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
- assertNotNull(customAttrib);
-
- }
-
- //remove our system property
- System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);;
+ // set the system property for the custom extension registry
+ System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY, CustomExtensionRegistry.class
+ .getName());
+
+ // create a DOM document
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ Document doc = documentBuilderFactory.newDocumentBuilder()
+ .parse(Resources.asURI("/external/externalAnnotations.xsd"));
+
+ XmlSchemaCollection schemaCol = new XmlSchemaCollection();
+ XmlSchema schema = schemaCol.read(doc, null);
+ assertNotNull(schema);
+
+ // get the elements and check whether their annotations are properly
+ // populated
+ Iterator values = schema.getElements().getValues();
+ while (values.hasNext()) {
+ XmlSchemaElement elt = (XmlSchemaElement)values.next();
+ assertNotNull(elt);
+ Map metaInfoMap = elt.getMetaInfoMap();
+ assertNotNull(metaInfoMap);
+
+ CustomAttribute customAttrib = (CustomAttribute)metaInfoMap
+ .get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
+ assertNotNull(customAttrib);
+
+ }
+
+ // remove our system property
+ System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);
+ ;
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionRegistry.java Sun Dec 14 15:18:54 2008
@@ -21,16 +21,14 @@
import org.apache.ws.commons.schema.extensions.ExtensionRegistry;
/**
- * Custom extension registry to test the functionality
- * of the extension mechanism
+ * Custom extension registry to test the functionality of the extension mechanism
*/
public class CustomExtensionRegistry extends ExtensionRegistry {
public CustomExtensionRegistry() {
- //register our custom type
- registerDeserializer(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME,new CustomAttributeDeserializer());
- registerSerializer(CustomAttribute.class,new CustomAttributeSerializer());
+ // register our custom type
+ registerDeserializer(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME, new CustomAttributeDeserializer());
+ registerSerializer(CustomAttribute.class, new CustomAttributeSerializer());
}
-
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/attrib/CustomExtensionSerializerTest.java Sun Dec 14 15:18:54 2008
@@ -38,11 +38,11 @@
public class CustomExtensionSerializerTest extends TestCase {
public void testSerialization() throws Exception {
- //set the system property for the custom extension registry
- System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY,
- CustomExtensionRegistry.class.getName());
+ // set the system property for the custom extension registry
+ System.setProperty(Constants.SystemConstants.EXTENSION_REGISTRY_KEY, CustomExtensionRegistry.class
+ .getName());
- //create a DOM document
+ // create a DOM document
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
@@ -50,42 +50,42 @@
if (documentBuilderFactory.getClass().toString().indexOf("crimson") != -1) {
return;
}
- Document doc1 = documentBuilderFactory.newDocumentBuilder().
- parse(Resources.asURI("/external/externalAnnotations.xsd"));
+ Document doc1 = documentBuilderFactory.newDocumentBuilder()
+ .parse(Resources.asURI("/external/externalAnnotations.xsd"));
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
- XmlSchema schema = schemaCol.read(doc1,null);
+ XmlSchema schema = schemaCol.read(doc1, null);
assertNotNull(schema);
- //now serialize it to a byte stream
- //and build a new document out of it
+ // now serialize it to a byte stream
+ // and build a new document out of it
ByteArrayOutputStream baos = new ByteArrayOutputStream();
schema.write(baos);
-
- Document doc2 = documentBuilderFactory.newDocumentBuilder().
- parse(new ByteArrayInputStream(baos.toByteArray()));
+ Document doc2 = documentBuilderFactory.newDocumentBuilder().parse(
+ new ByteArrayInputStream(baos
+ .toByteArray()));
schemaCol = new XmlSchemaCollection();
- schema = schemaCol.read(doc2,null);
+ schema = schemaCol.read(doc2, null);
assertNotNull(schema);
// get the elements and check whether their annotations are properly
// populated
Iterator values = schema.getElements().getValues();
while (values.hasNext()) {
- XmlSchemaElement elt = (XmlSchemaElement) values.next();
+ XmlSchemaElement elt = (XmlSchemaElement)values.next();
assertNotNull(elt);
Map metaInfoMap = elt.getMetaInfoMap();
assertNotNull(metaInfoMap);
- CustomAttribute customAttrib = (CustomAttribute)metaInfoMap.get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
+ CustomAttribute customAttrib = (CustomAttribute)metaInfoMap
+ .get(CustomAttribute.CUSTOM_ATTRIBUTE_QNAME);
assertNotNull(customAttrib);
}
-
- //remove our system property
+ // remove our system property
System.getProperties().remove(Constants.SystemConstants.EXTENSION_REGISTRY_KEY);
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElement.java Sun Dec 14 15:18:54 2008
@@ -21,15 +21,13 @@
import javax.xml.namespace.QName;
/**
- * Custom Element class
- * The is will be with reference to the http://customattrib.org
- * namespace and will have 'customElt' as the name and the
- * value will have two attributes , prefix and a suffix
- * see the externalAnnotationsElt.xsd for an example schema.
+ * Custom Element class The is will be with reference to the http://customattrib.org namespace and will have
+ * 'customElt' as the name and the value will have two attributes , prefix and a suffix see the
+ * externalAnnotationsElt.xsd for an example schema.
*/
public class CustomElement {
- public static final QName CUSTOM_ELT_QNAME = new QName("http://customattrib.org","customElt");
+ public static final QName CUSTOM_ELT_QNAME = new QName("http://customattrib.org", "customElt");
private String prefix;
private String suffix;
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementDeserializer.java Sun Dec 14 15:18:54 2008
@@ -31,25 +31,24 @@
public class CustomElementDeserializer implements ExtensionDeserializer {
/**
* deserialize the given element
- *
+ *
* @param schemaObject - Parent schema element
- * @param name - the QName of the element/attribute to be deserialized.
- * in the case where a deserializer is used to handle multiple elements/attributes
- * this may be useful to determine the correct deserialization
- * @param domNode - the raw DOM Node read from the source. This will be the
- * extension element itself if for an element or the extension attribute object if
- * it is an attribute
+ * @param name - the QName of the element/attribute to be deserialized. in the case where a deserializer
+ * is used to handle multiple elements/attributes this may be useful to determine the correct
+ * deserialization
+ * @param domNode - the raw DOM Node read from the source. This will be the extension element itself if
+ * for an element or the extension attribute object if it is an attribute
*/
public void deserialize(XmlSchemaObject schemaObject, QName name, Node domNode) {
- if (CustomElement.CUSTOM_ELT_QNAME.equals(name)){
- Element elt = (Element)domNode;
+ if (CustomElement.CUSTOM_ELT_QNAME.equals(name)) {
+ Element elt = (Element)domNode;
- CustomElement customElement = new CustomElement();
- customElement.setPrefix(elt.getAttribute("prefix"));
- customElement.setSuffix(elt.getAttribute("suffix"));
+ CustomElement customElement = new CustomElement();
+ customElement.setPrefix(elt.getAttribute("prefix"));
+ customElement.setSuffix(elt.getAttribute("suffix"));
- //put this in the schema object meta info map
- schemaObject.addMetaInfo(CustomElement.CUSTOM_ELT_QNAME,customElement);
- }
+ // put this in the schema object meta info map
+ schemaObject.addMetaInfo(CustomElement.CUSTOM_ELT_QNAME, customElement);
+ }
}
}
Modified: webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java?rev=726576&r1=726575&r2=726576&view=diff
==============================================================================
--- webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java (original)
+++ webservices/commons/trunk/modules/XmlSchema/src/test/java/tests/customext/elt/CustomElementSerializer.java Sun Dec 14 15:18:54 2008
@@ -31,22 +31,22 @@
public class CustomElementSerializer implements ExtensionSerializer {
/**
* serialize the given element
- *
- * @param schemaObject - Parent schema object.contains the extension
- * to be serialized
- * @param classOfType - The class of type to be serialized
- * @param domNode - the parent DOM Node that will ultimately be serialized. The XMLSchema
- * serialization mechanism is to create a DOM tree first and serialize it
+ *
+ * @param schemaObject - Parent schema object.contains the extension to be serialized
+ * @param classOfType - The class of type to be serialized
+ * @param domNode - the parent DOM Node that will ultimately be serialized. The XMLSchema serialization
+ * mechanism is to create a DOM tree first and serialize it
*/
public void serialize(XmlSchemaObject schemaObject, Class classOfType, Node domNode) {
- Map metaInfoMap = schemaObject.getMetaInfoMap();
- CustomElement customElt = (CustomElement)metaInfoMap.get(CustomElement.CUSTOM_ELT_QNAME);
+ Map metaInfoMap = schemaObject.getMetaInfoMap();
+ CustomElement customElt = (CustomElement)metaInfoMap.get(CustomElement.CUSTOM_ELT_QNAME);
Element elt = (Element)domNode;
- Element extElt = elt.getOwnerDocument().createElementNS(CustomElement.CUSTOM_ELT_QNAME.getNamespaceURI(),
- CustomElement.CUSTOM_ELT_QNAME.getLocalPart());
- extElt.setAttribute("prefix",customElt.getPrefix());
- extElt.setAttribute("suffix",customElt.getSuffix());
+ Element extElt = elt.getOwnerDocument()
+ .createElementNS(CustomElement.CUSTOM_ELT_QNAME.getNamespaceURI(),
+ CustomElement.CUSTOM_ELT_QNAME.getLocalPart());
+ extElt.setAttribute("prefix", customElt.getPrefix());
+ extElt.setAttribute("suffix", customElt.getSuffix());
elt.appendChild(extElt);