Skip to content
Snippets Groups Projects
Commit 6d51668d authored by Thomas Mortagne's avatar Thomas Mortagne
Browse files

[Misc] Improve environment handling during tests

(cherry picked from commit f7d57698)
parent 48306108
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,7 @@
import org.xwiki.extension.test.RepositoryUtils;
import org.xwiki.repository.test.RepositoryTestUtils;
import org.xwiki.repository.test.SolrTestUtils;
import org.xwiki.test.TestEnvironment;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.integration.XWikiExecutorSuite;
......@@ -48,13 +49,15 @@ public class AllIT
private static RepositoryUtils repositoryUtil;
private static TestEnvironment environment = new TestEnvironment();
@XWikiExecutorSuite.PreStart
public void preStart(List<XWikiExecutor> executors) throws Exception
{
XWikiExecutor executor = executors.get(0);
repositoryUtil = new RepositoryUtils();
repositoryUtil.setup();
repositoryUtil.setup(environment);
LOGGER.info("Adding repository to xwiki.properties");
......@@ -81,13 +84,13 @@ public static void initExtensions(PersistentTestContext context) throws Exceptio
// This will not be null if we are in the middle of allTests
if (repositoryUtil == null) {
repositoryUtil = new RepositoryUtils();
repositoryUtil.setup();
repositoryUtil.setup(environment);
}
// Initialize extensions and repositories
RepositoryTestUtils repositoryTestUtil =
new RepositoryTestUtils(context.getUtil(), repositoryUtil, new SolrTestUtils(context.getUtil()));
repositoryTestUtil.init();
repositoryTestUtil.init(environment);
ExtensionTestUtils extensionTestUtil = new ExtensionTestUtils(context.getUtil());
// Set integration repository and extension utils.
......
......@@ -31,6 +31,7 @@
import org.xwiki.extension.test.RepositoryUtils;
import org.xwiki.repository.test.RepositoryTestUtils;
import org.xwiki.repository.test.SolrTestUtils;
import org.xwiki.test.TestEnvironment;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.integration.XWikiExecutorSuite;
import org.xwiki.test.ui.PageObjectSuite;
......@@ -48,13 +49,15 @@ public class AllIT
private static RepositoryUtils repositoryUtil;
private static TestEnvironment environment = new TestEnvironment();
@XWikiExecutorSuite.PreStart
public void preStart(List<XWikiExecutor> executors) throws Exception
{
XWikiExecutor executor = executors.get(0);
repositoryUtil = new RepositoryUtils();
repositoryUtil.setup();
repositoryUtil.setup(environment);
LOGGER.info("Adding maven repository to xwiki.properties");
......@@ -81,14 +84,13 @@ public static void initExtensions(PersistentTestContext context) throws Exceptio
// Initialize extensions and repositories
RepositoryTestUtils repositoryTestUtil =
new RepositoryTestUtils(context.getUtil(), repositoryUtil, new SolrTestUtils(context.getUtil()));
repositoryTestUtil.init();
repositoryTestUtil.init(environment);
// Set integration repository and extension utils.
context.getProperties().put(RepositoryTestUtils.PROPERTY_KEY, repositoryTestUtil);
// Populate maven repository
File extensionFile =
repositoryTestUtil.getTestExtension(new ExtensionId("emptyjar", "1.0"), "jar").getFile().getFile();
File extensionFile = repositoryUtil.getExtensionPackager().getExtensionFile(new ExtensionId("emptyjar", "1.0"));
FileUtils.copyFile(extensionFile, new File(repositoryTestUtil.getRepositoryUtil().getMavenRepository(),
"maven/extension/1.0/extension-1.0.jar"));
FileUtils.copyFile(extensionFile, new File(repositoryTestUtil.getRepositoryUtil().getMavenRepository(),
......
......@@ -39,6 +39,7 @@
import org.xwiki.repository.internal.XWikiRepositoryModel;
import org.xwiki.rest.model.jaxb.Objects;
import org.xwiki.rest.model.jaxb.Page;
import org.xwiki.test.TestEnvironment;
import org.xwiki.test.ui.TestUtils;
import org.xwiki.test.ui.po.editor.ObjectEditPage;
......@@ -192,9 +193,14 @@ public RepositoryUtils getRepositoryUtil()
// Test init
public void init() throws Exception
{
init(new TestEnvironment());
}
public void init(TestEnvironment environment) throws Exception
{
// Initialize extensions and repositories
this.repositoryUtil.setup();
this.repositoryUtil.setup(environment);
}
// Test utils
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment