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));
}
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());
}
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);
}
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);
}
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);
}
Aggregations