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. 184
      airsonic-main/src/test/java/org/airsonic/player/TestCaseUtils.java
  2. 6
      airsonic-main/src/test/java/org/airsonic/player/api/jukebox/AbstractAirsonicRestApiJukeboxIntTest.java
  3. 2
      airsonic-main/src/test/java/org/airsonic/player/api/jukebox/AirsonicRestApiJukeboxIntTest.java
  4. 3
      airsonic-main/src/test/java/org/airsonic/player/dao/DaoTestCaseBean2.java
  5. 2
      airsonic-main/src/test/java/org/airsonic/player/dao/InternetRadioDaoTestCase.java
  6. 2
      airsonic-main/src/test/java/org/airsonic/player/dao/MusicFolderDaoTestCase.java
  7. 4
      airsonic-main/src/test/java/org/airsonic/player/dao/PlayerDaoTestCase.java
  8. 4
      airsonic-main/src/test/java/org/airsonic/player/dao/PodcastDaoTestCase.java
  9. 4
      airsonic-main/src/test/java/org/airsonic/player/dao/UserDaoTestCase.java
  10. 6
      airsonic-main/src/test/java/org/airsonic/player/domain/PlayQueueTestCase.java
  11. 2
      airsonic-main/src/test/java/org/airsonic/player/service/JukeboxServiceUnitTest.java
  12. 4
      airsonic-main/src/test/java/org/airsonic/player/service/LegacyDatabaseStartupTestCase.java
  13. 12
      airsonic-main/src/test/java/org/airsonic/player/service/MediaScannerServiceTestCase.java
  14. 6
      airsonic-main/src/test/java/org/airsonic/player/service/PlaylistServiceTestImport.java
  15. 1
      airsonic-main/src/test/java/org/airsonic/player/service/SecurityServiceTestCase.java
  16. 1
      airsonic-main/src/test/java/org/airsonic/player/service/TranscodingServiceIntTest.java
  17. 8
      airsonic-main/src/test/java/org/airsonic/player/service/search/AbstractAirsonicHomeTest.java
  18. 6
      airsonic-main/src/test/java/org/airsonic/player/service/search/AirsonicHomeTest.java
  19. 32
      airsonic-main/src/test/java/org/airsonic/player/service/search/AnalyzerFactoryTestCase.java
  20. 4
      airsonic-main/src/test/java/org/airsonic/player/service/search/IndexManagerTestCase.java
  21. 21
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceSpecialGenreTestCase.java
  22. 13
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceSpecialPathTestCase.java
  23. 11
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceStartWithStopwardsTestCase.java
  24. 12
      airsonic-main/src/test/java/org/airsonic/player/service/search/SearchServiceTestCase.java
  25. 2
      airsonic-main/src/test/java/org/airsonic/player/util/HomeRule.java
  26. 59
      airsonic-main/src/test/java/org/airsonic/player/util/MusicFolderTestData.java
  27. 2
      airsonic-main/src/test/java/org/airsonic/player/validator/PasswordSettingsValidatorTestCase.java
  28. 1
      pom.xml

@ -20,107 +20,101 @@ public class TestCaseUtils {
private static final Logger LOG = LoggerFactory.getLogger(TestCaseUtils.class);
private static File airsonicHomeDirForTest = null;
/**
* Returns the path of the AIRSONIC_HOME directory to use for tests.
* This will create a temporary directory.
*
* @return AIRSONIC_HOME directory path.
* @throws RuntimeException if it fails to create the temp directory.
*/
public static String airsonicHomePathForTest() {
if (airsonicHomeDirForTest == null) {
try {
airsonicHomeDirForTest = Files.createTempDirectory("airsonic_test_").toFile();
} catch (IOException e) {
throw new RuntimeException("Error while creating temporary AIRSONIC_HOME directory for tests");
}
LOG.info("AIRSONIC_HOME directory will be {}", airsonicHomeDirForTest.getAbsolutePath());
private static File airsonicHomeDirForTest = null;
/**
* Returns the path of the AIRSONIC_HOME directory to use for tests.
* This will create a temporary directory.
*
* @return AIRSONIC_HOME directory path.
* @throws RuntimeException if it fails to create the temp directory.
*/
public static String airsonicHomePathForTest() {
if (airsonicHomeDirForTest == null) {
try {
airsonicHomeDirForTest = Files.createTempDirectory("airsonic_test_").toFile();
} catch (IOException e) {
throw new RuntimeException("Error while creating temporary AIRSONIC_HOME directory for tests");
}
LOG.info("AIRSONIC_HOME directory will be {}", airsonicHomeDirForTest.getAbsolutePath());
}
return airsonicHomeDirForTest.getAbsolutePath();
}
/**
* @return current REST api version.
*/
public static String restApiVersion() {
return new JAXBWriter().getRestProtocolVersion();
}
return airsonicHomeDirForTest.getAbsolutePath();
}
/**
*
* @return current REST api version.
*/
public static String restApiVersion() {
return new JAXBWriter().getRestProtocolVersion();
}
/**
* Cleans the AIRSONIC_HOME directory used for tests.
*/
public static void cleanAirsonicHomeForTest() throws IOException {
File airsonicHomeDir = new File(airsonicHomePathForTest());
if (airsonicHomeDir.exists() && airsonicHomeDir.isDirectory()) {
LOG.debug("Delete airsonic home (ie. {}).", airsonicHomeDir.getAbsolutePath());
try {
FileUtils.deleteDirectory(airsonicHomeDir);
} catch (IOException e) {
LOG.warn("Error while deleting airsonic home.");
e.printStackTrace();
throw e;
}
/**
* Cleans the AIRSONIC_HOME directory used for tests.
*/
public static void cleanAirsonicHomeForTest() throws IOException {
File airsonicHomeDir = new File(airsonicHomePathForTest());
if (airsonicHomeDir.exists() && airsonicHomeDir.isDirectory()) {
LOG.debug("Delete airsonic home (ie. {}).", airsonicHomeDir.getAbsolutePath());
try {
FileUtils.deleteDirectory(airsonicHomeDir);
} catch (IOException e) {
LOG.warn("Error while deleting airsonic home.");
e.printStackTrace();
throw e;
}
}
}
}
/**
* Constructs a map of records count per table.
*
* @param daoHelper DaoHelper object
* @return Map table name -> records count
*/
public static Map<String, Integer> recordsInAllTables(DaoHelper daoHelper) {
List<String> tableNames = daoHelper.getJdbcTemplate().queryForList("" +
"select table_name " +
"from information_schema.system_tables " +
"where table_name not like 'SYSTEM%'"
, String.class);
return tableNames.stream()
.collect(Collectors.toMap(table -> table, table -> recordsInTable(table,daoHelper)));
}
/**
* Constructs a map of records count per table.
*
* @param daoHelper DaoHelper object
* @return Map table name -> records count
/**
* Counts records in a table.
*/
public static Map<String, Integer> recordsInAllTables(DaoHelper daoHelper) {
List<String> tableNames = daoHelper.getJdbcTemplate().queryForList("" +
"select table_name " +
"from information_schema.system_tables " +
"where table_name not like 'SYSTEM%'"
, String.class);
return tableNames.stream()
.collect(Collectors.toMap(table -> table, table -> recordsInTable(table,daoHelper)));
}
/**
* Counts records in a table.
*/
public static Integer recordsInTable(String tableName, DaoHelper daoHelper) {
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";
String[] configLocations = new String[]{
TestCaseUtils.class.getClass().getResource(applicationContextCache).toString(),
TestCaseUtils.class.getClass().getResource(applicationContextService).toString()
};
return new ClassPathXmlApplicationContext(configLocations);
}
/**
* Scans the music library * @param mediaScannerService
*/
public static void execScan(MediaScannerService mediaScannerService) {
// TODO create a synchronous scan
mediaScannerService.scanLibrary();
while (mediaScannerService.isScanning()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
public static Integer recordsInTable(String tableName, DaoHelper daoHelper) {
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";
String[] configLocations = new String[]{
TestCaseUtils.class.getClass().getResource(applicationContextCache).toString(),
TestCaseUtils.class.getClass().getResource(applicationContextService).toString()
};
return new ClassPathXmlApplicationContext(configLocations);
}
/**
* Scans the music library * @param mediaScannerService
*/
public static void execScan(MediaScannerService mediaScannerService) {
// TODO create a synchronous scan
mediaScannerService.scanLibrary();
while (mediaScannerService.isScanning()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

@ -152,9 +152,9 @@ public abstract class AbstractAirsonicRestApiJukeboxIntTest {
}
private String convertDateToString(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
return formatter.format(date);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
return formatter.format(date);
}
private ResultMatcher playListItem1isCorrect() {

@ -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.
@ -218,7 +218,7 @@ public class AnalyzerFactoryTestCase {
}
});
}
}
/**
* Simple test on FullWidth.
@ -480,18 +480,18 @@ public class AnalyzerFactoryTestCase {
assertEquals(asList("abc", "def"), toTermString("~ABC~DEF~"));
assertEquals(asList("abc", "def"), toTermString("*ABC*DEF*"));
assertEquals(asList("abc", "def"), toTermString("?ABC?DEF?"));
assertEquals(asList("abc:def"), toTermString(":ABC:DEF:")); // XXX 3.x -> 8.x : abc def -> abc:def
assertEquals(asList("abc:def"), toTermString(":ABC:DEF:")); // XXX 3.x -> 8.x : abc def -> abc:def
assertEquals(asList("abc", "def"), toTermString("-ABC-DEF-"));
assertEquals(asList("abc", "def"), toTermString("/ABC/DEF/"));
/*
* XXX 3.x -> 8.x : _abc_def_ in UAX#29.
* Since the effect is large, trim with Filter.
*/
assertEquals(asList("abc_def"), toTermString("_ABC_DEF_")); // XXX 3.x -> 8.x : abc def -> abc_def
assertEquals(asList("abc_def"), toTermString("_ABC_DEF_")); // XXX 3.x -> 8.x : abc def -> abc_def
assertEquals(asList("abc", "def"), toTermString(",ABC,DEF,"));
assertEquals(asList("abc.def"), toTermString(".ABC.DEF."));
assertEquals(asList("abc", "def"), toTermString("&ABC&DEF&")); // XXX 3.x -> 8.x : abc&def -> abc def
assertEquals(asList("abc", "def"), toTermString("@ABC@DEF@")); // XXX 3.x -> 8.x : abc@def -> abc def
assertEquals(asList("abc", "def"), toTermString("&ABC&DEF&")); // XXX 3.x -> 8.x : abc&def -> abc def
assertEquals(asList("abc", "def"), toTermString("@ABC@DEF@")); // XXX 3.x -> 8.x : abc@def -> abc def
assertEquals(asList("abc'def"), toTermString("'ABC'DEF'"));
// trim and delimiter and number
@ -511,15 +511,15 @@ public class AnalyzerFactoryTestCase {
assertEquals(asList("abc1", "def"), toTermString("*ABC1*DEF*"));
assertEquals(asList("abc1", "def"), toTermString("?ABC1?DEF?"));
assertEquals(asList("abc1", "def"), toTermString(":ABC1:DEF:"));
assertEquals(asList("abc1", "def"), toTermString(",ABC1,DEF,")); // XXX 3.x -> 8.x : abc1,def -> abc1 def
assertEquals(asList("abc1", "def"), toTermString("-ABC1-DEF-")); // XXX 3.x -> 8.x : abc1-def -> abc1 def
assertEquals(asList("abc1", "def"), toTermString("/ABC1/DEF/")); // XXX 3.x -> 8.x : abc1/def -> abc1 def
assertEquals(asList("abc1", "def"), toTermString(",ABC1,DEF,")); // XXX 3.x -> 8.x : abc1,def -> abc1 def
assertEquals(asList("abc1", "def"), toTermString("-ABC1-DEF-")); // XXX 3.x -> 8.x : abc1-def -> abc1 def
assertEquals(asList("abc1", "def"), toTermString("/ABC1/DEF/")); // XXX 3.x -> 8.x : abc1/def -> abc1 def
/*
* XXX 3.x -> 8.x : _abc1_def_ in UAX#29.
* Since the effect is large, trim with Filter.
*/
assertEquals(asList("abc1_def"), toTermString("_ABC1_DEF_"));
assertEquals(asList("abc1", "def"), toTermString(".ABC1.DEF.")); // XXX 3.x -> 8.x : abc1.def -> abc1 def
assertEquals(asList("abc1", "def"), toTermString(".ABC1.DEF.")); // XXX 3.x -> 8.x : abc1.def -> abc1 def
assertEquals(asList("abc1", "def"), toTermString("&ABC1&DEF&"));
assertEquals(asList("abc1", "def"), toTermString("@ABC1@DEF@"));
assertEquals(asList("abc1", "def"), toTermString("'ABC1'DEF'"));
@ -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.
@ -63,7 +62,7 @@ public class SearchServiceSpecialGenreTestCase extends AbstractAirsonicHomeTest
public void testQueryEscapeRequires() {
Function<String, RandomSearchCriteria> simpleStringCriteria = s ->
new RandomSearchCriteria(Integer.MAX_VALUE, // count
new RandomSearchCriteria(Integer.MAX_VALUE, // count
s, // genre,
null, // fromYear
null, // toYear
@ -194,7 +193,7 @@ public class SearchServiceSpecialGenreTestCase extends AbstractAirsonicHomeTest
public void testBrackets() {
Function<String, RandomSearchCriteria> simpleStringCriteria = s ->
new RandomSearchCriteria(Integer.MAX_VALUE, // count
new RandomSearchCriteria(Integer.MAX_VALUE, // count
s, // genre,
null, // fromYear
null, // toYear
@ -268,7 +267,7 @@ public class SearchServiceSpecialGenreTestCase extends AbstractAirsonicHomeTest
public void testOthers() {
Function<String, RandomSearchCriteria> simpleStringCriteria = s ->
new RandomSearchCriteria(Integer.MAX_VALUE, // count
new RandomSearchCriteria(Integer.MAX_VALUE, // count
s, // genre,
null, // fromYear
null, // toYear

@ -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

@ -9,34 +9,33 @@ import java.util.List;
public class MusicFolderTestData {
private static String baseResources = "/MEDIAS/";
public static String resolveBaseMediaPath() {
return MusicFolderTestData.class.getResource(baseResources).toString().replace("file:","");
}
public static String resolveMusicFolderPath() {
return (MusicFolderTestData.resolveBaseMediaPath() + "Music");
}
public static String resolveMusic2FolderPath() {
return (MusicFolderTestData.resolveBaseMediaPath() + "Music2");
}
public static String resolveMusic3FolderPath() {
return (MusicFolderTestData.resolveBaseMediaPath() + "Music3");
}
public static List<MusicFolder> getTestMusicFolders() {
List<MusicFolder> liste = new ArrayList<>();
File musicDir = new File(MusicFolderTestData.resolveMusicFolderPath());
MusicFolder musicFolder = new MusicFolder(1,musicDir,"Music",true,new Date());
liste.add(musicFolder);
File music2Dir = new File(MusicFolderTestData.resolveMusic2FolderPath());
MusicFolder musicFolder2 = new MusicFolder(2,music2Dir,"Music2",true,new Date());
liste.add(musicFolder2);
return liste;
}
private static String baseResources = "/MEDIAS/";
public static String resolveBaseMediaPath() {
return MusicFolderTestData.class.getResource(baseResources).toString().replace("file:","");
}
public static String resolveMusicFolderPath() {
return (MusicFolderTestData.resolveBaseMediaPath() + "Music");
}
public static String resolveMusic2FolderPath() {
return (MusicFolderTestData.resolveBaseMediaPath() + "Music2");
}
public static String resolveMusic3FolderPath() {
return (MusicFolderTestData.resolveBaseMediaPath() + "Music3");
}
public static List<MusicFolder> getTestMusicFolders() {
List<MusicFolder> liste = new ArrayList<>();
File musicDir = new File(MusicFolderTestData.resolveMusicFolderPath());
MusicFolder musicFolder = new MusicFolder(1,musicDir,"Music",true,new Date());
liste.add(musicFolder);
File music2Dir = new File(MusicFolderTestData.resolveMusic2FolderPath());
MusicFolder musicFolder2 = new MusicFolder(2,music2Dir,"Music2",true,new Date());
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