/**
  * A profile container should have VM arguments.
  *
  * @throws Exception
  */
 public void testArgumentsProfileContainer() throws Exception {
   ITargetLocation profileContainer =
       getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), null);
   String[] arguments = profileContainer.getVMArguments();
   assertNotNull("Profile containers should have arguments", arguments);
   assertTrue("Profile containers should have arguments", arguments.length > 0);
 }
 /**
  * A feature container should not have VM arguments.
  *
  * @throws Exception
  */
 public void testArgumentsFeatureContainer() throws Exception {
   ITargetLocation featureContainer =
       getTargetService()
           .newFeatureLocation(
               TargetPlatform.getDefaultLocation(), "DOES NOT EXIST", "DOES NOT EXIST");
   assertNull("Feature containers should not have arguments", featureContainer.getVMArguments());
 }
 /**
  * A directory that points to an installation should have VM arguments.
  *
  * @throws Exception
  */
 public void testArgumentsInstallDirectory() throws Exception {
   ITargetLocation installDirectory =
       getTargetService().newDirectoryLocation(TargetPlatform.getDefaultLocation());
   String[] installArgs = installDirectory.getVMArguments();
   assertNotNull("Install directory should have arguments", installArgs);
   assertTrue("Install directory should have arguments", installArgs.length > 0);
 }
  /**
   * Tests a JDT source feature bundle container contains the appropriate bundles
   *
   * @throws Exception
   */
  public void testSourceFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    ITargetLocation container =
        getTargetService()
            .newFeatureLocation(location.toOSString(), "org.eclipse.jdt.source", null);
    container.resolve(definition, null);
    TargetBundle[] bundles = container.getBundles();

    List expected = new ArrayList();
    expected.add("org.eclipse.jdt.source");
    expected.add("org.eclipse.jdt.launching.source");
    // There are two versions of junit available, each with source
    expected.add("org.junit.source");
    expected.add("org.junit.source");
    if (Platform.getOS().equals(Platform.OS_MACOSX)) {
      expected.add("org.eclipse.jdt.launching.macosx.source");
    }

    assertEquals("Wrong number of bundles", expected.size(), bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      if (bundles[i].getBundleInfo().getSymbolicName().equals("org.eclipse.jdt.doc.isv")) {
        assertFalse("Should not be a source bundle", bundles[i].isSourceBundle());
      } else {
        assertTrue(expected.remove(bundles[i].getBundleInfo().getSymbolicName()));
        assertTrue("Should be a source bundle", bundles[i].isSourceBundle());
      }
    }
    assertTrue("Wrong bundles in JDT feature", expected.isEmpty());
  }
 /**
  * A directory of bundles should not have VM arguments.
  *
  * @throws Exception
  */
 public void testArgumentsPluginsDirectory() throws Exception {
   // test bundle containers for known arguments
   ITargetLocation directoryContainer =
       getTargetService().newDirectoryLocation(TargetPlatform.getDefaultLocation() + "/plugins");
   assertNull(
       "Plugins directory containers should not have arguments",
       directoryContainer.getVMArguments());
 }
  /**
   * Tests a JDT feature bundle container contains the appropriate bundles for a specific OS.
   *
   * @throws Exception
   */
  public void testMacOSFeatureBundleContainer() throws Exception {
    // extract the feature
    IPath location = extractModifiedFeatures();

    ITargetDefinition definition = getNewTarget();
    definition.setOS(Platform.OS_MACOSX);
    ITargetLocation container =
        getTargetService().newFeatureLocation(location.toOSString(), "org.eclipse.jdt", null);
    container.resolve(definition, null);
    TargetBundle[] bundles = container.getBundles();

    List expected = new ArrayList();
    expected.add("org.eclipse.jdt");
    expected.add("org.eclipse.jdt.launching");
    // 2 versions of JUnit
    expected.add("org.junit");
    expected.add("org.junit");
    expected.add("org.junit4");
    expected.add("org.eclipse.jdt.launching.macosx");

    assertEquals("Wrong number of bundles in JDT feature", expected.size(), bundles.length);
    for (int i = 0; i < bundles.length; i++) {
      String symbolicName = bundles[i].getBundleInfo().getSymbolicName();
      expected.remove(symbolicName);
      if (symbolicName.equals("org.eclipse.jdt.launching.macosx")) {
        // the bundle should be missing unless on Mac
        IStatus status = bundles[i].getStatus();
        if (Platform.getOS().equals(Platform.OS_MACOSX)) {
          assertTrue("Mac bundle should be present", status.isOK());
        } else {
          assertFalse("Mac bundle should be missing", status.isOK());
          assertEquals(
              "Mac bundle should be mssing",
              TargetBundle.STATUS_PLUGIN_DOES_NOT_EXIST,
              status.getCode());
        }
      }
    }
    Iterator iterator = expected.iterator();
    while (iterator.hasNext()) {
      String name = (String) iterator.next();
      System.err.println("Missing: " + name);
    }
    assertTrue("Wrong bundles in JDT feature", expected.isEmpty());

    // should be no source bundles
    for (int i = 0; i < bundles.length; i++) {
      TargetBundle bundle = bundles[i];
      assertFalse("Should be no source bundles", bundle.isSourceBundle());
    }
  }