/** * Test file creation with metadata. * * @throws URISyntaxException * @throws StorageException */ @Test public void testCloudFileCreateWithMetadata() throws URISyntaxException, StorageException { CloudFile file = this.share.getRootDirectoryReference().getFileReference("file1"); HashMap<String, String> meta = new HashMap<String, String>(); meta.put("key1", "value1"); file.setMetadata(meta); file.create(1024); CloudFile file2 = this.share.getRootDirectoryReference().getFileReference("file1"); file2.downloadAttributes(); assertEquals(1, file2.getMetadata().size()); assertEquals("value1", file2.getMetadata().get("key1")); file2.setMetadata(new HashMap<String, String>()); file2.uploadMetadata(); file.downloadAttributes(); assertEquals(0, file.getMetadata().size()); }
snapshotFile.downloadAttributes(); assertTrue(snapshotFile.getMetadata().size() == 1 && snapshotFile.getMetadata().get("key1").equals("value1")); assertNotNull(snapshotFile.getProperties().getEtag()); assertTrue(file.getMetadata().size() == 1 && file.getMetadata().get("key2").equals("value2")); assertNotNull(file.getProperties().getEtag()); assertNotEquals(file.getProperties().getEtag(), snapshotFile.getProperties().getEtag());
options.setDisableContentMD5Validation(true); source.getMetadata().put("Test", "value"); source.uploadText(data); copy.getMetadata().put("Test2", "value2"); String copyId = copy.startCopy(FileTestHelper.defiddler(source)); FileTestHelper.waitForCopy(copy); assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals("value2", copy.getMetadata().get("Test2")); assertFalse(copy.getMetadata().containsKey("Test"));
assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals("value", destination.getMetadata().get("Test")); return destination;
source.getMetadata().put("Test", "value"); source.uploadText(data, Constants.UTF8_CHARSET, null, null, null); assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals("value", destination.getMetadata().get("Test"));
options.setDisableContentMD5Validation(true); source.getMetadata().put("Test", "value"); source.uploadText(data);
source.getMetadata().put("Test", "value"); source.uploadText(data, Constants.UTF8_CHARSET, null, null, null);
assertEquals(prop1.getContentType(), prop2.getContentType()); assertEquals("value", copySas.getMetadata().get("Test")); assertEquals(copyId, copySas.getCopyState().getCopyId());