use of org.apache.cxf.aegis.Context in project cxf by apache.
the class AbstractEncodedTest method verifyInvalid.
public void verifyInvalid(String resourceName, Class<?> expectedType) throws XMLStreamException {
AegisType type = mapping.getType(expectedType);
assertNotNull("type is null", type);
Context context = getContext();
ElementReader reader = new ElementReader(getClass().getResourceAsStream(resourceName));
try {
type.readObject(reader, context);
fail("expected DatabindingException");
} catch (DatabindingException expected) {
// expected
} finally {
reader.getXMLStreamReader().close();
}
}
use of org.apache.cxf.aegis.Context in project cxf by apache.
the class SoapArrayTypeTest method testSparseArray.
@Test
public void testSparseArray() throws Exception {
Context context = getContext();
// xsd:string[2,3,4]
ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySparse1.xml"));
String[][][] strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
reader.getXMLStreamReader().close();
verifySparseArray(strings);
// xsd:string[,][4] -> xsd:string[3,4]
reader = new ElementReader(getClass().getResourceAsStream("arraySparse2.xml"));
strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
reader.getXMLStreamReader().close();
verifySparseArray(strings);
// xsd:string[,][4] -> xsd:string[][3] -> xsd:string[4]
reader = new ElementReader(getClass().getResourceAsStream("arraySparse3.xml"));
strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
reader.getXMLStreamReader().close();
verifySparseArray(strings);
// round trip tests
strings = readWriteReadRef("arraySparse1.xml", String[][][].class);
verifySparseArray(strings);
strings = readWriteReadRef("arraySparse2.xml", String[][][].class);
verifySparseArray(strings);
strings = readWriteReadRef("arraySparse3.xml", String[][][].class);
verifySparseArray(strings);
}
use of org.apache.cxf.aegis.Context in project cxf by apache.
the class SoapArrayTypeTest method testSquareArray.
@Test
public void testSquareArray() throws Exception {
Context context = getContext();
// xsd:string[2,3,4]
ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySquare.xml"));
String[][][] strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
reader.getXMLStreamReader().close();
assertArrayEquals(ARRAY_2_3_4, strings);
// round trip tests
strings = readWriteReadRef("arraySquare.xml", String[][][].class);
assertArrayEquals(ARRAY_2_3_4, strings);
}
use of org.apache.cxf.aegis.Context 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.Context 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);
}
Aggregations