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());
}
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);
}
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());
}
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);
}
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);
}
Aggregations