make payloads repeatable

This commit is contained in:
Adrian Cole 2012-01-30 23:30:48 -08:00
parent abeffc1119
commit 52fc2c2be1
1 changed files with 6 additions and 5 deletions

View File

@ -144,15 +144,16 @@ public abstract class BaseRestClientExpectTest<S> {
* @return payload for use in http responses.
*/
public Payload payloadFromResource(String resource) {
return Payloads.newInputStreamPayload(getClass().getResourceAsStream(resource));
try {
return payloadFromString(Strings2.toStringAndClose(getClass().getResourceAsStream(resource)));
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
public Payload payloadFromResourceWithContentType(String resource, String contentType) {
try {
Payload payload = Payloads.newStringPayload(Strings2
.toStringAndClose(getClass().getResourceAsStream(resource)));
payload.getContentMetadata().setContentType(contentType);
return payload;
return payloadFromStringWithContentType(Strings2.toStringAndClose(getClass().getResourceAsStream(resource)), contentType);
} catch (IOException e) {
throw Throwables.propagate(e);
}