Search in sources :

Example 6 with TypeCreationOptions

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

the class MapTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    tm = new DefaultTypeMapping();
    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 7 with TypeCreationOptions

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

the class MapTest method testMapDTO.

@Test
public void testMapDTO() {
    tm = new DefaultTypeMapping();
    creator = new Java5TypeCreator();
    creator.setConfiguration(new TypeCreationOptions());
    tm.setTypeCreator(creator);
    AegisType dto = creator.createType(MapDTO.class);
    Set<AegisType> deps = dto.getDependencies();
    AegisType type = deps.iterator().next();
    assertTrue(type instanceof MapType);
    MapType mapType = (MapType) type;
    deps = dto.getDependencies();
    assertEquals(1, deps.size());
    type = mapType.getKeyType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(String.class));
    type = mapType.getValueType();
    assertNotNull(type);
    assertTrue(type.getTypeClass().isAssignableFrom(Integer.class));
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) AegisType(org.apache.cxf.aegis.type.AegisType) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) MapType(org.apache.cxf.aegis.type.collection.MapType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 8 with TypeCreationOptions

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

the class DuplicateArrayTest method testServiceStart.

@Test
public void testServiceStart() throws Exception {
    AegisDatabinding binder = new AegisDatabinding();
    JaxWsServerFactoryBean serviceFactory = new JaxWsServerFactoryBean();
    serviceFactory.getServiceFactory().setDataBinding(binder);
    TypeCreationOptions configuration = binder.getAegisContext().getTypeCreationOptions();
    configuration.setDefaultMinOccurs(1);
    configuration.setDefaultNillable(false);
    binder.getAegisContext().setWriteXsiTypes(true);
    serviceFactory.setAddress("local://DuplicateArrayService");
    serviceFactory.setServiceBean(new DuplicateArrayServiceBean());
    serviceFactory.setServiceClass(DuplicateArrayService.class);
    Document doc = this.getWSDLDocument(serviceFactory.create());
    this.assertValid("//wsdl:definitions/wsdl:types" + "/xsd:schema[@targetNamespace='http://cxf.apache.org/arrays']" + "/xsd:complexType[@name='ArrayOfAnyType']", doc.getDocumentElement());
}
Also used : AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Document(org.w3c.dom.Document) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 9 with TypeCreationOptions

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

the class ConfigurationTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    AegisContext context = new AegisContext();
    config = new TypeCreationOptions();
    context.setTypeCreationOptions(config);
    context.initialize();
    XMLTypeCreator creator = new XMLTypeCreator();
    creator.setConfiguration(config);
    Java5TypeCreator next = new Java5TypeCreator();
    next.setConfiguration(config);
    creator.setNextCreator(next);
    tm = (DefaultTypeMapping) context.getTypeMapping();
    tm.setTypeCreator(creator);
}
Also used : AegisContext(org.apache.cxf.aegis.AegisContext) XMLTypeCreator(org.apache.cxf.aegis.type.XMLTypeCreator) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Before(org.junit.Before)

Example 10 with TypeCreationOptions

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

the class AnnotatedTypeTest method testType.

@Test
public void testType() {
    AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, AnnotatedBean1.class, "urn:foo", new TypeCreationOptions());
    Iterator<QName> elements = info.getElements().iterator();
    assertTrue(elements.hasNext());
    QName element = elements.next();
    assertTrue(elements.hasNext());
    AegisType custom = info.getType(element);
    if ("bogusProperty".equals(element.getLocalPart())) {
        assertTrue(custom instanceof StringType);
    } else if ("elementProperty".equals(element.getLocalPart())) {
        assertTrue(custom instanceof CustomStringType);
    } else {
        fail("Unexpected element name: " + element.getLocalPart());
    }
    element = elements.next();
    assertFalse(elements.hasNext());
    custom = info.getType(element);
    if ("bogusProperty".equals(element.getLocalPart())) {
        assertTrue(custom instanceof StringType);
    } else if ("elementProperty".equals(element.getLocalPart())) {
        assertTrue(custom instanceof CustomStringType);
    } else {
        fail("Unexpected element name: " + element.getLocalPart());
    }
    Iterator<QName> atts = info.getAttributes().iterator();
    assertTrue(atts.hasNext());
    atts.next();
    assertFalse(atts.hasNext());
    assertTrue(info.isExtensibleElements());
    assertTrue(info.isExtensibleAttributes());
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) StringType(org.apache.cxf.aegis.type.basic.StringType) QName(javax.xml.namespace.QName) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

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