You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/08/13 19:42:43 UTC
svn commit: r803957 - in /cxf/branches/2.2.x-fixes: ./
rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
Author: dkulp
Date: Thu Aug 13 17:42:40 2009
New Revision: 803957
URL: http://svn.apache.org/viewvc?rev=803957&view=rev
Log:
Merged revisions 801447 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r801447 | bimargulies | 2009-08-05 18:40:05 -0400 (Wed, 05 Aug 2009) | 1 line
Merge branch 'benson' into trunk
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Aug 13 17:42:40 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
4,798654,798748-798749,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
4,798654,798748-798749,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=803957&r1=803956&r2=803957&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java (original)
+++ cxf/branches/2.2.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java Thu Aug 13 17:42:40 2009
@@ -23,6 +23,7 @@
import java.io.ByteArrayOutputStream;
import java.util.Date;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
@@ -62,6 +63,9 @@
addNamespace("a", "urn:anotherns");
addNamespace("xsi", SOAPConstants.XSI_NS);
+ }
+
+ private void defaultContext() {
context = new AegisContext();
context.initialize();
mapping = context.getTypeMapping();
@@ -69,6 +73,7 @@
@Test
public void testBean() throws Exception {
+ defaultContext();
BeanType type = new BeanType();
type.setTypeClass(SimpleBean.class);
type.setTypeMapping(mapping);
@@ -108,6 +113,7 @@
@Test
public void testBeanWithXsiType() throws Exception {
+ defaultContext();
BeanType type = new BeanType();
type.setTypeClass(SimpleBean.class);
type.setTypeMapping(mapping);
@@ -132,6 +138,8 @@
@Test
public void testUnmappedProperty() throws Exception {
+
+ defaultContext();
String ns = "urn:Bean";
BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, ns, false);
@@ -162,6 +170,7 @@
@Test
public void testAttributeMap() throws Exception {
+ defaultContext();
BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, "urn:Bean");
info.mapAttribute("howdy", new QName("urn:Bean", "howdy"));
info.mapAttribute("bleh", new QName("urn:Bean", "bleh"));
@@ -209,6 +218,7 @@
@Test
public void testAttributeMapDifferentNS() throws Exception {
+ defaultContext();
BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, "urn:Bean");
info.mapAttribute("howdy", new QName("urn:Bean2", "howdy"));
info.mapAttribute("bleh", new QName("urn:Bean2", "bleh"));
@@ -247,6 +257,7 @@
@Test
public void testNullProperties() throws Exception {
+ defaultContext();
BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, "urn:Bean");
info.setTypeMapping(mapping);
info.mapAttribute("howdy", new QName("urn:Bean", "howdy"));
@@ -300,6 +311,7 @@
@Test
public void testNillableInt() throws Exception {
+ defaultContext();
BeanTypeInfo info = new BeanTypeInfo(IntBean.class, "urn:Bean");
info.setTypeMapping(mapping);
@@ -333,10 +345,50 @@
assertTrue(int1ok);
assertTrue(int2ok);
}
+
@Test
- public void testNillableIntMinOccurs1() throws Exception {
+ public void testNillableAnnotation() throws Exception {
context = new AegisContext();
+ TypeCreationOptions config = new TypeCreationOptions();
+ config.setDefaultNillable(false);
+ config.setDefaultMinOccurs(1);
+ context.setTypeCreationOptions(config);
+ context.initialize();
+ mapping = context.getTypeMapping();
+ BeanType type = (BeanType)mapping.getTypeCreator().createType(BeanWithNillableItem.class);
+ type.setTypeClass(BeanWithNillableItem.class);
+ type.setTypeMapping(mapping);
+
+ XmlSchema schema = newXmlSchema("urn:Bean");
+ type.writeSchema(schema);
+
+ XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("BeanWithNillableItem");
+ XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
+ boolean itemFound = false;
+ boolean itemNotNillableFound = false;
+ for (int x = 0; x < seq.getItems().getCount(); x++) {
+ XmlSchemaObject o = seq.getItems().getItem(x);
+ if (o instanceof XmlSchemaElement) {
+ XmlSchemaElement oe = (XmlSchemaElement) o;
+ if ("item".equals(oe.getName())) {
+ itemFound = true;
+ assertTrue(oe.isNillable());
+ assertEquals(0, oe.getMinOccurs());
+ } else if ("itemNotNillable".equals(oe.getName())) {
+ itemNotNillableFound = true;
+ assertFalse(oe.isNillable());
+ }
+ }
+ }
+ assertTrue(itemFound);
+ assertTrue(itemNotNillableFound);
+ }
+
+
+ @Test
+ public void testNillableIntMinOccurs1() throws Exception {
+ context = new AegisContext();
TypeCreationOptions config = new TypeCreationOptions();
config.setDefaultMinOccurs(1);
config.setDefaultNillable(false);
@@ -370,9 +422,7 @@
@Test
public void testCharMappings() throws Exception {
- context = new AegisContext();
- context.initialize();
- mapping = context.getTypeMapping();
+ defaultContext();
BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
type.setTypeClass(SimpleBean.class);
@@ -403,9 +453,7 @@
@Test
public void testByteMappings() throws Exception {
- context = new AegisContext();
- context.initialize();
- mapping = context.getTypeMapping();
+ defaultContext();
BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
type.setTypeClass(SimpleBean.class);
@@ -457,6 +505,7 @@
@Test
public void testNullNonNillableWithDate() throws Exception {
+ defaultContext();
BeanTypeInfo info = new BeanTypeInfo(DateBean.class, "urn:Bean");
info.setTypeMapping(mapping);
@@ -476,8 +525,10 @@
assertInvalid("/b:root/b:date", element);
assertValid("/b:root", element);
}
+
@Test
public void testExtendedBean() throws Exception {
+ defaultContext();
BeanTypeInfo info = new BeanTypeInfo(ExtendedBean.class, "urn:Bean");
info.setTypeMapping(mapping);
@@ -495,8 +546,10 @@
Element element = writeObjectToElement(type, bean, getContext());
assertValid("/b:root/b:howdy[text()='howdy']", element);
}
+
@Test
public void testByteBean() throws Exception {
+ defaultContext();
BeanTypeInfo info = new BeanTypeInfo(ByteBean.class, "urn:Bean");
info.setTypeMapping(mapping);
@@ -530,6 +583,7 @@
}
@Test
public void testGetSetRequired() throws Exception {
+ defaultContext();
BeanType type = new BeanType();
type.setTypeClass(GoodBean.class);
type.setTypeMapping(mapping);
@@ -584,6 +638,30 @@
this.int2 = int2;
}
}
+
+ public static class BeanWithNillableItem {
+ private IntBean item;
+ private Integer itemNotNillable;
+
+ @XmlElement(nillable = true)
+ public IntBean getItem() {
+ return item;
+ }
+
+ public void setItem(IntBean item) {
+ this.item = item;
+ }
+
+ public Integer getItemNotNillable() {
+ return itemNotNillable;
+ }
+
+ public void setItemNotNillable(Integer itemNotNillable) {
+ this.itemNotNillable = itemNotNillable;
+ }
+
+
+ }
public static class ByteBean {
private byte[] data;