Search in sources :

Example 1 with ArtifactMock

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

the class P2ResolverTest method testSourceBundle.

@Test
public void testSourceBundle() throws Exception {
    String featureId = "org.eclipse.tycho.p2.impl.resolver.test.feature01";
    projectToResolve = createReactorProject(resourceFile("sourcebundles/feature01"), TYPE_ECLIPSE_FEATURE, featureId);
    File bundle = resourceFile("sourcebundles/bundle01");
    String bundleId = "org.eclipse.tycho.p2.impl.resolver.test.bundle01";
    String bundleVersion = "1.0.0-SNAPSHOT";
    reactorProjects.add(createReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, bundleId));
    ReactorProjectStub sb = new ReactorProjectStub(bundle, bundleId, bundleId, bundleVersion, TYPE_ECLIPSE_PLUGIN);
    DependencyMetadata metadata = new SourcesBundleDependencyMetadataGenerator().generateMetadata(new ArtifactMock(sb, "source"), getEnvironments(), null);
    sb.setDependencyMetadata(metadata);
    reactorProjects.add(sb);
    result = singleEnv(impl.resolveDependencies(getTargetPlatform(), projectToResolve));
    assertEquals(3, result.getArtifacts().size());
    List<P2ResolutionResult.Entry> entries = new ArrayList<>(result.getArtifacts());
    Collections.sort(entries, new Comparator<Entry>() {

        @Override
        public int compare(Entry entry1, Entry entry2) {
            return entry1.getId().compareTo(entry2.getId());
        }
    });
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01", entries.get(0).getId());
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.bundle01.source", entries.get(1).getId());
    assertEquals("org.eclipse.tycho.p2.impl.resolver.test.feature01", entries.get(2).getId());
    assertEquals(bundle, entries.get(0).getLocation());
    assertEquals(bundle, entries.get(1).getLocation());
    assertEquals("sources", entries.get(1).getClassifier());
}
Also used : Entry(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult.Entry) ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) ArrayList(java.util.ArrayList) DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ResourceUtil.resourceFile(org.eclipse.tycho.p2.impl.test.ResourceUtil.resourceFile) File(java.io.File) SourcesBundleDependencyMetadataGenerator(org.eclipse.tycho.p2.impl.publisher.SourcesBundleDependencyMetadataGenerator) Test(org.junit.Test)

Example 2 with ArtifactMock

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

the class P2ResolverTestBase method addContextProject.

protected final void addContextProject(File projectRoot, String packaging) throws IOException {
    ArtifactMock artifact = new ArtifactMock(projectRoot.getAbsoluteFile(), DEFAULT_GROUP_ID, projectRoot.getName(), DEFAULT_VERSION, packaging);
    DependencyMetadata metadata = fullGenerator.generateMetadata(artifact, getEnvironments());
    pomDependencies.addMavenArtifact(artifact, metadata.getInstallableUnits());
}
Also used : DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock)

Example 3 with ArtifactMock

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

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

the class FeatureRootAdviceTest method testGetProjectBaseDir.

@Test
public void testGetProjectBaseDir() throws Exception {
    ArtifactMock defaultArtifactMock = createDefaultArtifactMock();
    assertEquals(FEATURE_PROJECT_TEST_RESOURCE_ROOT.getCanonicalFile(), FeatureRootAdvice.getProjectBaseDir(defaultArtifactMock).getCanonicalFile());
    // null checks
    ArtifactMock wrongTypeArtifactMock = new ArtifactMock(new File(FEATURE_JAR_REL_PATH).getCanonicalFile(), GROUP_ID, ARTIFACT_ID, VERSION, "eclipse-plugin");
    assertNull(FeatureRootAdvice.getProjectBaseDir(wrongTypeArtifactMock));
    ArtifactMock invalidLocationArtifactMock = new ArtifactMock(new File("resources/rootfiles/feature-project/target/feature.jar").getCanonicalFile(), GROUP_ID, ARTIFACT_ID, VERSION, PACKAGING_TYPE);
    assertNull(FeatureRootAdvice.getProjectBaseDir(invalidLocationArtifactMock));
    ArtifactMock invalidRelativeLocationArtifactMock = new ArtifactMock(new File(FEATURE_JAR_REL_PATH), GROUP_ID, ARTIFACT_ID, VERSION, PACKAGING_TYPE);
    assertNull(FeatureRootAdvice.getProjectBaseDir(invalidRelativeLocationArtifactMock));
}
Also used : ArtifactMock(org.eclipse.tycho.p2.impl.test.ArtifactMock) File(java.io.File) Test(org.junit.Test)

Example 5 with ArtifactMock

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

the class TargetPlatformBundlePublisherTest method testPomDependencyOnOtherType.

@Test
public void testPomDependencyOnOtherType() throws Exception {
    File otherFile = resourceFile("platformbuilder/pom-dependencies/other-type.xml");
    IArtifactFacade otherArtifact = new ArtifactMock(otherFile, GROUP_ID, ARTIFACT_ID, VERSION, "pom");
    IInstallableUnit unit = subject.attemptToPublishBundle(otherArtifact);
    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)

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