@Override public void setHeaders(HttpURLConnection connection, CloudFileDirectory directory, OperationContext context) { FileRequest.addMetadata(connection, directory.getMetadata(), context); }
@Override public void setHeaders(HttpURLConnection connection, CloudFileDirectory directory, OperationContext context) { FileRequest.addMetadata(connection, directory.getMetadata(), context); }
@Override public void setHeaders(HttpURLConnection connection, CloudFileDirectory directory, OperationContext context) { FileRequest.addMetadata(connection, directory.getMetadata(), context); }
@Override public void setHeaders(HttpURLConnection connection, CloudFileDirectory directory, OperationContext context) { FileRequest.addMetadata(connection, directory.getMetadata(), context); }
/** * 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")); }
/** * 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()); }
private static void testMetadataFailures(CloudFileDirectory directory, String key, String value, boolean badKey) throws URISyntaxException { directory.getMetadata().put(key, value); try { directory.uploadMetadata(); fail(SR.METADATA_KEY_INVALID); } catch (StorageException e) { if (badKey) { assertEquals(SR.METADATA_KEY_INVALID, e.getMessage()); } else { assertEquals(SR.METADATA_VALUE_INVALID, e.getMessage()); } } directory.getMetadata().remove(key); }
snapshotDir.downloadAttributes(); assertTrue(snapshotDir.getMetadata().size() == 1 && snapshotDir.getMetadata().get("key1").equals("value1")); assertNotNull(snapshotDir.getProperties().getEtag()); assertTrue(dir.getMetadata().size() == 1 && dir.getMetadata().get("key2").equals("value2")); assertNotNull(dir.getProperties().getEtag()); assertNotEquals(dir.getProperties().getEtag(), snapshotDir.getProperties().getEtag());
assertTrue(snapshotDir1.getMetadata().size() == 1 && snapshotDir1.getMetadata().get("key2").equals("value2")); assertTrue(snapshotDir2.getMetadata().size() == 1 && snapshotDir2.getMetadata().get("key2").equals("value2"));