@Test(timeOut = 5 * 60 * 1000) public void testCreateContainer() throws Exception { boolean created = false; while (!created) { privateContainer = containerPrefix + new SecureRandom().nextInt(); try { created = client.createContainer( privateContainer, withMetadata(ImmutableMultimap.of("foo", "bar"))); } catch (UndeclaredThrowableException e) { HttpResponseException htpe = (HttpResponseException) e.getCause().getCause(); if (htpe.getResponse().getStatusCode() == 409) continue; throw e; } } Set<ContainerProperties> response = client.listContainers(includeMetadata()); assert null != response; long containerCount = response.size(); assertTrue(containerCount >= 1); ListBlobsResponse list = client.listBlobs(privateContainer); assertEquals( list.getUrl(), URI.create( String.format("https://%s.blob.core.windows.net/%s", identity, privateContainer))); // TODO .. check to see the container actually exists }
@Test public void testListContainers() throws Exception { Set<ContainerProperties> response = client.listContainers(); assert null != response; long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); }
@Test public void testListContainersWithOptions() throws Exception { BoundedSet<ContainerProperties> response = client.listContainers( ListOptions.Builder.prefix(privateContainer).maxResults(1).includeMetadata()); assert null != response; long initialContainerCount = response.size(); assertTrue(initialContainerCount >= 0); assertEquals(privateContainer, response.getPrefix()); assertEquals(1, response.getMaxResults()); }
@Test( timeOut = 5 * 60 * 1000, dependsOnMethods = {"testCreateContainer", "testCreatePublicContainer"}) public void testListOwnedContainers() throws Exception { // Test default listing Set<ContainerProperties> response = client.listContainers(); // assertEquals(response.size(), initialContainerCount + 2);// if the containers already // exist, this will fail // Test listing with options response = client.listContainers( ListOptions.Builder.prefix(privateContainer.substring(0, privateContainer.length() - 1)) .maxResults(1) .includeMetadata()); assertEquals(response.size(), 1); assertEquals(Iterables.getOnlyElement(response).getName(), privateContainer); assertEquals(Iterables.getOnlyElement(response).getMetadata(), ImmutableMap.of("foo", "bar")); response = client.listContainers(ListOptions.Builder.prefix(publicContainer).maxResults(1)); assertEquals(response.size(), 1); assertEquals(Iterables.getOnlyElement(response).getName(), publicContainer); }