/** * Creates the share if it does not exist. * * @return <code>true</code> if the share did not already exist and was created; otherwise, <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean createIfNotExists() throws StorageException { return this.createIfNotExists(null /* options */, null /* opContext */); }
private void create() throws StorageException, URISyntaxException { this.fileShare.createIfNotExists(); //TODO: create method must provide file length, but we don't know actual //file size when creating. Pending on github issue feedback. this.cloudFile.create(1024); } }
/** * Creates the share if it does not exist. * * @return <code>true</code> if the share did not already exist and was created; otherwise, <code>false</code>. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public boolean createIfNotExists() throws StorageException { return this.createIfNotExists(null /* options */, null /* opContext */); }
@Override public Triple<String, String, String> call() throws Exception { CloudFileShare cloudFileShare = client.getShareReference(fileShareName); cloudFileShare.createIfNotExists(); return Triple.of(volumeName, fileShareName, storageAccountKey); } });
@Override public Triple<String, String, String> call() throws Exception { CloudFileShare cloudFileShare = client.getShareReference(fileShareName); cloudFileShare.createIfNotExists(); return Triple.of(volumeName, fileShareName, storageAccountKey); } });
/** * CreateIfNotExists test. * * @throws StorageException */ @Test public void testCloudFileShareCreateIfNotExists() throws StorageException { assertTrue(this.share.createIfNotExists()); assertTrue(this.share.exists()); assertFalse(this.share.createIfNotExists()); }
@Test @Category({ SlowTests.class }) public void testShareSASCombinations() throws StorageException, URISyntaxException, IOException, InvalidKeyException, InterruptedException { EnumSet<SharedAccessFilePermissions> permissionSet = null; Map<Integer, CloudFileShare> shares = new HashMap<Integer, CloudFileShare>(); try { for (int bits = 0x1; bits < 0x40; bits++) { shares.put(bits, FileTestHelper.getRandomShareReference()); shares.get(bits).createIfNotExists(); permissionSet = getPermissions(bits); FileSharePermissions perms = new FileSharePermissions(); perms.getSharedAccessPolicies().put("readwrite" + bits, createSharedAccessPolicy(permissionSet, 300)); shares.get(bits).uploadPermissions(perms); } Thread.sleep(30000); for (int bits = 0x1; bits < 0x20; bits++) { permissionSet = getPermissions(bits); String sasToken = shares.get(bits).generateSharedAccessSignature(null, "readwrite" + bits); CloudFile testFile = FileTestHelper.uploadNewFile(shares.get(bits), 64, null); testAccess(sasToken, permissionSet, shares.get(bits), testFile); } } finally { for (int bits = 0x1; bits < shares.size(); bits++) { shares.get(bits).deleteIfExists(); } } }
/** * Test that Share Quota can be set, but only to allowable values. * * @throws StorageException * @throws URISyntaxException */ @Test public void testCloudFileShareQuotaListing() throws StorageException, URISyntaxException { int shareQuota = 16; this.share.getProperties().setShareQuota(shareQuota); this.share.createIfNotExists(); Iterable<CloudFileShare> shares = this.share.getServiceClient().listShares(this.share.getName()); for (CloudFileShare fileShare : shares) { assertEquals(shareQuota, fileShare.getProperties().getShareQuota().intValue()); } }
/** * Tests whether Share Stats can be updated and downloaded. * * @throws StorageException * @throws IOException * @throws URISyntaxException */ @Test @Category({ CloudTests.class }) public void testGetShareStats() throws StorageException, IOException, URISyntaxException { share.createIfNotExists(); ShareStats stats = share.getStats(); assertNotNull(stats); assertEquals(0, stats.getUsage()); FileTestHelper.uploadNewFile(share, 512, null); stats = share.getStats(); assertNotNull(stats); assertEquals(1, stats.getUsage()); }
public void testCloudFileShareQuota() throws StorageException, URISyntaxException { this.share.createIfNotExists(); this.share.downloadAttributes(); assertNotNull(this.share.getProperties().getShareQuota());