コード例 #1
0
  protected void handleAdd() {
    ElementListSelectionDialog dialog =
        new ElementListSelectionDialog(getShell(), new StyledBundleLabelProvider(false, false));

    try {
      dialog.setElements(getValidBundles());
    } catch (CoreException e) {
      dialog.setMessage(e.getMessage());
    }

    dialog.setTitle(PDEUIMessages.PluginSelectionDialog_title);
    dialog.setMessage(PDEUIMessages.PluginSelectionDialog_message);
    dialog.setMultipleSelection(true);
    if (dialog.open() == Window.OK) {

      Object[] models = dialog.getResult();
      ArrayList<NameVersionDescriptor> pluginsToAdd = new ArrayList<NameVersionDescriptor>();
      for (int i = 0; i < models.length; i++) {
        BundleInfo desc = ((BundleInfo) models[i]);
        pluginsToAdd.add(new NameVersionDescriptor(desc.getSymbolicName(), null));
      }
      Set<NameVersionDescriptor> allDependencies = new HashSet<NameVersionDescriptor>();
      allDependencies.addAll(pluginsToAdd);
      NameVersionDescriptor[] currentBundles = getTargetDefinition().getImplicitDependencies();
      if (currentBundles != null) {
        allDependencies.addAll(Arrays.asList(currentBundles));
      }
      getTargetDefinition()
          .setImplicitDependencies(
              allDependencies.toArray(new NameVersionDescriptor[allDependencies.size()]));
      fElementViewer.refresh();
      updateImpButtons();
    }
  }
コード例 #2
0
  /**
   * Gets a list of all the bundles that can be added as implicit dependencies
   *
   * @return list of possible dependencies
   */
  protected BundleInfo[] getValidBundles() throws CoreException {
    NameVersionDescriptor[] current = getTargetDefinition().getImplicitDependencies();
    Set<String> currentBundles = new HashSet<String>();
    if (current != null) {
      for (int i = 0; i < current.length; i++) {
        if (!currentBundles.contains(current[i].getId())) {
          currentBundles.add(current[i].getId());
        }
      }
    }

    List<BundleInfo> targetBundles = new ArrayList<BundleInfo>();
    TargetBundle[] allTargetBundles = getTargetDefinition().getAllBundles();
    if (allTargetBundles == null || allTargetBundles.length == 0) {
      throw new CoreException(
          new Status(
              IStatus.WARNING,
              PDEPlugin.getPluginId(),
              PDEUIMessages.ImplicitDependenciesSection_0));
    }
    for (int i = 0; i < allTargetBundles.length; i++) {
      BundleInfo bundleInfo = allTargetBundles[i].getBundleInfo();
      if (!currentBundles.contains(bundleInfo.getSymbolicName())) {
        currentBundles.add(bundleInfo.getSymbolicName()); // to avoid duplicate entries
        targetBundles.add(bundleInfo);
      }
    }

    return targetBundles.toArray(new BundleInfo[targetBundles.size()]);
  }
コード例 #3
0
ファイル: GitUtils.java プロジェクト: Corly/orion.server
 public static void _testAllowFileScheme(boolean allow) {
   if (allow) {
     uriSchemeWhitelist.add("file"); // $NON-NLS-1$
   } else {
     uriSchemeWhitelist.remove("file"); // $NON-NLS-1$
   }
 }
コード例 #4
0
  /**
   * Tests identification of source bundles in a 3.0.2 install.
   *
   * @throws Exception
   */
  public void testClassicSourcePlugins() throws Exception {
    // extract the 3.0.2 skeleton
    IPath location = extractClassicPlugins();

    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString());
    definition.setTargetLocations(new ITargetLocation[] {container});

    definition.resolve(null);
    TargetBundle[] bundles = definition.getBundles();
    List source = new ArrayList();
    for (int i = 0; i < bundles.length; i++) {
      TargetBundle sb = bundles[i];
      if (sb.isSourceBundle()) {
        source.add(sb);
      }
    }

    assertEquals("Wrong number of source bundles", 4, source.size());
    Set names = new HashSet();
    for (int i = 0; i < source.size(); i++) {
      names.add(((TargetBundle) source.get(i)).getBundleInfo().getSymbolicName());
    }
    String[] expected =
        new String[] {
          "org.eclipse.platform.source",
          "org.eclipse.jdt.source",
          "org.eclipse.pde.source",
          "org.eclipse.platform.source.win32.win32.x86"
        };
    for (int i = 0; i < expected.length; i++) {
      assertTrue("Missing source for " + expected[i], names.contains(expected[i]));
    }
  }
コード例 #5
0
 public static IMarker[] getProblemsFor(IResource resource) {
   try {
     if (resource != null && resource.exists()) {
       IMarker[] markers =
           resource.findMarkers(
               IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
       Set markerTypes =
           JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
       if (markerTypes.isEmpty()) return markers;
       ArrayList markerList = new ArrayList(5);
       for (int i = 0, length = markers.length; i < length; i++) {
         markerList.add(markers[i]);
       }
       Iterator iterator = markerTypes.iterator();
       while (iterator.hasNext()) {
         markers = resource.findMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE);
         for (int i = 0, length = markers.length; i < length; i++) {
           markerList.add(markers[i]);
         }
       }
       IMarker[] result;
       markerList.toArray(result = new IMarker[markerList.size()]);
       return result;
     }
   } catch (CoreException e) {
     // assume there are no problems
   }
   return new IMarker[0];
 }
コード例 #6
0
 /**
  * Method filterResources filters the given resources using the given working set.
  *
  * @param current
  * @param resources
  * @return ICVSRemoteResource[]
  */
 public ICVSRemoteResource[] filterResources(
     IWorkingSet workingSet, ICVSRemoteResource[] resources) {
   if (workingSet == null) return resources;
   // get the projects associated with the working set
   IAdaptable[] adaptables = workingSet.getElements();
   Set projects = new HashSet();
   for (int i = 0; i < adaptables.length; i++) {
     IAdaptable adaptable = adaptables[i];
     Object adapted = adaptable.getAdapter(IResource.class);
     if (adapted != null) {
       // Can this code be generalized?
       IProject project = ((IResource) adapted).getProject();
       projects.add(project);
     }
   }
   List result = new ArrayList();
   for (int i = 0; i < resources.length; i++) {
     ICVSRemoteResource resource = resources[i];
     for (Iterator iter = projects.iterator(); iter.hasNext(); ) {
       IProject project = (IProject) iter.next();
       if (project.getName().equals(resource.getName())) {
         result.add(resource);
         break;
       }
     }
   }
   return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]);
 }
コード例 #7
0
  /**
   * Tests reading a 3.0.2 install with a mix of classic and OSGi plug-ins.
   *
   * @throws Exception
   */
  public void testClassicPlugins() throws Exception {
    // extract the 3.0.2 skeleton
    IPath location = extractClassicPlugins();

    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString());
    definition.setTargetLocations(new ITargetLocation[] {container});
    Set urls = getAllBundleURLs(definition);
    assertTrue("Must be bundles", urls.size() > 0);

    Preferences store = PDECore.getDefault().getPluginPreferences();
    boolean restore = store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION);
    try {
      store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, false);
      // the old way
      URL[] pluginPaths = PluginPathFinder.getPluginPaths(location.toOSString());
      for (int i = 0; i < pluginPaths.length; i++) {
        URL url = pluginPaths[i];
        if (!urls.contains(url)) {
          System.err.println(url.toString());
        }
      }
      assertEquals("Wrong number of bundles", pluginPaths.length, urls.size());
    } finally {
      store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, restore);
    }
  }
コード例 #8
0
  /**
   * Creates an NL fragment project along with the locale specific properties files.
   *
   * @throws CoreException
   * @throws IOException
   * @throws InvocationTargetException
   * @throws InterruptedException
   */
  private void internationalizePlugins(List plugins, List locales, Map overwrites)
      throws CoreException, IOException, InvocationTargetException, InterruptedException {

    Set created = new HashSet();

    for (Iterator it = plugins.iterator(); it.hasNext(); ) {
      IPluginModelBase plugin = (IPluginModelBase) it.next();

      for (Iterator iter = locales.iterator(); iter.hasNext(); ) {
        Locale locale = (Locale) iter.next();

        IProject project = getNLProject(plugin, locale);
        if (created.contains(project)
            || overwriteWithoutAsking
            || !project.exists()
            || OVERWRITE == overwrites.get(project.getName())) {
          if (!created.contains(project) && project.exists()) {
            project.delete(true, getProgressMonitor());
          }

          if (!created.contains(project)) {
            createNLFragment(plugin, project, locale);
            created.add(project);
            project.getFolder(RESOURCE_FOLDER_PARENT).create(false, true, getProgressMonitor());
          }

          project
              .getFolder(RESOURCE_FOLDER_PARENT)
              .getFolder(locale.toString())
              .create(true, true, getProgressMonitor());
          createLocaleSpecificPropertiesFile(project, plugin, locale);
        }
      }
    }
  }
コード例 #9
0
 /**
  * Retrieves all bundles (source and code) in the given target definition returning them as a set
  * of URLs.
  *
  * @param target target definition
  * @return all bundle URLs
  */
 protected Set getAllBundleURLs(ITargetDefinition target) throws Exception {
   if (!target.isResolved()) {
     target.resolve(null);
   }
   TargetBundle[] bundles = target.getBundles();
   Set urls = new HashSet(bundles.length);
   for (int i = 0; i < bundles.length; i++) {
     urls.add(new File(bundles[i].getBundleInfo().getLocation()).toURL());
   }
   return urls;
 }
コード例 #10
0
 /*
  * Clean up the temporary data used to run the tests.
  * This method is not intended to be called by clients, it will be called
  * automatically when the clients use a ReconcilerTestSuite.
  */
 public void cleanup() throws Exception {
   // rm -rf eclipse sub-dir
   boolean leaveDirty =
       Boolean.parseBoolean(TestActivator.getContext().getProperty("p2.tests.doNotClean"));
   if (leaveDirty) return;
   for (Iterator iter = toRemove.iterator(); iter.hasNext(); ) {
     File next = (File) iter.next();
     delete(next);
   }
   output = null;
   toRemove.clear();
 }
コード例 #11
0
 /*
  * XXX I hope this methos is not needed in this form
  */
 public Map getKnownProjectsAndVersions(ICVSRepositoryLocation location) {
   Map knownTags = new HashMap();
   RepositoryRoot root = getRepositoryRootFor(location);
   String[] paths = root.getKnownRemotePaths();
   for (int i = 0; i < paths.length; i++) {
     String path = paths[i];
     Set result = new HashSet();
     result.addAll(Arrays.asList(root.getAllKnownTags(path)));
     knownTags.put(path, result);
   }
   return knownTags;
 }
コード例 #12
0
  private void readOldState(DataInputStream dis) throws IOException, TeamException {
    int repoSize = dis.readInt();
    boolean version1 = false;
    if (repoSize == STATE_FILE_VERSION_1) {
      version1 = true;
      repoSize = dis.readInt();
    }
    for (int i = 0; i < repoSize; i++) {
      ICVSRepositoryLocation root = KnownRepositories.getInstance().getRepository(dis.readUTF());
      RepositoryRoot repoRoot = getRepositoryRootFor(root);

      // read branch tags associated with this root
      int tagsSize = dis.readInt();
      CVSTag[] branchTags = new CVSTag[tagsSize];
      for (int j = 0; j < tagsSize; j++) {
        String tagName = dis.readUTF();
        int tagType = dis.readInt();
        branchTags[j] = new CVSTag(tagName, tagType);
      }
      // Ignore the branch tags since they are handled differently now
      // addBranchTags(root, branchTags);

      // read the number of projects for this root that have version tags
      int projSize = dis.readInt();
      if (projSize > 0) {
        for (int j = 0; j < projSize; j++) {
          String name = dis.readUTF();
          Set tagSet = new HashSet();
          int numTags = dis.readInt();
          for (int k = 0; k < numTags; k++) {
            tagSet.add(new CVSTag(dis.readUTF(), CVSTag.VERSION));
          }
          CVSTag[] tags = (CVSTag[]) tagSet.toArray(new CVSTag[tagSet.size()]);
          repoRoot.addTags(name, tags);
        }
      }
      // read the auto refresh filenames for this project
      if (version1) {
        try {
          projSize = dis.readInt();
          if (projSize > 0) {
            for (int j = 0; j < projSize; j++) {
              String name = dis.readUTF();
              Set filenames = new HashSet();
              int numFilenames = dis.readInt();
              for (int k = 0; k < numFilenames; k++) {
                filenames.add(name + "/" + dis.readUTF()); // $NON-NLS-1$
              }
              repoRoot.setAutoRefreshFiles(
                  name, (String[]) filenames.toArray(new String[filenames.size()]));
            }
          }
        } catch (EOFException e) {
          // auto refresh files are not persisted, continue and save them next time.
        }
      }
      broadcastRepositoryChange(repoRoot);
    }
  }
コード例 #13
0
 /**
  * Method getKnownTags.
  *
  * @param repository
  * @param set
  * @param i
  * @param monitor
  * @return CVSTag[]
  */
 public CVSTag[] getKnownTags(
     ICVSRepositoryLocation repository, IWorkingSet set, int tagType, IProgressMonitor monitor)
     throws CVSException {
   if (set == null) {
     return getKnownTags(repository, tagType);
   }
   ICVSRemoteResource[] folders = getFoldersForTag(repository, CVSTag.DEFAULT, monitor);
   folders = filterResources(set, folders);
   Set tags = new HashSet();
   for (int i = 0; i < folders.length; i++) {
     ICVSRemoteFolder folder = (ICVSRemoteFolder) folders[i];
     tags.addAll(Arrays.asList(getKnownTags(folder, tagType)));
   }
   return (CVSTag[]) tags.toArray(new CVSTag[tags.size()]);
 }
コード例 #14
0
  /** Get the list of known branch tags for a given remote root. */
  public CVSTag[] getKnownTags(ICVSFolder project, int tagType) {
    try {
      CVSTag[] tags = getKnownTags(project);
      Set result = new HashSet();
      for (int i = 0; i < tags.length; i++) {
        CVSTag tag = tags[i];
        if (tag.getType() == tagType) result.add(tag);
      }

      return (CVSTag[]) result.toArray(new CVSTag[result.size()]);
    } catch (CVSException e) {
      CVSUIPlugin.log(e);
      return new CVSTag[0];
    }
  }
コード例 #15
0
 public ICVSRemoteResource[] getFoldersForTag(
     ICVSRepositoryLocation location, CVSTag tag, IProgressMonitor monitor) throws CVSException {
   monitor = Policy.monitorFor(monitor);
   try {
     monitor.beginTask(
         NLS.bind(
             CVSUIMessages.RepositoryManager_fetchingRemoteFolders, new String[] {tag.getName()}),
         100);
     if (tag.getType() == CVSTag.HEAD) {
       ICVSRemoteResource[] resources =
           location.members(tag, false, Policy.subMonitorFor(monitor, 60));
       RepositoryRoot root = getRepositoryRootFor(location);
       ICVSRemoteResource[] modules =
           root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40));
       ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length];
       System.arraycopy(resources, 0, result, 0, resources.length);
       System.arraycopy(modules, 0, result, resources.length, modules.length);
       return result;
     }
     if (tag.getType() == CVSTag.DATE) {
       ICVSRemoteResource[] resources =
           location.members(tag, false, Policy.subMonitorFor(monitor, 60));
       RepositoryRoot root = getRepositoryRootFor(location);
       ICVSRemoteResource[] modules =
           root.getDefinedModules(tag, Policy.subMonitorFor(monitor, 40));
       ICVSRemoteResource[] result = new ICVSRemoteResource[resources.length + modules.length];
       System.arraycopy(resources, 0, result, 0, resources.length);
       System.arraycopy(modules, 0, result, resources.length, modules.length);
       return result;
     }
     Set result = new HashSet();
     // Get the tags for the location
     RepositoryRoot root = getRepositoryRootFor(location);
     String[] paths = root.getKnownRemotePaths();
     for (int i = 0; i < paths.length; i++) {
       String path = paths[i];
       List tags = Arrays.asList(root.getAllKnownTags(path));
       if (tags.contains(tag)) {
         ICVSRemoteFolder remote =
             root.getRemoteFolder(path, tag, Policy.subMonitorFor(monitor, 100));
         result.add(remote);
       }
     }
     return (ICVSRemoteResource[]) result.toArray(new ICVSRemoteResource[result.size()]);
   } finally {
     monitor.done();
   }
 }
コード例 #16
0
 /*
  * Set up the platform binary download and get it ready to run the tests.
  * This method is not intended to be called by clients, it will be called
  * automatically when the clients use a ReconcilerTestSuite. If the executable isn't
  * found on the file-system after the call, then we fail.
  */
 public void initialize() throws Exception {
   initialized = false;
   File file = getPlatformZip();
   output = getUniqueFolder();
   toRemove.add(output);
   // for now we will exec to un-tar archives to keep the executable bits
   if (file.getName().toLowerCase().endsWith(".zip")) {
     try {
       FileUtils.unzipFile(file, output);
     } catch (IOException e) {
       fail("0.99", e);
     }
   } else {
     untar("1.0", file);
   }
   File exe = new File(output, getExeFolder() + "eclipse.exe");
   if (!exe.exists()) {
     exe = new File(output, getExeFolder() + "eclipse");
     if (!exe.exists())
       fail(
           "Executable file: "
               + exe.getAbsolutePath()
               + "(or .exe) not found after extracting: "
               + file.getAbsolutePath()
               + " to: "
               + output);
   }
   initialized = true;
 }
コード例 #17
0
 /** Get the list of known version tags for a given project. */
 public CVSTag[] getKnownTags(ICVSRepositoryLocation location, int tagType) {
   Set result = new HashSet();
   RepositoryRoot root = (RepositoryRoot) repositoryRoots.get(location.getLocation(false));
   if (root != null) {
     String[] paths = root.getKnownRemotePaths();
     for (int i = 0; i < paths.length; i++) {
       String path = paths[i];
       CVSTag[] tags = root.getAllKnownTags(path);
       for (int j = 0; j < tags.length; j++) {
         CVSTag tag = tags[j];
         if (tag.getType() == tagType) result.add(tag);
       }
     }
   }
   return (CVSTag[]) result.toArray(new CVSTag[0]);
 }
コード例 #18
0
  /**
   * Tests that resetting the target platform should work OK (i.e. is equivalent to the models in
   * the default target platform).
   *
   * @throws CoreException
   */
  public void testResetTargetPlatform() throws Exception {
    ITargetDefinition definition = getDefaultTargetPlatorm();
    Set urls = getAllBundleURLs(definition);
    Set fragments = new HashSet();
    TargetBundle[] bundles = definition.getBundles();
    for (int i = 0; i < bundles.length; i++) {
      if (bundles[i].isFragment()) {
        fragments.add(new File(bundles[i].getBundleInfo().getLocation()).toURL());
      }
    }

    // current platform
    IPluginModelBase[] models = TargetPlatformHelper.getPDEState().getTargetModels();

    // should be equivalent
    assertEquals("Should have same number of bundles", urls.size(), models.length);
    for (int i = 0; i < models.length; i++) {
      String location = models[i].getInstallLocation();
      URL url = new File(location).toURL();
      assertTrue("Missing plug-in " + location, urls.contains(url));
      if (models[i].isFragmentModel()) {
        assertTrue("Missing fragmnet", fragments.remove(url));
      }
    }
    assertTrue("Different number of fragments", fragments.isEmpty());
  }
コード例 #19
0
  public static void removeProblemsFor(IResource resource) {
    try {
      if (resource != null && resource.exists()) {
        resource.deleteMarkers(
            IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);

        // delete managed markers
        Set markerTypes =
            JavaModelManager.getJavaModelManager().compilationParticipants.managedMarkerTypes();
        if (markerTypes.size() == 0) return;
        Iterator iterator = markerTypes.iterator();
        while (iterator.hasNext())
          resource.deleteMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE);
      }
    } catch (CoreException e) {
      // assume there were no problems
    }
  }
コード例 #20
0
  /**
   * Tests that a target definition equivalent to the default target platform contains the same
   * bundles as the default target platform using the platform's configuration location (which will
   * do target weaving). This is really only tested when run as a JUnit plug-in test suite from
   * within Eclipse.
   *
   * @throws Exception
   */
  public void testWovenTargetPlatform() throws Exception {
    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService()
            .newProfileLocation(
                TargetPlatform.getDefaultLocation(),
                new File(Platform.getConfigurationLocation().getURL().getFile()).getAbsolutePath());
    definition.setTargetLocations(new ITargetLocation[] {container});
    Set urls = getAllBundleURLs(definition);

    // the old way
    URL[] pluginPaths = PluginPathFinder.getPluginPaths(TargetPlatform.getDefaultLocation());
    assertEquals("Should have same number of bundles", pluginPaths.length, urls.size());
    for (int i = 0; i < pluginPaths.length; i++) {
      URL url = pluginPaths[i];
      assertTrue("Missing plug-in " + url.toString(), urls.contains(url));
    }
  }
コード例 #21
0
 public void removeDescriptor(IArtifactKey key, IProgressMonitor monitor) {
   for (IArtifactDescriptor nextDescriptor : artifactDescriptors) {
     if (key.equals(nextDescriptor.getArtifactKey())) artifactDescriptors.remove(nextDescriptor);
   }
   if (keysToLocations.containsKey(key)) {
     URI theLocation = keysToLocations.get(key);
     locationsToContents.remove(theLocation);
     keysToLocations.remove(key);
   }
 }
コード例 #22
0
 @Override
 protected void refreshPage() {
   fAvailableListViewer.addFilter(fSourceFilter);
   fImportListViewer.getTable().removeAll();
   fSelected.clear();
   fAvailableFilter.setPattern("*"); // $NON-NLS-1$
   fSourceFilter.setState(fPage1.getState());
   fVersionFilter.setModel(fModels);
   fAvailableListViewer.refresh();
   pageChanged();
 }
コード例 #23
0
  /**
   * Tests that a target definition equivalent to the default target platform contains the same
   * bundles as the default target platform (this is an explicit location with no target weaving),
   * when created with a variable referencing ${eclipse_home}
   *
   * @throws Exception
   */
  public void testEclipseHomeTargetPlatform() throws Exception {
    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container = getTargetService().newProfileLocation("${eclipse_home}", null);
    definition.setTargetLocations(new ITargetLocation[] {container});
    Set urls = getAllBundleURLs(definition);

    // the old way
    IPath location = new Path(TargetPlatform.getDefaultLocation());
    URL[] pluginPaths =
        P2Utils.readBundlesTxt(
            location.toOSString(), location.append("configuration").toFile().toURL());
    // pluginPaths will be null (and NPE) when self-hosting and the target platform is not a real
    // installation
    assertEquals("Should have same number of bundles", pluginPaths.length, urls.size());
    for (int i = 0; i < pluginPaths.length; i++) {
      URL url = pluginPaths[i];
      assertTrue("Missing plug-in " + url.toString(), urls.contains(url));
    }
  }
コード例 #24
0
  /**
   * Tests that a target definition based on the default target platform restricted to a subset of
   * bundles contains the right set.
   *
   * @throws Exception
   */
  public void testRestrictedDefaultTargetPlatform() throws Exception {
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), null);
    NameVersionDescriptor[] restrictions =
        new NameVersionDescriptor[] {
          new NameVersionDescriptor("org.eclipse.jdt.launching", null),
          new NameVersionDescriptor("org.eclipse.jdt.debug", null)
        };
    definition.setTargetLocations(new ITargetLocation[] {container});
    definition.setIncluded(restrictions);
    List infos = getAllBundleInfos(definition);

    assertEquals("Wrong number of bundles", 2, infos.size());
    Set set = collectAllSymbolicNames(infos);
    for (int i = 0; i < restrictions.length; i++) {
      NameVersionDescriptor info = restrictions[i];
      set.remove(info.getId());
    }
    assertEquals("Wrong bundles", 0, set.size());
  }
コード例 #25
0
  /**
   * Tests that a bundle directory container is equivalent to scanning locations when it uses a
   * variable to specify its location.
   *
   * @throws Exception
   */
  public void testVariableDirectoryBundleContainer() throws Exception {
    // the new way
    ITargetDefinition definition = getNewTarget();
    ITargetLocation container = getTargetService().newDirectoryLocation("${eclipse_home}/plugins");
    definition.setTargetLocations(new ITargetLocation[] {container});
    Set urls = getAllBundleURLs(definition);

    Preferences store = PDECore.getDefault().getPluginPreferences();
    boolean restore = store.getBoolean(ICoreConstants.TARGET_PLATFORM_REALIZATION);
    try {
      store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, false);
      // the old way
      URL[] pluginPaths = PluginPathFinder.getPluginPaths(TargetPlatform.getDefaultLocation());
      assertEquals("Should have same number of bundles", pluginPaths.length, urls.size());
      for (int i = 0; i < pluginPaths.length; i++) {
        URL url = pluginPaths[i];
        assertTrue("Missing plug-in " + url.toString(), urls.contains(url));
      }
    } finally {
      store.setValue(ICoreConstants.TARGET_PLATFORM_REALIZATION, restore);
    }
  }
コード例 #26
0
  protected void doIncludeVersions(NameVersionDescriptor[] descriptions) throws Exception {
    String bsn = MULTI_VERSION_LOW_DESCRIPTION.getId();

    IPath extras = extractMultiVersionPlugins();
    ITargetDefinition target = getNewTarget();
    ITargetLocation container = getTargetService().newDirectoryLocation(extras.toOSString());
    target.setTargetLocations(new ITargetLocation[] {container});
    target.setIncluded(descriptions);
    try {
      getTargetService().saveTargetDefinition(target);
      setTargetPlatform(target);
      IPluginModelBase[] models = PluginRegistry.getExternalModels();
      Set enabled = new HashSet();
      for (int i = 0; i < models.length; i++) {
        IPluginModelBase pm = models[i];
        if (pm.getBundleDescription().getSymbolicName().equals(bsn)) {
          NameVersionDescriptor desc =
              new NameVersionDescriptor(
                  pm.getPluginBase().getId(), pm.getPluginBase().getVersion());
          if (pm.isEnabled()) {
            enabled.add(desc);
          }
        }
      }
      if (descriptions == null) {

      } else {
        assertEquals("Wrong number of enabled bundles", descriptions.length, enabled.size());
        for (int i = 0; i < descriptions.length; i++) {
          assertTrue("Missing bundle", enabled.contains(descriptions[i]));
        }
      }
    } finally {
      getTargetService().deleteTarget(target.getHandle());
      resetTargetPlatform();
    }
  }
コード例 #27
0
  /**
   * Tests that a target definition based on the JDT feature restricted to a subset of bundles
   * contains the right set.
   *
   * @throws Exception
   */
  public void testRestrictedFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService().newFeatureLocation(location.toOSString(), "org.eclipse.jdt", null);
    NameVersionDescriptor[] restrictions =
        new NameVersionDescriptor[] {
          new NameVersionDescriptor("org.eclipse.jdt", null),
          new NameVersionDescriptor("org.junit", "3.8.2.v20090203-1005")
        };
    definition.setTargetLocations(new ITargetLocation[] {container});
    definition.setIncluded(restrictions);
    List infos = getAllBundleInfos(definition);

    assertEquals("Wrong number of bundles", 2, infos.size());
    Set set = collectAllSymbolicNames(infos);
    for (int i = 0; i < restrictions.length; i++) {
      NameVersionDescriptor info = restrictions[i];
      set.remove(info.getId());
    }
    assertEquals("Wrong bundles", 0, set.size());
  }
コード例 #28
0
ファイル: GitUtils.java プロジェクト: Corly/orion.server
  /**
   * Returns whether or not the git repository URI is forbidden. If a scheme of the URI is matched,
   * check if the scheme is a supported protocol. Otherwise, match for a scp-like ssh URI:
   * [user@]host.xz:path/to/repo.git/ and ensure the URI does not represent a local file path.
   *
   * @param uri A git repository URI
   * @return a boolean of whether or not the git repository URI is forbidden.
   */
  public static boolean isForbiddenGitUri(URIish uri) {
    String scheme = uri.getScheme();
    String host = uri.getHost();
    String path = uri.getPath();
    boolean isForbidden = false;

    if (scheme != null) {
      isForbidden = !uriSchemeWhitelist.contains(scheme);
    } else {
      // match for a scp-like ssh URI
      if (host != null) {
        isForbidden = host.length() == 1 || path == null;
      } else {
        isForbidden = true;
      }
    }

    return isForbidden;
  }
コード例 #29
0
 /* (non-Javadoc)
  * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector#supportsSourceContainerType(org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType)
  */
 public boolean supportsSourceContainerType(ISourceContainerType type) {
   return !fFilteredTypes.contains(type.getId());
 }
コード例 #30
0
 static {
   fFilteredTypes = new HashSet(3);
   fFilteredTypes.add(ProjectSourceContainer.TYPE_ID);
   fFilteredTypes.add(WorkspaceSourceContainer.TYPE_ID);
   fFilteredTypes.add("org.eclipse.debug.ui.containerType.workingSet"); // $NON-NLS-1$
 }