示例#1
0
 @After
 public void shutdownDatabase() throws Exception {
   if (Database.isStarted()) {
     wipeDatabase();
     Database.shutdown();
   }
 }
示例#2
0
 private void wipeDatabase() {
   DBBroker broker = null;
   Transaction tx = Database.requireTransaction();
   try {
     broker = db.acquireBroker();
     broker.removeCollection(tx.tx, broker.getCollection(XmldbURI.ROOT_COLLECTION_URI));
     tx.commit();
   } catch (PermissionDeniedException e) {
     throw new RuntimeException(e);
   } catch (IOException e) {
     throw new RuntimeException(e);
   } finally {
     tx.abortIfIncomplete();
     db.releaseBroker(broker);
   }
 }
示例#3
0
 @Before
 public void startupDatabase() {
   ConfigFile configFileAnnotation = getClass().getAnnotation(ConfigFile.class);
   assert configFileAnnotation != null;
   Database.ensureStarted(new File(configFileAnnotation.value()));
   db = new Database(SecurityManager.SYSTEM_USER);
   wipeDatabase();
   ListenerManager.configureTriggerDispatcher(db); // config file gets erased by command above
 }