Merge remote-tracking branch 'origin/pr/1332'

master
Andrew DeMaria 5 years ago
commit ceb6b3e598
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 6
      airsonic-main/src/test/java/org/airsonic/player/TestCaseUtils.java
  2. 2
      airsonic-main/src/test/java/org/airsonic/player/api/jukebox/AirsonicRestApiJukeboxIntTest.java
  3. 3
      airsonic-main/src/test/java/org/airsonic/player/dao/DaoTestCaseBean2.java
  4. 2
      airsonic-main/src/test/java/org/airsonic/player/dao/InternetRadioDaoTestCase.java
  5. 2
      airsonic-main/src/test/java/org/airsonic/player/dao/MusicFolderDaoTestCase.java
  6. 4
      airsonic-main/src/test/java/org/airsonic/player/dao/PlayerDaoTestCase.java
  7. 4
      airsonic-main/src/test/java/org/airsonic/player/dao/PodcastDaoTestCase.java
  8. 4
      airsonic-main/src/test/java/org/airsonic/player/dao/UserDaoTestCase.java
  9. 6
      airsonic-main/src/test/java/org/airsonic/player/domain/PlayQueueTestCase.java
  10. 2
      airsonic-main/src/test/java/org/airsonic/player/service/JukeboxServiceUnitTest.java
  11. 4
      airsonic-main/src/test/java/org/airsonic/player/service/LegacyDatabaseStartupTestCase.java
  12. 12
      airsonic-main/src/test/java/org/airsonic/player/service/MediaScannerServiceTestCase.java
  13. 6
      airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestImport.java
  14. 1
      airsonic-main/src/test/java/org/airsonic/player/service/SecurityServiceTestCase.java
  15. 1
      airsonic-main/src/test/java/org/airsonic/player/service/TranscodingServiceIntTest.java
  16. 8
      airsonic-main/src/test/java/org/airsonic/player/service/search/AbstractAirsonicHomeTest.java
  17. 6
      airsonic-main/src/test/java/org/airsonic/player/service/search/AirsonicHomeTest.java
  18. 14
      airsonic-main/src/test/java/org/airsonic/player/service/search/AnalyzerFactoryTestCase.java
  19. 4
      airsonic-main/src/test/java/org/airsonic/player/service/search/IndexManagerTestCase.java
  20. 15
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceSpecialGenreTestCase.java
  21. 13
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceSpecialPathTestCase.java
  22. 11
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceStartWithStopwardsTestCase.java
  23. 12
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceTestCase.java
  24. 2
      airsonic-main/src/test/java/org/airsonic/player/util/HomeRule.java
  25. 1
      airsonic-main/src/test/java/org/airsonic/player/util/MusicFolderTestData.java
  26. 2
      airsonic-main/src/test/java/org/airsonic/player/validator/PasswordSettingsValidatorTestCase.java
  27. 1
      pom.xml

@ -43,7 +43,6 @@ public class TestCaseUtils {
}
/**
*
* @return current REST api version.
*/
public static String restApiVersion() {
@ -66,7 +65,6 @@ public class TestCaseUtils {
throw e;
}
}
}
/**
@ -93,7 +91,6 @@ public class TestCaseUtils {
return daoHelper.getJdbcTemplate().queryForObject("select count(1) from " + tableName,Integer.class);
}
public static ApplicationContext loadSpringApplicationContext(String baseResources) {
String applicationContextService = baseResources + "applicationContext-service.xml";
String applicationContextCache = baseResources + "applicationContext-cache.xml";
@ -105,7 +102,6 @@ public class TestCaseUtils {
return new ClassPathXmlApplicationContext(configLocations);
}
/**
* Scans the music library * @param mediaScannerService
*/
@ -120,7 +116,5 @@ public class TestCaseUtils {
e.printStackTrace();
}
}
}
}

@ -20,7 +20,7 @@ public class AirsonicRestApiJukeboxIntTest extends AbstractAirsonicRestApiJukebo
public void setup() throws Exception {
super.setup();
JavaPlayer mockJavaPlayer = mock(JavaPlayer.class);
when(mockJavaPlayer.getPlayingInfos()).thenReturn( () -> 0 );
when(mockJavaPlayer.getPlayingInfos()).thenReturn(() -> 0);
when(mockJavaPlayer.getGain()).thenReturn(0.75f);
when(javaPlayerFactory.createJavaPlayer()).thenReturn(mockJavaPlayer);
}

@ -1,10 +1,10 @@
package org.airsonic.player.dao;
import org.airsonic.player.util.HomeRule;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.airsonic.player.util.HomeRule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
@ -33,7 +33,6 @@ public class DaoTestCaseBean2 {
@Autowired
GenericDaoHelper genericDaoHelper;
JdbcTemplate getJdbcTemplate() {
return genericDaoHelper.getJdbcTemplate();
}

@ -1,8 +1,8 @@
package org.airsonic.player.dao;
import org.airsonic.player.domain.InternetRadio;
import org.junit.Before;
import org.junit.Test;
import org.airsonic.player.domain.InternetRadio;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;

@ -18,10 +18,10 @@
Based upon Subsonic, Copyright 2009 (C) Sindre Mehus
*/
package org.airsonic.player.dao;
import org.airsonic.player.domain.MusicFolder;
import org.junit.Before;
import org.junit.Test;
import org.airsonic.player.domain.MusicFolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;

@ -1,11 +1,11 @@
package org.airsonic.player.dao;
import org.airsonic.player.domain.PlayQueue;
import org.airsonic.player.domain.Player;
import org.airsonic.player.domain.PlayerTechnology;
import org.airsonic.player.domain.TranscodeScheme;
import org.junit.Before;
import org.junit.Test;
import org.airsonic.player.domain.Player;
import org.airsonic.player.domain.TranscodeScheme;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;

@ -1,10 +1,10 @@
package org.airsonic.player.dao;
import org.airsonic.player.domain.PodcastChannel;
import org.airsonic.player.domain.PodcastEpisode;
import org.airsonic.player.domain.PodcastStatus;
import org.junit.Before;
import org.junit.Test;
import org.airsonic.player.domain.PodcastChannel;
import org.airsonic.player.domain.PodcastEpisode;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;

@ -1,11 +1,11 @@
package org.airsonic.player.dao;
import org.airsonic.player.domain.AvatarScheme;
import org.airsonic.player.domain.TranscodeScheme;
import org.airsonic.player.domain.User;
import org.airsonic.player.domain.UserSettings;
import org.junit.Before;
import org.junit.Test;
import org.airsonic.player.domain.TranscodeScheme;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
@ -51,7 +51,7 @@ public class UserDaoTestCase extends DaoTestCaseBean2 {
@Test
public void testCreateUserTransactionalError() {
User user = new User ("muff1nman", "secret", "noemail") {
User user = new User("muff1nman", "secret", "noemail") {
@Override
public boolean isPlaylistRole() {
throw new RuntimeException();

@ -23,6 +23,7 @@ import junit.framework.TestCase;
import java.io.File;
import java.util.Arrays;
import java.util.Objects;
/**
* Unit test of {@link PlayQueue}.
@ -320,5 +321,10 @@ public class PlayQueueTestCase extends TestCase {
public boolean equals(Object o) {
return this == o;
}
@Override
public int hashCode() {
return Objects.hash(name, track, album, artist);
}
}
}

@ -8,8 +8,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.verify;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)

@ -1,13 +1,13 @@
package org.airsonic.player.service;
import org.airsonic.player.TestCaseUtils;
import org.airsonic.player.util.HomeRule;
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.airsonic.player.TestCaseUtils;
import org.airsonic.player.util.HomeRule;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;

@ -3,9 +3,14 @@ package org.airsonic.player.service;
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import org.airsonic.player.TestCaseUtils;
import org.airsonic.player.dao.*;
import org.airsonic.player.domain.Album;
import org.airsonic.player.domain.Artist;
import org.airsonic.player.domain.MediaFile;
import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.util.HomeRule;
import org.airsonic.player.util.MusicFolderTestData;
import org.apache.commons.io.IOUtils;
import org.junit.Assert;
import org.junit.ClassRule;
@ -14,11 +19,6 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.airsonic.player.TestCaseUtils;
import org.airsonic.player.domain.Album;
import org.airsonic.player.domain.Artist;
import org.airsonic.player.util.HomeRule;
import org.airsonic.player.util.MusicFolderTestData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
@ -29,9 +29,9 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@ -95,7 +95,7 @@ public class PlaylistServiceTestImport {
doAnswer(new PersistPlayList(23)).when(playlistDao).createPlaylist(any());
doAnswer(new MediaFileHasEverything()).when(mediaFileService).getMediaFile(any(File.class));
InputStream inputStream = new ByteArrayInputStream(builder.toString().getBytes(StandardCharsets.UTF_8));
String path = "/path/to/"+playlistName+".m3u";
String path = "/path/to/" + playlistName + ".m3u";
playlistService.importPlaylist(username, playlistName, path, inputStream, null);
verify(playlistDao).createPlaylist(actual.capture());
verify(playlistDao).setFilesInPlaylist(eq(23), medias.capture());
@ -129,7 +129,7 @@ public class PlaylistServiceTestImport {
doAnswer(new PersistPlayList(23)).when(playlistDao).createPlaylist(any());
doAnswer(new MediaFileHasEverything()).when(mediaFileService).getMediaFile(any(File.class));
InputStream inputStream = new ByteArrayInputStream(builder.toString().getBytes(StandardCharsets.UTF_8));
String path = "/path/to/"+playlistName+".pls";
String path = "/path/to/" + playlistName + ".pls";
playlistService.importPlaylist(username, playlistName, path, inputStream, null);
verify(playlistDao).createPlaylist(actual.capture());
verify(playlistDao).setFilesInPlaylist(eq(23), medias.capture());
@ -166,7 +166,7 @@ public class PlaylistServiceTestImport {
doAnswer(new PersistPlayList(23)).when(playlistDao).createPlaylist(any());
doAnswer(new MediaFileHasEverything()).when(mediaFileService).getMediaFile(any(File.class));
InputStream inputStream = new ByteArrayInputStream(builder.toString().getBytes(StandardCharsets.UTF_8));
String path = "/path/to/"+playlistName+".xspf";
String path = "/path/to/" + playlistName + ".xspf";
playlistService.importPlaylist(username, playlistName, path, inputStream, null);
verify(playlistDao).createPlaylist(actual.capture());
verify(playlistDao).setFilesInPlaylist(eq(23), medias.capture());

@ -20,6 +20,7 @@
package org.airsonic.player.service;
import junit.framework.TestCase;
/**
* Unit test of {@link SecurityService}.
*

@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.test.context.junit4.SpringRunner;
import static org.mockito.Mockito.*;
@RunWith(SpringRunner.class)

@ -1,9 +1,5 @@
package org.airsonic.player.service.search;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import org.airsonic.player.TestCaseUtils;
import org.airsonic.player.dao.DaoHelper;
import org.airsonic.player.dao.MusicFolderDao;
@ -23,6 +19,10 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.rules.SpringClassRule;
import org.springframework.test.context.junit4.rules.SpringMethodRule;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
@ContextConfiguration(locations = {
"/applicationContext-service.xml",
"/applicationContext-cache.xml",

@ -1,11 +1,11 @@
package org.airsonic.player.service.search;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.util.MusicFolderTestData;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Test case interface for scanning MusicFolder.
*/

@ -1,8 +1,10 @@
package org.airsonic.player.service.search;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.StringReader;
@ -10,10 +12,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.junit.Test;
import org.slf4j.LoggerFactory;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
/**
* Test case for Analyzer.
@ -631,8 +631,6 @@ public class AnalyzerFactoryTestCase {
assertEquals("{ }", terms.get(0));
}
private List<String> toTermString(String str) {
return toTermString(null, str);
}

@ -26,8 +26,6 @@ import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.domain.SearchCriteria;
import org.airsonic.player.domain.SearchResult;
import org.airsonic.player.service.SearchService;
import org.airsonic.player.service.search.IndexManager;
import org.airsonic.player.service.search.IndexType;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -36,9 +34,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
import static org.springframework.util.ObjectUtils.isEmpty;

@ -1,13 +1,7 @@
package org.airsonic.player.service.search;
import static org.springframework.util.ObjectUtils.isEmpty;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.google.common.base.Function;
import org.airsonic.player.domain.MediaFile;
import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.domain.RandomSearchCriteria;
@ -17,7 +11,12 @@ import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.base.Function;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
/*
* Tests to prove what kind of strings/chars can be used in the genre field.

@ -1,12 +1,6 @@
package org.airsonic.player.service.search;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.airsonic.player.domain.MediaFile;
import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.service.SearchService;
@ -14,6 +8,13 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import static org.springframework.util.ObjectUtils.isEmpty;
/*

@ -1,11 +1,6 @@
package org.airsonic.player.service.search;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.domain.SearchCriteria;
import org.airsonic.player.domain.SearchResult;
@ -14,6 +9,12 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static org.springframework.util.ObjectUtils.isEmpty;
/*

@ -4,12 +4,6 @@ package org.airsonic.player.service.search;
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.airsonic.player.dao.AlbumDao;
import org.airsonic.player.dao.MusicFolderDao;
import org.airsonic.player.domain.Album;
@ -22,13 +16,17 @@ import org.airsonic.player.domain.RandomSearchCriteria;
import org.airsonic.player.domain.SearchCriteria;
import org.airsonic.player.domain.SearchResult;
import org.airsonic.player.service.SearchService;
import org.airsonic.player.service.search.IndexType;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.subsonic.restapi.ArtistID3;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class SearchServiceTestCase extends AbstractAirsonicHomeTest {
@Autowired

@ -1,7 +1,7 @@
package org.airsonic.player.util;
import org.junit.rules.ExternalResource;
import org.airsonic.player.TestCaseUtils;
import org.junit.rules.ExternalResource;
public class HomeRule extends ExternalResource {
@Override

@ -38,5 +38,4 @@ public class MusicFolderTestData {
liste.add(musicFolder2);
return liste;
}
}

@ -17,7 +17,7 @@ public class PasswordSettingsValidatorTestCase extends TestCase {
psc.setPassword("1234");
}
private Errors validatePassword(){
private Errors validatePassword() {
PasswordSettingsValidator psv = new PasswordSettingsValidator();
Errors errors = new BeanPropertyBindingResult(psc, "psv");
psv.validate(psc, errors);

@ -249,6 +249,7 @@
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
</configuration>
<goals>
<goal>check</goal>

Loading…
Cancel
Save