diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-07-27 14:33:25 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-07-27 14:33:38 -0700 |
commit | 4738428c2c205f42200386ae09b44b9ec07b9144 (patch) | |
tree | a6402978fe1b4655f90c3c8a181f4d246fbc5e89 /subsonic-main/src/test/java/net/sourceforge/subsonic/dao/DaoTestCaseBase.java | |
parent | 82ec8315f777c319f2372540098e21111019d629 (diff) | |
download | dsub-4738428c2c205f42200386ae09b44b9ec07b9144.tar.gz dsub-4738428c2c205f42200386ae09b44b9ec07b9144.tar.bz2 dsub-4738428c2c205f42200386ae09b44b9ec07b9144.zip |
Move subsonic-android to root
Diffstat (limited to 'subsonic-main/src/test/java/net/sourceforge/subsonic/dao/DaoTestCaseBase.java')
-rw-r--r-- | subsonic-main/src/test/java/net/sourceforge/subsonic/dao/DaoTestCaseBase.java | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/subsonic-main/src/test/java/net/sourceforge/subsonic/dao/DaoTestCaseBase.java b/subsonic-main/src/test/java/net/sourceforge/subsonic/dao/DaoTestCaseBase.java deleted file mode 100644 index 8d3a7f88..00000000 --- a/subsonic-main/src/test/java/net/sourceforge/subsonic/dao/DaoTestCaseBase.java +++ /dev/null @@ -1,83 +0,0 @@ -package net.sourceforge.subsonic.dao; - -import junit.framework.TestCase; -import net.sourceforge.subsonic.util.FileUtil; -import org.springframework.jdbc.core.JdbcTemplate; - -import java.io.File; - -/** - * Superclass for all DAO test cases. - * Creates and configures the DAO's, and resets the test database. - * - * @author Sindre Mehus - */ -public abstract class DaoTestCaseBase extends TestCase { - - /** Do not re-create database if it is less than one hour old. */ - private static final long MAX_DB_AGE_MILLIS = 60L * 60 * 1000; - - static { - deleteDatabase(); - } - - private DaoHelper daoHelper; - protected PlayerDao playerDao; - protected InternetRadioDao internetRadioDao; - protected RatingDao ratingDao; - protected MusicFolderDao musicFolderDao; - protected UserDao userDao; - protected TranscodingDao transcodingDao; - protected PodcastDao podcastDao; - - protected DaoTestCaseBase() { - daoHelper = new DaoHelper(); - - playerDao = new PlayerDao(); - internetRadioDao = new InternetRadioDao(); - ratingDao = new RatingDao(); - musicFolderDao = new MusicFolderDao(); - userDao = new UserDao(); - transcodingDao = new TranscodingDao(); - podcastDao = new PodcastDao(); - - playerDao.setDaoHelper(daoHelper); - internetRadioDao.setDaoHelper(daoHelper); - ratingDao.setDaoHelper(daoHelper); - musicFolderDao.setDaoHelper(daoHelper); - userDao.setDaoHelper(daoHelper); - transcodingDao.setDaoHelper(daoHelper); - podcastDao.setDaoHelper(daoHelper); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - getJdbcTemplate().execute("shutdown"); - } - - protected JdbcTemplate getJdbcTemplate() { - return daoHelper.getJdbcTemplate(); - } - - private static void deleteDatabase() { - File subsonicHome = new File("/tmp/subsonic"); - File dbHome = new File(subsonicHome, "db"); - System.setProperty("subsonic.home", subsonicHome.getPath()); - - long now = System.currentTimeMillis(); - if (now - dbHome.lastModified() > MAX_DB_AGE_MILLIS) { - System.out.println("Resetting test database: " + dbHome); - delete(dbHome); - } - } - - private static void delete(File file) { - if (file.isDirectory()) { - for (File child : FileUtil.listFiles(file)) { - delete(child); - } - } - file.delete(); - } -} |