Ensure local repository cache is always used
This commit is contained in:
@@ -88,8 +88,14 @@ public class CliTester implements TestRule {
|
||||
return Executors.newSingleThreadExecutor().submit(new Callable<T>() {
|
||||
@Override
|
||||
public T call() throws Exception {
|
||||
command.run(sources);
|
||||
return command;
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
command.run(sources);
|
||||
return command;
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setContextClassLoader(loader);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,9 +54,8 @@ public class GrabCommandIntegrationTests {
|
||||
|
||||
// Use --autoconfigure=false to limit the amount of downloaded dependencies
|
||||
String output = this.cli.grab("grab.groovy", "--autoconfigure=false");
|
||||
assertTrue(output.contains("Downloading: file:"));
|
||||
assertTrue(new File("target/repository/net/sf/jopt-simple/jopt-simple")
|
||||
.isDirectory());
|
||||
|
||||
assertTrue(output.contains("Downloading: file:"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -60,8 +61,16 @@ public class SpringCliTests {
|
||||
|
||||
private Set<Call> calls = EnumSet.noneOf(Call.class);
|
||||
|
||||
private ClassLoader loader;
|
||||
|
||||
@After
|
||||
public void close() {
|
||||
Thread.currentThread().setContextClassLoader(this.loader);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.loader = Thread.currentThread().getContextClassLoader();
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.cli = new SpringCli() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user