try {
broker = pool.get(pool.getSecurityManager().getSystemSubject());
transact = pool.getTransactionManager();
transaction = transact.beginTransaction();
Occurrences occur[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 1);
assertEquals("chair", occur[0].getTerm());
checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5);
XQuery xquery = broker.getXQueryService();
assertNotNull(xquery);
Sequence seq = xquery.execute("//item[ft:query(description, 'chair')]", null, AccessContext.TEST);
assertNotNull(seq);
assertEquals(1, seq.getItemCount());
XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST);
assertNotNull(proc);
proc.setBroker(broker);
proc.setDocumentSet(docs);
String xupdate =
XUPDATE_START +
"<xu:replace select=\"//item[@id = '1']\">" +
"<item id='4'><description>Wheelchair</description> <condition>poor</condition></item>" +
"</xu:replace>" +
XUPDATE_END;
Modification[] modifications = proc.parse(new InputSource(new StringReader(xupdate)));
assertNotNull(modifications);
modifications[0].process(transaction);
proc.reset();
checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 3);
checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 3);
checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 6);
checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 0);
checkIndex(docs, broker, new QName[] { new QName("item", "") }, "chair", 0);
Occurrences o[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "wheelchair", 1);
assertEquals("wheelchair", o[0].getTerm());
o = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "poor", 1);
assertEquals("poor", o[0].getTerm());
o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "wheelchair", 1);
assertEquals("wheelchair", o[0].getTerm());
o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "poor", 1);
assertEquals("poor", o[0].getTerm());
proc.setBroker(broker);
proc.setDocumentSet(docs);
xupdate =
XUPDATE_START +
"<xu:replace select=\"//item[@id = '4']/description\">" +
"<description>Armchair</description>" +
"</xu:replace>" +
XUPDATE_END;
modifications = proc.parse(new InputSource(new StringReader(xupdate)));
assertNotNull(modifications);
modifications[0].process(transaction);
proc.reset();
checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 3);
checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 6);
checkIndex(docs, broker, new QName[] { new QName("description", "") }, "wheelchair", 0);
checkIndex(docs, broker, new QName[] { new QName("item", "") }, "wheelchair", 0);
o = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "armchair", 1);
assertEquals("armchair", o[0].getTerm());
o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "armchair", 1);
assertEquals("armchair", o[0].getTerm());
transact.commit(transaction);
} catch (Exception e) {
if (transact != null)