use of org.webpieces.googlecloud.storage.api.GCPBlob in project webpieces by deanhiller.
the class TestLocalStorage method testCopyFromClassPath.
@Test
public void testCopyFromClassPath() throws IOException {
String bucketName = "testbucket";
String blobName = "mytest.txt";
String copyBlobName = "mytest_copy.txt";
Storage.CopyRequest request = Storage.CopyRequest.newBuilder().setSource(BlobId.of(bucketName, blobName)).setTarget(BlobId.of(bucketName, copyBlobName)).build();
Page<GCPBlob> testbucket = instance.list("copybucket");
CopyInterface copy = instance.copy(request);
ReadableByteChannel readFile = instance.reader("copybucket", "mytest_copy.txt");
InputStream i = Channels.newInputStream(readFile);
String text = new BufferedReader(new InputStreamReader(i, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
// Passed.
Assert.assertEquals("Some Test", text);
}
use of org.webpieces.googlecloud.storage.api.GCPBlob in project webpieces by deanhiller.
the class TestLocalStorage method testGetBlobFileSystem.
@Test
public void testGetBlobFileSystem() throws IOException {
// create a file
BlobId id = BlobId.of("testbucket", "fileSystemFile.txt");
writeFile(id);
GCPBlob bucket = instance.get("testbucket", "fileSystemFile.txt");
Assert.assertEquals("fileSystemFile.txt", bucket.getName());
}
use of org.webpieces.googlecloud.storage.api.GCPBlob in project webpieces by deanhiller.
the class TestLocalStorage method testGetBlobClassPath.
@Test
public void testGetBlobClassPath() {
GCPBlob testbucket = instance.get("testbucket", "mytest.txt");
Assert.assertEquals("mytest.txt", testbucket.getName());
}
use of org.webpieces.googlecloud.storage.api.GCPBlob in project webpieces by deanhiller.
the class TestLocalStorage method validateFileNotFoundReturnsNullBlob.
@Test
public void validateFileNotFoundReturnsNullBlob() {
GCPBlob basket = instance.get("backet", "non-existent");
Assert.assertNull(basket);
}
use of org.webpieces.googlecloud.storage.api.GCPBlob in project webpieces by deanhiller.
the class TestLocalStorage method addFileToBucketAndThenListFiles.
@Test
public void addFileToBucketAndThenListFiles() throws IOException {
instance.list("ListFilebucket");
writeFile(BlobId.of("ListFilebucket", "mytest1.txt"));
GCPBlob bucket = instance.get("ListFilebucket", "mytest1.txt");
// passed.
Assert.assertEquals("mytest1.txt", bucket.getName());
ReadableByteChannel readFile = instance.reader("ListFilebucket", "mytest1.txt");
InputStream i = Channels.newInputStream(readFile);
String text = new BufferedReader(new InputStreamReader(i, StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
Page<GCPBlob> listfilebucket = instance.list("ListFilebucket");
Iterable<GCPBlob> values = listfilebucket.getValues();
Iterator<GCPBlob> iter = values.iterator();
List<String> list = new ArrayList<>();
while (iter.hasNext()) {
list.add(iter.next().getName());
}
Assert.assertEquals(1, list.size());
}
Aggregations