Search in sources :

Example 76 with Artifact

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

the class TimeoutTest method testRequestTimeout.

@Test(timeout = 3000)
public void testRequestTimeout() throws Exception {
    Map<String, Object> configProps = new HashMap<String, Object>();
    configProps.put(ConfigurationProperties.CONNECT_TIMEOUT, "60000");
    configProps.put(ConfigurationProperties.REQUEST_TIMEOUT, "1000");
    session().setConfigProperties(configProps);
    File f = TestFileUtils.createTempFile("");
    Artifact a = artifact("foo");
    ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
    connector().get(downs, null);
    assertNotNull(down.getException());
}
Also used : ArtifactDownload(org.sonatype.aether.spi.connector.ArtifactDownload) HashMap(java.util.HashMap) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 77 with Artifact

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

the class ArtifactWorkerTest method testDecodeURL.

@Test
public void testDecodeURL() throws ArtifactTransferException, IOException {
    String enc = "%72%65%70%6F";
    File dir = TestFileUtils.createTempDir();
    String repoDir = dir.toURI().toURL().toString() + "/" + enc;
    repository = new RemoteRepository("test", "default", repoDir);
    Artifact artifact = new DefaultArtifact("gid", "aid", "jar", "ver");
    String content = "test content";
    uploadArtifact(artifact, content);
    File repo = new File(dir, "repo");
    assertTrue("Repository from encoded URL does not exist.", repo.exists());
    assertTrue("Artifact was not uploaded correctly.", new File(repo, layout.getPath(artifact).getRawPath()).exists());
    TestFileUtils.delete(dir);
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Test(org.junit.Test)

Example 78 with Artifact

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

the class PutTest method testArtifactUpload.

@Test
public void testArtifactUpload() throws Exception {
    addExpectation("gid/aid/version/aid-version-classifier.extension", "artifact");
    addExpectation("gid/aid/version/aid-version-classifier.extension.sha1", sha1("artifact"));
    addExpectation("gid/aid/version/aid-version-classifier.extension.md5", md5("artifact"));
    Artifact artifact = artifact("artifact");
    ArtifactUpload up = new ArtifactUpload(artifact, artifact.getFile());
    List<ArtifactUpload> uploads = Arrays.asList(up);
    connector().put(uploads, null);
    ArtifactTransferException ex = up.getException();
    assertNull(ex != null ? ex.getMessage() : "", ex);
    assertExpectations();
}
Also used : ArtifactTransferException(org.sonatype.aether.transfer.ArtifactTransferException) ArtifactUpload(org.sonatype.aether.spi.connector.ArtifactUpload) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 79 with Artifact

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

the class PutTest method testArtifactWithZeroBytesFile.

@Test
@Ignore("https://issues.sonatype.org/browse/AHC-5")
public void testArtifactWithZeroBytesFile() throws Exception {
    String content = "";
    addExpectation("gid/aid/version/aid-version-classifier.extension", content);
    addExpectation("gid/aid/version/aid-version-classifier.extension.sha1", sha1(content));
    addExpectation("gid/aid/version/aid-version-classifier.extension.md5", md5(content));
    Artifact artifact = artifact(content);
    ArtifactUpload up = new ArtifactUpload(artifact, artifact.getFile());
    List<ArtifactUpload> uploads = Arrays.asList(up);
    connector().put(uploads, null);
    ArtifactTransferException ex = up.getException();
    assertNull(ex != null ? ex.getMessage() : "", ex);
    assertExpectations();
}
Also used : ArtifactTransferException(org.sonatype.aether.transfer.ArtifactTransferException) ArtifactUpload(org.sonatype.aether.spi.connector.ArtifactUpload) Artifact(org.sonatype.aether.artifact.Artifact) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 80 with Artifact

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

the class GetTest method testDownloadArtifact.

@Test
public void testDownloadArtifact() throws Exception {
    addDelivery("gid/aid/version/aid-version-classifier.extension", "artifact");
    addDelivery("gid/aid/version/aid-version-classifier.extension.sha1", sha1("artifact"));
    addDelivery("gid/aid/version/aid-version-classifier.extension.md5", md5("artifact"));
    File f = TestFileUtils.createTempFile("");
    Artifact a = artifact("bla");
    ArtifactDownload down = new ArtifactDownload(a, null, f, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    Collection<? extends ArtifactDownload> downs = Arrays.asList(down);
    RepositoryConnector c = connector();
    c.get(downs, null);
    assertNull(String.valueOf(down.getException()), down.getException());
    TestFileUtils.assertContent("artifact", f);
}
Also used : ArtifactDownload(org.sonatype.aether.spi.connector.ArtifactDownload) RepositoryConnector(org.sonatype.aether.spi.connector.RepositoryConnector) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) 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