Prevents tests that use Elasticsearch from polluting the filesystem

By default, Elasticsearch writes it data to ./data. This led to data
being left on the filesystem after a mvn clean which could cause
failures when moving between branches that use different versions of
Elasticsearch.

This commit updates the tests for the Elasticsearch sample and
the Elasticsearch auto-configuration classes to write the
Elasticsearch data and logs into the target directory.
This commit is contained in:
Andy Wilkinson
2015-04-21 12:50:18 +01:00
parent 326bdf29c2
commit dabbb02dfe
6 changed files with 29 additions and 7 deletions

View File

@@ -20,6 +20,7 @@ import java.net.ConnectException;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.test.OutputCapture;
import org.springframework.core.NestedCheckedException;
@@ -38,7 +39,11 @@ public class SampleElasticsearchApplicationTests {
@Test
public void testDefaultSettings() throws Exception {
try {
SampleElasticsearchApplication.main(new String[0]);
new SpringApplicationBuilder(SampleElasticsearchApplication.class)
.properties(
"spring.data.elasticsearch.properties.path.data:target/data",
"spring.data.elasticsearch.properties.path.logs:target/logs")
.run();
}
catch (IllegalStateException ex) {
if (serverNotRunning(ex)) {