@Override public void put(String path, Payload payload) { try { LOG.info(toString() + " >> put(" + path + ", md5[" + md5Hex(Strings2.toString(payload)) + "])"); } catch (IOException e) { throw new RuntimeException(e); } contents.put(path, payload); }
public boolean matches(Object actual) { if (this.expected == null) { return actual == null; } try { String real = Strings2.toString(((Payload) actual)); assertEquals(real, expected); return true; } catch (IOException e) { Throwables.propagate(e); return false; } }
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } } return null; } }
public void handleError(HttpCommand command, HttpResponse from) { String content; try { content = from.getPayload() != null ? Strings2.toString(from.getPayload()) : null; command.setException(new HttpResponseException(command, from, content)); } catch (IOException e) { command.setException(new HttpResponseException(command, from)); } finally { releasePayload(from); } } }
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } } return null; } }
public void handleError(HttpCommand command, HttpResponse from) { String content; try { content = from.getPayload() != null ? Strings2.toString(from.getPayload()) : null; command.setException(new HttpResponseException(command, from, content)); } catch (IOException e) { command.setException(new HttpResponseException(command, from)); } finally { releasePayload(from); } } }
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } } return null; } }
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } } return null; } }
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } } return null; } }
String parseErrorFromContentOrNull(HttpCommand command, HttpResponse response) { if (response.getPayload() != null) { try { return Strings2.toString(response.getPayload()); } catch (IOException e) { logger.warn(e, "exception reading error from response", response); } } return null; } }
public void handleError(HttpCommand command, HttpResponse from) { String content; try { content = from.getPayload() != null ? Strings2.toString(from.getPayload()) : null; command.setException(new HttpResponseException(command, from, content)); } catch (IOException e) { command.setException(new HttpResponseException(command, from)); } finally { releasePayload(from); } } }
@Test public void testGetEtcPassword() throws IOException { Payload input = setupClient().get("/etc/passwd"); String contents = Strings2.toString(input); assert contents.indexOf("root") >= 0 : "no root in " + contents; }
public void testSinglePart() throws IOException { StringBuilder builder = new StringBuilder(); addData(boundary, "hello", builder); builder.append("--").append(boundary).append("--").append("\r\n"); String expects = builder.toString(); assertEquals(expects.length(), 199); MultipartForm multipartForm = new MultipartForm(boundary, newPart("hello")); assertEquals(Strings2.toString(multipartForm), expects); assertEquals(multipartForm.getContentMetadata().getContentLength(), Long.valueOf(199)); }
@Test public void testPutAndGet() throws IOException { temp = File.createTempFile("foo", "bar"); temp.deleteOnExit(); SshClient client = setupClient(); client.put(temp.getAbsolutePath(), Payloads.newStringPayload("rabbit")); Payload input = setupClient().get(temp.getAbsolutePath()); String contents = Strings2.toString(input); assertEquals(contents, "rabbit"); }
@Test(invocationCount = 5, timeOut = 5000) public void testGetStringViaRequest() throws IOException { HttpResponse getStringResponse = client.invoke(HttpRequest.builder().method("GET") .endpoint(format("http://localhost:%d/objects/", testPort)).build()); assertEquals(Strings2.toString(getStringResponse.getPayload()).trim(), XML); }
private static void verifyObject(AtmosClient connection, String path, String compare, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.readFile(path); assertEquals(Strings2.toString(getBlob.getPayload()), compare); verifyMetadata(metadataValue, getBlob); }
private static void verifyHeadObject(AtmosClient connection, String path, String metadataValue) throws InterruptedException, ExecutionException, TimeoutException, IOException { AtmosObject getBlob = connection.headFile(path); assertEquals(Strings2.toString(getBlob.getPayload()), ""); verifyMetadata(metadataValue, getBlob); }
protected S3Object validateObject(String sourceContainer, String key) throws InterruptedException, ExecutionException, TimeoutException, IOException { assertConsistencyAwareContainerSize(sourceContainer, 1); S3Object newObject = getApi().getObject(sourceContainer, key); assert newObject != null; assertEquals(Strings2.toString(newObject.getPayload()), TEST_STRING); return newObject; }
public void testSinglePart() throws IOException { assertEquals(EXPECTS.length(), 113); BindBlobToMultipartForm binder = new BindBlobToMultipartForm(); HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost:8001").build(); binder.bindToRequest(request, TEST_BLOB); assertEquals(Strings2.toString(request.getPayload()), EXPECTS); assertEquals(request.getPayload().getContentMetadata().getContentLength(), Long.valueOf(113)); assertEquals(request.getPayload().getContentMetadata().getContentType(), "multipart/form-data; boundary=" + BOUNDARY); }
public void testWeCanReadAndWriteToDrive() throws IOException { drive2 = client.createDrive(new CreateDriveRequest.Builder().name(prefix + "2").size(1 * 1024 * 1024l).build()); client.writeDrive(drive2.getUuid(), Payloads.newStringPayload("foo")); assertEquals(Strings2.toString(client.readDrive(drive2.getUuid(), 0, 3)), "foo"); }