/** * Uploads the directory's metadata. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException */ @DoesServiceRequest public void uploadMetadata() throws StorageException, URISyntaxException { this.uploadMetadata(null /* accessCondition */, null /* options */, null /* opContext */); }
/** * Uploads the directory's metadata. * * @throws StorageException * If a storage service error occurred. * @throws URISyntaxException */ @DoesServiceRequest public void uploadMetadata() throws StorageException, URISyntaxException { this.uploadMetadata(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()); }
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); }
@Test public void testUnsupportedDirectoryApisWithinShareSnapshot() throws StorageException, URISyntaxException { CloudFileShare snapshot = this.share.createSnapshot(); CloudFileDirectory rootDir = snapshot.getRootDirectoryReference(); try { rootDir.create(); fail("Shouldn't get here"); } catch (IllegalArgumentException e) { assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage()); } try { rootDir.delete(); fail("Shouldn't get here"); } catch (IllegalArgumentException e) { assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage()); } try { rootDir.uploadMetadata(); fail("Shouldn't get here"); } catch (IllegalArgumentException e) { assertEquals(SR.INVALID_OPERATION_FOR_A_SHARE_SNAPSHOT, e.getMessage()); } snapshot.delete(); }
meta.put("key1", "value1"); dir.setMetadata(meta); dir.uploadMetadata(); CloudFileShare snapshot = this.share.createSnapshot(); CloudFileDirectory snapshotDir = snapshot.getRootDirectoryReference().getDirectoryReference("dir1"); meta2.put("key2", "value2"); dir.setMetadata(meta2); dir.uploadMetadata(); snapshotDir.downloadAttributes();
dirMeta.put("key2", "value2"); dir1.setMetadata(dirMeta); dir1.uploadMetadata();
@Test public void testCloudFileDirectoryEncryption() throws URISyntaxException, StorageException, IOException { this.requestFound = false; OperationContext ctxt = new OperationContext(); ctxt.getRequestCompletedEventHandler().addListener(new StorageEvent<RequestCompletedEvent>() { @Override public void eventOccurred(RequestCompletedEvent eventArg) { assertTrue(eventArg.getRequestResult().isRequestServiceEncrypted()); CloudFileServerEncryptionTests.this.requestFound = true; } }); this.dir.uploadMetadata(null, null, ctxt); assertTrue(this.requestFound); this.requestFound = false; CloudFileDirectory dir2 = this.share.getRootDirectoryReference().getDirectoryReference("dir2"); dir2.create(null, ctxt); assertTrue(this.requestFound); } }