use of org.exist.storage.BrokerPool in project exist by eXist-db.
the class SerializeAttrMatchesTest method configureAndStore.
private DocumentSet configureAndStore(final String configuration, final String data, final String docName) throws EXistException, CollectionConfigurationException, PermissionDeniedException, SAXException, TriggerException, LockException, IOException {
final MutableDocumentSet docs = new DefaultDocumentSet();
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager transact = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = transact.beginTransaction()) {
if (configuration != null) {
final CollectionConfigurationManager mgr = pool.getConfigurationManager();
mgr.addConfiguration(transaction, broker, test, configuration);
}
broker.storeDocument(transaction, XmldbURI.create(docName), new StringInputSource(data), MimeType.XML_TYPE, test);
docs.add(test.getDocument(broker, XmldbURI.create(docName)));
transact.commit(transaction);
}
return docs;
}
use of org.exist.storage.BrokerPool in project exist by eXist-db.
the class SerializeAttrMatchesTest method setup.
@Before
public void setup() throws EXistException, PermissionDeniedException, IOException, TriggerException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager transact = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = transact.beginTransaction()) {
test = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
broker.saveCollection(transaction, test);
transact.commit(transaction);
}
}
use of org.exist.storage.BrokerPool in project exist by eXist-db.
the class LuceneIndexTest method configureAndStore.
private DocumentSet configureAndStore(final String configuration, final String data, final String docName) throws EXistException, CollectionConfigurationException, PermissionDeniedException, SAXException, TriggerException, LockException, IOException {
final MutableDocumentSet docs = new DefaultDocumentSet();
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager transact = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = transact.beginTransaction()) {
if (configuration != null) {
final CollectionConfigurationManager mgr = pool.getConfigurationManager();
mgr.addConfiguration(transaction, broker, root, configuration);
}
broker.storeDocument(transaction, XmldbURI.create(docName), new StringInputSource(data), MimeType.XML_TYPE, root);
docs.add(root.getDocument(broker, XmldbURI.create(docName)));
transact.commit(transaction);
}
return docs;
}
use of org.exist.storage.BrokerPool in project exist by eXist-db.
the class LuceneIndexTest method MultiTermQueryRewriteMethod.
@Test
public void MultiTermQueryRewriteMethod() throws EXistException, CollectionConfigurationException, PermissionDeniedException, SAXException, TriggerException, LockException, IOException, XPathException {
configureAndStore(COLLECTION_CONFIG8, XML9, "test.xml");
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
final XQuery xquery = pool.getXQueryService();
assertNotNull(xquery);
Sequence seq = xquery.execute(broker, "declare namespace tei=\"http://www.tei-c.org/ns/1.0\";" + " for $expr in (\"au*\", \"ha*\", \"ma*\", \"za*\", \"ya*\", \"ra*\", \"qa*\")" + " let $query := <query><wildcard>{$expr}</wildcard></query>" + " return for $hit in //tei:p[ft:query(., $query)]" + " return util:expand($hit)//exist:match", null);
assertNotNull(seq);
assertEquals(10, seq.getItemCount());
assertEquals("aus", seq.itemAt(0).getStringValue());
seq = xquery.execute(broker, "declare namespace tei=\"http://www.tei-c.org/ns/1.0\";" + " for $expr in (\"ha*\", \"ma*\")" + " let $query := <query><wildcard>{$expr}</wildcard></query>" + " return for $hit in //tei:p[ft:query(., $query)]" + " return util:expand($hit)//exist:match", null);
assertNotNull(seq);
assertEquals(2, seq.getItemCount());
assertEquals("haus", seq.itemAt(0).getStringValue());
}
}
use of org.exist.storage.BrokerPool in project exist by eXist-db.
the class LuceneIndexTest method reindex.
@Test
public void reindex() throws EXistException, CollectionConfigurationException, PermissionDeniedException, SAXException, LockException, IOException, QName.IllegalQNameException {
final DocumentSet docs = configureAndStore(COLLECTION_CONFIG1, XML1, "dropDocument.xml");
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final TransactionManager transact = pool.getTransactionManager();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = transact.beginTransaction()) {
broker.reindexCollection(transaction, TestConstants.TEST_COLLECTION_URI);
checkIndex(docs, broker, new QName[] { new QName("head") }, "title", 1);
final Occurrences[] o = checkIndex(docs, broker, new QName[] { new QName("p") }, "with", 1);
assertEquals(2, o[0].getOccurrences());
checkIndex(docs, broker, new QName[] { new QName("hi") }, "just", 1);
checkIndex(docs, broker, null, "in", 1);
final QName attrQN = new QName("rend", XMLConstants.NULL_NS_URI, ElementValue.ATTRIBUTE);
checkIndex(docs, broker, new QName[] { attrQN }, null, 2);
checkIndex(docs, broker, new QName[] { attrQN }, "center", 1);
transaction.commit();
}
}
Aggregations