try {
System.out.println("testRead() ...\n");
pool = startDB();
broker = pool.get(pool.getSecurityManager().getSystemSubject());
Serializer serializer = broker.getSerializer();
serializer.reset();
DocumentImpl doc;
String data;
doc = broker.getXMLResource(TEST_COLLECTION_URI.append("test2/test.xml"), Lock.READ_LOCK);
assertNotNull("Document '"+ TEST_COLLECTION_URI.append("test2/test.xml")+"' should not be null", doc);
data = serializer.serialize(doc);
System.out.println(data);
doc.getUpdateLock().release(Lock.READ_LOCK);
XQuery xquery = broker.getXQueryService();
Sequence seq = xquery.execute("/products/product[last()]", null, AccessContext.TEST);
System.out.println("Found: " + seq.getItemCount());
for (SequenceIterator i = seq.iterate(); i.hasNext(); ) {
Item next = i.nextItem();
System.out.println(serializer.serialize((NodeValue) next));
}
} catch (Exception e) {
fail(e.getMessage());
} finally {
if (pool != null) pool.release(broker);