use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class XMLTestRunner method run.
@Override
public void run(final RunNotifier notifier) {
try {
final String pkgName = getClass().getPackage().getName().replace('.', '/');
final Source query = new ClassLoaderSource(pkgName + "/xml-test-runner.xq");
final List<java.util.function.Function<XQueryContext, Tuple2<String, Object>>> externalVariableDeclarations = Arrays.asList(context -> new Tuple2<>("doc", doc), context -> new Tuple2<>("id", Sequence.EMPTY_SEQUENCE), // set callback functions for notifying junit!
context -> new Tuple2<>("test-ignored-function", new FunctionReference(new FunctionCall(context, new ExtTestIgnoredFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-started-function", new FunctionReference(new FunctionCall(context, new ExtTestStartedFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-failure-function", new FunctionReference(new FunctionCall(context, new ExtTestFailureFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-assumption-failed-function", new FunctionReference(new FunctionCall(context, new ExtTestAssumptionFailedFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-error-function", new FunctionReference(new FunctionCall(context, new ExtTestErrorFunction(context, getSuiteName(), notifier)))), context -> new Tuple2<>("test-finished-function", new FunctionReference(new FunctionCall(context, new ExtTestFinishedFunction(context, getSuiteName(), notifier)))));
// NOTE: at this stage EXIST_EMBEDDED_SERVER_CLASS_INSTANCE in XSuite will be usable
final BrokerPool brokerPool = XSuite.EXIST_EMBEDDED_SERVER_CLASS_INSTANCE.getBrokerPool();
executeQuery(brokerPool, query, externalVariableDeclarations);
} catch (final DatabaseConfigurationException | IOException | EXistException | PermissionDeniedException | XPathException e) {
// TODO(AR) what to do here?
throw new RuntimeException(e);
}
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class XQueryTestRunner method run.
@Override
public void run(final RunNotifier notifier) {
try {
final String pkgName = getClass().getPackage().getName().replace('.', '/');
final Source query = new ClassLoaderSource(pkgName + "/xquery-test-runner.xq");
final URI testModuleUri = path.toAbsolutePath().toUri();
final String suiteName = getSuiteName();
final List<java.util.function.Function<XQueryContext, Tuple2<String, Object>>> externalVariableDeclarations = Arrays.asList(context -> new Tuple2<>("test-module-uri", new AnyURIValue(testModuleUri)), // set callback functions for notifying junit!
context -> new Tuple2<>("test-ignored-function", new FunctionReference(new FunctionCall(context, new ExtTestIgnoredFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-started-function", new FunctionReference(new FunctionCall(context, new ExtTestStartedFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-failure-function", new FunctionReference(new FunctionCall(context, new ExtTestFailureFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-assumption-failed-function", new FunctionReference(new FunctionCall(context, new ExtTestAssumptionFailedFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-error-function", new FunctionReference(new FunctionCall(context, new ExtTestErrorFunction(context, suiteName, notifier)))), context -> new Tuple2<>("test-finished-function", new FunctionReference(new FunctionCall(context, new ExtTestFinishedFunction(context, suiteName, notifier)))));
// NOTE: at this stage EXIST_EMBEDDED_SERVER_CLASS_INSTANCE in XSuite will be usable
final BrokerPool brokerPool = XSuite.EXIST_EMBEDDED_SERVER_CLASS_INSTANCE.getBrokerPool();
executeQuery(brokerPool, query, externalVariableDeclarations);
} catch (final DatabaseConfigurationException | IOException | EXistException | PermissionDeniedException | XPathException e) {
// TODO(AR) what to do here?
throw new RuntimeException(e);
}
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class BrokerPoolsTest method shutdownConcurrent.
@Test
public void shutdownConcurrent() throws InterruptedException, ExecutionException, EXistException, DatabaseConfigurationException, IOException {
final int testThreads = 5;
final CountDownLatch shutdownLatch = new CountDownLatch(1);
final CountDownLatch acquiredLatch = new CountDownLatch(testThreads);
final List<Future<Exception>> shutdownTasks = new ArrayList<>();
final ExecutorService executorService = Executors.newFixedThreadPool(testThreads);
for (int i = 0; i < testThreads; i++) {
final Path dataDir = temporaryFolder.newFolder("exist" + i).toPath().normalize().toAbsolutePath();
// load config from classpath and override data and journal dir
final Configuration configuration = new Configuration("conf.xml");
configuration.setProperty(BrokerPool.PROPERTY_DATA_DIR, dataDir);
configuration.setProperty(Journal.PROPERTY_RECOVERY_JOURNAL_DIR, dataDir);
BrokerPool.configure("instance" + i, 0, 1, configuration);
shutdownTasks.add(executorService.submit(new BrokerPoolShutdownTask(acquiredLatch, shutdownLatch)));
}
// wait for all shutdown threads to be acquired
acquiredLatch.await();
shutdownLatch.countDown();
executorService.shutdown();
assertTrue(executorService.awaitTermination(8, TimeUnit.SECONDS));
for (final Future<Exception> shutdownTask : shutdownTasks) {
assertNull(shutdownTask.get());
}
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class NativeStructuralIndex method open.
@Override
public void open() throws DatabaseConfigurationException {
final Path file = getDataDir().resolve(FILE_NAME);
LOG.debug("Creating '{}'...", FileUtils.fileName(file));
try {
btree = new BTreeStore(pool, STRUCTURAL_INDEX_ID, FILE_FORMAT_VERSION_ID, false, file, pool.getCacheManager());
} catch (final DBException e) {
LOG.error("Failed to initialize structural index: {}", e.getMessage(), e);
throw new DatabaseConfigurationException(e.getMessage(), e);
}
}
use of org.exist.util.DatabaseConfigurationException in project exist by eXist-db.
the class RangeIndexConfig method parseChildren.
private void parseChildren(NodeList configNodes, Map<String, String> namespaces) {
Node node;
for (int i = 0; i < configNodes.getLength(); i++) {
node = configNodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE && CREATE_ELEM.equals(node.getLocalName())) {
try {
NodeList fields = getFieldsAndConditions((Element) node);
RangeIndexConfigElement newConfig;
if (fields.getLength() > 0) {
newConfig = new ComplexRangeIndexConfigElement((Element) node, fields, namespaces);
} else {
newConfig = new RangeIndexConfigElement((Element) node, namespaces);
}
RangeIndexConfigElement idxConf = paths.get(newConfig.getNodePath().getLastComponent());
if (idxConf == null) {
paths.put(newConfig.getNodePath().getLastComponent(), newConfig);
} else {
idxConf.add(newConfig);
}
} catch (final DatabaseConfigurationException e) {
String uri = null;
final Document doc = node.getOwnerDocument();
if (doc != null) {
uri = doc.getDocumentURI();
}
if (uri != null) {
LOG.error("Invalid range index configuration (" + uri + "): " + e.getMessage());
} else {
LOG.error("Invalid range index configuration: " + e.getMessage());
}
}
}
}
}
Aggregations