/** Purge the test container */
 public void cleanRepositoryFiles(String path) throws StorageException, URISyntaxException {
   String container =
       internalCluster().getInstance(Settings.class).get("repositories.azure.container");
   logger.info("--> remove blobs in container [{}]", container);
   AzureStorageService client = internalCluster().getInstance(AzureStorageService.class);
   client.deleteFiles(null, LocationMode.PRIMARY_ONLY, container, path);
 }
 /** Purge the test containers */
 public void cleanRepositoryFiles(String... containers)
     throws StorageException, URISyntaxException {
   Settings settings = readSettingsFromFile();
   AzureStorageService client = new AzureStorageServiceImpl(settings);
   for (String container : containers) {
     client.removeContainer(container);
   }
 }
  /** When a user remove a container you can not immediately create it again. */
  @Test
  public void testRemoveAndCreateContainer() throws Exception {
    final String container = getContainerName().concat("-testremove");
    final AzureStorageService storageService =
        internalCluster().getInstance(AzureStorageService.class);

    // It could happen that we run this test really close to a previous one
    // so we might need some time to be able to create the container
    assertBusy(
        new Runnable() {

          public void run() {
            try {
              storageService.createContainer(container);
              logger.debug(" -> container created...");
            } catch (URISyntaxException e) {
              // Incorrect URL. This should never happen.
              fail();
            } catch (StorageException e) {
              // It could happen. Let's wait for a while.
              logger.debug(" -> container is being removed. Let's wait a bit...");
              fail();
            }
          }
        },
        30,
        TimeUnit.SECONDS);
    storageService.removeContainer(container);

    ClusterAdminClient client = client().admin().cluster();
    logger.info("-->  creating azure repository while container is being removed");
    try {
      client
          .preparePutRepository("test-repo")
          .setType("azure")
          .setSettings(Settings.settingsBuilder().put(Repository.CONTAINER, container))
          .get();
      fail("we should get a RepositoryVerificationException");
    } catch (RepositoryVerificationException e) {
      // Fine we expect that
    }
  }