From 7d4ca2ffe2d4f5bdb894cb9de98210a0ba2487e6 Mon Sep 17 00:00:00 2001 From: Andrew DeMaria Date: Sun, 20 Aug 2017 14:48:57 -0600 Subject: [PATCH] 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 --- airsonic-main/pom.xml | 12 +----- .../java/org/airsonic/player/Application.java | 5 +-- .../airsonic/player/TomcatApplication.java | 2 +- .../main/resources/META-INF/spring.factories | 3 ++ .../service/PlaylistServiceTestExport.java | 8 ++-- .../service/PlaylistServiceTestImport.java | 7 ++-- pom.xml | 41 ++++++++++++++++++- 7 files changed, 54 insertions(+), 24 deletions(-) diff --git a/airsonic-main/pom.xml b/airsonic-main/pom.xml index 3b323679..c94b9b39 100644 --- a/airsonic-main/pom.xml +++ b/airsonic-main/pom.xml @@ -79,7 +79,6 @@ org.springframework.ldap spring-ldap-core - 2.0.2.RELEASE org.springframework.security @@ -153,13 +152,11 @@ org.apache.httpcomponents httpcore - 4.4.5 org.apache.httpcomponents httpclient - 4.5.2 @@ -278,7 +275,7 @@ org.mockito mockito-core - 2.5.7 + 1.10.19 test @@ -380,8 +377,6 @@ org.liquibase liquibase-core - - 3.5.1 @@ -419,7 +414,6 @@ org.slf4j slf4j-api - 1.7.24 @@ -448,12 +442,10 @@ com.fasterxml.jackson.core jackson-core - 2.8.7 com.fasterxml.jackson.core jackson-databind - 2.8.7 com.jayway.jsonpath @@ -479,7 +471,7 @@ spring-boot-maven-plugin 1.5.2.RELEASE - org.airsonic.player.boot.Application + org.airsonic.player.Application WAR ${boot.group.excludes} ${boot.artifact.excludes} diff --git a/airsonic-main/src/main/java/org/airsonic/player/Application.java b/airsonic-main/src/main/java/org/airsonic/player/Application.java index b9429b6b..9935421e 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/Application.java +++ b/airsonic-main/src/main/java/org/airsonic/player/Application.java @@ -1,8 +1,7 @@ -package org.airsonic.player.boot; +package org.airsonic.player; import net.sf.ehcache.constructs.web.ShutdownListener; import org.airsonic.player.filter.*; -import org.airsonic.player.spring.CustomPropertySourceConfigurer; import org.directwebremoting.servlet.DwrServlet; import org.slf4j.Logger; 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 // Since our example is itself a @Configuration class (via @SpringBootApplication) // 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 diff --git a/airsonic-main/src/main/java/org/airsonic/player/TomcatApplication.java b/airsonic-main/src/main/java/org/airsonic/player/TomcatApplication.java index 8cadde6a..8cf23390 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/TomcatApplication.java +++ b/airsonic-main/src/main/java/org/airsonic/player/TomcatApplication.java @@ -1,4 +1,4 @@ -package org.airsonic.player.boot; +package org.airsonic.player; import org.apache.catalina.Container; import org.apache.catalina.Wrapper; diff --git a/airsonic-main/src/main/resources/META-INF/spring.factories b/airsonic-main/src/main/resources/META-INF/spring.factories index ae85c840..461b5e67 100644 --- a/airsonic-main/src/main/resources/META-INF/spring.factories +++ b/airsonic-main/src/main/resources/META-INF/spring.factories @@ -1,3 +1,6 @@ org.springframework.context.ApplicationListener=\ org.airsonic.player.spring.LoggingFileOverrideListener,\ org.airsonic.player.security.LoginFailureListener + +org.springframework.context.ApplicationContextInitializer=\ + org.airsonic.player.spring.CustomPropertySourceConfigurer diff --git a/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestExport.java b/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestExport.java index 287a8818..af4d99b1 100644 --- a/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestExport.java +++ b/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestExport.java @@ -2,8 +2,10 @@ package org.airsonic.player.service; import com.google.common.collect.Lists; import org.airsonic.player.dao.MediaFileDao; +import org.airsonic.player.dao.PlaylistDao; import org.airsonic.player.domain.MediaFile; import org.airsonic.player.domain.Playlist; +import org.airsonic.player.service.playlist.DefaultPlaylistExportHandler; import org.apache.commons.io.IOUtils; import org.apache.commons.io.output.ByteArrayOutputStream; import org.junit.Assert; @@ -12,19 +14,17 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; 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.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.runners.MockitoJUnitRunner; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) diff --git a/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestImport.java b/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestImport.java index af0a7043..c63cd473 100644 --- a/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestImport.java +++ b/airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestImport.java @@ -19,7 +19,7 @@ import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.invocation.InvocationOnMock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.runners.MockitoJUnitRunner; import org.mockito.stubbing.Answer; import java.io.ByteArrayInputStream; @@ -30,7 +30,6 @@ import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; @RunWith(MockitoJUnitRunner.class) @@ -190,7 +189,7 @@ public class PlaylistServiceTestImport { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { - Playlist playlist = invocationOnMock.getArgument(0); + Playlist playlist = invocationOnMock.getArgumentAt(0, Playlist.class); playlist.setId(id); return null; } @@ -200,7 +199,7 @@ public class PlaylistServiceTestImport { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { - File file = invocationOnMock.getArgument(0); + File file = invocationOnMock.getArgumentAt(0, File.class); MediaFile mediaFile = new MediaFile(); mediaFile.setPath(file.getPath()); return mediaFile; diff --git a/pom.xml b/pom.xml index e626f25c..9ac650de 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,7 @@ true iso-8859-1 - 3.1.8 + 3.1.12 @@ -86,10 +86,28 @@ org.springframework.boot spring-boot-dependencies - 1.4.5.RELEASE + 1.5.6.RELEASE pom import + + org.liquibase + liquibase-core + + 3.5.1 + + + + + org.ow2.asm + asm + 5.1 + + + org.apache.commons + commons-lang3 + 3.3.2 + @@ -219,6 +237,25 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M1 + true + + + enforce + + + + + + + enforce + + + +