Add simple test cases for internet radios

This commit is contained in:
François-Xavier Thomas
2019-07-02 23:00:03 +02:00
parent 86510a4d42
commit 073b7e35e1
2 changed files with 181 additions and 4 deletions
@@ -224,7 +224,7 @@ public class InternetRadioService {
* @param maxRedirects maximum number of redirects, or 0 if unlimited
* @return the remote playlist data
*/
private SpecificPlaylist retrievePlaylist(URL url, long maxByteSize, int maxRedirects) throws IOException, PlaylistException {
protected SpecificPlaylist retrievePlaylist(URL url, long maxByteSize, int maxRedirects) throws IOException, PlaylistException {
SpecificPlaylist playlist;
HttpURLConnection urlConnection = connectToURLWithRedirects(url, maxRedirects);
@@ -252,7 +252,7 @@ public class InternetRadioService {
* @param maxRedirects maximum number of redirects, or 0 if unlimited
* @return an open connection
*/
private HttpURLConnection connectToURLWithRedirects(URL url, int maxRedirects) throws IOException, PlaylistException {
protected HttpURLConnection connectToURLWithRedirects(URL url, int maxRedirects) throws IOException, PlaylistException {
int redirectCount = 0;
URL currentURL = url;
@@ -269,7 +269,7 @@ public class InternetRadioService {
redirectCount += 1;
if (maxRedirects > 0 && redirectCount > maxRedirects) {
connection.disconnect();
throw new PlaylistHasTooManyRedirects(String.format("Too many redirects ({0}) for URL {1}", redirectCount, url));
throw new PlaylistHasTooManyRedirects(String.format("Too many redirects (%d) for URL %s", redirectCount, url));
}
// Reconnect to the new URL.
@@ -288,7 +288,7 @@ public class InternetRadioService {
* @param url the remote URL
* @return an open connection
*/
private HttpURLConnection connectToURL(URL url) throws IOException {
protected HttpURLConnection connectToURL(URL url) throws IOException {
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setAllowUserInteraction(false);
urlConnection.setConnectTimeout(10000);