Search in sources :

Example 41 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class DefaultArtifactTest method testArtifactType.

@Test
public void testArtifactType() {
    DefaultArtifactType type = new DefaultArtifactType("typeId", "typeExt", "typeCls", "typeLang", true, true);
    Artifact a = new DefaultArtifact("gid", "aid", null, null, null, null, type);
    assertEquals("typeExt", a.getExtension());
    assertEquals("typeCls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", null, type);
    assertEquals("ext", a.getExtension());
    assertEquals("cls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    Map<String, String> props = new HashMap<String, String>();
    props.put("someNonStandardProperty", "someNonStandardProperty");
    a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", props, type);
    assertEquals("ext", a.getExtension());
    assertEquals("cls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("true", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("true", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    assertEquals("someNonStandardProperty", a.getProperties().get("someNonStandardProperty"));
    props = new HashMap<String, String>();
    props.put("someNonStandardProperty", "someNonStandardProperty");
    props.put(ArtifactProperties.CONSTITUTES_BUILD_PATH, "rubbish");
    props.put(ArtifactProperties.INCLUDES_DEPENDENCIES, "rubbish");
    a = new DefaultArtifact("gid", "aid", "cls", "ext", "ver", props, type);
    assertEquals("ext", a.getExtension());
    assertEquals("cls", a.getClassifier());
    assertEquals("typeLang", a.getProperties().get(ArtifactProperties.LANGUAGE));
    assertEquals("typeId", a.getProperties().get(ArtifactProperties.TYPE));
    assertEquals("rubbish", a.getProperties().get(ArtifactProperties.INCLUDES_DEPENDENCIES));
    assertEquals("rubbish", a.getProperties().get(ArtifactProperties.CONSTITUTES_BUILD_PATH));
    assertEquals("someNonStandardProperty", a.getProperties().get("someNonStandardProperty"));
}
Also used : HashMap(java.util.HashMap) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 42 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class DefaultArtifactTest method testImmutability.

@Test
public void testImmutability() {
    Artifact a = new DefaultArtifact("gid:aid:ext:cls:ver");
    assertNotSame(a, a.setFile(new File("file")));
    assertNotSame(a, a.setVersion("otherVersion"));
    assertNotSame(a, a.setProperties(Collections.singletonMap("key", "value")));
}
Also used : File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 43 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testImmutability.

@Test
public void testImmutability() {
    Artifact a = new SubArtifact(newMainArtifact("gid:aid:ver"), "", "pom");
    assertNotSame(a, a.setFile(new File("file")));
    assertNotSame(a, a.setVersion("otherVersion"));
    assertNotSame(a, a.setProperties(Collections.singletonMap("key", "value")));
}
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 44 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class SubArtifactTest method testEmptyClassifier.

@Test
public void testEmptyClassifier() {
    Artifact main = newMainArtifact("gid:aid:ext:cls:ver");
    Artifact sub = new SubArtifact(main, "", "pom");
    assertEquals("", sub.getClassifier());
    sub = new SubArtifact(main, null, "pom");
    assertEquals("", 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)

Example 45 with Artifact

use of org.sonatype.aether.artifact.Artifact in project sonatype-aether by sonatype.

the class DefaultUpdateCheckManager method touchArtifact.

public void touchArtifact(RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check) {
    Artifact artifact = check.getItem();
    File artifactFile = check.getFile();
    File touchFile = getTouchFile(artifact, artifactFile);
    String updateKey = getUpdateKey(artifactFile, check.getRepository());
    String dataKey = getDataKey(artifact, artifactFile, check.getAuthoritativeRepository());
    String transferKey = getTransferKey(artifact, artifactFile, check.getRepository());
    setUpdated(session.getData(), updateKey);
    Properties props = write(touchFile, dataKey, transferKey, check.getException());
    if (artifactFile.exists() && !hasErrors(props)) {
        touchFile.delete();
    }
}
Also used : Properties(java.util.Properties) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact)

Aggregations

Artifact (org.sonatype.aether.artifact.Artifact)116 Test (org.junit.Test)63 File (java.io.File)33 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)30 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)28 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)27 Dependency (org.sonatype.aether.graph.Dependency)22 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)14 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 ArrayList (java.util.ArrayList)12 ArtifactTransferException (org.sonatype.aether.transfer.ArtifactTransferException)12 Metadata (org.sonatype.aether.metadata.Metadata)10 RepositorySystem (org.sonatype.aether.RepositorySystem)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8