Search in sources :

Example 1 with DefaultMetadata

use of org.sonatype.aether.util.metadata.DefaultMetadata in project sonatype-aether by sonatype.

the class EnhancedLocalRepositoryManagerTest method setup.

@Before
public void setup() throws Exception {
    repository = new RemoteRepository("enhanced-remote-repo", "default", TestFileUtils.createTempDir("enhanced-remote-repo").toURI().toURL().toString());
    repository.setRepositoryManager(true);
    artifact = new DefaultArtifact("gid", "aid", "", "jar", "1-test", Collections.<String, String>emptyMap(), TestFileUtils.createTempFile("artifact"));
    metadata = new DefaultMetadata("gid", "aid", "1-test", "maven-metadata.xml", Nature.RELEASE, TestFileUtils.createTempFile("metadata"));
    noVerMetadata = new DefaultMetadata("gid", "aid", null, "maven-metadata.xml", Nature.RELEASE, TestFileUtils.createTempFile("metadata"));
    basedir = TestFileUtils.createTempDir("enhanced-repo");
    manager = new EnhancedLocalRepositoryManager(basedir);
    artifactFile = new File(basedir, manager.getPathForLocalArtifact(artifact));
    session = new TestRepositorySystemSession();
}
Also used : TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) DefaultMetadata(org.sonatype.aether.util.metadata.DefaultMetadata) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) File(java.io.File) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Before(org.junit.Before)

Example 2 with DefaultMetadata

use of org.sonatype.aether.util.metadata.DefaultMetadata in project sonatype-aether by sonatype.

the class DefaultDeployerTest method setup.

@Before
public void setup() throws IOException {
    artifact = new DefaultArtifact("gid", "aid", "jar", "ver");
    artifact = artifact.setFile(TestFileUtils.createTempFile("artifact"));
    metadata = new DefaultMetadata("gid", "aid", "ver", "type", Nature.RELEASE_OR_SNAPSHOT, TestFileUtils.createTempFile("metadata"));
    session = new TestRepositorySystemSession();
    manager = new StubRemoteRepositoryManager();
    deployer = new DefaultDeployer();
    deployer.setRemoteRepositoryManager(manager);
    deployer.setRepositoryEventDispatcher(new StubRepositoryEventDispatcher());
    UpdateCheckManager updateCheckManager = new StaticUpdateCheckManager(true);
    deployer.setUpdateCheckManager(updateCheckManager);
    deployer.setFileProcessor(TestFileProcessor.INSTANCE);
    deployer.setSyncContextFactory(new StubSyncContextFactory());
    request = new DeployRequest();
    request.setRepository(new RemoteRepository("id", "default", "file:///"));
    connector = new RecordingRepositoryConnector();
    manager.setConnector(connector);
    listener = new RecordingRepositoryListener();
    session.setRepositoryListener(listener);
}
Also used : DeployRequest(org.sonatype.aether.deployment.DeployRequest) DefaultMetadata(org.sonatype.aether.util.metadata.DefaultMetadata) UpdateCheckManager(org.sonatype.aether.impl.UpdateCheckManager) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) RecordingRepositoryListener(org.sonatype.aether.test.impl.RecordingRepositoryListener) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Before(org.junit.Before)

Example 3 with DefaultMetadata

use of org.sonatype.aether.util.metadata.DefaultMetadata 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 4 with DefaultMetadata

use of org.sonatype.aether.util.metadata.DefaultMetadata in project sonatype-aether by sonatype.

the class ArtifactWorkerTest method testMetadataTransfer.

@Test
public void testMetadataTransfer() throws IOException, MetadataTransferException {
    String expectedContent = "Dies ist ein Test.";
    File srcFile = TestFileUtils.createTempFile(expectedContent);
    DefaultMetadata metadata = new DefaultMetadata("test", "artId1", "1", "jar", Nature.RELEASE_OR_SNAPSHOT);
    MetadataUpload up = new MetadataUpload(metadata, srcFile);
    FileRepositoryWorker worker = new FileRepositoryWorker(up, repository, session);
    worker.setFileProcessor(TestFileProcessor.INSTANCE);
    worker.run();
    if (up.getException() != null) {
        throw up.getException();
    }
    File targetFile = TestFileUtils.createTempFile("");
    TestFileUtils.delete(targetFile);
    MetadataDownload down = new MetadataDownload();
    down.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    down.setMetadata(metadata).setFile(targetFile);
    worker = new FileRepositoryWorker(down, repository, session);
    worker.setFileProcessor(TestFileProcessor.INSTANCE);
    worker.run();
    if (down.getException() != null) {
        throw down.getException();
    }
    assertTrue("download did not happen.", targetFile.exists());
    assertContentEquals(targetFile, expectedContent);
}
Also used : DefaultMetadata(org.sonatype.aether.util.metadata.DefaultMetadata) MetadataUpload(org.sonatype.aether.spi.connector.MetadataUpload) MetadataDownload(org.sonatype.aether.spi.connector.MetadataDownload) File(java.io.File) Test(org.junit.Test)

Aggregations

DefaultMetadata (org.sonatype.aether.util.metadata.DefaultMetadata)4 File (java.io.File)3 Before (org.junit.Before)3 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)3 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)3 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)2 RecordingRepositoryListener (org.sonatype.aether.test.impl.RecordingRepositoryListener)2 Test (org.junit.Test)1 DeployRequest (org.sonatype.aether.deployment.DeployRequest)1 UpdateCheckManager (org.sonatype.aether.impl.UpdateCheckManager)1 InstallRequest (org.sonatype.aether.installation.InstallRequest)1 MetadataDownload (org.sonatype.aether.spi.connector.MetadataDownload)1 MetadataUpload (org.sonatype.aether.spi.connector.MetadataUpload)1