Package com.google.common.io

Examples of com.google.common.io.ByteSource.openStream()


                        }
                    }

                    // TODO: Open buffered stream??

                    return is.openStream();
                } catch (IOException e) {
                    throw new IllegalStateException("Error reading data", e);
                }
            }
        });
View Full Code Here


  }

  public FakeGFileBuilder contents(File file) {
    try {
      ByteSource byteSource = Files.asByteSource(file);
      this.contents = byteSource.openStream();
    } catch (IOException e) {
      Throwables.propagate(e);
    }

    return this;
View Full Code Here

   public void testPutInputStreamPayloadEnclosingGenerateMD5() throws SecurityException, NoSuchMethodException,
         IOException {
      Invokable<?, ?> method = method(TestTransformers.class, "put", PayloadEnclosing.class);
      ByteSource byteSource = ByteSource.wrap("whoops".getBytes(UTF_8));
      PayloadEnclosing payloadEnclosing = new PayloadEnclosingImpl(
            newInputStreamPayload(byteSource.openStream()));
      payloadEnclosing.getPayload().getContentMetadata().setContentLength(byteSource.size());
      payloadEnclosing.getPayload().getContentMetadata().setContentMD5(byteSource.hash(Hashing.md5()).asBytes());

      GeneratedHttpRequest request = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of(payloadEnclosing)));
View Full Code Here

        ByteSource byteSource = ByteSource.wrap(new byte[1]);
        Payload payload = new ByteSourcePayload(byteSource);
        payload.getContentMetadata().setContentLength(byteSource.size());
        httpClient.put(uri, payload);
        try (InputStream actual = httpClient.get(uri);
             InputStream expected = byteSource.openStream()) {
            assertThat(actual).hasContentEqualTo(expected);
        }
    }

    @Test
View Full Code Here

                .build();
        s3BlobStore.putBlob(containerName, blob);

        Blob blob2 = s3BlobStore.getBlob(containerName, blobName);
        try (InputStream actual = blob2.getPayload().openStream();
             InputStream expected = byteSource.openStream()) {
            assertThat(actual).hasContentEqualTo(expected);
        }
    }

    @Test
View Full Code Here

         blobStore.createContainerInLocation(null, container);

         ByteSource input = createByteSourceBiggerThan(PART_SIZE);

         Blob write = blobStore.blobBuilder("const.txt")
             .payload(input.openStream())
             .contentLength(input.size())
             .build();
         blobStore.putBlob(container, write, PutOptions.Builder.multipart());

         Blob read = blobStore.getBlob(container, "const.txt");
View Full Code Here

   public void testPutInputStreamPayloadEnclosingGenerateMD5() throws SecurityException, NoSuchMethodException,
         IOException {
      Invokable<?, ?> method = method(TestTransformers.class, "put", PayloadEnclosing.class);
      ByteSource byteSource = ByteSource.wrap("whoops".getBytes(UTF_8));
      PayloadEnclosing payloadEnclosing = new PayloadEnclosingImpl(
            newInputStreamPayload(byteSource.openStream()));
      payloadEnclosing.getPayload().getContentMetadata().setContentLength(byteSource.size());
      payloadEnclosing.getPayload().getContentMetadata().setContentMD5(byteSource.hash(Hashing.md5()).asBytes());

      GeneratedHttpRequest request = processor.apply(Invocation.create(method,
            ImmutableList.<Object> of(payloadEnclosing)));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.