Search in sources :

Example 1 with TestFileProcessor

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

the class AsyncHandlerExceptionTest method testIt.

@Test
public void testIt() throws Exception {
    HttpServer server = new HttpServer();
    server.addResources("/", baseDir.getAbsolutePath());
    server.start();
    try {
        RemoteRepository repo = new RemoteRepository("id", "default", server.getHttpUrl() + "/repo");
        RepositorySystemSession session = new DefaultRepositorySystemSession();
        AsyncRepositoryConnector connector = new AsyncRepositoryConnector(repo, session, new TestFileProcessor(), new SysoutLogger());
        try {
            StubArtifact artifact = new StubArtifact("gid:aid:1.0");
            for (int i = 0; i < 16; i++) {
                System.out.println("RUN #" + i);
                TestFileUtils.delete(baseDir);
                ArtifactDownload download = new ArtifactDownload(artifact, "project", new File(baseDir, "a.jar"), "ignore");
                System.out.println("GET");
                connector.get(Arrays.asList(download), null);
                assertTrue(String.valueOf(download.getException()), download.getException() instanceof ArtifactNotFoundException);
                ArtifactUpload upload = new ArtifactUpload(artifact, new File("pom.xml"));
                System.out.println("PUT");
                connector.put(Arrays.asList(upload), null);
                if (upload.getException() != null) {
                    upload.getException().printStackTrace();
                }
                assertNull(String.valueOf(upload.getException()), upload.getException());
            }
        } finally {
            connector.close();
        }
    } finally {
        server.stop();
    }
}
Also used : RepositorySystemSession(org.sonatype.aether.RepositorySystemSession) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) SysoutLogger(org.sonatype.aether.test.impl.SysoutLogger) ArtifactUpload(org.sonatype.aether.spi.connector.ArtifactUpload) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) ArtifactDownload(org.sonatype.aether.spi.connector.ArtifactDownload) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) StubArtifact(org.sonatype.aether.test.util.impl.StubArtifact) File(java.io.File) ArtifactNotFoundException(org.sonatype.aether.transfer.ArtifactNotFoundException) Test(org.junit.Test)

Example 2 with TestFileProcessor

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

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new SysoutLogger(), Logger.class, null);
    getContainer().addComponent(new TestFileProcessor(), FileProcessor.class, null);
    RepositoryConnectorFactory factory = lookup(RepositoryConnectorFactory.class, "async-http");
    assertNotNull(factory);
    assertEquals(AsyncRepositoryConnectorFactory.class, factory.getClass());
}
Also used : TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) SysoutLogger(org.sonatype.aether.test.impl.SysoutLogger) RepositoryConnectorFactory(org.sonatype.aether.spi.connector.RepositoryConnectorFactory)

Example 3 with TestFileProcessor

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

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new SysoutLogger(), Logger.class, null);
    getContainer().addComponent(new TestFileProcessor(), FileProcessor.class, null);
    RepositoryConnectorFactory factory = lookup(RepositoryConnectorFactory.class, "file");
    assertNotNull(factory);
    assertEquals(FileRepositoryConnectorFactory.class, factory.getClass());
}
Also used : TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) SysoutLogger(org.sonatype.aether.test.impl.SysoutLogger) RepositoryConnectorFactory(org.sonatype.aether.spi.connector.RepositoryConnectorFactory)

Example 4 with TestFileProcessor

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

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new SysoutLogger(), Logger.class, null);
    getContainer().addComponent(new TestFileProcessor(), FileProcessor.class, null);
    RepositoryConnectorFactory factory = lookup(RepositoryConnectorFactory.class, "wagon");
    assertNotNull(factory);
    assertEquals(WagonRepositoryConnectorFactory.class, factory.getClass());
}
Also used : TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) SysoutLogger(org.sonatype.aether.test.impl.SysoutLogger) RepositoryConnectorFactory(org.sonatype.aether.spi.connector.RepositoryConnectorFactory)

Example 5 with TestFileProcessor

use of org.sonatype.aether.test.impl.TestFileProcessor 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

TestFileProcessor (org.sonatype.aether.test.impl.TestFileProcessor)6 SysoutLogger (org.sonatype.aether.test.impl.SysoutLogger)5 RepositoryConnectorFactory (org.sonatype.aether.spi.connector.RepositoryConnectorFactory)3 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)3 Before (org.junit.Before)2 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)2 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)2 File (java.io.File)1 Server (org.eclipse.jetty.server.Server)1 Test (org.junit.Test)1 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)1 ArtifactDownload (org.sonatype.aether.spi.connector.ArtifactDownload)1 ArtifactUpload (org.sonatype.aether.spi.connector.ArtifactUpload)1 StubMetadata (org.sonatype.aether.test.util.impl.StubMetadata)1 ArtifactNotFoundException (org.sonatype.aether.transfer.ArtifactNotFoundException)1 DefaultRepositorySystemSession (org.sonatype.aether.util.DefaultRepositorySystemSession)1