Search in sources :

Example 6 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class ConfigurationTest method testNillableDefaultFalse.

@Test
public void testNillableDefaultFalse() throws Exception {
    config.setDefaultNillable(false);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertFalse(info.isNillable(new QName(info.getDefaultNamespace(), "bogusProperty")));
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) QName(javax.xml.namespace.QName) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 7 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class ConfigurationTest method testNillableDefaultTrue.

@Test
public void testNillableDefaultTrue() throws Exception {
    config.setDefaultNillable(true);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertTrue(info.isNillable(new QName(info.getDefaultNamespace(), "bogusProperty")));
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) QName(javax.xml.namespace.QName) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 8 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class ConfigurationTest method testMinOccursDefault1.

@Test
public void testMinOccursDefault1() throws Exception {
    config.setDefaultMinOccurs(1);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertEquals(info.getMinOccurs(new QName(info.getDefaultNamespace(), "bogusProperty")), 1);
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) QName(javax.xml.namespace.QName) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 9 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class NoDefaultConstructorBeanType method readObject.

@Override
public Object readObject(MessageReader reader, Context context) throws DatabindingException {
    BeanTypeInfo inf = getTypeInfo();
    try {
        String id = null;
        String name = null;
        // Read child elements
        while (reader.hasMoreElementReaders()) {
            MessageReader childReader = reader.getNextElementReader();
            if (childReader.isXsiNil()) {
                childReader.readToEnd();
                continue;
            }
            QName qName = childReader.getName();
            AegisType defaultType = inf.getType(qName);
            AegisType type = TypeUtil.getReadType(childReader.getXMLStreamReader(), context.getGlobalContext(), defaultType);
            if (type != null) {
                String value = (String) type.readObject(childReader, context);
                if ("id".equals(qName.getLocalPart())) {
                    id = value;
                } else if ("name".equals(qName.getLocalPart())) {
                    name = value;
                }
            } else {
                childReader.readToEnd();
            }
        }
        return new NoDefaultConstructorBeanImpl(id, name);
    } catch (IllegalArgumentException e) {
        throw new DatabindingException("Illegal argument. " + e.getMessage(), e);
    }
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) DatabindingException(org.apache.cxf.aegis.DatabindingException) AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) MessageReader(org.apache.cxf.aegis.xml.MessageReader) NoDefaultConstructorBeanImpl(org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanImpl)

Example 10 with BeanTypeInfo

use of org.apache.cxf.aegis.type.basic.BeanTypeInfo in project cxf by apache.

the class SoapArrayTypeTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    // address type
    BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
    addressInfo.setTypeMapping(mapping);
    StructType addressType = new StructType(addressInfo);
    addressType.setTypeClass(Address.class);
    addressType.setSchemaType(new QName("urn:Bean", "address"));
    mapping.register(addressType);
    // purchase order type
    BeanTypeInfo poInfo = new BeanTypeInfo(PurchaseOrder.class, "urn:Bean");
    poInfo.setTypeMapping(mapping);
    StructType purchaseOrderType = new StructType(poInfo);
    purchaseOrderType.setTypeClass(PurchaseOrder.class);
    purchaseOrderType.setTypeMapping(mapping);
    purchaseOrderType.setSchemaType(new QName("urn:Bean", "po"));
    mapping.register(purchaseOrderType);
    // String[][][]
    SoapArrayType arrayOfString = createArrayType(String[].class, new QName("urn:Bean", "SOAPArrayOfString"));
    mapping.register(arrayOfString);
    SoapArrayType arrayOfArrayOfString = createArrayType(String[][].class, new QName("urn:Bean", "SOAPArrayOfArrayOfString"));
    mapping.register(arrayOfArrayOfString);
    SoapArrayType arrayOfArrayOfArrayOfString = createArrayType(String[][][].class, new QName("urn:Bean", "SOAPArrayOfArrayOfArrayOfString"));
    mapping.register(arrayOfArrayOfArrayOfString);
    // int[][]
    SoapArrayType arrayOfInt = createArrayType(int[].class, new QName("urn:Bean", "SOAPArrayOfInt"));
    mapping.register(arrayOfInt);
    SoapArrayType arrayOfArrayOfInt = createArrayType(int[][].class, new QName("urn:Bean", "SOAPArrayOfArrayOfInt"));
    mapping.register(arrayOfArrayOfInt);
    // Object[]
    SoapArrayType arrayOfAddress = createArrayType(Address[].class, new QName("urn:Bean", "SOAPArrayOfAddress"));
    mapping.register(arrayOfAddress);
    SoapArrayType arrayOfAny = createArrayType(Object[].class, new QName("urn:Bean", "SOAPArrayOfAny"));
    mapping.register(arrayOfAny);
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) QName(javax.xml.namespace.QName)

Aggregations

BeanTypeInfo (org.apache.cxf.aegis.type.basic.BeanTypeInfo)13 QName (javax.xml.namespace.QName)10 AegisType (org.apache.cxf.aegis.type.AegisType)8 BeanType (org.apache.cxf.aegis.type.basic.BeanType)8 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)7 Test (org.junit.Test)7 DatabindingException (org.apache.cxf.aegis.DatabindingException)3 AegisContext (org.apache.cxf.aegis.AegisContext)2 MessageReader (org.apache.cxf.aegis.xml.MessageReader)2 NoDefaultConstructorBeanImpl (org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanImpl)1 NoDefaultConstructorBeanKeyImpl (org.apache.cxf.aegis.custom.service.NoDefaultConstructorBeanKeyImpl)1 TypeMapping (org.apache.cxf.aegis.type.TypeMapping)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1