/** * 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])); } }
/** * 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; }
/** * Tests reading a 3.0 style plug-in that has a MANIFEST file that is not a bundle manifest. * * @throws Exception */ public void testClassicPluginsWithNonBundleManifest() throws Exception { // extract the plug-in IPath location = extractClassicNonBundleManifestPlugins(); // the new way ITargetDefinition definition = getNewTarget(); ITargetLocation container = getTargetService().newDirectoryLocation(location.toOSString()); definition.setTargetLocations(new ITargetLocation[] {container}); definition.resolve(null); TargetBundle[] bundles = definition.getAllBundles(); assertEquals("Wrong number of bundles", 1, bundles.length); assertEquals( "Wrong bundle", "org.eclipse.core.variables", bundles[0].getBundleInfo().getSymbolicName()); }
/** * 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()); } }