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


Java UriQueryBuilder.addToURI方法代码示例

本文整理汇总了Java中com.microsoft.azure.storage.core.UriQueryBuilder.addToURI方法的典型用法代码示例。如果您正苦于以下问题:Java UriQueryBuilder.addToURI方法的具体用法?Java UriQueryBuilder.addToURI怎么用?Java UriQueryBuilder.addToURI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.microsoft.azure.storage.core.UriQueryBuilder的用法示例。


在下文中一共展示了UriQueryBuilder.addToURI方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSupportedFileApisInShareSnapshot

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入方法依赖的package包/类
@Test
public void testSupportedFileApisInShareSnapshot() throws StorageException, URISyntaxException, UnsupportedEncodingException {
    CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
    dir.deleteIfExists();
    dir.create();
    CloudFile file = dir.getFileReference("file");
    file.create(1024);

    HashMap<String, String> meta = new HashMap<String, String>();
    meta.put("key1", "value1");
    file.setMetadata(meta);
    file.uploadMetadata();

    CloudFileShare snapshot = this.share.createSnapshot();
    CloudFile snapshotFile = snapshot.getRootDirectoryReference()
                                     .getDirectoryReference("dir1").getFileReference("file");

    HashMap<String, String> meta2 = new HashMap<String, String>();
    meta2.put("key2", "value2");
    file.setMetadata(meta2);
    file.uploadMetadata();
    snapshotFile.downloadAttributes();
    
    assertTrue(snapshotFile.getMetadata().size() == 1 && snapshotFile.getMetadata().get("key1").equals("value1"));
    assertNotNull(snapshotFile.getProperties().getEtag());

    file.downloadAttributes();
    assertTrue(file.getMetadata().size() == 1 && file.getMetadata().get("key2").equals("value2"));
    assertNotNull(file.getProperties().getEtag());
    assertNotEquals(file.getProperties().getEtag(), snapshotFile.getProperties().getEtag());

    final UriQueryBuilder uriBuilder = new UriQueryBuilder();
    uriBuilder.add("sharesnapshot", snapshot.snapshotID);
    CloudFile snapshotFile2 = new CloudFile(uriBuilder.addToURI(file.getUri()), this.share.getServiceClient().getCredentials());
    assertEquals(snapshot.snapshotID, snapshotFile2.getShare().snapshotID);
    assertTrue(snapshotFile2.exists());
    
    snapshot.delete();
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:40,代码来源:CloudFileTests.java

示例2: testSupportedDirectoryApisInShareSnapshot

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入方法依赖的package包/类
@Test
public void testSupportedDirectoryApisInShareSnapshot() throws StorageException, URISyntaxException {
    CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
    dir.deleteIfExists();
    dir.create();
    HashMap<String, String> meta = new HashMap<String, String>();
    meta.put("key1", "value1");
    dir.setMetadata(meta);
    dir.uploadMetadata();
    CloudFileShare snapshot = this.share.createSnapshot();
    CloudFileDirectory snapshotDir = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
    
    HashMap<String, String> meta2 = new HashMap<String, String>();
    meta2.put("key2", "value2");
    dir.setMetadata(meta2);
    dir.uploadMetadata();
    snapshotDir.downloadAttributes();
    
    assertTrue(snapshotDir.getMetadata().size() == 1 && snapshotDir.getMetadata().get("key1").equals("value1"));
    assertNotNull(snapshotDir.getProperties().getEtag());
    
    dir.downloadAttributes();
    assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2"));
    assertNotNull(dir.getProperties().getEtag());
    assertNotEquals(dir.getProperties().getEtag(), snapshotDir.getProperties().getEtag());
    
    final UriQueryBuilder uriBuilder = new UriQueryBuilder();
    uriBuilder.add("sharesnapshot", snapshot.snapshotID);
    uriBuilder.add("restype", "directory");
    CloudFileDirectory snapshotDir2 = new CloudFileDirectory(uriBuilder.addToURI(dir.getUri()), this.share.getServiceClient().getCredentials());
    assertEquals(snapshot.snapshotID, snapshotDir2.getShare().snapshotID);
    assertTrue(snapshotDir2.exists());

    snapshot.delete();
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:36,代码来源:CloudFileDirectoryTests.java

示例3: testCreateShareSnapshot

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入方法依赖的package包/类
@Test
public void testCreateShareSnapshot() throws StorageException, URISyntaxException, IOException {
    // create share with metadata
    this.share.create();
    assertTrue(this.share.exists());
    HashMap<String, String> shareMeta = new HashMap<String, String>();
    shareMeta.put("key1", "value1");
    this.share.setMetadata(shareMeta);
    this.share.uploadMetadata();

    CloudFileDirectory dir1 = this.share.getRootDirectoryReference().getDirectoryReference("dir1");
    dir1.create();
    CloudFile file1 = dir1.getFileReference("file1");
    file1.create(1024);
    ByteArrayInputStream srcStream = FileTestHelper.getRandomDataStream(1024);
    file1.upload(srcStream, 1024);

    // create directory with metadata
    HashMap<String, String> dirMeta = new HashMap<String, String>();
    dirMeta.put("key2", "value2");
    dir1.setMetadata(dirMeta);
    dir1.uploadMetadata();

    // verify that exists() call on snapshot populates metadata
    CloudFileShare snapshot = this.share.createSnapshot();
    CloudFileClient client = FileTestHelper.createCloudFileClient();
    CloudFileShare snapshotRef = client.getShareReference(snapshot.name, snapshot.snapshotID);
    assertTrue(snapshotRef.exists());
    assertTrue(snapshotRef.getMetadata().size() == 1 && snapshotRef.getMetadata().get("key1").equals("value1"));

    // verify that downloadAttributes() populates metadata
    CloudFileShare snapshotRef2 = client.getShareReference(snapshot.name, snapshot.snapshotID);
    snapshotRef2.downloadAttributes();
    snapshot.downloadAttributes();
    assertTrue(snapshotRef2.getMetadata().size() == 1 && snapshotRef2.getMetadata().get("key1").equals("value1"));
    assertTrue(snapshot.getMetadata().size() == 1 && snapshot.getMetadata().get("key1").equals("value1"));

    // verify that exists() populates the metadata
    CloudFileDirectory snapshotDir1 = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
    snapshotDir1.exists();
    assertTrue(snapshotDir1.getMetadata().size() == 1 && snapshotDir1.getMetadata().get("key2").equals("value2"));

    // verify that downloadAttributes() populates the metadata
    CloudFileDirectory snapshotDir2 = snapshot.getRootDirectoryReference().getDirectoryReference("dir1");
    snapshotDir2.downloadAttributes();
    assertTrue(snapshotDir2.getMetadata().size() == 1 && snapshotDir2.getMetadata().get("key2").equals("value2"));

    // create snapshot with metadata
    HashMap<String, String> shareMeta2 = new HashMap<String, String>();
    shareMeta2.put("abc", "def");
    CloudFileShare snapshotRef3 = this.share.createSnapshot(shareMeta2, null, null, null);
    CloudFileShare snapshotRef4 = client.getShareReference(snapshotRef3.name, snapshotRef3.snapshotID);
    assertTrue(snapshotRef4.exists());
    assertTrue(snapshotRef4.getMetadata().size() == 1 && snapshotRef4.getMetadata().get("abc").equals("def"));

    final UriQueryBuilder uriBuilder = new UriQueryBuilder();
    uriBuilder.add("sharesnapshot", snapshot.snapshotID);
    CloudFileShare snapshotRef5 = new CloudFileShare(uriBuilder.addToURI(this.share.getUri()),
                                                     this.share.getServiceClient().getCredentials());
    assertEquals(snapshot.snapshotID, snapshotRef5.snapshotID);
    assertTrue(snapshotRef5.exists());

    snapshot.delete();
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:65,代码来源:CloudFileShareTests.java

示例4: startIncrementalCopy

import com.microsoft.azure.storage.core.UriQueryBuilder; //导入方法依赖的package包/类
/**
 * Requests the service to start an incremental copy of another page blob's contents, properties, and metadata
 * to this blob.
 *
 * @param sourceSnapshot
 *            A <code>CloudPageBlob</code> object that represents the source blob to copy. Must be a snapshot.
 *
 * @return A <code>String</code> which represents the copy ID associated with the copy operation.
 *
 * @throws StorageException
 *             If a storage service error occurred.
 * @throws URISyntaxException
 */
@DoesServiceRequest
public final String startIncrementalCopy(final CloudPageBlob sourceSnapshot) throws StorageException, URISyntaxException {
    final UriQueryBuilder builder = new UriQueryBuilder();
    builder.add(Constants.QueryConstants.SNAPSHOT, sourceSnapshot.snapshotID);
    URI sourceUri = builder.addToURI(sourceSnapshot.getTransformedAddress(null).getPrimaryUri());

    return this.startIncrementalCopy(sourceUri, null /* destinationAccessCondition */,
            null /* options */, null /* opContext */);
}
 
开发者ID:Azure,项目名称:azure-storage-android,代码行数:23,代码来源:CloudPageBlob.java


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