Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions testutils/src/main/java/org/apache/cxf/test/TestUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,20 @@ public void assertNoFault(Node node) throws Exception {
XPathAssert.assertNoFault(node);
}

public byte[] invokeBytes(String address, String transport, byte[] message) throws Exception {
return invokeBytes(address, transport, new ByteArrayInputStream(message));
}

public byte[] invokeBytes(String address, String transport, String message) throws Exception {
try (InputStream is = getResourceAsStream(message)) {
if (is == null) {
throw new RuntimeException("Could not find resource " + message);
}
return invokeBytes(address, transport, is);
}
}

public byte[] invokeBytes(String address, String transport, InputStream message) throws Exception {
EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
ei.setAddress(address);

Expand All @@ -211,17 +224,12 @@ public byte[] invokeBytes(String address, String transport, String message) thro
conduit.prepare(m);

OutputStream os = m.getContent(OutputStream.class);
InputStream is = getResourceAsStream(message);
if (is == null) {
throw new RuntimeException("Could not find resource " + message);
}

IOUtils.copy(is, os);
IOUtils.copy(message, os);

// TODO: shouldn't have to do this. IO caching needs cleaning
// up or possibly removal...
os.flush();
is.close();
os.close();

return obs.getResponseStream().toByteArray();
Expand Down