/** * 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])); } }
/** * 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()); } }
/** * Tests that a target definition based on the default target platform restricted to a subset of * bundles contains the right set. In this case empty, since the versions specified are bogus. * * @throws Exception */ public void testMissingVersionRestrictedDefaultTargetPlatform() throws Exception { ITargetDefinition definition = getNewTarget(); ITargetLocation container = getTargetService().newProfileLocation(TargetPlatform.getDefaultLocation(), null); NameVersionDescriptor[] restrictions = new NameVersionDescriptor[] { new NameVersionDescriptor("org.eclipse.jdt.launching", "xyz"), new NameVersionDescriptor("org.eclipse.jdt.debug", "abc") }; definition.setTargetLocations(new ITargetLocation[] {container}); definition.setIncluded(restrictions); definition.resolve(null); TargetBundle[] bundles = definition.getBundles(); assertEquals("Wrong number of bundles", 2, bundles.length); for (int i = 0; i < bundles.length; i++) { TargetBundle rb = bundles[i]; assertEquals( "Should be a missing bundle version", TargetBundle.STATUS_VERSION_DOES_NOT_EXIST, rb.getStatus().getCode()); assertEquals("Should be an error", IStatus.ERROR, rb.getStatus().getSeverity()); } }