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));
}
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));
}
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());
}
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());
}
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());
}
Aggregations