Prep work for spring boot test

- Added enforcer plugin
- Fix some version conflicts
- Moved custom initializer to spring.factories
- Bump spring boot version

Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
master
Andrew DeMaria 7 years ago
parent 753d76e0fe
commit 7d4ca2ffe2
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 12
      airsonic-main/pom.xml
  2. 5
      airsonic-main/src/main/java/org/airsonic/player/Application.java
  3. 2
      airsonic-main/src/main/java/org/airsonic/player/TomcatApplication.java
  4. 3
      airsonic-main/src/main/resources/META-INF/spring.factories
  5. 8
      airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestExport.java
  6. 7
      airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestImport.java
  7. 41
      pom.xml

@ -79,7 +79,6 @@
<dependency> <dependency>
<groupId>org.springframework.ldap</groupId> <groupId>org.springframework.ldap</groupId>
<artifactId>spring-ldap-core</artifactId> <artifactId>spring-ldap-core</artifactId>
<version>2.0.2.RELEASE</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.security</groupId> <groupId>org.springframework.security</groupId>
@ -153,13 +152,11 @@
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId> <artifactId>httpcore</artifactId>
<version>4.4.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency> </dependency>
<dependency> <dependency>
@ -278,7 +275,7 @@
<dependency> <dependency>
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId> <artifactId>mockito-core</artifactId>
<version>2.5.7</version> <version>1.10.19</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -380,8 +377,6 @@
<dependency> <dependency>
<groupId>org.liquibase</groupId> <groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId> <artifactId>liquibase-core</artifactId>
<!-- Cannot use 3.5.3/2 due to https://liquibase.jira.com/browse/CORE-2944 -->
<version>3.5.1</version>
</dependency> </dependency>
<dependency> <dependency>
@ -419,7 +414,6 @@
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.7.24</version>
</dependency> </dependency>
<!-- Embedded tomcat --> <!-- Embedded tomcat -->
@ -448,12 +442,10 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>2.8.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.jayway.jsonpath</groupId> <groupId>com.jayway.jsonpath</groupId>
@ -479,7 +471,7 @@
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>1.5.2.RELEASE</version> <version>1.5.2.RELEASE</version>
<configuration> <configuration>
<mainClass>org.airsonic.player.boot.Application</mainClass> <mainClass>org.airsonic.player.Application</mainClass>
<layout>WAR</layout> <layout>WAR</layout>
<excludeGroupIds>${boot.group.excludes}</excludeGroupIds> <excludeGroupIds>${boot.group.excludes}</excludeGroupIds>
<excludeArtifactIds>${boot.artifact.excludes}</excludeArtifactIds> <excludeArtifactIds>${boot.artifact.excludes}</excludeArtifactIds>

@ -1,8 +1,7 @@
package org.airsonic.player.boot; package org.airsonic.player;
import net.sf.ehcache.constructs.web.ShutdownListener; import net.sf.ehcache.constructs.web.ShutdownListener;
import org.airsonic.player.filter.*; import org.airsonic.player.filter.*;
import org.airsonic.player.spring.CustomPropertySourceConfigurer;
import org.directwebremoting.servlet.DwrServlet; import org.directwebremoting.servlet.DwrServlet;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -180,7 +179,7 @@ public class Application extends SpringBootServletInitializer implements Embedde
// Customize the application or call application.sources(...) to add sources // Customize the application or call application.sources(...) to add sources
// Since our example is itself a @Configuration class (via @SpringBootApplication) // Since our example is itself a @Configuration class (via @SpringBootApplication)
// we actually don't need to override this method. // we actually don't need to override this method.
return application.sources(Application.class).web(true).initializers(new CustomPropertySourceConfigurer()); return application.sources(Application.class).web(true);
} }
@Override @Override

@ -1,4 +1,4 @@
package org.airsonic.player.boot; package org.airsonic.player;
import org.apache.catalina.Container; import org.apache.catalina.Container;
import org.apache.catalina.Wrapper; import org.apache.catalina.Wrapper;

@ -1,3 +1,6 @@
org.springframework.context.ApplicationListener=\ org.springframework.context.ApplicationListener=\
org.airsonic.player.spring.LoggingFileOverrideListener,\ org.airsonic.player.spring.LoggingFileOverrideListener,\
org.airsonic.player.security.LoginFailureListener org.airsonic.player.security.LoginFailureListener
org.springframework.context.ApplicationContextInitializer=\
org.airsonic.player.spring.CustomPropertySourceConfigurer

@ -2,8 +2,10 @@ package org.airsonic.player.service;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.airsonic.player.dao.MediaFileDao; import org.airsonic.player.dao.MediaFileDao;
import org.airsonic.player.dao.PlaylistDao;
import org.airsonic.player.domain.MediaFile; import org.airsonic.player.domain.MediaFile;
import org.airsonic.player.domain.Playlist; import org.airsonic.player.domain.Playlist;
import org.airsonic.player.service.playlist.DefaultPlaylistExportHandler;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream; import org.apache.commons.io.output.ByteArrayOutputStream;
import org.junit.Assert; import org.junit.Assert;
@ -12,19 +14,17 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder; import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.airsonic.player.dao.PlaylistDao;
import org.airsonic.player.service.playlist.DefaultPlaylistExportHandler;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.runners.MockitoJUnitRunner;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)

@ -19,7 +19,7 @@ import org.mockito.Captor;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
@ -30,7 +30,6 @@ import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
@ -190,7 +189,7 @@ public class PlaylistServiceTestImport {
@Override @Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable { public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
Playlist playlist = invocationOnMock.getArgument(0); Playlist playlist = invocationOnMock.getArgumentAt(0, Playlist.class);
playlist.setId(id); playlist.setId(id);
return null; return null;
} }
@ -200,7 +199,7 @@ public class PlaylistServiceTestImport {
@Override @Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable { public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
File file = invocationOnMock.getArgument(0); File file = invocationOnMock.getArgumentAt(0, File.class);
MediaFile mediaFile = new MediaFile(); MediaFile mediaFile = new MediaFile();
mediaFile.setPath(file.getPath()); mediaFile.setPath(file.getPath());
return mediaFile; return mediaFile;

@ -16,7 +16,7 @@
<properties> <properties>
<failOnDependencyWarning>true</failOnDependencyWarning> <failOnDependencyWarning>true</failOnDependencyWarning>
<project.build.sourceEncoding>iso-8859-1</project.build.sourceEncoding> <project.build.sourceEncoding>iso-8859-1</project.build.sourceEncoding>
<cxf.version>3.1.8</cxf.version> <cxf.version>3.1.12</cxf.version>
</properties> </properties>
<repositories> <repositories>
@ -86,10 +86,28 @@
<!-- Import dependency management from Spring Boot --> <!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>1.4.5.RELEASE</version> <version>1.5.6.RELEASE</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<!-- Cannot use 3.5.3/2 due to https://liquibase.jira.com/browse/CORE-2944 -->
<version>3.5.1</version>
</dependency>
<!-- Fix convergence issues -->
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -219,6 +237,25 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version>
<inherited>true</inherited>
<executions>
<execution>
<id>enforce</id>
<configuration>
<rules>
<dependencyConvergence/>
</rules>
</configuration>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

Loading…
Cancel
Save