* fixed some unit tests

This commit is contained in:
Reinhard Pointner 2009-07-03 13:07:43 +00:00
parent 2fe8bd1306
commit c9bc001a9c
4 changed files with 109 additions and 15 deletions

View File

@ -0,0 +1,94 @@
package net.sourceforge.filebot.web;
import static org.junit.Assert.*;
import java.nio.ByteBuffer;
import java.util.List;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class OpenSubtitlesXmlRpcTest {
private static OpenSubtitlesXmlRpc xmlrpc = new OpenSubtitlesXmlRpc("FileBot 0.0");
@BeforeClass
public static void login() throws Exception {
// login manually
xmlrpc.loginAnonymous();
}
@Test
public void search() throws Exception {
List<MovieDescriptor> list = xmlrpc.searchMoviesOnIMDB("babylon 5");
MovieDescriptor sample = (MovieDescriptor) list.get(0);
// check sample entry
assertEquals("\"Babylon 5\" (1994) (TV series)", sample.getName());
assertEquals(105946, sample.getImdbId());
}
@Test
public void getSubtitleListEnglish() throws Exception {
List<OpenSubtitlesSubtitleDescriptor> list = xmlrpc.searchSubtitles(361256, "eng");
SubtitleDescriptor sample = list.get(0);
assertTrue(sample.getName().startsWith("Wonderfalls"));
assertEquals("English", sample.getLanguageName());
// check size
assertTrue(list.size() > 20);
}
@Test
public void getSubtitleListAllLanguages() throws Exception {
List<OpenSubtitlesSubtitleDescriptor> list = xmlrpc.searchSubtitles(361256);
OpenSubtitlesSubtitleDescriptor sample = list.get(75);
assertTrue(sample.getName().startsWith("Wonderfalls"));
assertEquals("Hungarian", sample.getLanguageName());
// check size
assertTrue(list.size() > 70);
}
@Test
public void getSubtitleListMovieHash() {
//TODO not implemented yet
}
@Test
public void fetchSubtitle() throws Exception {
List<OpenSubtitlesSubtitleDescriptor> list = xmlrpc.searchSubtitles(361256, "eng");
// check format
assertEquals("srt", list.get(0).getType());
// fetch subtitle file
ByteBuffer data = list.get(0).fetch();
// check size
assertEquals(48550, data.remaining(), 0);
}
@AfterClass
public static void logout() throws Exception {
// logout manually
xmlrpc.logout();
}
}

View File

@ -17,7 +17,7 @@ public class TVDotComClientTest {
private static HyperLink buffySearchResult;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
buffySearchResult = new HyperLink("Buffy the Vampire Slayer", new URL("http://www.tv.com/buffy-the-vampire-slayer/show/10/episode.html"));
@ -87,8 +87,8 @@ public class TVDotComClientTest {
@Test
public void getEpisodeListAllManySeasons() throws Exception {
// more than 700 episodes / 26 seasons (on going)
List<Episode> list = tvdotcom.getEpisodeList(tvdotcom.search("Doctor Who").get(0));
// more than 700 episodes / 26 seasons
List<Episode> list = tvdotcom.getEpisodeList(tvdotcom.search("Doctor Who (1963)").get(0));
// there are still new episodes coming out
assertTrue(list.size() > 700);

View File

@ -8,19 +8,19 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import org.junit.After;
import org.junit.Test;
import net.sf.ehcache.CacheManager;
import net.sourceforge.filebot.web.TheTVDBClient.MirrorType;
import net.sourceforge.filebot.web.TheTVDBClient.TheTVDBSearchResult;
import org.junit.After;
import org.junit.Test;
public class TheTVDBClientTest {
private TheTVDBClient thetvdb = new TheTVDBClient("BA864DEE427E384A");
@After
public void clearCache() {
CacheManager.getInstance().clearAll();
@ -77,16 +77,16 @@ public class TheTVDBClientTest {
@Test
public void getEpisodeListSingleSeason() throws Exception {
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Buffy the Vampire Slayer", 70327), 7);
List<Episode> list = thetvdb.getEpisodeList(new TheTVDBSearchResult("Wonderfalls", 78845), 1);
assertEquals(22, list.size());
assertEquals(13, list.size());
Episode chosen = list.get(21);
Episode chosen = list.get(0);
assertEquals("Buffy the Vampire Slayer", chosen.getSeriesName());
assertEquals("Chosen", chosen.getTitle());
assertEquals("22", chosen.getEpisode());
assertEquals("7", chosen.getSeason());
assertEquals("Wonderfalls", chosen.getSeriesName());
assertEquals("Wax Lion", chosen.getTitle());
assertEquals("1", chosen.getEpisode());
assertEquals("1", chosen.getSeason());
}

View File

@ -8,7 +8,7 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses( { TVDotComClientTest.class, AnidbClientTest.class, TVRageClientTest.class, TheTVDBClientTest.class, IMDbClientTest.class, SubsceneSubtitleClientTest.class, SubtitleSourceClientTest.class, SublightSubtitleClientTest.class })
@SuiteClasses( { TVDotComClientTest.class, AnidbClientTest.class, TVRageClientTest.class, TheTVDBClientTest.class, IMDbClientTest.class, SubsceneSubtitleClientTest.class, SubtitleSourceClientTest.class, SublightSubtitleClientTest.class, OpenSubtitlesXmlRpcTest.class })
public class WebTestSuite {
}