Search in sources :

Example 11 with MavenConfigurationImpl

use of io.fabric8.maven.util.MavenConfigurationImpl in project fabric8 by jboss-fuse.

the class AetherTimeoutTest method readTimeout.

@Test
public void readTimeout() throws Exception {
    // case 1: resolution fails because of timeout
    // - aether uses 500ms read timeout
    // - server responds with 1000ms delay
    // - we interrupt resolution after 3000ms in case read timeout in socket.setSoTimeout() is set to 0
    MavenConfigurationImpl mavenConfiguration = basicMavenConfiguration(500);
    mavenConfiguration.setSettings(settingsWithJettyRepository());
    Future<Boolean> task = pool.submit(new ResolveArtifactTask(mavenConfiguration, 1000));
    try {
        boolean resolved = task.get(3000, TimeUnit.MILLISECONDS);
        assertFalse("Should not be resolved due to read timeout", resolved);
    } catch (TimeoutException e) {
        task.cancel(true);
        fail("Should fail due to socket read timeout earlier, not due to future.get() timeout.");
    }
    // case 2: resolution doesn't fail, we're cancelling the task earlier
    // - aether uses 6s read timeout
    // - server responds with 3s delay
    // - we interrupt resolution after 2s ensuring that Aether resolution didn't end on timeout yet
    mavenConfiguration = basicMavenConfiguration(6000);
    mavenConfiguration.setSettings(settingsWithJettyRepository());
    task = pool.submit(new ResolveArtifactTask(mavenConfiguration, 3000));
    boolean timedOut;
    try {
        task.get(2000, TimeUnit.MILLISECONDS);
        timedOut = false;
        fail("Task should not be completed yet");
    } catch (TimeoutException e) {
        timedOut = true;
        task.cancel(true);
    }
    assertTrue("Resolution task should be interrupted", timedOut);
}
Also used : MavenConfigurationImpl(io.fabric8.maven.util.MavenConfigurationImpl) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

MavenConfigurationImpl (io.fabric8.maven.util.MavenConfigurationImpl)11 PropertiesPropertyResolver (org.ops4j.util.property.PropertiesPropertyResolver)5 Properties (java.util.Properties)4 DictionaryPropertyResolver (org.ops4j.util.property.DictionaryPropertyResolver)4 AetherBasedResolver (io.fabric8.maven.url.internal.AetherBasedResolver)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 MavenResolver (io.fabric8.maven.MavenResolver)2 MavenConfiguration (io.fabric8.maven.util.MavenConfiguration)2 TimeoutException (java.util.concurrent.TimeoutException)2 File (java.io.File)1 URL (java.net.URL)1 Dictionary (java.util.Dictionary)1 Hashtable (java.util.Hashtable)1 Proxy (org.apache.maven.settings.Proxy)1 RepositoryException (org.eclipse.aether.RepositoryException)1 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)1 ArtifactNotFoundException (org.eclipse.aether.transfer.ArtifactNotFoundException)1 ArtifactTransferException (org.eclipse.aether.transfer.ArtifactTransferException)1 PropertyResolver (org.ops4j.util.property.PropertyResolver)1