use of org.apache.cxf.swa.types.DataStruct in project cxf by apache.
the class ClientServerSwaTest method testSwaDataStruct.
@Test
public void testSwaDataStruct() throws Exception {
SwAService service = new SwAService();
SwAServiceInterface port = service.getSwAServiceHttpPort();
setAddress(port, "http://localhost:" + serverPort + "/swa");
Holder<DataStruct> structHolder = new Holder<DataStruct>();
ByteArrayDataSource source = new ByteArrayDataSource("foobar".getBytes(), "application/octet-stream");
DataHandler handler = new DataHandler(source);
DataStruct struct = new DataStruct();
struct.setDataRef(handler);
structHolder.value = struct;
port.echoDataRef(structHolder);
handler = structHolder.value.getDataRef();
InputStream bis = handler.getDataSource().getInputStream();
byte[] b = new byte[10];
bis.read(b, 0, 10);
String string = IOUtils.newStringFromBytes(b);
assertEquals("testfoobar", string);
bis.close();
}
Aggregations