Search in sources :

Example 11 with DefaultDependencyArtifacts

use of org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts in project tycho by eclipse.

the class DefaultDependencyArtifactsTest method testVersionMatch.

@Test
public void testVersionMatch() {
    String type = "foo";
    String id = "foo";
    DefaultDependencyArtifacts tp = new DefaultDependencyArtifacts();
    addArtifact(tp, type, id, "1.1.0");
    addArtifact(tp, type, id, "1.2.3");
    addArtifact(tp, type, id, "1.2.3.aaa");
    addArtifact(tp, type, id, "1.2.3.bbb");
    addArtifact(tp, type, id, "1.2.3.ccc");
    addArtifact(tp, type, id, "1.2.3.qualifier");
    addArtifact(tp, type, id, "1.2.3.zzz");
    addArtifact(tp, type, id, "5.6.7.zzz");
    // 0.0.0 or null match the latest version
    Assert.assertEquals("5.6.7.zzz", tp.getArtifact(type, id, null).getKey().getVersion());
    Assert.assertEquals("5.6.7.zzz", tp.getArtifact(type, id, "0.0.0").getKey().getVersion());
    // 1.2.3 matches the latest qualifier
    Assert.assertEquals("1.1.0", tp.getArtifact(type, id, "1.1.0").getKey().getVersion());
    Assert.assertEquals("1.2.3.zzz", tp.getArtifact(type, id, "1.2.3").getKey().getVersion());
    // 1.2.3.qualifier matches the latest qualifier
    Assert.assertEquals("1.1.0", tp.getArtifact(type, id, "1.1.0.qualifier").getKey().getVersion());
    Assert.assertEquals("1.2.3.zzz", tp.getArtifact(type, id, "1.2.3.qualifier").getKey().getVersion());
    // anything else matches just that exact version
    Assert.assertEquals("1.2.3.bbb", tp.getArtifact(type, id, "1.2.3.bbb").getKey().getVersion());
    // does not match anything
    Assert.assertNull(tp.getArtifact(type, id, "0.0.0.qualifier"));
    Assert.assertNull(tp.getArtifact(type, id, "1.0.0"));
    Assert.assertNull(tp.getArtifact(type, id, "1.0.0.qualifier"));
    Assert.assertNull(tp.getArtifact(type, id, "1.2.0"));
    Assert.assertNull(tp.getArtifact(type, id, "1.2.0.qualifier"));
    Assert.assertNull(tp.getArtifact(type, id, "9.9.9"));
    Assert.assertNull(tp.getArtifact(type, id, "9.9.9.qualifier"));
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) Test(org.junit.Test)

Aggregations

DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)11 File (java.io.File)8 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)7 Test (org.junit.Test)7 ArtifactKey (org.eclipse.tycho.ArtifactKey)6 ReactorProject (org.eclipse.tycho.ReactorProject)4 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)4 MavenProject (org.apache.maven.project.MavenProject)2 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)2 DefaultArtifactDescriptor (org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor)2 MultiEnvironmentDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Properties (java.util.Properties)1 MavenSession (org.apache.maven.execution.MavenSession)1 Dependency (org.apache.maven.model.Dependency)1 ComponentDependency (org.codehaus.plexus.component.repository.ComponentDependency)1 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)1