Search in sources :

Example 11 with Location

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Location in project tycho by eclipse.

the class P2GeneratorImplTest method testGenerateSourceBundleMetadata.

@Test
public void testGenerateSourceBundleMetadata() throws Exception {
    DependencyMetadataGenerator p2GeneratorImpl = new SourcesBundleDependencyMetadataGenerator();
    File location = new File("resources/generator/bundle").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "org.acme", "foo", "0.0.1", "eclipse-plugin");
    Set<Object> units = p2GeneratorImpl.generateMetadata(artifactMock, getEnvironments(), null).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit sourceBundleUnit = getUnit("foo.source", units);
    assertNotNull(sourceBundleUnit);
    assertEquals(Version.create("0.0.1"), sourceBundleUnit.getVersion());
    assertThat(sourceBundleUnit, hasGAV("org.acme", "foo", "0.0.1", "sources"));
    ITouchpointData touchPointData = sourceBundleUnit.getTouchpointData().iterator().next();
    String manifestContent = touchPointData.getInstruction("manifest").getBody();
    Manifest manifest = new Manifest(new ByteArrayInputStream(manifestContent.getBytes("UTF-8")));
    Attributes attributes = manifest.getMainAttributes();
    assertEquals("foo.source", attributes.getValue("Bundle-SymbolicName"));
// assertEquals("foo;version=0.0.1;roots:=\".\"", attributes.getValue("Eclipse-SourceBundle"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Attributes(java.util.jar.Attributes) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ITouchpointData(org.eclipse.equinox.p2.metadata.ITouchpointData) Manifest(java.util.jar.Manifest) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) 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 12 with Location

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Location 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 13 with Location

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Location in project tycho by eclipse.

the class P2GeneratorImplTest method generateSourceBundleMetadataForProjectWithP2Inf.

@Test
public void generateSourceBundleMetadataForProjectWithP2Inf() throws Exception {
    // p2.inf must not leak into sources bundle
    DependencyMetadataGenerator p2GeneratorImpl = new SourcesBundleDependencyMetadataGenerator();
    File location = new File("resources/generator/bundle-p2-inf").getCanonicalFile();
    ArtifactMock artifactMock = new ArtifactMock(location, "org.acme", "foo", "0.0.1", "eclipse-plugin");
    Set<Object> units = p2GeneratorImpl.generateMetadata(artifactMock, getEnvironments(), null).getMetadata();
    assertEquals(1, units.size());
    IInstallableUnit unit = getUnit("foo.source", units);
    assertEquals(0, unit.getRequirements().size());
}
Also used : 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) 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 14 with Location

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Location 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 15 with Location

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Location 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

Test (org.junit.Test)16 File (java.io.File)14 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)11 ArrayList (java.util.ArrayList)10 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)8 ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)8 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)7 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)7 InstallableUnitLocation (org.eclipse.tycho.p2.target.facade.TargetDefinition.InstallableUnitLocation)7 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)6 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)4 TargetDefinition (org.eclipse.tycho.p2.target.facade.TargetDefinition)4 IOException (java.io.IOException)3 URI (java.net.URI)3 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)3 TychoRepositoryIndex (org.eclipse.tycho.p2.repository.TychoRepositoryIndex)3 BufferedOutputStream (java.io.BufferedOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)2