Search in sources :

Example 16 with TypeCreationOptions

use of org.apache.cxf.aegis.type.TypeCreationOptions in project cxf by apache.

the class CollectionTest method testCollectionDTO.

@Test
public void testCollectionDTO() {
    tm = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD);
    creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);
    AegisType dto = creator.createType(CollectionDTO.class);
    Set<AegisType> deps = dto.getDependencies();
    AegisType type = deps.iterator().next();
    assertTrue(type instanceof CollectionType);
    CollectionType colType = (CollectionType) type;
    deps = dto.getDependencies();
    assertEquals(1, deps.size());
    AegisType comType = colType.getComponentType();
    assertEquals(String.class, comType.getTypeClass());
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) AegisType(org.apache.cxf.aegis.type.AegisType) CollectionType(org.apache.cxf.aegis.type.collection.CollectionType) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 17 with TypeCreationOptions

use of org.apache.cxf.aegis.type.TypeCreationOptions in project cxf by apache.

the class BeanTest method testNillableAnnotation.

@Test
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().size(); x++) {
        XmlSchemaSequenceMember o = seq.getItems().get(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);
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) AegisContext(org.apache.cxf.aegis.AegisContext) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest) Test(org.junit.Test)

Example 18 with TypeCreationOptions

use of org.apache.cxf.aegis.type.TypeCreationOptions in project cxf by apache.

the class CollectionTest method testObjectDTO.

@Test
public void testObjectDTO() {
    tm = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD);
    creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);
    AegisType dto = creator.createType(ObjectDTO.class);
    Set<AegisType> deps = dto.getDependencies();
    assertFalse(deps.isEmpty());
    AegisType type = deps.iterator().next();
    assertTrue(type instanceof CollectionType);
    CollectionType colType = (CollectionType) type;
    deps = dto.getDependencies();
    assertEquals(1, deps.size());
    AegisType comType = colType.getComponentType();
    assertEquals(Object.class, comType.getTypeClass());
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) AegisType(org.apache.cxf.aegis.type.AegisType) CollectionType(org.apache.cxf.aegis.type.collection.CollectionType) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 19 with TypeCreationOptions

use of org.apache.cxf.aegis.type.TypeCreationOptions in project cxf by apache.

the class CollectionTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    tm = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD);
    creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Before(org.junit.Before)

Example 20 with TypeCreationOptions

use of org.apache.cxf.aegis.type.TypeCreationOptions in project cxf by apache.

the class EnumTypeTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    tm = new DefaultTypeMapping();
    Java5TypeCreator creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Before(org.junit.Before)

Aggregations

TypeCreationOptions (org.apache.cxf.aegis.type.TypeCreationOptions)22 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)14 Test (org.junit.Test)14 DefaultTypeMapping (org.apache.cxf.aegis.type.DefaultTypeMapping)10 QName (javax.xml.namespace.QName)8 AegisType (org.apache.cxf.aegis.type.AegisType)8 AegisContext (org.apache.cxf.aegis.AegisContext)6 Before (org.junit.Before)6 TypeMapping (org.apache.cxf.aegis.type.TypeMapping)4 BeanType (org.apache.cxf.aegis.type.basic.BeanType)3 StringType (org.apache.cxf.aegis.type.basic.StringType)3 Context (org.apache.cxf.aegis.Context)2 XmlMappedAttributeBean (org.apache.cxf.aegis.services.XmlMappedAttributeBean)2 DefaultTypeCreator (org.apache.cxf.aegis.type.DefaultTypeCreator)2 XMLTypeCreator (org.apache.cxf.aegis.type.XMLTypeCreator)2 CollectionType (org.apache.cxf.aegis.type.collection.CollectionType)2 XmlSchema (org.apache.ws.commons.schema.XmlSchema)2 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)2 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)2 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)2