Search in sources :

Example 6 with InstallRequest

use of org.sonatype.aether.installation.InstallRequest in project sonatype-aether by sonatype.

the class DefaultInstallerTest method testSuccessfulMetadataEvents.

@Test
public void testSuccessfulMetadataEvents() throws InstallationException {
    InstallRequest request = new InstallRequest();
    request.addMetadata(metadata);
    installer.install(session, request);
    checkEvents("Repository Event problem", metadata, false);
}
Also used : InstallRequest(org.sonatype.aether.installation.InstallRequest) Test(org.junit.Test)

Example 7 with InstallRequest

use of org.sonatype.aether.installation.InstallRequest 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 8 with InstallRequest

use of org.sonatype.aether.installation.InstallRequest in project sonatype-aether by sonatype.

the class DefaultInstallerTest method testNullArtifactFile.

@Test(expected = InstallationException.class)
public void testNullArtifactFile() throws InstallationException {
    InstallRequest request = new InstallRequest();
    request.addArtifact(artifact.setFile(null));
    installer.install(session, request);
}
Also used : InstallRequest(org.sonatype.aether.installation.InstallRequest) Test(org.junit.Test)

Example 9 with InstallRequest

use of org.sonatype.aether.installation.InstallRequest in project sonatype-aether by sonatype.

the class DefaultInstallerTest method checkFailedEvents.

private void checkFailedEvents(String msg, Metadata metadata) {
    InstallRequest request = new InstallRequest().addMetadata(metadata);
    msg = "Repository events problem (case: " + msg + ")";
    try {
        installer.install(session, request);
        fail("expected exception");
    } catch (InstallationException e) {
        checkEvents(msg, metadata, true);
    }
}
Also used : InstallRequest(org.sonatype.aether.installation.InstallRequest) InstallationException(org.sonatype.aether.installation.InstallationException)

Example 10 with InstallRequest

use of org.sonatype.aether.installation.InstallRequest in project sonatype-aether by sonatype.

the class DefaultInstallerTest method testSetArtifactTimestamps.

@Test
public void testSetArtifactTimestamps() throws InstallationException {
    artifact.getFile().setLastModified(artifact.getFile().lastModified() - 60000);
    request.addArtifact(artifact);
    installer.install(session, request);
    assertEquals("artifact timestamp was not set to src file", artifact.getFile().lastModified(), localArtifactFile.lastModified());
    request = new InstallRequest();
    request.addArtifact(artifact);
    artifact.getFile().setLastModified(artifact.getFile().lastModified() - 60000);
    installer.install(session, request);
    assertEquals("artifact timestamp was not set to src file", artifact.getFile().lastModified(), localArtifactFile.lastModified());
}
Also used : InstallRequest(org.sonatype.aether.installation.InstallRequest) Test(org.junit.Test)

Aggregations

InstallRequest (org.sonatype.aether.installation.InstallRequest)12 Test (org.junit.Test)6 File (java.io.File)3 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)2 Artifact (org.sonatype.aether.artifact.Artifact)2 InstallationException (org.sonatype.aether.installation.InstallationException)2 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)2 IOException (java.io.IOException)1 MavenRepositorySystemSession (org.apache.maven.repository.internal.MavenRepositorySystemSession)1 Before (org.junit.Before)1 RepositorySystem (org.sonatype.aether.RepositorySystem)1 RecordingRepositoryListener (org.sonatype.aether.test.impl.RecordingRepositoryListener)1 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)1 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)1 DefaultMetadata (org.sonatype.aether.util.metadata.DefaultMetadata)1