Permalink
Browse files

Fixed tests

  • Loading branch information...
1 parent 1500211 commit 40b0470d3fdc626fadc1ee3b1def16a12d2704d2 Acerbic committed Sep 27, 2012
Showing with 25 additions and 24 deletions.
  1. +3 −4 src/dloader/page/AbstractPage.java
  2. +6 −6 src/dloader/pagejob/UpdatePageJob.java
  3. +16 −14 test/dloader/JobMasterTest.java
View
7 src/dloader/page/AbstractPage.java
@@ -435,7 +435,7 @@ private void mergeNewChildren (Collection<AbstractPage> oldChildren, Collection<
for (AbstractPage current: oldChildren)
if (newChild.url.equals(current.url) &&
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;
}
@@ -595,8 +595,7 @@ boolean isPageOK() {
@Override
public
String toString() {
-// String className = this.getClass().getSimpleName();
-// return ((getTitle() == null || getTitle().isEmpty())? "????" : "[" +className+ "] " + getTitle());
- return ((getTitle() == null || getTitle().isEmpty())? "????" : getTitle());
+ String className = this.getClass().getSimpleName();
+ return ((getTitle() == null || getTitle().isEmpty())? url.toString() : "[" +className+ "] " + getTitle());
}
}
View
12 src/dloader/pagejob/UpdatePageJob.java
@@ -43,12 +43,12 @@ public void run() {
report ("download job started", 1);
if (!forceDownload) page.loadFromCache();
try {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+// try {
+// Thread.sleep(3000);
+// } catch (InterruptedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
if (page.updateFromNet(this) || forceDownload) {
page.saveToCache();
//note: this iterator does not require locking because of ConcurrentLinkedQueue implementation
View
30 test/dloader/JobMasterTest.java
@@ -92,16 +92,16 @@ public void test_SimpleJob() {
AbstractPage p = AbstractPage.bakeAPage("Track", "failaddress", null, null);
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p);
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
public void test_GeneratedJobs() {
AbstractPage p = AbstractPage.bakeAPage(null, "http://homestuck.bandcamp.com/album/alterniabound", null, null);
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p);
jm.goGoGo(); // starts and waits for other threads...
- assertTrue(results.contains("AlterniaBound[Album]read from cache1"));
- assertTrue(results.contains("Arisen Anew[Track]read from cache1"));
+ assertTrue(results.contains("[Album] AlterniaBoundread from cache1"));
+ assertTrue(results.contains("[Track] Arisen Anewread from cache1"));
}
@@ -110,12 +110,12 @@ public void test_ReadCacheJob() throws MalformedURLException {
AbstractPage p = AbstractPage.bakeAPage(null, "http://emancipator.bandcamp.com", null, null);
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.READCACHEPAGES, p);
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());
- assertTrue(results.contains("Remixes[Album]read from cache1"));
- assertTrue(results.contains("soon it will be cold enough[Album]read from cache1"));
- assertTrue(results.contains("safe in the steep cliffs[Album]read from cache1"));
- assertTrue(results.contains("http://emancipator.bandcamp.com/album/free-downloads[Album]read cache failed1"));
+ assertTrue(results.contains("[Album] Remixesread from cache1"));
+ assertTrue(results.contains("[Album] soon it will be cold enoughread from cache1"));
+ assertTrue(results.contains("[Album] safe in the steep cliffsread from cache1"));
+ assertTrue(results.contains("http://emancipator.bandcamp.com/album/free-downloadsread cache failed1"));
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());
@@ -127,12 +127,14 @@ public void test_DownloadPageJob() throws IOException {
null, null) ;
LocalReportJobMaser jm = new LocalReportJobMaser(results, JobMaster.JobType.UPDATEPAGES, px);
jm.goGoGo(); // starts and waits for other threads...
- assertTrue(results.contains("emancipator[DiscographyForDownloadPageTest]download finished1"));
- assertTrue(results.contains("Remixes[Album]up to date1"));
- assertTrue(results.contains("Elephant Survival[Track]download finished1"));
- assertTrue(results.contains("soon it will be cold enough[Album]download finished1"));
- assertTrue(results.contains("safe in the steep cliffs[Album]download failed1"));
- assertTrue(results.contains("Shook (Sigur Ros X Mobb Deep)[Track]download failed1"));
+ assertTrue(results.contains("[DiscographyForDownloadPageTest] emancipatordownload finished1"));
+ assertTrue(results.contains("[Album] Remixesup to date1"));
+ assertTrue(results.contains("[Track] Elephant Survivaldownload finished1"));
+ assertTrue(results.contains("[Album] soon it will be cold enoughdownload finished1"));
+ String failedUrl = ((AbstractPage)px.childPages.toArray()[2]).url.toString();
+// 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());
}

0 comments on commit 40b0470

Please sign in to comment.