Search in sources :

Example 6 with ArtifactMock

use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.

the class TargetPlatformBundlePublisherTest method testPomDependencyOnPlainJar.

@Test
public void testPomDependencyOnPlainJar() throws Exception {
    File jarFile = resourceFile("platformbuilder/pom-dependencies/non-bundle.jar");
    IArtifactFacade jarArtifact = new ArtifactMock(jarFile, GROUP_ID, ARTIFACT_ID, VERSION, "jar");
    IInstallableUnit unit = subject.attemptToPublishBundle(jarArtifact);
    assertNull(unit);
}
Also used : IArtifactFacade(org.eclipse.tycho.p2.metadata.IArtifactFacade) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) Test(org.junit.Test)

Example 7 with ArtifactMock

use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.

the class TargetPlatformBundlePublisherTest method testPomDependencyOnBundle.

@Test
public void testPomDependencyOnBundle() throws Exception {
    String bundleId = "org.eclipse.osgi";
    String bundleVersion = "3.5.2.R35x_v20100126";
    FileUtils.copyDirectory(resourceFile("platformbuilder/pom-dependencies/bundle-repo"), localRepositoryRoot);
    File bundleFile = new File(localRepositoryRoot, RepositoryLayoutHelper.getRelativePath(GROUP_ID, ARTIFACT_ID, VERSION, null, "jar"));
    IArtifactFacade bundleArtifact = new ArtifactMock(bundleFile, GROUP_ID, ARTIFACT_ID, VERSION, "jar");
    IInstallableUnit publishedUnit = subject.attemptToPublishBundle(bundleArtifact);
    assertThat(publishedUnit, is(unit(bundleId, bundleVersion)));
    assertThat(publishedUnit.getProperties(), containsGAV(GROUP_ID, ARTIFACT_ID, VERSION));
    assertThat(publishedUnit.getArtifacts().size(), is(1));
    IArtifactKey referencedArtifact = publishedUnit.getArtifacts().iterator().next();
    IRawArtifactProvider artifactRepo = subject.getArtifactRepoOfPublishedBundles();
    assertThat(artifactRepo, contains(referencedArtifact));
    IArtifactDescriptor[] artifactDescriptors = artifactRepo.getArtifactDescriptors(referencedArtifact);
    assertThat(artifactDescriptors.length, is(1));
    assertThat(artifactDescriptors[0].getProperties(), containsGAV(GROUP_ID, ARTIFACT_ID, VERSION));
    assertThat(artifactDescriptors[0].getProperties(), hasProperty("download.md5", "6303323acc98658c0fed307c84db4411"));
    // test that reading the artifact succeeds (because the way it is added to the repository is a bit special)
    assertThat(artifactMD5Of(referencedArtifact, artifactRepo), is("6303323acc98658c0fed307c84db4411"));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) IArtifactFacade(org.eclipse.tycho.p2.metadata.IArtifactFacade) IArtifactKey(org.eclipse.equinox.p2.metadata.IArtifactKey) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IRawArtifactProvider(org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactProvider) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) Test(org.junit.Test)

Example 8 with ArtifactMock

use of org.eclipse.tycho.p2.impl.test.ArtifactMock in project tycho by eclipse.

the class P2ResolverTestBase method createReactorProject.

protected ReactorProject createReactorProject(File projectRoot, String packagingType, String artifactId, OptionalResolutionAction optionalDependencies) {
    ReactorProjectStub project = new ReactorProjectStub(projectRoot, DEFAULT_GROUP_ID, artifactId, DEFAULT_VERSION, packagingType);
    IDependencyMetadata metadata = dependencyGenerator.generateMetadata(new ArtifactMock(project, null), getEnvironments(), optionalDependencies);
    project.setDependencyMetadata(metadata);
    return project;
}
Also used : ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock)

Example 9 with ArtifactMock

use of org.eclipse.tycho.p2.impl.test.ArtifactMock 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 10 with ArtifactMock

use of org.eclipse.tycho.p2.impl.test.ArtifactMock 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)

Aggregations

ArtifactMock (org.eclipse.tycho.p2.impl.test.ArtifactMock)16 File (java.io.File)15 Test (org.junit.Test)14 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)12 ArrayList (java.util.ArrayList)9 DefaultDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.DefaultDependencyMetadataGenerator)8 SourcesBundleDependencyMetadataGenerator (org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator)8 DependencyMetadataGenerator (org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator)7 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)6 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)4 ResourceUtil.resourceFile (org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile)4 DependencyMetadata (org.eclipse.tycho.p2.impl.publisher.DependencyMetadata)3 IArtifactFacade (org.eclipse.tycho.p2.metadata.IArtifactFacade)3 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 ReactorProjectStub (org.eclipse.tycho.p2.impl.test.ReactorProjectStub)2 IDependencyMetadata (org.eclipse.tycho.p2.metadata.IDependencyMetadata)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Attributes (java.util.jar.Attributes)1 Manifest (java.util.jar.Manifest)1