broker = pool.get(pool.getSecurityManager().getSystemSubject());
assertNotNull(broker);
TransactionManager mgr = pool.getTransactionManager();
assertNotNull(mgr);
IndexInfo info = init(broker, mgr);
assertNotNull(info);
MutableDocumentSet docs = new DefaultDocumentSet();
docs.add(info.getDocument());
XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
assertNotNull(proc);
Txn transaction = mgr.beginTransaction();
assertNotNull(transaction);
System.out.println("Transaction started ...");
String xupdate;
Modification modifications[];
// append some new element to records
for (int i = 1; i <= 200; i++) {
xupdate =
"<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">" +
" <xu:append select=\"/products\">" +
" <product>" +
" <xu:attribute name=\"id\"><xu:value-of select=\"count(/products/product) + 1\"/></xu:attribute>" +
" <description>Product " + i + "</description>" +
" <price>" + (i * 2.5) + "</price>" +
" <stock>" + (i * 10) + "</stock>" +
" </product>" +
" </xu:append>" +
"</xu:modifications>";
proc.setBroker(broker);
proc.setDocumentSet(docs);
modifications = proc.parse(new InputSource(new StringReader(xupdate)));
assertNotNull(modifications);
modifications[0].process(transaction);
proc.reset();
}
DOMFile domDb = ((NativeBroker) broker).getDOMFile();
assertNotNull(domDb);
System.out.println(domDb.debugPages(info.getDocument(), false));
mgr.commit(transaction);
System.out.println("Transaction commited ...");
// the following transaction will not be committed and thus undone during recovery