TestUtilities.recoverKeepAliveSystemProperty();
}
@Test
public void testMtomXop() throws Exception {
TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, true);
try {
Holder<DataHandler> param = new Holder<DataHandler>();
Holder<String> name;
byte bytes[];
InputStream in;
InputStream pre = this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl");
int fileSize = 0;
for (int i = pre.read(); i != -1; i = pre.read()) {
fileSize++;
}
int count = 50;
byte[] data = new byte[fileSize * count];
for (int x = 0; x < count; x++) {
this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl").read(data,
fileSize * x,
fileSize);
}
((BindingProvider)mtomPort).getRequestContext().put("schema-validation-enabled",
Boolean.TRUE);
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<String>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);
assertEquals(data.length, bytes.length);
in.close();
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<String>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);
assertEquals(data.length, bytes.length);
in.close();
((BindingProvider)mtomPort).getRequestContext().put("schema-validation-enabled",
Boolean.FALSE);
SAAJOutInterceptor saajOut = new SAAJOutInterceptor();
SAAJInInterceptor saajIn = new SAAJInInterceptor();
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<String>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);
assertEquals(data.length, bytes.length);
in.close();
ClientProxy.getClient(mtomPort).getInInterceptors().add(saajIn);
ClientProxy.getClient(mtomPort).getInInterceptors().add(saajOut);
param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
name = new Holder<String>("call detail");
mtomPort.testXop(name, param);
assertEquals("name unchanged", "return detail + call detail", name.value);
assertNotNull(param.value);
in = param.value.getInputStream();
bytes = IOUtils.readBytesFromStream(in);