use of org.xwiki.test.integration.XWikiExecutor in project xwiki-platform by xwiki.
the class AbstractClusterHttpTest method init.
@BeforeClass
public static void init() throws Exception {
if (context == null) {
// Start HSQLDB server if not already running
try (Socket ignored = new Socket("localhost", 9001)) {
LOGGER.info("HSQLDB server is already running");
} catch (IOException ignored) {
LOGGER.info("HSQLDB server is not running. Starting one...");
Server server = new Server();
server.setSilent(true);
File testDirectory = new File("target/test-" + new Date().getTime()).getAbsoluteFile();
File databaseDirectory = new File(testDirectory, "database");
server.setDatabaseName(0, "xwiki_db");
server.setDatabasePath(0, databaseDirectory.toString());
server.setDaemon(true);
server.start();
LOGGER.info("HSQLDB server started");
}
List<XWikiExecutor> executors = new ArrayList<>(2);
executors.add(createExecutor(0));
executors.add(createExecutor(1));
// Require some AbstractTest initialization
AbstractTest.init(executors);
}
}
use of org.xwiki.test.integration.XWikiExecutor in project xwiki-platform by xwiki.
the class AllITs method preStart.
@XWikiExecutorSuite.PreStart
public void preStart(List<XWikiExecutor> executors) throws Exception {
XWikiExecutor executor = executors.get(0);
repositoryUtil = new RepositoryUtils();
LOGGER.info("Adding repository to xwiki.properties");
PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
// Put self and Maven as extensions repository
properties.setProperty("extension.repositories", Arrays.asList("self:xwiki:http://localhost:8080/xwiki/rest", "maven-test:maven:" + repositoryUtil.getMavenRepository().toURI()));
// Disable core extension resolve because Jetty is not ready when it starts
properties.setProperty("extension.core.resolve", false);
executor.saveXWikiProperties();
}
use of org.xwiki.test.integration.XWikiExecutor in project xwiki-platform by xwiki.
the class ForEachProfileSuite method run.
@Override
public void run(RunNotifier notifier) {
// Get the list of test profiles.
final List<Class<?>> profiles = new ClasspathClassesFinder(IsProfileTester.INSTANCE, "java.class.path").find();
final Map<Profile, XWikiExecutor> executorByProfile = new HashMap<Profile, XWikiExecutor>();
for (int i = 0; i < profiles.size(); i++) {
try {
// All executors are #0 because they will not be run in parallel.
executorByProfile.put(((Class<Profile>) profiles.get(i)).newInstance(), new XWikiExecutor(0));
} catch (Exception e) {
throw new RuntimeException("Failed to instanciate configuration profile.", e);
}
}
// Callback to setup executors in the suite class.
try {
for (Profile profile : executorByProfile.keySet()) {
profile.apply(executorByProfile.get(profile));
}
} catch (Exception e) {
throw new RuntimeException("Failed to initialize XWiki Executors", e);
}
for (final Profile profile : executorByProfile.keySet()) {
final XWikiExecutor executor = executorByProfile.get(profile);
try {
try {
executor.start();
} catch (Exception e) {
throw new RuntimeException("Failed to start XWiki", e);
}
try {
Object instance = this.getTestClass().getJavaClass().newInstance();
// and has an @Inject annotation, inject the current executor.
for (Field field : this.getTestClass().getJavaClass().getDeclaredFields()) {
if (field.getType() == XWikiExecutor.class && field.getAnnotation(Inject.class) != null) {
field.setAccessible(true);
field.set(instance, executor);
}
}
// If the class is initializable then call initialize.
final Class<?>[] interfaces = this.getTestClass().getJavaClass().getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
if (interfaces[i] == Initializable.class) {
this.getTestClass().getJavaClass().getMethod("initialize").invoke(instance);
}
}
} catch (Exception e) {
throw new RuntimeException("Failed to prepare tests to run in config profile.", e);
}
super.run(notifier);
} finally {
try {
executor.stop();
} catch (Exception e) {
// Squash this and let the original exception be thrown.
}
}
}
}
use of org.xwiki.test.integration.XWikiExecutor in project xwiki-platform by xwiki.
the class AbstractClusterHttpTest method createExecutor.
protected static XWikiExecutor createExecutor(int index) {
XWikiExecutor executor = new XWikiExecutor(index);
AllTests.setupExecutor(executor);
return executor;
}
use of org.xwiki.test.integration.XWikiExecutor in project xwiki-platform by xwiki.
the class AllTests method preStart.
@XWikiExecutorSuite.PreStart
public void preStart(List<XWikiExecutor> executors) throws Exception {
XWikiExecutor executor = executors.get(0);
repositoryUtil = new RepositoryUtils();
LOGGER.info("Adding maven repository to xwiki.properties");
PropertiesConfiguration properties = executor.loadXWikiPropertiesConfiguration();
// Put self as extensions repository
properties.setProperty("extension.repositories", "maven-test:maven:" + repositoryUtil.getMavenRepository().toURI());
// Disable core extension resolve because Jetty is not ready when it starts
properties.setProperty("extension.core.resolve", false);
executor.saveXWikiProperties();
}
Aggregations