@AfterClass public static void tearDown() { TransactionManager transact = null; Txn transaction = null; try { transact = pool.getTransactionManager(); transaction = transact.beginTransaction(); root = broker.getOrCreateCollection( transaction, XmldbURI.create(XmldbURI.ROOT_COLLECTION + "/test")); // broker.removeCollection(transaction, root); transact.commit(transaction); } catch (Exception e) { if (transaction != null) { transact.abort(transaction); } } finally { if (pool != null) pool.release(broker); } BrokerPool.stopAll(false); pool = null; root = null; }
@BeforeClass public static void setUp() throws Exception { TransactionManager transact = null; Txn transaction = null; try { pool = startDB(); broker = pool.get(pool.getSecurityManager().getSystemSubject()); transact = pool.getTransactionManager(); transaction = transact.beginTransaction(); root = broker.getOrCreateCollection( transaction, XmldbURI.create(XmldbURI.ROOT_COLLECTION + "/test")); broker.saveCollection(transaction, root); String existHome = System.getProperty("exist.home"); File existDir = existHome == null ? new File(".") : new File(existHome); String directory = "samples/shakespeare"; File dir = new File(existDir, directory); // store some documents. for (File f : dir.listFiles(new XMLFilenameFilter())) { IndexInfo info = root.validateXMLResource( transaction, broker, XmldbURI.create(f.getName()), new InputSource(f.toURI().toASCIIString())); root.store(transaction, broker, info, new InputSource(f.toURI().toASCIIString()), false); } IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create("nested.xml"), NESTED_XML); root.store(transaction, broker, info, NESTED_XML, false); transact.commit(transaction); // for the tests docs = root.allDocs(broker, new DefaultDocumentSet(), true); seqSpeech = executeQuery(broker, "//SPEECH", 2628, null); } catch (Exception e) { if (pool != null) { pool.release(broker); BrokerPool.stopAll(false); pool = null; root = null; } throw e; } }
/* (non-Javadoc) * @see javax.servlet.GenericServlet#destroy() */ public void destroy() { super.destroy(); BrokerPool.stopAll(false); }