commit
						ffcbed5611
					
				| @ -0,0 +1,40 @@ | ||||
| package org.libresonic.player.dao; | ||||
| 
 | ||||
| import org.junit.ClassRule; | ||||
| import org.junit.Rule; | ||||
| import org.junit.runner.Description; | ||||
| import org.junit.runners.model.Statement; | ||||
| import org.libresonic.player.util.LibresonicHomeRule; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.jdbc.core.JdbcTemplate; | ||||
| import org.springframework.test.context.ContextConfiguration; | ||||
| import org.springframework.test.context.junit4.rules.SpringClassRule; | ||||
| import org.springframework.test.context.junit4.rules.SpringMethodRule; | ||||
| 
 | ||||
| @ContextConfiguration(locations = { | ||||
|         "/applicationContext-service.xml", | ||||
|         "/applicationContext-cache.xml", | ||||
|         "/applicationContext-testdb.xml", | ||||
|         "/applicationContext-mockSonos.xml"}) | ||||
| public class DaoTestCaseBean2 { | ||||
|     @ClassRule | ||||
|     public static final SpringClassRule classRule = new SpringClassRule() { | ||||
|         LibresonicHomeRule libresonicRule = new LibresonicHomeRule(); | ||||
|         @Override | ||||
|         public Statement apply(Statement base, Description description) { | ||||
|             Statement spring = super.apply(base, description); | ||||
|             return libresonicRule.apply(spring, description); | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     @Rule | ||||
|     public final SpringMethodRule springMethodRule = new SpringMethodRule(); | ||||
| 
 | ||||
|     @Autowired | ||||
|     GenericDaoHelper genericDaoHelper; | ||||
| 
 | ||||
| 
 | ||||
|     JdbcTemplate getJdbcTemplate() { | ||||
|         return genericDaoHelper.getJdbcTemplate(); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,54 @@ | ||||
| package org.libresonic.player.service; | ||||
| 
 | ||||
| import org.apache.commons.io.FileUtils; | ||||
| import org.junit.ClassRule; | ||||
| import org.junit.Rule; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.Description; | ||||
| import org.junit.runners.model.Statement; | ||||
| import org.libresonic.player.TestCaseUtils; | ||||
| import org.libresonic.player.util.LibresonicHomeRule; | ||||
| import org.springframework.test.context.ContextConfiguration; | ||||
| import org.springframework.test.context.junit4.rules.SpringClassRule; | ||||
| import org.springframework.test.context.junit4.rules.SpringMethodRule; | ||||
| 
 | ||||
| import java.io.File; | ||||
| 
 | ||||
| @ContextConfiguration(locations = { | ||||
|         "/applicationContext-service.xml", | ||||
|         "/applicationContext-cache.xml", | ||||
|         "/applicationContext-testdb.xml", | ||||
|         "/applicationContext-mockSonos.xml"}) | ||||
| public class LegacyDatabaseStartupTestCase { | ||||
| 
 | ||||
|     @ClassRule | ||||
|     public static final SpringClassRule classRule = new SpringClassRule() { | ||||
|         LibresonicHomeRule libresonicRule = new LibresonicHomeRule() { | ||||
|             @Override | ||||
|             protected void before() throws Throwable { | ||||
|                 super.before(); | ||||
|                 String homeParent = TestCaseUtils.libresonicHomePathForTest(); | ||||
|                 System.setProperty("libresonic.home", TestCaseUtils.libresonicHomePathForTest()); | ||||
|                 TestCaseUtils.cleanLibresonicHomeForTest(); | ||||
|                 File dbDirectory = new File(homeParent, "/db"); | ||||
|                 FileUtils.forceMkdir(dbDirectory); | ||||
|                 org.libresonic.player.util.FileUtils.copyResourcesRecursively(getClass().getResource("/db/pre-liquibase/db"), new File(homeParent)); | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|         @Override | ||||
|         public Statement apply(Statement base, Description description) { | ||||
|             Statement spring = super.apply(base, description); | ||||
|             return libresonicRule.apply(spring, description); | ||||
|         } | ||||
|     }; | ||||
| 
 | ||||
|     @Rule | ||||
|     public final SpringMethodRule springMethodRule = new SpringMethodRule(); | ||||
| 
 | ||||
|     @Test | ||||
|     public void testStartup() throws Exception { | ||||
|         System.out.println("Successful startup"); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -1,32 +0,0 @@ | ||||
| package org.libresonic.player.service; | ||||
| 
 | ||||
| import junit.framework.TestCase; | ||||
| import org.apache.commons.io.FileUtils; | ||||
| import org.libresonic.player.TestCaseUtils; | ||||
| import org.springframework.context.ApplicationContext; | ||||
| 
 | ||||
| import java.io.File; | ||||
| 
 | ||||
| public class StartupTestCase extends TestCase { | ||||
| 
 | ||||
|     private static String baseResources = "/org/libresonic/player/service/mediaScannerServiceTestCase/"; | ||||
| 
 | ||||
|     @Override | ||||
|     protected void setUp() throws Exception { | ||||
|         super.setUp(); | ||||
|     } | ||||
| 
 | ||||
|     public void testStartup() throws Exception { | ||||
|         String homeParent = TestCaseUtils.libresonicHomePathForTest(); | ||||
|         System.setProperty("libresonic.home", TestCaseUtils.libresonicHomePathForTest()); | ||||
|         TestCaseUtils.cleanLibresonicHomeForTest(); | ||||
|         File dbDirectory = new File(homeParent, "/db"); | ||||
|         FileUtils.forceMkdir(dbDirectory); | ||||
|         org.libresonic.player.util.FileUtils.copyResourcesRecursively(getClass().getResource("/db/pre-liquibase/db"), new File(homeParent)); | ||||
| 
 | ||||
|         // load spring context
 | ||||
|         ApplicationContext context = TestCaseUtils.loadSpringApplicationContext(baseResources); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| package org.libresonic.player.util; | ||||
| 
 | ||||
| import org.junit.rules.ExternalResource; | ||||
| import org.libresonic.player.TestCaseUtils; | ||||
| 
 | ||||
| public class LibresonicHomeRule extends ExternalResource { | ||||
|     @Override | ||||
|     protected void before() throws Throwable { | ||||
|         super.before(); | ||||
|         System.setProperty("libresonic.home", TestCaseUtils.libresonicHomePathForTest()); | ||||
| 
 | ||||
|         TestCaseUtils.cleanLibresonicHomeForTest(); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,11 @@ | ||||
| <?xml version="1.0" encoding="ISO-8859-1"?> | ||||
| <beans xmlns="http://www.springframework.org/schema/beans" | ||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|        xmlns:jaxws="http://cxf.apache.org/jaxws" | ||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> | ||||
| 
 | ||||
|     <bean id="sonosHelper" class="org.mockito.Mockito" factory-method="mock"> | ||||
|         <constructor-arg value="org.libresonic.player.service.sonos.SonosHelper" /> | ||||
|     </bean> | ||||
| 
 | ||||
| </beans> | ||||
| @ -0,0 +1,14 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <beans xmlns="http://www.springframework.org/schema/beans" | ||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||||
| 
 | ||||
|     <bean id="dataSource" | ||||
|           class="org.springframework.jdbc.datasource.DriverManagerDataSource"> | ||||
| 
 | ||||
|         <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> | ||||
|         <property name="url" value="jdbc:hsqldb:file:#{systemProperties['libresonic.home']}/db/libresonic" /> | ||||
|         <property name="username" value="sa" /> | ||||
|         <property name="password" value="" /> | ||||
|     </bean> | ||||
| </beans> | ||||
| @ -1,17 +0,0 @@ | ||||
| <?xml version="1.0" encoding="ISO-8859-1"?> | ||||
| 
 | ||||
| <beans xmlns="http://www.springframework.org/schema/beans" | ||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> | ||||
| 
 | ||||
|     <bean id="cacheFactory" class="org.libresonic.player.cache.CacheFactory"/> | ||||
| 
 | ||||
|     <bean id="userCache" factory-bean="cacheFactory" factory-method="getCache"> | ||||
|         <constructor-arg value="userCache"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="mediaFileMemoryCache" factory-bean="cacheFactory" factory-method="getCache"> | ||||
|         <constructor-arg value="mediaFileMemoryCache"/> | ||||
|     </bean> | ||||
| 
 | ||||
| </beans> | ||||
| @ -1,217 +0,0 @@ | ||||
| <?xml version="1.0" encoding="ISO-8859-1"?> | ||||
| <beans xmlns="http://www.springframework.org/schema/beans" | ||||
|        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||
|        xsi:schemaLocation=" | ||||
|        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||||
| 
 | ||||
| 
 | ||||
|     <!-- DAO's --> | ||||
| 
 | ||||
|     <bean id="playerDao" class="org.libresonic.player.dao.PlayerDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="mediaFileDao" class="org.libresonic.player.dao.MediaFileDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="artistDao" class="org.libresonic.player.dao.ArtistDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="albumDao" class="org.libresonic.player.dao.AlbumDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="playlistDao" class="org.libresonic.player.dao.PlaylistDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="playQueueDao" class="org.libresonic.player.dao.PlayQueueDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="internetRadioDao" class="org.libresonic.player.dao.InternetRadioDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="musicFileInfoDao" class="org.libresonic.player.dao.RatingDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="musicFolderDao" class="org.libresonic.player.dao.MusicFolderDaoMock"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="userDao" class="org.libresonic.player.dao.UserDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="transcodingDao" class="org.libresonic.player.dao.TranscodingDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="podcastDao" class="org.libresonic.player.dao.PodcastDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="avatarDao" class="org.libresonic.player.dao.AvatarDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="shareDao" class="org.libresonic.player.dao.ShareDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="bookmarkDao" class="org.libresonic.player.dao.BookmarkDao"> | ||||
|         <property name="daoHelper" ref="daoHelper"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="daoHelper" class="org.libresonic.player.dao.GenericDaoHelper"> | ||||
|         <constructor-arg name="dataSource" ref="dataSource" /> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="rollbackFile" class="java.io.File"> | ||||
|         <constructor-arg type="java.io.File" index="0" value="#{T(org.libresonic.player.service.SettingsService).libresonicHome}" /> | ||||
|         <constructor-arg type="java.lang.String" index="1" value="rollback.sql" /> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="dataSource" | ||||
|           class="org.springframework.jdbc.datasource.DriverManagerDataSource"> | ||||
| 
 | ||||
|         <property name="driverClassName" value="org.hsqldb.jdbcDriver" /> | ||||
|         <property name="url" value="jdbc:hsqldb:file:#{systemProperties['libresonic.home']}/db/libresonic" /> | ||||
|         <property name="username" value="sa" /> | ||||
|         <property name="password" value="" /> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="liquibase" class="org.libresonic.player.spring.SpringLiquibase"> | ||||
|         <property name="dataSource" ref="dataSource" /> | ||||
|         <property name="changeLog" value="classpath:liquibase/db-changelog.xml" /> | ||||
|         <property name="rollbackFile" ref="rollbackFile" /> | ||||
|         <property name="changeLogParameters"> | ||||
|             <map> | ||||
|                 <entry key="defaultMusicFolder" value="#{T(org.libresonic.player.util.Util).getDefaultMusicFolder()}" /> | ||||
|                 <entry key="varcharLimit" value="${database.varchar.maxlength:512}" /> | ||||
|                 <entry key="userTableQuote" value="" /> | ||||
|             </map> | ||||
|         </property> | ||||
|     </bean> | ||||
| 
 | ||||
|     <!-- Services --> | ||||
| 
 | ||||
|     <bean id="mediaFileService" class="org.libresonic.player.service.MediaFileService"> | ||||
|         <property name="securityService" ref="securityService"/> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|         <property name="mediaFileMemoryCache" ref="mediaFileMemoryCache"/> | ||||
|         <property name="mediaFileDao" ref="mediaFileDao"/> | ||||
|         <property name="albumDao" ref="albumDao"/> | ||||
|         <property name="metaDataParserFactory" ref="metaDataParserFactory"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="securityService" class="org.libresonic.player.service.SecurityService"> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|         <property name="userDao" ref="userDao"/> | ||||
|         <property name="userCache" ref="userCache"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="configurationService" class="org.libresonic.player.service.ApacheCommonsConfigurationService" /> | ||||
| 
 | ||||
|     <bean id="settingsService" class="org.libresonic.player.service.SettingsService" init-method="init"> | ||||
|         <property name="internetRadioDao" ref="internetRadioDao"/> | ||||
|         <property name="musicFolderDao" ref="musicFolderDao"/> | ||||
|         <property name="userDao" ref="userDao"/> | ||||
|         <property name="avatarDao" ref="avatarDao"/> | ||||
|         <property name="versionService" ref="versionService"/> | ||||
|         <property name="configurationService" ref="configurationService" /> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="mediaScannerService" class="org.libresonic.player.service.MediaScannerService" init-method="initNoSchedule" depends-on="metaDataParserFactory"> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|         <property name="mediaFileService" ref="mediaFileService"/> | ||||
|         <property name="mediaFileDao" ref="mediaFileDao"/> | ||||
|         <property name="playlistService" ref="playlistService"/> | ||||
|         <property name="artistDao" ref="artistDao"/> | ||||
|         <property name="albumDao" ref="albumDao"/> | ||||
|         <property name="searchService" ref="searchService"/> | ||||
|         <!-- <property name="queueSender" ref="queueSender"/> --> | ||||
|     </bean> | ||||
| 
 | ||||
| 
 | ||||
|     <bean id="searchService" class="org.libresonic.player.service.SearchService"> | ||||
|         <property name="mediaFileService" ref="mediaFileService"/> | ||||
|         <property name="artistDao" ref="artistDao"/> | ||||
|         <property name="albumDao" ref="albumDao"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="networkService" class="org.libresonic.player.service.NetworkService" init-method="init"> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="playerService" class="org.libresonic.player.service.PlayerService" init-method="init"> | ||||
|         <property name="playerDao" ref="playerDao"/> | ||||
|         <property name="statusService" ref="statusService"/> | ||||
|         <property name="securityService" ref="securityService"/> | ||||
|         <property name="transcodingService" ref="transcodingService"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="playlistService" class="org.libresonic.player.service.PlaylistService"> | ||||
|         <property name="mediaFileService" ref="mediaFileService"/> | ||||
|         <property name="securityService" ref="securityService"/> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|         <property name="mediaFileDao" ref="mediaFileDao"/> | ||||
|         <property name="playlistDao" ref="playlistDao"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="versionService" class="org.libresonic.player.service.VersionService" init-method="init"/> | ||||
| 
 | ||||
|     <bean id="statusService" class="org.libresonic.player.service.StatusService"> | ||||
|         <property name="mediaFileService" ref="mediaFileService"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="ratingService" class="org.libresonic.player.service.RatingService"> | ||||
|         <property name="ratingDao" ref="musicFileInfoDao"/> | ||||
|         <property name="mediaFileService" ref="mediaFileService"/> | ||||
|         <property name="securityService" ref="securityService"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="musicIndexService" class="org.libresonic.player.service.MusicIndexService"> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|         <property name="mediaFileService" ref="mediaFileService"/> | ||||
|     </bean> | ||||
| 
 | ||||
|     <bean id="transcodingService" class="org.libresonic.player.service.TranscodingService"> | ||||
|         <property name="transcodingDao" ref="transcodingDao"/> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|     </bean> | ||||
| 
 | ||||
| 
 | ||||
|     <bean id="podcastService" class="org.libresonic.player.service.PodcastService" init-method="init"> | ||||
|         <property name="podcastDao" ref="podcastDao"/> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|         <property name="securityService" ref="securityService"/> | ||||
|         <property name="mediaFileService" ref="mediaFileService"/> | ||||
|         <property name="metaDataParserFactory" ref="metaDataParserFactory"/> | ||||
|     </bean> | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     <bean id="metaDataParserFactory" class="org.libresonic.player.service.metadata.MetaDataParserFactory"> | ||||
|         <property name="parsers"> | ||||
|             <list> | ||||
|                 <bean class="org.libresonic.player.service.metadata.JaudiotaggerParser"/> | ||||
|                 <bean class="org.libresonic.player.service.metadata.FFmpegParser"> | ||||
|                     <property name="transcodingService" ref="transcodingService"/> | ||||
|                 </bean> | ||||
|                 <bean class="org.libresonic.player.service.metadata.DefaultMetaDataParser"/> | ||||
|             </list> | ||||
|         </property> | ||||
|     </bean> | ||||
| 
 | ||||
| 
 | ||||
|     <bean id="localeResolver" class="org.libresonic.player.i18n.LibresonicLocaleResolver"> | ||||
|         <property name="securityService" ref="securityService"/> | ||||
|         <property name="settingsService" ref="settingsService"/> | ||||
|     </bean> | ||||
| 
 | ||||
| </beans> | ||||
					Loading…
					
					
				
		Reference in new issue