use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class MapTest method testType.
@Test
public void testType() throws Exception {
Method m = MapService.class.getMethod("getMap", 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.getTypeClass().isAssignableFrom(String.class));
type = mapType.getValueType();
assertNotNull(type);
assertTrue(type.getTypeClass().isAssignableFrom(Integer.class));
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class MapTest method testPDType.
@Test
public void testPDType() throws Exception {
PropertyDescriptor pd = Introspector.getBeanInfo(MapDTO.class, Object.class).getPropertyDescriptors()[0];
AegisType type = creator.createType(pd);
tm.register(type);
assertTrue(type instanceof MapType);
MapType mapType = (MapType) type;
QName keyName = mapType.getKeyName();
assertNotNull(keyName);
type = mapType.getKeyType();
assertNotNull(type);
assertTrue(type.getTypeClass().isAssignableFrom(String.class));
type = mapType.getValueType();
assertNotNull(type);
assertTrue(type.getTypeClass().isAssignableFrom(Integer.class));
}
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());
}
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<java.lang.reflect.Type>();
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);
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class AegisXMLStreamDataReader method read.
/**
* {@inheritDoc}
*/
public Object read(XMLStreamReader reader, AegisType desiredType) throws Exception {
setupReaderPosition(reader);
ElementReader elReader = new ElementReader(reader);
if (elReader.isXsiNil()) {
elReader.readToEnd();
return null;
}
AegisType type = TypeUtil.getReadTypeStandalone(reader, aegisContext, desiredType);
if (type == null) {
throw new DatabindingException(new Message("NO_MAPPING", LOG));
}
return type.readObject(elReader, context);
}
Aggregations