Search in sources :

Example 1 with IRequiredCapability

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

the class P2GeneratorImplTest method testOptionalImportPackage_REQUIRE.

@Test
public void testOptionalImportPackage_REQUIRE() throws Exception {
    DefaultDependencyMetadataGenerator 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.REQUIRE).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit iu = getUnit("optional-import-package", 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(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, requirement.getNamespace());
    assertEquals("org.osgi.framework", 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) DefaultDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator) Test(org.junit.Test)

Example 2 with IRequiredCapability

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

the class P2DependencyGeneratorImplTest method rcp_with_p2_inf.

@Test
public void rcp_with_p2_inf() throws Exception {
    generateDependencies("rcp-p2-inf", PackagingType.TYPE_ECLIPSE_APPLICATION);
    assertEquals(2, units.size());
    IInstallableUnit unit = getUnitWithId("org.eclipse.tycho.p2.impl.test.rcp-p2-inf", units);
    assertNotNull(unit);
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
    assertEquals(1, requirements.size());
    IRequiredCapability p2InfCapability = getRequiredCapability("required.p2.inf", requirements);
    assertNotNull(p2InfCapability);
    assertEquals(0, artifacts.size());
    assertNotNull(getUnitWithId("iu.p2.inf", units));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 3 with IRequiredCapability

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

the class P2DependencyGeneratorImplTest method bundle_with_p2_inf.

@Test
public void bundle_with_p2_inf() throws Exception {
    generateDependencies("bundle-p2-inf", PackagingType.TYPE_ECLIPSE_PLUGIN);
    assertEquals(2, units.size());
    IInstallableUnit unit = getUnitWithId("org.eclipse.tycho.p2.impl.test.bundle-p2-inf", units);
    assertNotNull(unit);
    assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    List<IRequirement> requirements = new ArrayList<>(unit.getRequirements());
    assertEquals(1, requirements.size());
    IRequiredCapability requirement = (IRequiredCapability) requirements.get(0);
    assertEquals(IInstallableUnit.NAMESPACE_IU_ID, requirement.getNamespace());
    assertEquals("required.p2.inf", requirement.getName());
    assertNotNull(getUnitWithId("iu.p2.inf", units));
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) ArrayList(java.util.ArrayList) IRequiredCapability(org.eclipse.equinox.internal.p2.metadata.IRequiredCapability) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 4 with IRequiredCapability

use of org.eclipse.equinox.internal.p2.metadata.IRequiredCapability 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 5 with IRequiredCapability

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

the class P2GeneratorImplTest method testOptionalRequireBundle_OPTIONAL.

@Test
public void testOptionalRequireBundle_OPTIONAL() 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.OPTIONAL).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);
    assertFalse(requirement.isGreedy());
    assertEquals(0, 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)

Aggregations

ArrayList (java.util.ArrayList)8 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)8 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)8 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)8 Test (org.junit.Test)8 File (java.io.File)4 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)4 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)4 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)3 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)3