Ensure local repository cache is always used

This commit is contained in:
Dave Syer
2014-01-03 09:56:11 +00:00
parent 47a0df1e3d
commit df476bed1f
7 changed files with 81 additions and 30 deletions

View File

@@ -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);
}
}
});
}

View File

@@ -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:"));
}
}

View 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() {