use of io.fabric8.maven.util.MavenConfiguration 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);
}
Aggregations