mirror of https://github.com/apache/jclouds.git
make payloads repeatable
This commit is contained in:
parent
abeffc1119
commit
52fc2c2be1
|
@ -144,15 +144,16 @@ public abstract class BaseRestClientExpectTest<S> {
|
||||||
* @return payload for use in http responses.
|
* @return payload for use in http responses.
|
||||||
*/
|
*/
|
||||||
public Payload payloadFromResource(String resource) {
|
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) {
|
public Payload payloadFromResourceWithContentType(String resource, String contentType) {
|
||||||
try {
|
try {
|
||||||
Payload payload = Payloads.newStringPayload(Strings2
|
return payloadFromStringWithContentType(Strings2.toStringAndClose(getClass().getResourceAsStream(resource)), contentType);
|
||||||
.toStringAndClose(getClass().getResourceAsStream(resource)));
|
|
||||||
payload.getContentMetadata().setContentType(contentType);
|
|
||||||
return payload;
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw Throwables.propagate(e);
|
throw Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue