public static StringPayload newStringPayload(String data) { return new StringPayload(checkNotNull(data, "data")); }
public static StringPayload newStringPayload(String data) { return new StringPayload(checkNotNull(data, "data")); }
public static StringPayload newStringPayload(String data) { return new StringPayload(checkNotNull(data, "data")); }
public static StringPayload newStringPayload(String data) { return new StringPayload(checkNotNull(data, "data")); }
public static StringPayload newStringPayload(String data) { return new StringPayload(checkNotNull(data, "data")); }
/** * @deprecated see newPayload(ByteSource) */ @Deprecated public static StringPayload newStringPayload(String data) { return new StringPayload(checkNotNull(data, "data")); }
@Override public InputStream putString(String key, String value) { return putInternal(key, new StringPayload(value)); }
@Override public void put(String path, String text) { put(path, new StringPayload(text)); }
@Override public InputStream putString(String key, String value) { return putInternal(key, new StringPayload(value)); }
@Override public void put(String path, String text) { put(path, new StringPayload(text)); }
public void testLengthIsCorrectPerUTF8() { Payload stringPayload = new StringPayload("unic₪de"); assertEquals(stringPayload.getContentMetadata().getContentLength(), Long.valueOf( "unic₪de".getBytes(Charsets.UTF_8).length)); } }
public void testLengthIsCorrectPerUTF8() { Payload stringPayload = new StringPayload("unic₪de"); assertEquals(stringPayload.getContentMetadata().getContentLength(), Long.valueOf( "unic₪de".getBytes(Charsets.UTF_8).length)); } }
@Test public void testInputPayload() throws Exception { HttpWire wire = setUp(); StringPayload payload = new StringPayload("foo"); PayloadEnclosing request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.input(request); BufferLogger wireLog = (BufferLogger) wire.getWireLog(); assertEquals(wireLog.buff.toString(), "<< \"foo\"", "Expected payload to be printed in logs"); wireLog.buff.setLength(0); payload.setSensitive(true); request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.input(request); assertNotEquals(wireLog.buff.toString(), "<< \"foo\"", "Expected payload to NOT be printed in logs"); wireLog.buff.setLength(0); wire.logSensitiveInformation = true; request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.input(request); assertEquals(wireLog.buff.toString(), "<< \"foo\"", "Expected payload to be printed in logs"); }
@Test public void testOutputPayload() throws Exception { HttpWire wire = setUp(); StringPayload payload = new StringPayload("foo"); PayloadEnclosing request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.output(request); BufferLogger wireLog = (BufferLogger) wire.getWireLog(); assertEquals(wireLog.buff.toString(), ">> \"foo\"", "Expected payload to be printed in logs"); wireLog.buff.setLength(0); payload.setSensitive(true); request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.output(request); assertNotEquals(wireLog.buff.toString(), ">> \"foo\"", "Expected payload to NOT be printed in logs"); wireLog.buff.setLength(0); wire.logSensitiveInformation = true; request = HttpRequest.builder().method("foo").endpoint("http://foo").payload(payload).build(); wire.output(request); assertEquals(wireLog.buff.toString(), ">> \"foo\"", "Expected payload to be printed in logs"); } }
public void testUploadContent() throws SecurityException, NoSuchMethodException, IOException { Invokable<?, ?> method = method(ChefApi.class, "uploadContent", URI.class, Payload.class); GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of(URI.create("http://foo/bar"), new StringPayload("{\"foo\": \"bar\"}")))); assertRequestLineEquals(httpRequest, "PUT http://foo/bar HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApiMetadata.DEFAULT_API_VERSION + "-test\n"); assertPayloadEquals(httpRequest, "{\"foo\": \"bar\"}", "application/x-binary", false); assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); assertSaxResponseParserClassEquals(method, null); assertFallbackClassEquals(method, null); checkFilters(httpRequest); }
public void testUploadContent() throws SecurityException, NoSuchMethodException, IOException { Invokable<?, ?> method = method(ChefApi.class, "uploadContent", URI.class, Payload.class); GeneratedHttpRequest httpRequest = processor.apply(Invocation.create(method, ImmutableList.<Object> of(URI.create("http://foo/bar"), new StringPayload("{\"foo\": \"bar\"}")))); assertRequestLineEquals(httpRequest, "PUT http://foo/bar HTTP/1.1"); assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefApi.VERSION + "-test\n"); assertPayloadEquals(httpRequest, "{\"foo\": \"bar\"}", "application/x-binary", false); assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); assertSaxResponseParserClassEquals(method, null); assertFallbackClassEquals(method, null); checkFilters(httpRequest); }
Payload fakePayload = new StringPayload(""); fakePayload.getContentMetadata().setContentLength(reallyLongContent);
String input = "abcdefgh"; Payload payload; Blob blob = blobStore.blobBuilder("test").payload(new StringPayload(input)).build(); blobStore.putBlob(CONTAINER_NAME, blob);