Search in sources :

Example 6 with StringType

use of org.apache.cxf.aegis.type.basic.StringType 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);
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) StringWriter(java.io.StringWriter) StringType(org.apache.cxf.aegis.type.basic.StringType) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) QName(javax.xml.namespace.QName) AegisContext(org.apache.cxf.aegis.AegisContext) StringReader(java.io.StringReader) Test(org.junit.Test)

Aggregations

StringType (org.apache.cxf.aegis.type.basic.StringType)6 QName (javax.xml.namespace.QName)5 Test (org.junit.Test)4 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)3 AegisType (org.apache.cxf.aegis.type.AegisType)3 TypeCreationOptions (org.apache.cxf.aegis.type.TypeCreationOptions)3 Base64Type (org.apache.cxf.aegis.type.basic.Base64Type)2 BigDecimalType (org.apache.cxf.aegis.type.basic.BigDecimalType)2 BigIntegerType (org.apache.cxf.aegis.type.basic.BigIntegerType)2 BooleanType (org.apache.cxf.aegis.type.basic.BooleanType)2 CalendarType (org.apache.cxf.aegis.type.basic.CalendarType)2 CharacterAsStringType (org.apache.cxf.aegis.type.basic.CharacterAsStringType)2 DateTimeType (org.apache.cxf.aegis.type.basic.DateTimeType)2 DoubleType (org.apache.cxf.aegis.type.basic.DoubleType)2 FloatType (org.apache.cxf.aegis.type.basic.FloatType)2 IntType (org.apache.cxf.aegis.type.basic.IntType)2 LongType (org.apache.cxf.aegis.type.basic.LongType)2 ShortType (org.apache.cxf.aegis.type.basic.ShortType)2 SqlDateType (org.apache.cxf.aegis.type.basic.SqlDateType)2 StringReader (java.io.StringReader)1