Search in sources :

Example 76 with AegisType

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

the class ConfigurationTest method testExtensibleDefaultTrue.

@Test
public void testExtensibleDefaultTrue() throws Exception {
    config.setDefaultExtensibleElements(true);
    config.setDefaultExtensibleAttributes(true);
    AegisType type = tm.getTypeCreator().createType(AnnotatedBean1.class);
    BeanTypeInfo info = ((BeanType) type).getTypeInfo();
    assertTrue(info.isExtensibleElements());
    assertTrue(info.isExtensibleAttributes());
}
Also used : BeanTypeInfo(org.apache.cxf.aegis.type.basic.BeanTypeInfo) AegisType(org.apache.cxf.aegis.type.AegisType) BeanType(org.apache.cxf.aegis.type.basic.BeanType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 77 with AegisType

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

the class MapTest method testRecursiveType.

@Test
public void testRecursiveType() throws Exception {
    Method m = MapService.class.getMethod("getMapOfCollections", new Class[0]);
    AegisType type = creator.createType(m, -1);
    tm.register(type);
    assertTrue(type instanceof MapType);
    MapType mapType = (MapType) type;
    QName keyName = mapType.getKeyName();
    assertNotNull(keyName);
    type = mapType.getKeyType();
    assertNotNull(type);
    assertTrue(type instanceof CollectionType);
    assertEquals(String.class, ((CollectionType) type).getComponentType().getTypeClass());
    type = mapType.getValueType();
    assertNotNull(type);
    assertTrue(type instanceof CollectionType);
    assertEquals(Double.class, ((CollectionType) type).getComponentType().getTypeClass());
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) CollectionType(org.apache.cxf.aegis.type.collection.CollectionType) Method(java.lang.reflect.Method) MapType(org.apache.cxf.aegis.type.collection.MapType) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 78 with AegisType

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

the class TestDateMapping method testWriteSqlDateAsDate.

@Test
public void testWriteSqlDateAsDate() 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());
    AegisWriter<XMLStreamWriter> writer = context.createXMLStreamWriter();
    StringWriter stringWriter = new StringWriter();
    XMLStreamWriter xmlWriter = xmlOutputFactory.createXMLStreamWriter(stringWriter);
    writer.write(bean, new QName("urn:test", "beanWithDate"), false, xmlWriter, sbType);
    xmlWriter.close();
// an absence of exception is success here.
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) AegisContext(org.apache.cxf.aegis.AegisContext) AegisType(org.apache.cxf.aegis.type.AegisType) StringWriter(java.io.StringWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 79 with AegisType

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

the class XmlParamTypeTest method testType.

@Test
public void testType() throws Exception {
    Method m = CustomTypeService.class.getMethod("doFoo", new Class[] { String.class });
    AegisType type = creator.createType(m, 0);
    tm.register(type);
    assertTrue(type instanceof CustomStringType);
    // assertEquals(new QName("urn:xfire:foo", "custom"), type.getSchemaType());
    type = creator.createType(m, -1);
    tm.register(type);
    assertTrue(type instanceof CustomStringType);
    assertEquals(new QName("urn:xfire:foo", "custom"), type.getSchemaType());
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) QName(javax.xml.namespace.QName) Method(java.lang.reflect.Method) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 80 with AegisType

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

the class EnumTypeTest method testNillable.

@Test
public void testNillable() throws Exception {
    AegisType type = tm.getTypeCreator().createType(EnumBean.class);
    tm.register(type);
    Element root = writeObjectToElement(type, new EnumBean(), getContext());
    ElementReader reader = new ElementReader(StaxUtils.createXMLStreamReader(root));
    Object value = type.readObject(reader, getContext());
    assertTrue(value instanceof EnumBean);
    EnumBean bean = (EnumBean) value;
    assertNull(bean.getCurrency());
}
Also used : AegisType(org.apache.cxf.aegis.type.AegisType) Element(org.w3c.dom.Element) ElementReader(org.apache.cxf.aegis.xml.stax.ElementReader) 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