@Test
  public void testBundleStorageForInputStream() throws Exception {

    BundleStoragePlugin storagePlugin = getFrameworkState().getBundleStoragePlugin();
    assertNotNull("BundleStoragePlugin not null", storagePlugin);

    JavaArchive archive = getArchive();
    InternalStorageState storageState =
        storagePlugin.createStorageState(1, archive.getName(), 1, toVirtualFile(archive));
    assertStorageState(storageState);

    storagePlugin.deleteStorageState(storageState);
    File storageDir = storageState.getStorageDir();
    assertFalse("Storage dir deleted", storageDir.exists());

    String location = storageState.getLocation();
    assertNull("StorageState deleted", storagePlugin.getStorageState(location));

    // Try this a second time
    storageState =
        storagePlugin.createStorageState(2, archive.getName(), 1, toVirtualFile(archive));
    assertStorageState(storageState);

    storagePlugin.deleteStorageState(storageState);
    storageDir = storageState.getStorageDir();
    assertFalse("Storage dir deleted", storageDir.exists());
  }
  @Test
  public void testBundleStorageForExternalFile() throws Exception {

    BundleStoragePlugin storagePlugin = getFrameworkState().getBundleStoragePlugin();
    assertNotNull("BundleStoragePlugin not null", storagePlugin);

    File file = new File(storagePlugin.getStorageDir(0) + "/testBundleExternalFile.jar");
    FileOutputStream fos = new FileOutputStream(file);
    VFSUtils.copyStream(toInputStream(getArchive()), fos);
    fos.close();

    VirtualFile rootFile = AbstractVFS.toVirtualFile(file.toURI().toURL());
    InternalStorageState storageState =
        storagePlugin.createStorageState(1, file.getAbsolutePath(), 1, rootFile);
    assertStorageState(storageState);

    storagePlugin.deleteStorageState(storageState);
    File storageDir = storageState.getStorageDir();
    assertFalse("Storage dir deleted", storageDir.exists());
  }