Search in sources :

Example 26 with AegisType

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

the class TestDateMapping method testWriteCustomTypeSchemaType.

@Test
public void testWriteCustomTypeSchemaType() throws Exception {
    context = new AegisContext();
    Set<java.lang.reflect.Type> rootClasses = new HashSet<>();
    rootClasses.add(BeanWithDate.class);
    context.setRootClasses(rootClasses);
    context.initialize();
    BeanWithDate bean = new BeanWithDate();
    java.sql.Date date = new java.sql.Date(0);
    bean.setFig(date);
    AegisType sbType = context.getTypeMapping().getType(bean.getClass());
    // dummy to put schema in.
    XmlSchema root = new XmlSchema();
    /* will explode if the type object created for the custom mapping isn't fully initialized.
      */
    sbType.writeSchema(root);
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) AegisType(org.apache.cxf.aegis.type.AegisType) XmlSchema(org.apache.ws.commons.schema.XmlSchema) AegisContext(org.apache.cxf.aegis.AegisContext) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with AegisType

use of org.apache.cxf.aegis.type.AegisType 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 28 with AegisType

use of org.apache.cxf.aegis.type.AegisType 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)

Example 29 with AegisType

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

the class EnumTypeTest method testTypeAttributeOnEnum.

@Test
public void testTypeAttributeOnEnum() throws Exception {
    AegisType type = tm.getTypeCreator().createType(TestEnum.class);
    assertEquals("urn:xfire:foo", type.getSchemaType().getNamespaceURI());
    assertTrue(type instanceof EnumType);
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 30 with AegisType

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

the class EnumTypeTest method testXFireTypeAttributeOnEnum.

@Test
public void testXFireTypeAttributeOnEnum() throws Exception {
    AegisType type = tm.getTypeCreator().createType(XFireTestEnum.class);
    assertEquals("urn:xfire:foo", type.getSchemaType().getNamespaceURI());
    assertTrue(type instanceof EnumType);
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Aggregations

AegisType (org.apache.cxf.aegis.type.AegisType)97 QName (javax.xml.namespace.QName)43 Test (org.junit.Test)40 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)35 DatabindingException (org.apache.cxf.aegis.DatabindingException)18 AegisContext (org.apache.cxf.aegis.AegisContext)16 TypeMapping (org.apache.cxf.aegis.type.TypeMapping)11 Element (org.w3c.dom.Element)11 Context (org.apache.cxf.aegis.Context)10 BeanType (org.apache.cxf.aegis.type.basic.BeanType)10 Method (java.lang.reflect.Method)9 MessageReader (org.apache.cxf.aegis.xml.MessageReader)9 TypeCreationOptions (org.apache.cxf.aegis.type.TypeCreationOptions)8 BeanTypeInfo (org.apache.cxf.aegis.type.basic.BeanTypeInfo)8 CollectionType (org.apache.cxf.aegis.type.collection.CollectionType)8 HashSet (java.util.HashSet)7 MapType (org.apache.cxf.aegis.type.collection.MapType)7 MessageWriter (org.apache.cxf.aegis.xml.MessageWriter)7 ElementReader (org.apache.cxf.aegis.xml.stax.ElementReader)7 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)5