Search in sources :

Example 11 with TypeCreationOptions

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

the class XFireTypeTest method testType.

@Test
public void testType() {
    AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, XFireBean1.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)

Example 12 with TypeCreationOptions

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

the class XFireTypeTest method testGetSetRequired.

@Test
public void testGetSetRequired() throws Exception {
    BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo", new TypeCreationOptions()));
    type.setSchemaType(new QName("urn:foo", "BadBean"));
    assertEquals(0, type.getTypeInfo().getElements().size());
}
Also used : BeanType(org.apache.cxf.aegis.type.basic.BeanType) QName(javax.xml.namespace.QName) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 13 with TypeCreationOptions

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

the class XmlParamTypeTest method setUp.

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

Example 14 with TypeCreationOptions

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

the class AegisContext method initialize.

/**
 * Initialize the context. The encodingStyleURI allows .aegis.xml files to have multiple mappings for,
 * say, SOAP 1.1 versus SOAP 1.2. Passing null uses a default URI.
 */
public void initialize() {
    // allow spring config of an alternative mapping.
    if (configuration == null) {
        configuration = new TypeCreationOptions();
    }
    if (typeMapping == null) {
        boolean defaultNillable = configuration.isDefaultNillable();
        TypeMapping baseTM = DefaultTypeMapping.createDefaultTypeMapping(defaultNillable, mtomUseXmime, enableJDOMMappings);
        if (mappingNamespaceURI == null) {
            mappingNamespaceURI = DefaultTypeMapping.DEFAULT_MAPPING_URI;
        }
        DefaultTypeMapping defaultTypeMapping = new DefaultTypeMapping(mappingNamespaceURI, baseTM);
        defaultTypeMapping.setTypeCreator(createTypeCreator());
        typeMapping = defaultTypeMapping;
    }
    processRootTypes();
}
Also used : DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions)

Example 15 with TypeCreationOptions

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

the class NoNamespaceAegisElementProvider method getAegisContext.

@Override
protected AegisContext getAegisContext(Class<?> plainClass, Type genericType) {
    AegisContext context = new AegisContext();
    context.setWriteXsiTypes(writeXsiType);
    context.setReadXsiTypes(readXsiType);
    TypeCreationOptions tco = new TypeCreationOptions();
    tco.setQualifyElements(false);
    Set<java.lang.reflect.Type> rootClasses = new HashSet<>();
    rootClasses.add(genericType);
    context.setTypeCreationOptions(tco);
    context.setRootClasses(rootClasses);
    TypeMapping baseMapping = DefaultTypeMapping.createSoap11TypeMapping(true, false, false);
    DefaultTypeMapping mapping = new DefaultTypeMapping(Constants.URI_2001_SCHEMA_XSD, baseMapping);
    TypeCreator stockTypeCreator = createTypeCreator(tco);
    mapping.setTypeCreator(stockTypeCreator);
    context.setTypeMapping(mapping);
    context.initialize();
    return context;
}
Also used : Type(java.lang.reflect.Type) DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) AegisContext(org.apache.cxf.aegis.AegisContext) DefaultTypeMapping(org.apache.cxf.aegis.type.DefaultTypeMapping) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) TypeCreationOptions(org.apache.cxf.aegis.type.TypeCreationOptions) XMLTypeCreator(org.apache.cxf.aegis.type.XMLTypeCreator) TypeCreator(org.apache.cxf.aegis.type.TypeCreator) AbstractTypeCreator(org.apache.cxf.aegis.type.AbstractTypeCreator) Java5TypeCreator(org.apache.cxf.aegis.type.java5.Java5TypeCreator) HashSet(java.util.HashSet)

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