use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class QualificationTest method testXmlDefaultQualifiedAttribute.
@Test
public void testXmlDefaultQualifiedAttribute() throws Exception {
AegisContext context = new AegisContext();
TypeCreationOptions typeCreationOptions = new TypeCreationOptions();
typeCreationOptions.setQualifyAttributes(true);
context.setTypeCreationOptions(typeCreationOptions);
context.initialize();
TypeMapping mapping = context.getTypeMapping();
AegisType type = mapping.getTypeCreator().createType(XmlMappedAttributeBean.class);
type.setSchemaType(new QName("urn:Bean", "bean"));
Context messageContext = new Context(context);
XmlMappedAttributeBean bean = new XmlMappedAttributeBean();
Element element = writeObjectToElement(type, bean, messageContext);
assertValid("/b:root[@pkg:attrXmlString]", element);
assertXPathEquals("/b:root/@pkg:attrXmlString", "attrXml", element);
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class JaxbTypeTest method testType.
@Test
public void testType() {
AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, JaxbBean1.class, "urn:foo", new TypeCreationOptions());
Iterator<QName> elements = info.getElements().iterator();
assertTrue(elements.hasNext());
// 1st element of 3 expected
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 if ("Annotated".equals(element.getLocalPart())) {
assertTrue(custom instanceof StringType);
} else {
fail("Unexpected element name: " + element.getLocalPart());
}
assertTrue(elements.hasNext());
// 2nd element of 3 expected
element = elements.next();
assertTrue(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 if ("Annotated".equals(element.getLocalPart())) {
assertTrue(custom instanceof StringType);
} else {
fail("Unexpected element name: " + element.getLocalPart());
}
// 3rd element of 3 expected
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 if ("Annotated".equals(element.getLocalPart())) {
assertTrue(custom instanceof StringType);
} 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 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 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));
}
Aggregations