mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-23 06:05:46 +00:00
Part of fix for [HER-1725] on engine page, 'create new job' form gives NPE
* Engine.java made protected getProfileCxmlResource() for clear testability * EngineTest.java added testGetProfileCxmlResource()
This commit is contained in:
@@ -55,7 +55,10 @@ public class Engine {
|
||||
protected File jobsDir;
|
||||
/** map of job short names -> CrawlJob instances */
|
||||
protected HashMap<String,CrawlJob> jobConfigs = new HashMap<String,CrawlJob>();
|
||||
|
||||
|
||||
protected String profileCxmlPath =
|
||||
"/org/archive/crawler/restlet/profile-crawler-beans.cxml";
|
||||
|
||||
public Engine(File jobsDir) {
|
||||
this.jobsDir = jobsDir;
|
||||
this.jobsDir.mkdirs();
|
||||
@@ -319,6 +322,13 @@ public class Engine {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return InputStream resource from defined profile CXML path
|
||||
*/
|
||||
protected InputStream getProfileCxmlResource() {
|
||||
return getClass().getResourceAsStream(profileCxmlPath);
|
||||
}
|
||||
|
||||
public boolean createNewJobWithDefaults(String path) throws IOException {
|
||||
|
||||
File newJobDir = new File(jobsDir,"/"+path);
|
||||
@@ -327,9 +337,8 @@ public class Engine {
|
||||
}
|
||||
newJobDir.mkdirs();
|
||||
|
||||
// get crawler-beans template from this package into string
|
||||
InputStream inStream = getClass().getResourceAsStream(
|
||||
"/org/archive/crawler/restlet/profile-crawler-beans.cxml");
|
||||
// get crawler-beans template from this package into string
|
||||
InputStream inStream = getProfileCxmlResource();
|
||||
String defaultCxmlStr = IOUtils.toString(inStream);
|
||||
inStream.close();
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package org.archive.crawler.framework;
|
||||
|
||||
import org.archive.util.TmpDirTestCase;
|
||||
|
||||
public class EngineTest extends TmpDirTestCase {
|
||||
|
||||
public void testGetProfileCxmlResource() {
|
||||
assertNotNull(new Engine(getTmpDir()).getProfileCxmlResource());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user