use of com.microsoft.azure.storage.blob.CloudBlockBlob in project camel by apache.
the class BlobServiceUtilTest method testGetConfiguredClientTypeMismatch.
@Test
public void testGetConfiguredClientTypeMismatch() throws Exception {
CloudBlockBlob client = new CloudBlockBlob(URI.create("https://camelazure.blob.core.windows.net/container/blob"));
JndiRegistry registry = (JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry();
registry.bind("azureBlobClient", client);
BlobServiceComponent component = new BlobServiceComponent(context);
BlobServiceEndpoint endpoint = (BlobServiceEndpoint) component.createEndpoint("azure-blob://camelazure/container/blob?azureBlobClient=#azureBlobClient&publicForRead=true" + "&blobType=appendBlob");
try {
BlobServiceUtil.getConfiguredClient(endpoint.getConfiguration());
fail();
} catch (IllegalArgumentException ex) {
assertEquals("Invalid Client Type", ex.getMessage());
}
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project hadoop by apache.
the class TestWasbUriAndConfiguration method testConnectUsingSASReadonly.
@Test
public void testConnectUsingSASReadonly() throws Exception {
Assume.assumeFalse(runningInSASMode);
// Create the test account with SAS credentials.
testAccount = AzureBlobStorageTestAccount.create("", EnumSet.of(CreateOptions.UseSas, CreateOptions.CreateContainer, CreateOptions.Readonly));
assumeNotNull(testAccount);
// Create a blob in there
final String blobKey = "blobForReadonly";
CloudBlobContainer container = testAccount.getRealContainer();
CloudBlockBlob blob = container.getBlockBlobReference(blobKey);
ByteArrayInputStream inputStream = new ByteArrayInputStream(new byte[] { 1, 2, 3 });
blob.upload(inputStream, 3);
inputStream.close();
// Make sure we can read it from the file system
Path filePath = new Path("/" + blobKey);
FileSystem fs = testAccount.getFileSystem();
assertTrue(fs.exists(filePath));
byte[] obtained = new byte[3];
DataInputStream obtainedInputStream = fs.open(filePath);
obtainedInputStream.readFully(obtained);
obtainedInputStream.close();
assertEquals(3, obtained[2]);
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandFolder_firstLevelFolderDelete.
@Test
public void outOfBandFolder_firstLevelFolderDelete() throws Exception {
CloudBlockBlob blob = testAccount.getBlobReference("folderW/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("/folderW")));
assertTrue(fs.exists(new Path("/folderW/file")));
assertTrue(fs.delete(new Path("/folderW"), true));
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandFolder_rename.
// scenario for this particular test described at MONARCH-HADOOP-764
@Test
public void outOfBandFolder_rename() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder4/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
Path srcFilePath = new Path("testFolder4/a/input/file");
assertTrue(fs.exists(srcFilePath));
Path destFilePath = new Path("testFolder4/a/input/file2");
fs.rename(srcFilePath, destFilePath);
}
use of com.microsoft.azure.storage.blob.CloudBlockBlob in project hadoop by apache.
the class TestOutOfBandAzureBlobOperationsLive method outOfBandFolder_siblingCreate.
// scenario for this particular test described at MONARCH-HADOOP-764
@Test
public void outOfBandFolder_siblingCreate() throws Exception {
// NOTE: manual use of CloubBlockBlob targets working directory explicitly.
// WASB driver methods prepend working directory implicitly.
String workingDir = "user/" + UserGroupInformation.getCurrentUser().getShortUserName() + "/";
CloudBlockBlob blob = testAccount.getBlobReference(workingDir + "testFolder3/a/input/file");
BlobOutputStream s = blob.openOutputStream();
s.close();
assertTrue(fs.exists(new Path("testFolder3/a/input/file")));
Path targetFile = new Path("testFolder3/a/input/file2");
FSDataOutputStream s2 = fs.create(targetFile);
s2.close();
}
Aggregations