Search in sources :

Example 11 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class ConnectorTestSuite method testProgressEventsDataBuffer.

@Test
public void testProgressEventsDataBuffer() throws UnsupportedEncodingException, IOException, NoSuchAlgorithmException, NoRepositoryConnectorException {
    byte[] bytes = "These are the test contents.\n".getBytes("UTF-8");
    int count = 120000;
    MessageDigest digest = MessageDigest.getInstance("SHA-1");
    for (int i = 0; i < count; i++) {
        digest.update(bytes);
    }
    byte[] hash = digest.digest();
    File file = TestFileUtils.createTempFile(bytes, count);
    Artifact artifact = new StubArtifact("gid:aid:ext:ver");
    ArtifactUpload upA = new ArtifactUpload(artifact, file);
    File dir = TestFileUtils.createTempDir("con-test");
    File downAFile = new File(dir, "downA.file");
    downAFile.deleteOnExit();
    ArtifactDownload downA = new ArtifactDownload(artifact, "", downAFile, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    Metadata metadata = new StubMetadata("gid", "aid", "ver", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT);
    MetadataUpload upM = new MetadataUpload(metadata, file);
    File downMFile = new File(dir, "downM.file");
    downMFile.deleteOnExit();
    MetadataDownload downM = new MetadataDownload(metadata, "", downMFile, RepositoryPolicy.CHECKSUM_POLICY_FAIL);
    DigestingTransferListener listener = new DigestingTransferListener();
    session.setTransferListener(listener);
    RepositoryConnector connector = factory().newInstance(session, repository);
    connector.put(Arrays.asList(upA), null);
    assertArrayEquals(hash, listener.getHash());
    listener.rewind();
    connector.put(null, Arrays.asList(upM));
    assertArrayEquals(hash, listener.getHash());
    listener.rewind();
    connector.get(Arrays.asList(downA), null);
    assertArrayEquals(hash, listener.getHash());
    listener.rewind();
    connector.get(null, Arrays.asList(downM));
    assertArrayEquals(hash, listener.getHash());
    listener.rewind();
    connector.close();
}
Also used : ArtifactUpload(org.sonatype.aether.spi.connector.ArtifactUpload) StubMetadata(org.sonatype.aether.test.util.impl.StubMetadata) Metadata(org.sonatype.aether.metadata.Metadata) MetadataUpload(org.sonatype.aether.spi.connector.MetadataUpload) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) ArtifactDownload(org.sonatype.aether.spi.connector.ArtifactDownload) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) StubMetadata(org.sonatype.aether.test.util.impl.StubMetadata) RepositoryConnector(org.sonatype.aether.spi.connector.RepositoryConnector) MetadataDownload(org.sonatype.aether.spi.connector.MetadataDownload) MessageDigest(java.security.MessageDigest) File(java.io.File) Test(org.junit.Test)

Example 12 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class IniArtifactDescriptorReaderTest method testMissingDescriptor.

@Test(expected = ArtifactDescriptorException.class)
public void testMissingDescriptor() throws ArtifactDescriptorException {
    StubArtifact art = new StubArtifact("missing:aid:ver:ext");
    ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(art, null, "");
    reader.readArtifactDescriptor(session, request);
}
Also used : StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) ArtifactDescriptorRequest(org.sonatype.aether.resolution.ArtifactDescriptorRequest) Test(org.junit.Test)

Example 13 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class IniArtifactDescriptorReaderTest method testLookup.

@Test
public void testLookup() throws ArtifactDescriptorException {
    StubArtifact art = new StubArtifact("gid:aid:ext:ver");
    ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(art, null, "");
    ArtifactDescriptorResult description = reader.readArtifactDescriptor(session, request);
    assertEquals(request, description.getRequest());
    assertEquals(art, description.getArtifact());
    assertEquals(1, description.getRelocations().size());
    Artifact artifact = description.getRelocations().get(0);
    assertEquals("gid", artifact.getGroupId());
    assertEquals("aid", artifact.getArtifactId());
    assertEquals("ver", artifact.getVersion());
    assertEquals("ext", artifact.getExtension());
    assertEquals(1, description.getRepositories().size());
    RemoteRepository repo = description.getRepositories().get(0);
    assertEquals("id", repo.getId());
    assertEquals("type", repo.getContentType());
    assertEquals("protocol://some/url?for=testing", repo.getUrl());
    assertDependencies(description.getDependencies());
    assertDependencies(description.getManagedDependencies());
}
Also used : StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) ArtifactDescriptorResult(org.sonatype.aether.resolution.ArtifactDescriptorResult) ArtifactDescriptorRequest(org.sonatype.aether.resolution.ArtifactDescriptorRequest) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) Artifact(org.sonatype.aether.artifact.Artifact) Test(org.junit.Test)

Example 14 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class DefaultUpdateCheckManagerTest method setup.

@Before
public void setup() throws Exception {
    File dir = TestFileUtils.createTempFile("");
    TestFileUtils.delete(dir);
    File metadataFile = new File(dir, "metadata.txt");
    TestFileUtils.write("metadata", metadataFile);
    File artifactFile = new File(dir, "artifact.txt");
    TestFileUtils.write("artifact", artifactFile);
    session = new TestRepositorySystemSession();
    repository = new RemoteRepository("id", "default", TestFileUtils.createTempDir().toURL().toString());
    manager = new DefaultUpdateCheckManager();
    metadata = new StubMetadata("gid", "aid", "ver", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT, metadataFile);
    artifact = new StubArtifact("gid", "aid", "", "ext", "ver").setFile(artifactFile);
}
Also used : TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) StubMetadata(org.sonatype.aether.test.util.impl.StubMetadata) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) File(java.io.File) Before(org.junit.Before)

Example 15 with StubArtifact

use of org.sonatype.aether.test.util.impl.StubArtifact in project sonatype-aether by sonatype.

the class AsyncConnectorSuiteConfiguration method before.

@Override
@Before
public void before() throws Exception {
    super.before();
    this.factory = new AsyncRepositoryConnectorFactory(NullLogger.INSTANCE, new TestFileProcessor());
    this.session = new TestRepositorySystemSession();
    this.repository = new RemoteRepository("async-test-repo", "default", url("repo"));
    this.artifact = new StubArtifact("gid", "aid", "classifier", "extension", "version", null);
    this.metadata = new StubMetadata("gid", "aid", "version", "maven-metadata.xml", Metadata.Nature.RELEASE_OR_SNAPSHOT, null);
    connector = null;
}
Also used : TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) StubMetadata(org.sonatype.aether.test.util.impl.StubMetadata) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Before(org.junit.Before)

Aggregations

StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)17 Test (org.junit.Test)8 Artifact (org.sonatype.aether.artifact.Artifact)8 StubMetadata (org.sonatype.aether.test.util.impl.StubMetadata)7 File (java.io.File)6 ArtifactDownload (org.sonatype.aether.spi.connector.ArtifactDownload)6 ArtifactUpload (org.sonatype.aether.spi.connector.ArtifactUpload)6 MetadataDownload (org.sonatype.aether.spi.connector.MetadataDownload)5 MetadataUpload (org.sonatype.aether.spi.connector.MetadataUpload)5 Before (org.junit.Before)4 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)4 RepositoryConnector (org.sonatype.aether.spi.connector.RepositoryConnector)4 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)4 ArrayList (java.util.ArrayList)3 Metadata (org.sonatype.aether.metadata.Metadata)3 TestFileProcessor (org.sonatype.aether.test.impl.TestFileProcessor)3 Dependency (org.sonatype.aether.graph.Dependency)2 ArtifactDescriptorRequest (org.sonatype.aether.resolution.ArtifactDescriptorRequest)2 SysoutLogger (org.sonatype.aether.test.impl.SysoutLogger)2 IOException (java.io.IOException)1