Author: bimargulies
Date: Thu Feb 26 14:10:07 2009
New Revision: 748159
URL: http://svn.apache.org/viewvc?rev=748159&view=rev
Log:
CXF-2057, once more.
Added:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/
- copied from r747648,
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/
Removed:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/date/
Modified:
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/BeanWithDate.java
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/TestDateMapping.java
Modified:
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java?rev=748159&r1=748158&r2=748159&view=diff
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
(original)
+++
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
Thu Feb 26 14:10:07 2009
@@ -105,13 +105,35 @@
if (e != null) {
+
+ QName mappedType = NamespaceHelper.createQName(e,
+
DOMUtils.getAttributeValueEmptyNull(e, "typeName"),
+
getDefaultNamespace());
+ if (mappedType != null) {
+ mapTypeName(mappedName, mappedType);
+ }
+
+ /*
+ * Whenever we create a type object, it has to have a schema type.
If we created a custom type
+ * object out of thin air here, we've may have a problem. If
"typeName" was specified, then then
+ * we know the mapping. But if mappedName was not specified, then
the typeName will come from the
+ * type mapping, so we have to ask it. And if some other type
creator has something to say about
+ * it, we'll get it wrong.
+ */
+
+
String explicitTypeName = DOMUtils.getAttributeValueEmptyNull(e,
"type");
if (explicitTypeName != null) {
try {
Class<?> typeClass =
ClassLoaderUtils.loadClass(explicitTypeName,
XMLBeanTypeInfo.class);
- Type typeObject = (Type) typeClass.newInstance();
- mapType(mappedName, typeObject);
+ Type customTypeObject = (Type) typeClass.newInstance();
+ mapType(mappedName, customTypeObject);
+ QName schemaType = mappedType;
+ if (schemaType == null) {
+ schemaType =
getTypeMapping().getTypeQName(pd.getPropertyType());
+ }
+ customTypeObject.setSchemaType(schemaType);
} catch (ClassNotFoundException e1) {
//
} catch (InstantiationException e2) {
@@ -121,13 +143,6 @@
}
}
- QName mappedType = NamespaceHelper.createQName(e,
-
DOMUtils.getAttributeValueEmptyNull(e, "typeName"),
-
getDefaultNamespace());
- if (mappedType != null) {
- mapTypeName(mappedName, mappedType);
- }
-
String nillableVal = DOMUtils.getAttributeValueEmptyNull(e,
"nillable");
if (nillableVal != null && nillableVal.length() > 0) {
ensurePropertyInfo(mappedName).setNillable(Boolean.valueOf(nillableVal).booleanValue());
Modified:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/BeanWithDate.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/BeanWithDate.java?rev=748159&r1=747648&r2=748159&view=diff
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/BeanWithDate.java
(original)
+++
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/BeanWithDate.java
Thu Feb 26 14:10:07 2009
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.cxf.aegis.date;
+package org.apache.cxf.aegis.xmlconfig;
/**
* class used to test remapping the schema type of date.
Modified:
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/TestDateMapping.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/TestDateMapping.java?rev=748159&r1=747648&r2=748159&view=diff
==============================================================================
---
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/TestDateMapping.java
(original)
+++
cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/xmlconfig/TestDateMapping.java
Thu Feb 26 14:10:07 2009
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.cxf.aegis.date;
+package org.apache.cxf.aegis.xmlconfig;
import java.io.StringWriter;
import java.util.HashSet;
@@ -30,6 +30,7 @@
import org.apache.cxf.aegis.AegisWriter;
import org.apache.cxf.aegis.type.Type;
import org.apache.cxf.test.TestUtilities;
+import org.apache.ws.commons.schema.XmlSchema;
import org.junit.Before;
import org.junit.Test;
@@ -65,5 +66,21 @@
xmlWriter.close();
// an absence of exception is success here.
}
-
+
+ @Test
+ public void testWriteCustomTypeSchemaType() throws Exception {
+ context = new AegisContext();
+ Set<Class<?>> rootClasses = new HashSet<Class<?>>();
+ rootClasses.add(BeanWithDate.class);
+ context.setRootClasses(rootClasses);
+ context.initialize();
+ BeanWithDate bean = new BeanWithDate();
+ java.sql.Date date = new java.sql.Date(0);
+ bean.setFig(date);
+ Type sbType = context.getTypeMapping().getType(bean.getClass());
+ XmlSchema root = new XmlSchema(); // dummy to put schema in.
+ /* will explode if the type object created for the custom mapping isn't
fully initialized.
+ */
+ sbType.writeSchema(root);
+ }
}