Search in sources :

Example 26 with DefaultArtifact

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

the class EnhancedLocalRepositoryManagerTest method testGetPathForLocalArtifact.

@Test
public void testGetPathForLocalArtifact() {
    Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
    assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
    assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForLocalArtifact(artifact));
    artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-20110329.221805-4");
    assertEquals("1.0-SNAPSHOT", artifact.getBaseVersion());
    assertEquals("g/i/d/a.i.d/1.0-SNAPSHOT/a.i.d-1.0-SNAPSHOT.jar", manager.getPathForLocalArtifact(artifact));
}
Also used : 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 27 with DefaultArtifact

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

the class DefaultInstallerTest method setup.

@Before
public void setup() throws IOException {
    artifact = new DefaultArtifact("gid", "aid", "jar", "ver");
    artifact = artifact.setFile(TestFileUtils.createTempFile("artifact".getBytes(), 1));
    metadata = new DefaultMetadata("gid", "aid", "ver", "type", Nature.RELEASE_OR_SNAPSHOT, TestFileUtils.createTempFile("metadata".getBytes(), 1));
    session = new TestRepositorySystemSession();
    localArtifactPath = session.getLocalRepositoryManager().getPathForLocalArtifact(artifact);
    localMetadataPath = session.getLocalRepositoryManager().getPathForLocalMetadata(metadata);
    localArtifactFile = new File(session.getLocalRepository().getBasedir(), localArtifactPath);
    installer = new DefaultInstaller();
    installer.setFileProcessor(TestFileProcessor.INSTANCE);
    installer.setRepositoryEventDispatcher(new StubRepositoryEventDispatcher());
    installer.setSyncContextFactory(new StubSyncContextFactory());
    request = new InstallRequest();
    listener = new RecordingRepositoryListener();
    session.setRepositoryListener(listener);
    lrm = (TestLocalRepositoryManager) session.getLocalRepositoryManager();
    TestFileUtils.delete(session.getLocalRepository().getBasedir());
}
Also used : TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) InstallRequest(org.sonatype.aether.installation.InstallRequest) DefaultMetadata(org.sonatype.aether.util.metadata.DefaultMetadata) RecordingRepositoryListener(org.sonatype.aether.test.impl.RecordingRepositoryListener) File(java.io.File) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Before(org.junit.Before)

Example 28 with DefaultArtifact

use of org.sonatype.aether.util.artifact.DefaultArtifact 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 29 with DefaultArtifact

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

the class ArtifactWorkerTest method testArtifactTransfer.

@Test
public void testArtifactTransfer() throws IOException, ArtifactTransferException {
    DefaultArtifact artifact = new DefaultArtifact("test", "artId1", "jar", "1");
    String expectedContent = "Dies ist ein Test.";
    uploadArtifact(artifact, expectedContent);
    File file = downloadArtifact(artifact);
    assertContentEquals(file, expectedContent);
}
Also used : File(java.io.File) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Test(org.junit.Test)

Example 30 with DefaultArtifact

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

the class FindAvailableVersions method main.

public static void main(String[] args) throws Exception {
    System.out.println("------------------------------------------------------------");
    System.out.println(FindAvailableVersions.class.getSimpleName());
    RepositorySystem system = Booter.newRepositorySystem();
    RepositorySystemSession session = Booter.newRepositorySystemSession(system);
    Artifact artifact = new DefaultArtifact("org.sonatype.aether:aether-util:[0,)");
    RemoteRepository repo = Booter.newCentralRepository();
    VersionRangeRequest rangeRequest = new VersionRangeRequest();
    rangeRequest.setArtifact(artifact);
    rangeRequest.addRepository(repo);
    VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
    List<Version> versions = rangeResult.getVersions();
    System.out.println("Available versions " + versions);
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) VersionRangeResult(org.sonatype.aether.resolution.VersionRangeResult) Version(org.sonatype.aether.version.Version) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) VersionRangeRequest(org.sonatype.aether.resolution.VersionRangeRequest) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Aggregations

DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)33 Artifact (org.sonatype.aether.artifact.Artifact)23 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)18 Test (org.junit.Test)10 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)10 File (java.io.File)9 RepositorySystem (org.sonatype.aether.RepositorySystem)9 Dependency (org.sonatype.aether.graph.Dependency)9 CollectRequest (org.sonatype.aether.collection.CollectRequest)8 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)6 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)5 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)4 PatternExclusionsDependencyFilter (org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter)4 Before (org.junit.Before)3 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)3 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)3 DefaultMetadata (org.sonatype.aether.util.metadata.DefaultMetadata)3 ConsoleDependencyGraphDumper (demo.util.ConsoleDependencyGraphDumper)2 CollectResult (org.sonatype.aether.collection.CollectResult)2 DeployRequest (org.sonatype.aether.deployment.DeployRequest)2