use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class QualificationTest method testXmlDefaultUnqualifiedAttribute.
@Test
public void testXmlDefaultUnqualifiedAttribute() throws Exception {
AegisContext context = new AegisContext();
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[@attrXmlString]", element);
assertXPathEquals("/b:root/@attrXmlString", "attrXml", element);
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class StandaloneWriteTest method testBean.
@Test
public void testBean() throws Exception {
context = new AegisContext();
Set<java.lang.reflect.Type> rootClasses = new HashSet<>();
rootClasses.add(SimpleBean.class);
context.setRootClasses(rootClasses);
context.initialize();
SimpleBean sb = new SimpleBean();
sb.setCharacter('\u4000');
sb.setHowdy("doody");
AegisType sbType = context.getTypeMapping().getType(sb.getClass());
AegisWriter<XMLStreamWriter> writer = context.createXMLStreamWriter();
StringWriter stringWriter = new StringWriter();
XMLStreamWriter xmlWriter = xmlOutputFactory.createXMLStreamWriter(stringWriter);
writer.write(sb, new QName("urn:meow", "catnip"), false, xmlWriter, sbType);
xmlWriter.close();
String xml = stringWriter.toString();
assertTrue(xml.contains("doody"));
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class StandaloneWriteTest method testTypeLookup.
@Test
public void testTypeLookup() throws Exception {
context = new AegisContext();
context.initialize();
AegisType st = context.getTypeMapping().getType(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string"));
assertNotNull(st);
assertEquals(st.getClass(), StringType.class);
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class SoapArrayTypeTest method createArrayType.
private SoapArrayType createArrayType(Class<?> typeClass, QName schemaType) {
AegisType type = mapping.getType(typeClass);
if (type != null) {
return (SoapArrayType) type;
}
SoapArrayType arrayType = new SoapArrayType();
arrayType.setTypeClass(typeClass);
arrayType.setTypeMapping(mapping);
arrayType.setSchemaType(schemaType);
return arrayType;
}
use of org.apache.cxf.aegis.type.AegisType in project cxf by apache.
the class CollectionTest method testRecursiveCollections.
@Test
public void testRecursiveCollections() throws Exception {
Method m = CollectionService.class.getMethod("getStringCollections", new Class[0]);
AegisType type = creator.createType(m, -1);
tm.register(type);
assertTrue(type instanceof CollectionType);
CollectionType colType = (CollectionType) type;
QName componentName = colType.getSchemaType();
assertEquals("ArrayOfArrayOfString", componentName.getLocalPart());
type = colType.getComponentType();
assertNotNull(type);
assertTrue(type instanceof CollectionType);
CollectionType colType2 = (CollectionType) type;
componentName = colType2.getSchemaType();
assertEquals("ArrayOfString", componentName.getLocalPart());
type = colType2.getComponentType();
assertTrue(type.getTypeClass().isAssignableFrom(String.class));
}
Aggregations