Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Acerbic committed Sep 27, 2012
1 parent 1500211 commit 40b0470
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
7 changes: 3 additions & 4 deletions src/dloader/page/AbstractPage.java
Expand Up @@ -435,7 +435,7 @@ private void mergeNewChildren (Collection<AbstractPage> oldChildren, Collection<
for (AbstractPage current: oldChildren) for (AbstractPage current: oldChildren)
if (newChild.url.equals(current.url) && if (newChild.url.equals(current.url) &&
newChild.getClass().equals(current.getClass()) && newChild.getClass().equals(current.getClass()) &&
newChild.saveTo.equals(current.saveTo)) { // last check is probably excessive ((newChild.saveTo == null && current.saveTo==null) || newChild.saveTo.equals(current.saveTo))) { // last check is probably excessive
oldChild = current; break; oldChild = current; break;
} }


Expand Down Expand Up @@ -595,8 +595,7 @@ boolean isPageOK() {
@Override @Override
public public
String toString() { String toString() {
// String className = this.getClass().getSimpleName(); String className = this.getClass().getSimpleName();
// return ((getTitle() == null || getTitle().isEmpty())? "????" : "[" +className+ "] " + getTitle()); return ((getTitle() == null || getTitle().isEmpty())? url.toString() : "[" +className+ "] " + getTitle());
return ((getTitle() == null || getTitle().isEmpty())? "????" : getTitle());
} }
} }
12 changes: 6 additions & 6 deletions src/dloader/pagejob/UpdatePageJob.java
Expand Up @@ -43,12 +43,12 @@ public void run() {
report ("download job started", 1); report ("download job started", 1);
if (!forceDownload) page.loadFromCache(); if (!forceDownload) page.loadFromCache();
try { try {
try { // try {
Thread.sleep(3000); // Thread.sleep(3000);
} catch (InterruptedException e) { // } catch (InterruptedException e) {
// TODO Auto-generated catch block // // TODO Auto-generated catch block
e.printStackTrace(); // e.printStackTrace();
} // }
if (page.updateFromNet(this) || forceDownload) { if (page.updateFromNet(this) || forceDownload) {
page.saveToCache(); page.saveToCache();
//note: this iterator does not require locking because of ConcurrentLinkedQueue implementation //note: this iterator does not require locking because of ConcurrentLinkedQueue implementation
Expand Down
30 changes: 16 additions & 14 deletions test/dloader/JobMasterTest.java
Expand Up @@ -92,16 +92,16 @@ public void test_SimpleJob() {
AbstractPage p = AbstractPage.bakeAPage("Track", "failaddress", null, null); AbstractPage p = AbstractPage.bakeAPage("Track", "failaddress", null, null);
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p); LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p);
jm.goGoGo(); // starts and waits for other threads... jm.goGoGo(); // starts and waits for other threads...
assertTrue(results.contains("http://failaddress[Track]read cache failed1")); assertTrue(results.contains("http://failaddressread cache failed1"));
} }


@Test @Test
public void test_GeneratedJobs() { public void test_GeneratedJobs() {
AbstractPage p = AbstractPage.bakeAPage(null, "http://homestuck.bandcamp.com/album/alterniabound", null, null); AbstractPage p = AbstractPage.bakeAPage(null, "http://homestuck.bandcamp.com/album/alterniabound", null, null);
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p); LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p);
jm.goGoGo(); // starts and waits for other threads... jm.goGoGo(); // starts and waits for other threads...
assertTrue(results.contains("AlterniaBound[Album]read from cache1")); assertTrue(results.contains("[Album] AlterniaBoundread from cache1"));
assertTrue(results.contains("Arisen Anew[Track]read from cache1")); assertTrue(results.contains("[Track] Arisen Anewread from cache1"));


} }


Expand All @@ -110,12 +110,12 @@ public void test_ReadCacheJob() throws MalformedURLException {
AbstractPage p = AbstractPage.bakeAPage(null, "http://emancipator.bandcamp.com", null, null); AbstractPage p = AbstractPage.bakeAPage(null, "http://emancipator.bandcamp.com", null, null);
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p); LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p);
jm.goGoGo(); // starts and waits for other threads... jm.goGoGo(); // starts and waits for other threads...
assertTrue(results.contains("emancipator[Discography]read from cache1")); assertTrue(results.contains("[Discography] emancipatorread from cache1"));
assertEquals("emancipator", p.getTitle()); assertEquals("emancipator", p.getTitle());
assertTrue(results.contains("Remixes[Album]read from cache1")); assertTrue(results.contains("[Album] Remixesread from cache1"));
assertTrue(results.contains("soon it will be cold enough[Album]read from cache1")); assertTrue(results.contains("[Album] soon it will be cold enoughread from cache1"));
assertTrue(results.contains("safe in the steep cliffs[Album]read from cache1")); assertTrue(results.contains("[Album] safe in the steep cliffsread from cache1"));
assertTrue(results.contains("http://emancipator.bandcamp.com/album/free-downloads[Album]read cache failed1")); assertTrue(results.contains("http://emancipator.bandcamp.com/album/free-downloadsread cache failed1"));


assertEquals(5, p.childPages.size()); assertEquals(5, p.childPages.size());
assertEquals("http://f0.bcbits.com/z/17/92/1792496746-1.jpg", ((Album) p.getChildByURL(new URL("http://emancipator.bandcamp.com/album/remixes-2"))).getCoverUrl().toString()); assertEquals("http://f0.bcbits.com/z/17/92/1792496746-1.jpg", ((Album) p.getChildByURL(new URL("http://emancipator.bandcamp.com/album/remixes-2"))).getCoverUrl().toString());
Expand All @@ -127,12 +127,14 @@ public void test_DownloadPageJob() throws IOException {
null, null) ; null, null) ;
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.UPDATEPAGES, px); LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.UPDATEPAGES, px);
jm.goGoGo(); // starts and waits for other threads... jm.goGoGo(); // starts and waits for other threads...
assertTrue(results.contains("emancipator[DiscographyForDownloadPageTest]download finished1")); assertTrue(results.contains("[DiscographyForDownloadPageTest] emancipatordownload finished1"));
assertTrue(results.contains("Remixes[Album]up to date1")); assertTrue(results.contains("[Album] Remixesup to date1"));
assertTrue(results.contains("Elephant Survival[Track]download finished1")); assertTrue(results.contains("[Track] Elephant Survivaldownload finished1"));
assertTrue(results.contains("soon it will be cold enough[Album]download finished1")); assertTrue(results.contains("[Album] soon it will be cold enoughdownload finished1"));
assertTrue(results.contains("safe in the steep cliffs[Album]download failed1")); String failedUrl = ((AbstractPage)px.childPages.toArray()[2]).url.toString();
assertTrue(results.contains("Shook (Sigur Ros X Mobb Deep)[Track]download failed1")); // assertTrue(results.contains("[Album] safe in the steep cliffsdownload failed1"));
assertTrue(results.contains(failedUrl+"download failed1"));
assertTrue(results.contains("[Track] Shook (Sigur Ros X Mobb Deep)download failed1"));


assertEquals(5, px.childPages.size()); assertEquals(5, px.childPages.size());
} }
Expand Down

0 comments on commit 40b0470

Please sign in to comment.