Search in sources :

Example 6 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testPropertiesCopied.

@Test
public void testPropertiesCopied() {
    Map<String, String> props = new HashMap<String, String>();
    props.put("key", "value1");
    Artifact a = new SubArtifact(newMainArtifact("gid:aid:ver"), "", "pom", props, null);
    assertEquals("value1", a.getProperty("key", null));
    props.clear();
    assertEquals("value1", a.getProperty("key", null));
    props.put("key", "value2");
    a = a.setProperties(props);
    assertEquals("value2", a.getProperty("key", null));
    props.clear();
    assertEquals("value2", a.getProperty("key", null));
}
Also used : HashMap(java.util.HashMap) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Test(org.junit.Test)

Example 7 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testMainArtifactFileNotRetained.

@Test
public void testMainArtifactFileNotRetained() {
    Artifact a = newMainArtifact("gid:aid:ver").setFile(new File(""));
    assertNotNull(a.getFile());
    a = new SubArtifact(a, "", "pom");
    assertNull(a.getFile());
}
Also used : SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Test(org.junit.Test)

Example 8 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testSameExtension.

@Test
public void testSameExtension() {
    Artifact main = newMainArtifact("gid:aid:ext:cls:ver");
    Artifact sub = new SubArtifact(main, "tests", "*");
    assertEquals("ext", sub.getExtension());
}
Also used : SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Test(org.junit.Test)

Example 9 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testMainArtifactPropertiesNotRetained.

@Test
public void testMainArtifactPropertiesNotRetained() {
    Artifact a = newMainArtifact("gid:aid:ver").setProperties(Collections.singletonMap("key", "value"));
    assertEquals(1, a.getProperties().size());
    a = new SubArtifact(a, "", "pom");
    assertEquals(0, a.getProperties().size());
    assertSame(null, a.getProperty("key", null));
}
Also used : SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Test(org.junit.Test)

Example 10 with SubArtifact

use of org.sonatype.aether.util.artifact.SubArtifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testSameClassifier.

@Test
public void testSameClassifier() {
    Artifact main = newMainArtifact("gid:aid:ext:cls:ver");
    Artifact sub = new SubArtifact(main, "*", "pom");
    assertEquals("cls", sub.getClassifier());
}
Also used : SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) Test(org.junit.Test)

Aggregations

Artifact (org.sonatype.aether.artifact.Artifact)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 Test (org.junit.Test)10 File (java.io.File)5 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)3 RepositorySystem (org.sonatype.aether.RepositorySystem)2 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2 HashMap (java.util.HashMap)1 DeployRequest (org.sonatype.aether.deployment.DeployRequest)1 InstallRequest (org.sonatype.aether.installation.InstallRequest)1 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)1