Exemplo n.º 1
0
 @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 boolean matches(IInstallableUnit unit, ParsedCapabilityPattern pattern) {
    switch (pattern.getType()) {
      case P2_INSTALLABLE_UNIT:
        return pattern.matchesId(unit.getId()) && pattern.matchesVersion(unit.getVersion());

      case OSGI_BUNDLE:
        IProvidedCapability bundle = getBundleCapability(unit);
        if (bundle == null) return false;
        return pattern.matchesId(bundle.getName()) && pattern.matchesVersion(bundle.getVersion());

      case JAVA_PACKAGE:
        for (IProvidedCapability exportedPackage : getPackageCapabilities(unit)) {
          if (pattern.matchesId(exportedPackage.getName())
              && pattern.matchesVersion(exportedPackage.getVersion())) {
            return true;
          }
        }
        return false;
    }
    return false;
  }
Exemplo n.º 3
0
  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;
  }