use of org.apache.cxf.aegis.xml.stax.ElementReader in project cxf by apache.
the class SoapArrayTypeTest method testAnyTypeArray.
@Test
public void testAnyTypeArray() throws Exception {
Context context = getContext();
// ur-type[4] nested elements have xsi:type
ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayAnyType1.xml"));
Object[] objects = (Object[]) createArrayType(Object[].class).readObject(reader, context);
reader.getXMLStreamReader().close();
assertArrayEquals(new Object[] { 42, (float) 42.42, "Forty Two" }, objects);
// ur-type[4] nested element name have a global schema type
reader = new ElementReader(getClass().getResourceAsStream("arrayAnyType2.xml"));
objects = (Object[]) createArrayType(Object[].class).readObject(reader, context);
reader.getXMLStreamReader().close();
assertArrayEquals(new Object[] { 42, new BigDecimal("42.42"), "Forty Two" }, objects);
// round trip tests
objects = readWriteReadRef("arrayAnyType1.xml", Object[].class);
assertArrayEquals(new Object[] { 42, (float) 42.42, "Forty Two" }, objects);
objects = readWriteReadRef("arrayAnyType2.xml", Object[].class);
assertArrayEquals(new Object[] { 42, new BigDecimal("42.42"), "Forty Two" }, objects);
}
use of org.apache.cxf.aegis.xml.stax.ElementReader in project cxf by apache.
the class SoapArrayTypeTest method testArrayOfArrays.
@Test
public void testArrayOfArrays() throws Exception {
Context context = getContext();
// xsd:string[,][2]
ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayArrayOfArrays1.xml"));
String[][][] strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
reader.getXMLStreamReader().close();
assertArrayEquals(ARRAY_2_3_4, strings);
// round trip tests
strings = readWriteReadRef("arrayArrayOfArrays1.xml", String[][][].class);
assertArrayEquals(ARRAY_2_3_4, strings);
}
use of org.apache.cxf.aegis.xml.stax.ElementReader in project cxf by apache.
the class SoapArrayTypeTest method testSimpleArray.
@Test
public void testSimpleArray() throws Exception {
Context context = getContext();
// xsd:int[2]
ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySimple.xml"));
int[] numbers = (int[]) createArrayType(int[].class).readObject(reader, context);
reader.getXMLStreamReader().close();
assertArrayEquals(new int[] { 3, 4 }, numbers);
// round trip tests
numbers = readWriteReadRef("arraySimple.xml", int[].class);
assertArrayEquals(new int[] { 3, 4 }, numbers);
}
use of org.apache.cxf.aegis.xml.stax.ElementReader in project cxf by apache.
the class EnumTypeTest method testNillable.
@Test
public void testNillable() throws Exception {
AegisType type = tm.getTypeCreator().createType(EnumBean.class);
tm.register(type);
Element root = writeObjectToElement(type, new EnumBean(), getContext());
ElementReader reader = new ElementReader(StaxUtils.createXMLStreamReader(root));
Object value = type.readObject(reader, getContext());
assertTrue(value instanceof EnumBean);
EnumBean bean = (EnumBean) value;
assertNull(bean.getCurrency());
}
Aggregations