Update JUnits

- Complet AllTest class
- Fix JSONSearchAlbumTracksTest class
This commit is contained in:
Tanguy Herbron 2018-10-14 17:26:06 +02:00
parent 763c503229
commit a439511e47
4 changed files with 25 additions and 19 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,7 @@ import org.apache.log4j.Logger;
import org.junit.Test; import org.junit.Test;
import fr.ensim.xml.deezer.data.Album; import fr.ensim.xml.deezer.data.Album;
import fr.ensim.xml.deezer.data.Track;
public class JSONSearchAlbumTracksTest { public class JSONSearchAlbumTracksTest {
@ -20,24 +21,18 @@ public class JSONSearchAlbumTracksTest {
// Recuperation du flux a parser // Recuperation du flux a parser
//InputStream in = getClass().getResourceAsStream("../list-albums.json"); //InputStream in = getClass().getResourceAsStream("../list-albums.json");
InputStream in = getClass().getClassLoader().getResourceAsStream("fr/ensim/json/list-albums.json"); InputStream in = getClass().getClassLoader().getResourceAsStream("fr/ensim/json/47685332.json");
List<Tra> listAlbums = new JSONSearchAlbum().readAlbums(in); List<Track> trackList = new JSONSearchAlbumTracks().find(in);
assertEquals(10, handler.getListAlbum().size()); assertEquals(13, trackList.size());
//First album //First album
assertEquals("47685332", handler.getListAlbum().get(0).getId()); assertEquals("Gung Ho", trackList.get(0).getTitle());
assertEquals("The Evol", handler.getListAlbum().get(0).getTitle()); assertEquals("http://cdn-preview-a.deezer.com/stream/c-abbf47cd151375ceee9a5d3835545268-4.mp3", trackList.get(0).getPreview());
assertEquals("http://api.deezer.com/2.0/album/47685332/image", handler.getListAlbum().get(0).getCover());
assertEquals("83325", handler.getListAlbum().get(0).getArtist().getId());
assertEquals("Shaka Ponk", handler.getListAlbum().get(0).getArtist().getName());
//Second album //Second album
assertEquals("1121440", handler.getListAlbum().get(1).getId()); assertEquals("Fear Ya", trackList.get(1).getTitle());
assertEquals("The Geeks And The Jerkin' Socks", handler.getListAlbum().get(1).getTitle()); assertEquals("http://cdn-preview-f.deezer.com/stream/c-f2ff0cdc8bd8e4764f59d36ccf996d7c-4.mp3", trackList.get(1).getPreview());
assertEquals("http://api.deezer.com/2.0/album/1121440/image", handler.getListAlbum().get(1).getCover());
assertEquals("83325", handler.getListAlbum().get(1).getArtist().getId());
assertEquals("Shaka Ponk", handler.getListAlbum().get(1).getArtist().getName());
LOG.debug("<<testParse"); LOG.debug("<<testParse");
} }

View File

@ -4,12 +4,18 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite; import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses; import org.junit.runners.Suite.SuiteClasses;
import fr.ensim.json.JSONSearchAlbumTest;
import fr.ensim.json.JSONSearchAlbumTracksTest;
import fr.ensim.xml.deezer.dom.DOMSearchAlbumTracksTest;
import fr.ensim.xml.deezer.dom.DOMSearchAlbumsTest; import fr.ensim.xml.deezer.dom.DOMSearchAlbumsTest;
import fr.ensim.xml.deezer.sax.SAXSearchAlbumsTest; import fr.ensim.xml.deezer.sax.SAXSearchAlbumsTest;
import fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest; import fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest;
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ DOMSearchAlbumsTest.class, SAXSearchAlbumsTest.class, StAXSearchAlbumsTest.class}) @SuiteClasses({ JSONSearchAlbumTest.class, JSONSearchAlbumTracksTest.class
, DOMSearchAlbumsTest.class, DOMSearchAlbumTracksTest.class
, SAXSearchAlbumsTest.class
, StAXSearchAlbumsTest.class})
public class AllTests { public class AllTests {
} }

View File

@ -1,4 +1,8 @@
17:15:23,447 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracksTest - >>testParse 17:25:23,069 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - >>testCount
17:15:23,450 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find 17:25:23,071 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>count
17:15:23,461 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracks - >>find 17:25:23,082 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <<count 10
17:15:23,462 DEBUG fr.ensim.xml.deezer.dom.DOMSearchAlbumTracksTest - <<testParse 17:25:23,082 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - <<testCount
17:25:23,083 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - >>testParse
17:25:23,083 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - >>readAlbums
17:25:23,085 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbums - <<readAlbums
17:25:23,085 DEBUG fr.ensim.xml.deezer.stax.StAXSearchAlbumsTest - <<testParse