Search in sources :

Example 21 with IRequirement

use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.

the class P2ResolverAdditionalRequirementsTest method testAddDependencyWithVersionRange.

@Test
public void testAddDependencyWithVersionRange() throws Exception {
    String range = "[2.0.0,3.0.0)";
    impl.addDependency(IU_TYPE, TARGET_UNIT_ID, range);
    impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, range);
    List<IRequirement> additionalRequirements = impl.getAdditionalRequirements();
    String matchingVersion = "2.5.8";
    IInstallableUnit iu = createIU(matchingVersion);
    Assert.assertTrue("version range " + range + " should be satisfied by " + matchingVersion, additionalRequirements.get(0).isMatch(iu));
    Assert.assertTrue("version range " + range + " should be satisfied by " + matchingVersion, additionalRequirements.get(1).isMatch(iu));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 22 with IRequirement

use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.

the class P2ResolverAdditionalRequirementsTest method testZeroVersionInTargetDefinitionUnit.

@Test
public void testZeroVersionInTargetDefinitionUnit() throws Exception {
    String zeroVersion = "0.0.0";
    String arbitraryVersion = "2.5.8";
    impl.addDependency(IU_TYPE, TARGET_UNIT_ID, zeroVersion);
    impl.addDependency(BUNDLE_TYPE, TARGET_UNIT_ID, zeroVersion);
    List<IRequirement> additionalRequirements = impl.getAdditionalRequirements();
    IInstallableUnit iu = createIU(arbitraryVersion);
    Assert.assertTrue("Requires version 0.0.0; should be satisfied by any version", additionalRequirements.get(0).isMatch(iu));
    Assert.assertTrue("Requires version 0.0.0; should be satisfied by any version", additionalRequirements.get(1).isMatch(iu));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 23 with IRequirement

use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.

the class P2GeneratorImplTest method testOptionalRequireBundle_IGNORE.

@Test
public void testOptionalRequireBundle_IGNORE() throws Exception {
    DependencyMetadataGenerator generator = createDependencyMetadataGenerator();
    File location = new File("resources/generator/optional-require-bundle").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "optional-require-bundle", "optional-require-bundle", "0.0.1", "eclipse-plugin");
    Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.IGNORE).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit iu = getUnit("optional-require-bundle", units);
    assertNotNull(iu);
    List<IRequirement> requirements = new ArrayList<>(iu.getRequirements());
    assertEquals(0, requirements.size());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Example 24 with IRequirement

use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.

the class P2GeneratorImplTest method testOptionalRequireBundle_REQUIRE.

@Test
public void testOptionalRequireBundle_REQUIRE() throws Exception {
    DependencyMetadataGenerator generator = createDependencyMetadataGenerator();
    File location = new File("resources/generator/optional-require-bundle").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "optional-require-bundle", "optional-require-bundle", "0.0.1", "eclipse-plugin");
    Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.REQUIRE).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit iu = getUnit("optional-require-bundle", units);
    assertNotNull(iu);
    List<IRequirement> requirements = new ArrayList<>(iu.getRequirements());
    assertEquals(1, requirements.size());
    IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
    assertTrue(requirement.isGreedy());
    assertEquals(1, requirement.getMin());
    assertEquals(1, requirement.getMax());
    assertEquals(BundlesAction.CAPABILITY_NS_OSGI_BUNDLE, requirement.getNamespace());
    assertEquals("org.eclipse.osgi", requirement.getName());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Example 25 with IRequirement

use of org.eclipse.equinox.p2.metadata.IRequirement in project tycho by eclipse.

the class P2GeneratorImplTest method testOptionalImportPackage_IGNORE.

@Test
public void testOptionalImportPackage_IGNORE() throws Exception {
    DependencyMetadataGenerator generator = createDependencyMetadataGenerator();
    File location = new File("resources/generator/optional-import-package").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "optional-import-package", "optional-import-package", "0.0.1", "eclipse-plugin");
    Set<Object> units = generator.generateMetadata(artifactMock, getEnvironments(), OptionalResolutionAction.IGNORE).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit iu = getUnit("optional-import-package", units);
    assertNotNull(iu);
    List<IRequirement> requirements = new ArrayList<>(iu.getRequirements());
    assertEquals(0, requirements.size());
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) DependencyMetadataGenerator(org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator) Test(org.junit.Test)

Aggregations

IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)31 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)23 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)17 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)11 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8 File (java.io.File)7 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)6 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)6 LinkedHashSet (java.util.LinkedHashSet)5 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)5 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)5 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)4 List (java.util.List)2 Map (java.util.Map)2 IStatus (org.eclipse.core.runtime.IStatus)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Version (org.eclipse.equinox.p2.metadata.Version)2 FeatureEntry (org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry)2