ElasticContainer: Create with static method
Move creation of the container and handling of failure into a static method in ElasticContainer, which is then called from the tests. Change-Id: I176acdc05bbc6e06ce8c1fd76acbc9b3902c06be
This commit is contained in:
@@ -24,7 +24,6 @@ import com.google.inject.Injector;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.internal.AssumptionViolatedException;
|
||||
|
||||
public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
private static ElasticNodeInfo nodeInfo;
|
||||
@@ -37,15 +36,7 @@ public class ElasticQueryAccountsTest extends AbstractQueryAccountsTest {
|
||||
return;
|
||||
}
|
||||
|
||||
// Assumption violation is not natively supported by Testcontainers.
|
||||
// See https://github.com/testcontainers/testcontainers-java/issues/343
|
||||
try {
|
||||
container = new ElasticContainer<>();
|
||||
container.start();
|
||||
} catch (Throwable t) {
|
||||
throw new AssumptionViolatedException("Unable to start container[might be docker related]");
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart();
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,6 @@ import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.internal.AssumptionViolatedException;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
|
||||
@@ -44,13 +43,7 @@ public class ElasticQueryChangesTest extends AbstractQueryChangesTest {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
container = new ElasticContainer<>();
|
||||
container.start();
|
||||
} catch (Throwable t) {
|
||||
throw new AssumptionViolatedException("Unable to start container[might be docker related]");
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart();
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
|
@@ -24,7 +24,6 @@ import com.google.inject.Injector;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.internal.AssumptionViolatedException;
|
||||
|
||||
public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
private static ElasticNodeInfo nodeInfo;
|
||||
@@ -37,13 +36,7 @@ public class ElasticQueryGroupsTest extends AbstractQueryGroupsTest {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
container = new ElasticContainer<>();
|
||||
container.start();
|
||||
} catch (Throwable t) {
|
||||
throw new AssumptionViolatedException("Unable to start container[might be docker related]");
|
||||
}
|
||||
|
||||
container = ElasticContainer.createAndStart();
|
||||
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user