本文整理汇总了Java中com.microsoft.azure.storage.blob.BlobType类的典型用法代码示例。如果您正苦于以下问题:Java BlobType类的具体用法?Java BlobType怎么用?Java BlobType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlobType类属于com.microsoft.azure.storage.blob包,在下文中一共展示了BlobType类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRetryOn304
import com.microsoft.azure.storage.blob.BlobType; //导入依赖的package包/类
@Test
public void testRetryOn304() throws StorageException, IOException, URISyntaxException {
OperationContext operationContext = new OperationContext();
operationContext.getRetryingEventHandler().addListener(new StorageEvent<RetryingEvent>() {
@Override
public void eventOccurred(RetryingEvent eventArg) {
fail("Request should not be retried.");
}
});
CloudBlobContainer container = BlobTestHelper.getRandomContainerReference();
try {
container.create();
CloudBlockBlob blockBlobRef = (CloudBlockBlob) BlobTestHelper.uploadNewBlob(container, BlobType.BLOCK_BLOB,
"originalBlob", 1024, null);
AccessCondition accessCondition = AccessCondition.generateIfNoneMatchCondition(blockBlobRef.getProperties().getEtag());
blockBlobRef.download(new ByteArrayOutputStream(), accessCondition, null, operationContext);
fail("Download should fail with a 304.");
} catch (StorageException ex) {
assertEquals("The condition specified using HTTP conditional header(s) is not met.", ex.getMessage());
} finally {
container.deleteIfExists();
}
}
示例2: testStringToSign
import com.microsoft.azure.storage.blob.BlobType; //导入依赖的package包/类
@Test
public synchronized void testStringToSign()
throws IOException, InvalidKeyException, StorageException, URISyntaxException {
OperationContext.setLoggingEnabledByDefault(true);
final CloudBlobContainer cont = BlobTestHelper.getRandomContainerReference();
try {
cont.create();
final CloudBlob blob = BlobTestHelper.uploadNewBlob(cont, BlobType.BLOCK_BLOB, "", 0, null);
// Test logging for SAS access
baos.reset();
blob.generateSharedAccessSignature(null, null);
baos.flush();
String log = baos.toString();
String[] logEntries = log.split("[\\r\\n]+");
assertEquals(1, logEntries.length);
// example log entry: TRACE ROOT - {0b902691-1a8e-41da-ab60-5b912df186a6}: {Test string}
String[] segment = logEntries[0].split("\\{");
assertEquals(3, segment.length);
assertTrue(segment[1].startsWith("*"));
assertTrue(segment[2].startsWith(String.format(LogConstants.SIGNING, Constants.EMPTY_STRING)));
baos.reset();
// Test logging for Shared Key access
OperationContext ctx = new OperationContext();
blob.downloadAttributes(null, null, ctx);
baos.flush();
log = baos.toString();
logEntries = log.split("[\\r\\n]+");
assertNotEquals(0, logEntries.length);
// Select correct log entry
for (int n = 0; n < logEntries.length; n++) {
if (logEntries[n].startsWith(LoggerTests.TRACE)) {
segment = logEntries[n].split("\\{");
assertEquals(3, segment.length);
assertTrue(segment[1].startsWith(ctx.getClientRequestID()));
assertTrue(segment[2].startsWith(String.format(LogConstants.SIGNING, Constants.EMPTY_STRING)));
return;
}
}
// If this line is reached then the log entry was not found
fail();
}
finally {
cont.deleteIfExists();
}
}