当前位置: 首页>>代码示例>>Java>>正文


Java BlobType类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:Azure,项目名称:azure-storage-java,代码行数:26,代码来源:SecondaryTests.java

示例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();
    }
}
 
开发者ID:Azure,项目名称:azure-storage-java,代码行数:56,代码来源:LoggerTests.java


注:本文中的com.microsoft.azure.storage.blob.BlobType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。