@Test public void testProfilePublishing() throws Exception { File customProfile = resourceFile("publishers/virgo-1.6.profile"); Collection<DependencySeed> seeds = subject.publishEEProfile(customProfile); assertThat(seeds.size(), is(2)); IInstallableUnit virgoProfileIU = unitsById(seeds).get("a.jre.virgo"); assertThat(virgoProfileIU, not(nullValue())); Collection<IProvidedCapability> provided = virgoProfileIU.getProvidedCapabilities(); boolean customJavaxActivationVersionFound = false; Version version_1_1_1 = Version.create("1.1.1"); for (IProvidedCapability capability : provided) { if (PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(capability.getNamespace())) { if ("javax.activation".equals(capability.getName())) { if (version_1_1_1.equals(capability.getVersion())) { customJavaxActivationVersionFound = true; break; } } } } assertTrue( "did not find capability for package javax.activation with custom version " + version_1_1_1, customJavaxActivationVersionFound); assertThat(unitsById(seeds).keySet(), hasItem("config.a.jre.virgo")); }
private IProvidedCapability getBundleCapability(IInstallableUnit unit) { for (IProvidedCapability capability : unit.getProvidedCapabilities()) { if (BundlesAction.CAPABILITY_NS_OSGI_BUNDLE.equals(capability.getNamespace())) { return capability; } } return null; }
private List<IProvidedCapability> getPackageCapabilities(IInstallableUnit unit) { Collection<IProvidedCapability> allCapabilities = unit.getProvidedCapabilities(); List<IProvidedCapability> packageCapabilities = new ArrayList<IProvidedCapability>(allCapabilities.size()); for (IProvidedCapability capability : allCapabilities) { if (PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(capability.getNamespace())) { packageCapabilities.add(capability); } } return packageCapabilities; }
public static BundleInfo createBundleInfo(File bundleFile, IInstallableUnit unit) { BundleInfo bundleInfo = new BundleInfo(); if (bundleFile != null) bundleInfo.setLocation(bundleFile.toURI()); Collection<IProvidedCapability> capabilities = unit.getProvidedCapabilities(); for (IProvidedCapability capability : capabilities) { String nameSpace = capability.getNamespace(); if (nameSpace.equals("osgi.bundle")) { // $NON-NLS-1$ bundleInfo.setSymbolicName(capability.getName()); bundleInfo.setVersion(capability.getVersion().toString()); } else if (nameSpace.equals("osgi.fragment")) { // $NON-NLS-1$ String fragmentName = capability.getName(); String fragmentHost = getFragmentHost(unit, fragmentName); // shouldn't happen as long as the metadata is well-formed if (fragmentHost == null) LogHelper.log(createError("Unable to find fragment host for IU: " + unit)); // $NON-NLS-1$ else bundleInfo.setFragmentHost(fragmentHost); bundleInfo.setVersion(capability.getVersion().toString()); } } return bundleInfo; }