Search in sources :

Example 6 with BlobHttpContent

use of com.google.cloud.tools.jib.http.BlobHttpContent in project jib by GoogleContainerTools.

the class BlobPusherTest method testWriter_getContent.

@Test
public void testWriter_getContent() throws IOException {
    LongAdder byteCount = new LongAdder();
    BlobHttpContent body = testBlobPusher.writer(mockUrl, byteCount::add).getContent();
    Assert.assertNotNull(body);
    Assert.assertEquals("application/octet-stream", body.getType());
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    body.writeTo(byteArrayOutputStream);
    Assert.assertEquals(TEST_BLOB_CONTENT, new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8));
    Assert.assertEquals(TEST_BLOB_CONTENT.length(), byteCount.sum());
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) BlobHttpContent(com.google.cloud.tools.jib.http.BlobHttpContent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Aggregations

BlobHttpContent (com.google.cloud.tools.jib.http.BlobHttpContent)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 Test (org.junit.Test)4 RegistryAuthenticationFailedException (com.google.cloud.tools.jib.api.RegistryAuthenticationFailedException)2 Request (com.google.cloud.tools.jib.http.Request)2 Response (com.google.cloud.tools.jib.http.Response)2 ResponseException (com.google.cloud.tools.jib.http.ResponseException)2 IOException (java.io.IOException)2 URL (java.net.URL)2 LongAdder (java.util.concurrent.atomic.LongAdder)2