use of org.apache.cxf.aegis.AegisContext 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<java.lang.reflect.Type>();
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.AegisContext in project cxf by apache.
the class StandaloneWriteTest method testBasicTypeWrite.
@Test
public void testBasicTypeWrite() throws Exception {
context = new AegisContext();
context.initialize();
AegisWriter<XMLStreamWriter> writer = context.createXMLStreamWriter();
StringWriter stringWriter = new StringWriter();
XMLStreamWriter xmlWriter = xmlOutputFactory.createXMLStreamWriter(stringWriter);
writer.write("ball-of-yarn", new QName("urn:meow", "cat-toy"), false, xmlWriter, new StringType());
xmlWriter.close();
String xml = stringWriter.toString();
XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(new StringReader(xml));
reader.nextTag();
assertEquals("urn:meow", reader.getNamespaceURI());
assertEquals("cat-toy", reader.getLocalName());
reader.next();
String text = reader.getText();
assertEquals("ball-of-yarn", text);
}
use of org.apache.cxf.aegis.AegisContext in project cxf by apache.
the class BeanTest method testNillableAnnotation.
@Test
public void testNillableAnnotation() throws Exception {
context = new AegisContext();
TypeCreationOptions config = new TypeCreationOptions();
config.setDefaultNillable(false);
config.setDefaultMinOccurs(1);
context.setTypeCreationOptions(config);
context.initialize();
mapping = context.getTypeMapping();
BeanType type = (BeanType) mapping.getTypeCreator().createType(BeanWithNillableItem.class);
type.setTypeClass(BeanWithNillableItem.class);
type.setTypeMapping(mapping);
XmlSchema schema = newXmlSchema("urn:Bean");
type.writeSchema(schema);
XmlSchemaComplexType btype = (XmlSchemaComplexType) schema.getTypeByName("BeanWithNillableItem");
XmlSchemaSequence seq = (XmlSchemaSequence) btype.getParticle();
boolean itemFound = false;
boolean itemNotNillableFound = false;
for (int x = 0; x < seq.getItems().size(); x++) {
XmlSchemaSequenceMember o = seq.getItems().get(x);
if (o instanceof XmlSchemaElement) {
XmlSchemaElement oe = (XmlSchemaElement) o;
if ("item".equals(oe.getName())) {
itemFound = true;
assertTrue(oe.isNillable());
assertEquals(0, oe.getMinOccurs());
} else if ("itemNotNillable".equals(oe.getName())) {
itemNotNillableFound = true;
assertFalse(oe.isNillable());
}
}
}
assertTrue(itemFound);
assertTrue(itemNotNillableFound);
}
use of org.apache.cxf.aegis.AegisContext in project cxf by apache.
the class DateTimezoneTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
context = new AegisContext();
context.initialize();
mapping = context.getTypeMapping();
}
use of org.apache.cxf.aegis.AegisContext in project cxf by apache.
the class DynamicProxyTest method setUp.
public void setUp() throws Exception {
super.setUp();
AegisContext context = new AegisContext();
context.initialize();
mapping = context.getTypeMapping();
}
Aggregations