use of org.exist.storage.DBBroker in project exist by eXist-db.
the class TransformTest method cleanupResources.
@AfterClass
public static void cleanupResources() throws EXistException, PermissionDeniedException, IOException, TriggerException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = pool.getTransactionManager().beginTransaction()) {
deleteCollection(broker, transaction, TEST_IDS_COLLECTION);
deleteCollection(broker, transaction, TEST_DOCUMENT_XSLT_COLLECTION);
deleteCollection(broker, transaction, TEST_SIMPLE_XML_COLLECTION);
deleteCollection(broker, transaction, TEST_SIMPLE_XML_WITH_COMMENT_COLLECTION);
deleteCollection(broker, transaction, TEST_SIMPLE_XML_WITH_TWO_COMMENTS_COLLECTION);
deleteCollection(broker, transaction, TEST_TWO_NODES_COLLECTION);
transaction.commit();
}
}
use of org.exist.storage.DBBroker in project exist by eXist-db.
the class TransformTest method transform1.
private static void transform1(final XmldbURI collectionUri) throws EXistException, PermissionDeniedException, XPathException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final XQuery xquery = pool.getXQueryService();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
final Sequence sequence = xquery.execute(broker, getCountDescendantsXquery(collectionUri), null);
assertNotNull(sequence);
assertTrue(sequence.hasOne());
final Source expected = Input.fromString("<count-descendants>1</count-descendants>").build();
final Source actual = Input.fromDocument(sequence.itemAt(0).toJavaObject(Node.class).getOwnerDocument()).build();
final Diff diff = DiffBuilder.compare(expected).withTest(actual).checkForSimilar().build();
assertFalse(diff.toString(), diff.hasDifferences());
}
}
use of org.exist.storage.DBBroker in project exist by eXist-db.
the class TransformTest method transform_twoNodesCountDescendants.
private static void transform_twoNodesCountDescendants() throws EXistException, PermissionDeniedException, XPathException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final XQuery xquery = pool.getXQueryService();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
final Sequence sequence = xquery.execute(broker, COUNT_DESCENDANTS_TWO_NODES_QUERY, null);
assertNotNull(sequence);
assertTrue(sequence.hasOne());
final Source expected = Input.fromString("<counts><count1>2</count1><count2>1</count2></counts>").build();
final Source actual = Input.fromDocument(sequence.itemAt(0).toJavaObject(Node.class).getOwnerDocument()).build();
final Diff diff = DiffBuilder.compare(expected).withTest(actual).checkForSimilar().build();
assertFalse(diff.toString(), diff.hasDifferences());
}
}
use of org.exist.storage.DBBroker in project exist by eXist-db.
the class TransformTest method storeResources.
@BeforeClass
public static void storeResources() throws EXistException, PermissionDeniedException, IOException, SAXException, LockException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
final Txn transaction = pool.getTransactionManager().beginTransaction()) {
createCollection(broker, transaction, TEST_IDS_COLLECTION, Tuple(LIST_OPS_XSLT_NAME, LIST_OPS_XSLT), Tuple(INPUT_LIST_XML_NAME, INPUT_XML), Tuple(DICTIONARY_XML_NAME, DICTIONARY_XML));
createCollection(broker, transaction, TEST_DOCUMENT_XSLT_COLLECTION, Tuple(DOCUMENT_XSLT_NAME, DOCUMENT_XSLT));
createCollection(broker, transaction, TEST_SIMPLE_XML_COLLECTION, Tuple(SIMPLE_XML_NAME, SIMPLE_XML), Tuple(COUNT_DESCENDANTS_XSLT_NAME, getCountDescendantsXslt(TEST_SIMPLE_XML_COLLECTION)));
createCollection(broker, transaction, TEST_SIMPLE_XML_WITH_COMMENT_COLLECTION, Tuple(SIMPLE_XML_NAME, SIMPLE_XML_WITH_COMMENT), Tuple(COUNT_DESCENDANTS_XSLT_NAME, getCountDescendantsXslt(TEST_SIMPLE_XML_WITH_COMMENT_COLLECTION)));
createCollection(broker, transaction, TEST_SIMPLE_XML_WITH_TWO_COMMENTS_COLLECTION, Tuple(SIMPLE_XML_NAME, SIMPLE_XML_WITH_TWO_COMMENTS), Tuple(COUNT_DESCENDANTS_XSLT_NAME, getCountDescendantsXslt(TEST_SIMPLE_XML_WITH_TWO_COMMENTS_COLLECTION)));
createCollection(broker, transaction, TEST_TWO_NODES_COLLECTION, Tuple(TWO_NODES_XML_NAME, TWO_NODES_XML), Tuple(COUNT_DESCENDANTS_TWO_NODES_XSLT_NAME, COUNT_DESCENDANTS_TWO_NODES_XSLT));
transaction.commit();
}
}
use of org.exist.storage.DBBroker in project exist by eXist-db.
the class TransformTest method keys.
/**
* {@see https://github.com/eXist-db/exist/issues/1506}
*/
@Test
public void keys() throws EXistException, PermissionDeniedException, XPathException {
final BrokerPool pool = existEmbeddedServer.getBrokerPool();
final XQuery xquery = pool.getXQueryService();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
final Sequence sequence = xquery.execute(broker, LIST_OPS_XQUERY, null);
assertNotNull(sequence);
assertEquals(1, sequence.getItemCount());
final Item item = sequence.itemAt(0);
assertTrue(item instanceof Element);
final Element dsn_flat = ((Element) item);
assertEquals("DSN_FLAT", dsn_flat.getNodeName());
final NodeList nodeList = dsn_flat.getElementsByTagName("listOpsEntry");
assertEquals(4, nodeList.getLength());
assertEquals("id: IRCANTEC doEntiteAff: false doGenerateB20: true ", nodeList.item(0).getTextContent());
assertEquals("id: CIBTP doEntiteAff: true doGenerateB20: true ", nodeList.item(1).getTextContent());
assertEquals("id: AGIRC-ARRCO doEntiteAff: true doGenerateB20: false ", nodeList.item(2).getTextContent());
assertEquals("id: CTIP-FFSA-FNMF doEntiteAff: true doGenerateB20: true ", nodeList.item(3).getTextContent());
}
}
Aggregations