/** * Downloads the directory's properties. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void downloadAttributes() throws StorageException { this.downloadAttributes(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Downloads the directory's properties. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void downloadAttributes() throws StorageException { this.downloadAttributes(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Check uploading/downloading directory metadata. * * @throws StorageException * @throws URISyntaxException */ @Test public void testCloudFileDirectoryUploadMetadata() throws StorageException, URISyntaxException { CloudFileDirectory directory = this.share.getRootDirectoryReference(); directory.downloadAttributes(); Assert.assertEquals(0, directory.getMetadata().size()); directory.getMetadata().put("key1", "value1"); directory.uploadMetadata(); directory.getMetadata().clear(); directory.downloadAttributes(); Assert.assertEquals(1, directory.getMetadata().size()); Assert.assertEquals("value1", directory.getMetadata().get("key1")); directory.getMetadata().clear(); directory.uploadMetadata(); directory.getMetadata().put("key2", "value2"); directory.downloadAttributes(); Assert.assertEquals(0, directory.getMetadata().size()); }
/** * Check if a directory reference with metadata will still have that metadata after being created. * * @throws StorageException * @throws URISyntaxException */ @Test public void testCreateDirectoryWithMetadata() throws StorageException, URISyntaxException { String directoryName = "newDirectory1"; CloudFileDirectory directory = new CloudFileDirectory( PathUtility.appendPathToUri(this.share.getStorageUri(), directoryName), directoryName, this.share); Assert.assertEquals(0, directory.getMetadata().size()); directory.getMetadata().put("key1", "value1"); directory.createIfNotExists(); directory.getMetadata().clear(); directory.downloadAttributes(); Assert.assertEquals(1, directory.getMetadata().size()); Assert.assertEquals("value1", directory.getMetadata().get("key1")); }
@Test public void testDirectorySas() throws InvalidKeyException, IllegalArgumentException, StorageException, URISyntaxException, InterruptedException { CloudFileDirectory dir = this.share.getRootDirectoryReference().getDirectoryReference("dirFile"); CloudFile file = dir.getFileReference("dirFile"); dir.create(); file.create(512); SharedAccessFilePolicy policy = createSharedAccessPolicy( EnumSet.of(SharedAccessFilePermissions.READ, SharedAccessFilePermissions.LIST, SharedAccessFilePermissions.DELETE), 300); // Test directory SAS with a file SAS token from an identically named file String sas = file.generateSharedAccessSignature(policy, null); CloudFileDirectory sasDir = new CloudFileDirectory(new URI(dir.getUri().toString() + "?" + sas)); try { sasDir.downloadAttributes(); fail("This should result in an authentication error."); } catch (StorageException ex) { assertEquals(HttpURLConnection.HTTP_FORBIDDEN, ex.getHttpStatusCode()); } // Test directory SAS with a share SAS token sas = this.share.generateSharedAccessSignature(policy, null); sasDir = new CloudFileDirectory(new URI(dir.getUri().toString() + "?" + sas)); sasDir.downloadAttributes(); // Test deleting a directory using a SAS token. The directory must be empty for this request to succeed. file.delete(); sasDir.delete(); }
@Test public void testDirectoryAttributesEncryption() throws URISyntaxException, StorageException, IOException { assertFalse(this.dir.getProperties().isServerEncrypted()); CloudFileDirectory testDir = this.share.getRootDirectoryReference().getDirectoryReference("dir"); testDir.downloadAttributes(); assertTrue(testDir.getProperties().isServerEncrypted()); }
assertEquals("EndDir2", ((CloudFileDirectory) item22).getName()); topDir1.downloadAttributes(); assertNotNull(topDir1.getProperties().getEtag()); assertNotNull(topDir1.getProperties().getLastModified());
dir.setMetadata(meta2); dir.uploadMetadata(); snapshotDir.downloadAttributes(); dir.downloadAttributes(); assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2")); assertNotNull(dir.getProperties().getEtag());
snapshotDir2.downloadAttributes(); assertTrue(snapshotDir2.getMetadata().size() == 1 && snapshotDir2.getMetadata().get("key2").equals("value2"));