Search in sources :

Example 66 with Artifact

use of org.sonatype.aether.artifact.Artifact 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 67 with Artifact

use of org.sonatype.aether.artifact.Artifact 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 68 with Artifact

use of org.sonatype.aether.artifact.Artifact 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 69 with Artifact

use of org.sonatype.aether.artifact.Artifact 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 70 with Artifact

use of org.sonatype.aether.artifact.Artifact 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)116 Test (org.junit.Test)62 File (java.io.File)34 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)33 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)28 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)28 Dependency (org.sonatype.aether.graph.Dependency)21 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)17 ArtifactDownload (org.sonatype.aether.spi.connector.ArtifactDownload)16 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)15 LocalArtifactResult (org.sonatype.aether.repository.LocalArtifactResult)15 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)15 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 ArtifactTransferException (org.sonatype.aether.transfer.ArtifactTransferException)12 ArrayList (java.util.ArrayList)11 RepositorySystem (org.sonatype.aether.RepositorySystem)10 Metadata (org.sonatype.aether.metadata.Metadata)10 CollectRequest (org.sonatype.aether.collection.CollectRequest)9 IOException (java.io.IOException)8