コード例 #1
0
  @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());
  }
コード例 #2
0
  void removeBundle(UserBundleState userBundle, int options) {
    LOGGER.tracef("Start removing bundle: %s", userBundle);

    if ((options & Bundle.STOP_TRANSIENT) == 0) {
      BundleStoragePlugin storagePlugin = getFrameworkState().getBundleStoragePlugin();
      storagePlugin.deleteStorageState(userBundle.getStorageState());
    }

    XEnvironment env = getFrameworkState().getEnvironment();
    for (XBundleRevision abr : userBundle.getAllBundleRevisions()) {
      env.uninstallResources(abr);
    }

    FrameworkEventsPlugin eventsPlugin = getFrameworkState().getFrameworkEventsPlugin();
    eventsPlugin.fireBundleEvent(userBundle, BundleEvent.UNRESOLVED);

    ModuleManagerPlugin moduleManager = getFrameworkState().getModuleManagerPlugin();
    for (XBundleRevision brev : userBundle.getAllBundleRevisions()) {
      UserBundleRevision userRev = (UserBundleRevision) brev;
      if (userRev.isFragment() == false) {
        ModuleIdentifier identifier = moduleManager.getModuleIdentifier(brev);
        moduleManager.removeModule(brev, identifier);
      }
      userRev.close();
    }

    LOGGER.debugf("Removed bundle: %s", userBundle);
  }
コード例 #3
0
  @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());
  }