Remove unnecessary exceptions and unused imports

Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
This commit is contained in:
jvoisin
2019-10-06 16:00:29 -06:00
committed by Andrew DeMaria
parent 90e6c77563
commit e5404648a4
103 changed files with 237 additions and 272 deletions
@@ -11,7 +11,6 @@ import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.security.test.context.support.WithMockUser;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
public class AirsonicRestApiJukeboxLegacyIntTest extends AirsonicRestApiJukeboxIntTest {
@@ -20,7 +20,7 @@ public class InternetRadioDaoTestCase extends DaoTestCaseBean2 {
InternetRadioDao internetRadioDao;
@Before
public void setUp() throws Exception {
public void setUp() {
getJdbcTemplate().execute("delete from internet_radio");
}
@@ -40,7 +40,7 @@ public class MusicFolderDaoTestCase extends DaoTestCaseBean2 {
MusicFolderDao musicFolderDao;
@Before
public void setUp() throws Exception {
public void setUp() {
getJdbcTemplate().execute("delete from music_folder");
}
@@ -24,7 +24,7 @@ public class PlayerDaoTestCase extends DaoTestCaseBean2 {
PlayerDao playerDao;
@Before
public void setUp() throws Exception {
public void setUp() {
getJdbcTemplate().execute("delete from player");
}
@@ -23,7 +23,7 @@ public class PodcastDaoTestCase extends DaoTestCaseBean2 {
PodcastDao podcastDao;
@Before
public void setUp() throws Exception {
public void setUp() {
getJdbcTemplate().execute("delete from podcast_channel");
}
@@ -24,7 +24,7 @@ public class TranscodingDaoTestCase extends DaoTestCaseBean2 {
PlayerDao playerDao;
@Before
public void setUp() throws Exception {
public void setUp() {
getJdbcTemplate().execute("delete from transcoding2");
}
@@ -25,7 +25,7 @@ public class UserDaoTestCase extends DaoTestCaseBean2 {
UserDao userDao;
@Before
public void setUp() throws Exception {
public void setUp() {
getJdbcTemplate().execute("delete from user_role");
getJdbcTemplate().execute("delete from user");
}
@@ -29,7 +29,7 @@ public class MediaFileComparatorTestCase extends TestCase {
private final MediaFileComparator comparator = new MediaFileComparator(true);
public void testCompareAlbums() throws Exception {
public void testCompareAlbums() {
MediaFile albumA2012 = new MediaFile();
albumA2012.setMediaType(MediaFile.MediaType.ALBUM);
@@ -65,7 +65,7 @@ public class MediaFileComparatorTestCase extends TestCase {
assertEquals(1, comparator.compare(albumB2012, albumA2012));
}
public void testCompareDiscNumbers() throws Exception {
public void testCompareDiscNumbers() {
MediaFile discXtrack1 = new MediaFile();
discXtrack1.setMediaType(MediaFile.MediaType.MUSIC);
@@ -22,7 +22,6 @@ package org.airsonic.player.domain;
import junit.framework.TestCase;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
/**
@@ -40,7 +39,7 @@ public class PlayQueueTestCase extends TestCase {
assertNull(playQueue.getCurrentFile());
}
public void testStatus() throws Exception {
public void testStatus() {
PlayQueue playQueue = new PlayQueue();
assertEquals(PlayQueue.Status.PLAYING, playQueue.getStatus());
@@ -54,7 +53,7 @@ public class PlayQueueTestCase extends TestCase {
assertEquals(PlayQueue.Status.PLAYING, playQueue.getStatus());
}
public void testMoveUp() throws Exception {
public void testMoveUp() {
PlayQueue playQueue = createPlaylist(0, "A", "B", "C", "D");
playQueue.moveUp(0);
assertPlaylistEquals(playQueue, 0, "A", "B", "C", "D");
@@ -72,7 +71,7 @@ public class PlayQueueTestCase extends TestCase {
assertPlaylistEquals(playQueue, 2, "A", "B", "D", "C");
}
public void testMoveDown() throws Exception {
public void testMoveDown() {
PlayQueue playQueue = createPlaylist(0, "A", "B", "C", "D");
playQueue.moveDown(0);
assertPlaylistEquals(playQueue, 1, "B", "A", "C", "D");
@@ -90,7 +89,7 @@ public class PlayQueueTestCase extends TestCase {
assertPlaylistEquals(playQueue, 3, "A", "B", "C", "D");
}
public void testRemove() throws Exception {
public void testRemove() {
PlayQueue playQueue = createPlaylist(0, "A", "B", "C", "D");
playQueue.removeFileAt(0);
assertPlaylistEquals(playQueue, 0, "B", "C", "D");
@@ -116,7 +115,7 @@ public class PlayQueueTestCase extends TestCase {
assertPlaylistEquals(playQueue, -1);
}
public void testNext() throws Exception {
public void testNext() {
PlayQueue playQueue = createPlaylist(0, "A", "B", "C");
assertFalse(playQueue.isRepeatEnabled());
playQueue.next();
@@ -137,7 +136,7 @@ public class PlayQueueTestCase extends TestCase {
assertPlaylistEquals(playQueue, 0, "A", "B", "C");
}
public void testPlayAfterEndReached() throws Exception {
public void testPlayAfterEndReached() {
PlayQueue playQueue = createPlaylist(2, "A", "B", "C");
playQueue.setStatus(PlayQueue.Status.PLAYING);
playQueue.next();
@@ -150,7 +149,7 @@ public class PlayQueueTestCase extends TestCase {
assertEquals("A", playQueue.getCurrentFile().getName());
}
public void testPlayLast() throws Exception {
public void testPlayLast() {
PlayQueue playQueue = createPlaylist(1, "A", "B", "C");
playQueue.addFiles(true, new TestMediaFile("D"));
@@ -160,7 +159,7 @@ public class PlayQueueTestCase extends TestCase {
assertPlaylistEquals(playQueue, 0, "E");
}
public void testAddFilesAt() throws Exception {
public void testAddFilesAt() {
PlayQueue playQueue = createPlaylist(0);
playQueue.addFilesAt(Arrays.<MediaFile>asList(new TestMediaFile("A"), new TestMediaFile("B"), new TestMediaFile("C")), 0);
@@ -174,7 +173,7 @@ public class PlayQueueTestCase extends TestCase {
}
public void testUndo() throws Exception {
public void testUndo() {
PlayQueue playQueue = createPlaylist(0, "A", "B", "C");
playQueue.setIndex(2);
playQueue.undo();
@@ -201,7 +200,7 @@ public class PlayQueueTestCase extends TestCase {
assertPlaylistEquals(playQueue, 0, "A", "B", "C");
}
public void testOrder() throws IOException {
public void testOrder() {
PlayQueue playQueue = new PlayQueue();
playQueue.addFiles(true, new TestMediaFile(2, "Artist A", "Album B"));
playQueue.addFiles(true, new TestMediaFile(1, "Artist C", "Album C"));
@@ -248,7 +247,7 @@ public class PlayQueueTestCase extends TestCase {
}
}
private PlayQueue createPlaylist(int index, String... songs) throws Exception {
private PlayQueue createPlaylist(int index, String... songs) {
PlayQueue playQueue = new PlayQueue();
for (String song : songs) {
playQueue.addFiles(true, new TestMediaFile(song));
@@ -32,11 +32,11 @@ public class SortableArtistTestCase extends TestCase {
private Collator collator;
@Override
public void setUp() throws Exception {
public void setUp() {
collator = Collator.getInstance(Locale.US);
}
public void testSorting() throws Exception {
public void testSorting() {
List<TestSortableArtist> artists = new ArrayList<TestSortableArtist>();
artists.add(new TestSortableArtist("ABBA"));
@@ -52,7 +52,7 @@ public class SortableArtistTestCase extends TestCase {
assertEquals("[abba, Abba, ABBA, abc, ABC, acdc, ACDC, ACDC]", artists.toString());
}
public void testSortingWithAccents() throws Exception {
public void testSortingWithAccents() {
List<TestSortableArtist> artists = new ArrayList<TestSortableArtist>();
TestSortableArtist a1 = new TestSortableArtist("Sea");
@@ -94,7 +94,7 @@ public class SortableArtistTestCase extends TestCase {
assertEquals("[Sea, Seb, SEB, S\u00e9b, Sed, See]", artists.toString());
}
public void testCollation() throws Exception {
public void testCollation() {
List<TestSortableArtist> artists = new ArrayList<TestSortableArtist>();
artists.add(new TestSortableArtist("p\u00e9ch\u00e9"));
@@ -10,14 +10,12 @@ import org.mockito.*;
import org.mockito.runners.MockitoJUnitRunner;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import java.util.List;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
@@ -99,7 +97,7 @@ public class InternetRadioServiceTest {
InputStream mockURLInputStreamLarge = new InputStream() {
private long pos = 0;
@Override
public int read() throws IOException {
public int read() {
return TEST_STREAM_PLAYLIST_CONTENTS_2.charAt((int)(pos++ % TEST_STREAM_PLAYLIST_CONTENTS_2.length()));
}
};
@@ -112,7 +110,7 @@ public class InternetRadioServiceTest {
InputStream mockURLInputStreamLarge2 = new InputStream() {
private long pos = 0;
@Override
public int read() throws IOException {
public int read() {
return 0x41;
}
};
@@ -129,7 +127,7 @@ public class InternetRadioServiceTest {
}
@Test
public void testParseSimplePlaylist() throws Exception {
public void testParseSimplePlaylist() {
List<InternetRadioSource> radioSources = internetRadioService.getInternetRadioSources(radio1);
Assert.assertEquals(2, radioSources.size());
@@ -138,7 +136,7 @@ public class InternetRadioServiceTest {
}
@Test
public void testRedirects() throws Exception {
public void testRedirects() {
List<InternetRadioSource> radioSources = internetRadioService.getInternetRadioSources(radioMove);
Assert.assertEquals(2, radioSources.size());
@@ -147,7 +145,7 @@ public class InternetRadioServiceTest {
}
@Test
public void testLargeInput() throws Exception {
public void testLargeInput() {
List<InternetRadioSource> radioSources = internetRadioService.getInternetRadioSources(radioLarge);
// A PlaylistTooLarge exception is thrown internally, and the
@@ -157,7 +155,7 @@ public class InternetRadioServiceTest {
}
@Test
public void testLargeInputURL() throws Exception {
public void testLargeInputURL() {
List<InternetRadioSource> radioSources = internetRadioService.getInternetRadioSources(radioLarge2);
// A PlaylistTooLarge exception is thrown internally, and the
@@ -167,7 +165,7 @@ public class InternetRadioServiceTest {
}
@Test
public void testRedirectLoop() throws Exception {
public void testRedirectLoop() {
List<InternetRadioSource> radioSources = internetRadioService.getInternetRadioSources(radioMoveLoop);
// A PlaylistHasTooManyRedirects exception is thrown internally,
@@ -40,7 +40,7 @@ public class JWTSecurityServiceTest {
@Test
public void addJWTToken() throws Exception {
public void addJWTToken() {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(uriString);
String actualUri = service.addJWTToken(builder).build().toUriString();
String jwtToken = UriComponentsBuilder.fromUriString(actualUri).build().getQueryParams().getFirst(
@@ -92,7 +92,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void updateJukebox() throws Exception {
public void updateJukebox() {
// When
jukeboxService.updateJukebox(legacyJukeboxPlayer, 0);
// Then
@@ -140,7 +140,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void startWithJukeboxPlayer() throws Exception {
public void startWithJukeboxPlayer() {
// When
jukeboxService.start(jukeboxPlayer);
// Then
@@ -148,7 +148,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void startWithLegacyJukeboxPlayer() throws Exception {
public void startWithLegacyJukeboxPlayer() {
// When
jukeboxService.start(legacyJukeboxPlayer);
@@ -157,7 +157,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void playWithJukeboxPlayer() throws Exception {
public void playWithJukeboxPlayer() {
// When
jukeboxService.play(jukeboxPlayer);
// Then
@@ -165,7 +165,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void playWithLegacyJukeboxPlayer() throws Exception {
public void playWithLegacyJukeboxPlayer() {
// When
jukeboxService.play(legacyJukeboxPlayer);
// Then
@@ -173,7 +173,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void stopWithJukeboxPlayer() throws Exception {
public void stopWithJukeboxPlayer() {
// When
jukeboxService.stop(jukeboxPlayer);
// Then
@@ -181,7 +181,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void stopWithLegacyJukeboxPlayer() throws Exception {
public void stopWithLegacyJukeboxPlayer() {
// When
jukeboxService.stop(legacyJukeboxPlayer);
// Then
@@ -190,7 +190,7 @@ public class JukeboxServiceUnitTest {
@Test
public void skipWithJukeboxPlayer() throws Exception {
public void skipWithJukeboxPlayer() {
// When
jukeboxService.skip(jukeboxPlayer, 0, 1);
// Then
@@ -198,7 +198,7 @@ public class JukeboxServiceUnitTest {
}
@Test
public void skipWithLegacyJukeboxPlayer() throws Exception {
public void skipWithLegacyJukeboxPlayer() {
// When
jukeboxService.skip(legacyJukeboxPlayer, 0, 1);
// Then
@@ -47,7 +47,7 @@ public class LegacyDatabaseStartupTestCase {
public final SpringMethodRule springMethodRule = new SpringMethodRule();
@Test
public void testStartup() throws Exception {
public void testStartup() {
System.out.println("Successful startup");
}
@@ -33,7 +33,7 @@ public class MusicIndexServiceTestCase extends TestCase {
private final MusicIndexService musicIndexService = new MusicIndexService();
public void testCreateIndexFromExpression() throws Exception {
public void testCreateIndexFromExpression() {
MusicIndex index = musicIndexService.createIndexFromExpression("A");
assertEquals("A", index.getIndex());
assertEquals(1, index.getPrefixes().size());
@@ -52,7 +52,7 @@ public class MusicIndexServiceTestCase extends TestCase {
assertEquals("Z", index.getPrefixes().get(2));
}
public void testCreateIndexesFromExpression() throws Exception {
public void testCreateIndexesFromExpression() {
List<MusicIndex> indexes = musicIndexService.createIndexesFromExpression("A B The X-Z(XYZ)");
assertEquals(4, indexes.size());
@@ -189,7 +189,7 @@ public class PlaylistServiceTestImport {
}
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
public Object answer(InvocationOnMock invocationOnMock) {
Playlist playlist = invocationOnMock.getArgumentAt(0, Playlist.class);
playlist.setId(id);
return null;
@@ -199,7 +199,7 @@ public class PlaylistServiceTestImport {
private class MediaFileHasEverything implements Answer {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
public Object answer(InvocationOnMock invocationOnMock) {
File file = invocationOnMock.getArgumentAt(0, File.class);
MediaFile mediaFile = new MediaFile();
mediaFile.setPath(file.getPath());
@@ -36,7 +36,7 @@ public class SettingsServiceTestCase extends TestCase {
private SettingsService settingsService;
@Override
protected void setUp() throws Exception {
protected void setUp() {
String airsonicHome = TestCaseUtils.airsonicHomePathForTest();
System.setProperty("airsonic.home", airsonicHome);
new File(airsonicHome, "airsonic.properties").delete();
@@ -29,7 +29,7 @@ import org.airsonic.player.domain.MediaFile;
*/
public class MediaFileTestCase extends TestCase {
public void testGetDurationAsString() throws Exception {
public void testGetDurationAsString() {
doTestGetDurationAsString(0, "0:00");
doTestGetDurationAsString(1, "0:01");
doTestGetDurationAsString(10, "0:10");
@@ -32,7 +32,7 @@ import java.io.File;
*/
public class MetaDataParserTestCase extends TestCase {
public void testRemoveTrackNumberFromTitle() throws Exception {
public void testRemoveTrackNumberFromTitle() {
MetaDataParser parser = new MetaDataParser() {
public MetaData getRawMetaData(File file) {
@@ -64,7 +64,7 @@ public class IndexManagerTestCase extends AbstractAirsonicHomeTest {
}
@Before
public void setup() throws Exception {
public void setup() {
populateDatabaseOnlyOnce();
}
@@ -84,7 +84,7 @@ public class IndexManagerTestCase extends AbstractAirsonicHomeTest {
ResourceLoader resourceLoader;
@Test
public void testExpunge() throws InterruptedException {
public void testExpunge() {
SearchCriteria criteria = new SearchCriteria();
criteria.setOffset(0);
@@ -40,7 +40,7 @@ public class SearchServiceSpecialGenreTestCase extends AbstractAirsonicHomeTest
}
@Before
public void setup() throws Exception {
public void setup() {
populateDatabaseOnlyOnce();
}
@@ -51,7 +51,7 @@ public class SearchServiceSpecialPathTestCase extends AbstractAirsonicHomeTest {
}
@Before
public void setup() throws Exception {
public void setup() {
populateDatabaseOnlyOnce();
}
@@ -41,7 +41,7 @@ public class SearchServiceStartWithStopwardsTestCase extends AbstractAirsonicHom
}
@Before
public void setup() throws Exception {
public void setup() {
populateDatabaseOnlyOnce();
}
@@ -43,7 +43,7 @@ public class SearchServiceTestCase extends AbstractAirsonicHomeTest {
private SearchService searchService;
@Before
public void setup() throws Exception {
public void setup() {
populateDatabaseOnlyOnce();
}
@@ -31,7 +31,7 @@ import java.util.Locale;
*/
public class StringUtilTestCase extends TestCase {
public void testToHtml() throws Exception {
public void testToHtml() {
assertEquals(null, StringUtil.toHtml(null));
assertEquals("", StringUtil.toHtml(""));
assertEquals(" ", StringUtil.toHtml(" "));
@@ -57,7 +57,7 @@ public class StringUtilTestCase extends TestCase {
assertEquals("Error in getMimeType().", "application/octet-stream", StringUtil.getMimeType(null));
}
public void testFormatBytes() throws Exception {
public void testFormatBytes() {
Locale locale = Locale.ENGLISH;
assertEquals("Error in formatBytes().", "918 B", StringUtil.formatBytes(918, locale));
assertEquals("Error in formatBytes().", "1023 B", StringUtil.formatBytes(1023, locale));
@@ -11,7 +11,7 @@ public class PasswordSettingsValidatorTestCase extends TestCase {
private PasswordSettingsCommand psc;
@Before
public void setUp() throws Exception {
public void setUp() {
psc = new PasswordSettingsCommand();
psc.setUsername("username");
psc.setPassword("1234");