* fixed encoding problem, added unit test

This commit is contained in:
Reinhard Pointner 2009-09-22 20:56:43 +00:00
parent 64eb0ab911
commit 9be7101759
2 changed files with 14 additions and 2 deletions

View File

@ -145,8 +145,8 @@ public final class WebRequest {
}
}
// use http default encoding if charset cannot be determined
return Charset.forName("ISO-8859-1");
// use http default encoding only for text/html, use UTF-8 for everything else (e.g. XML)
return Charset.forName(contentType.equals("text/html") ? "ISO-8859-1" : "UTF-8");
}

View File

@ -24,11 +24,17 @@ public class AnidbClientTest {
*/
private static HyperLink twelvekingdomsSearchResult;
/**
* 38 episodes, lots of special characters
*/
private static HyperLink princessTutuSearchResult;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
monsterSearchResult = new HyperLink("Monster", new URL("http://anidb.net/perl-bin/animedb.pl?show=anime&aid=1539"));
twelvekingdomsSearchResult = new HyperLink("Juuni Kokuki", new URL("http://anidb.net/a26"));
princessTutuSearchResult = new HyperLink("Princess Tutu", new URL("http://anidb.net/a516"));
}
@ -125,6 +131,12 @@ public class AnidbClientTest {
}
@Test
public void getEpisodeListEncoding() throws Exception {
assertEquals("Raven Princess - An der schönen blauen Donau", anidb.getEpisodeList(princessTutuSearchResult).get(6).getTitle());
}
@Test
public void getEpisodeListTrimRecap() throws Exception {
assertEquals("Sea God of the East, Azure Sea of the West - Transition Chapter", anidb.getEpisodeList(twelvekingdomsSearchResult).get(44).getTitle());