Skip to content

Commit

Permalink
Test-configuration changes to ensure consistent use of H1/H3 for the …
Browse files Browse the repository at this point in the history
…relevant tests.
  • Loading branch information
csrster committed Dec 22, 2015
1 parent 0fc3ff5 commit 5c6e916
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package dk.netarkivet.harvester;

import dk.netarkivet.common.utils.Settings;
import dk.netarkivet.harvester.HarvesterSettings;

/**
* Contains utility methods to switch between use of Heritrix1 and Heritrix3.
*/
public class HeritrixConfigurator {

/**
* No instances.
*/
private HeritrixConfigurator(){}

/**
* Use Heritrix1.
*/
public static void setUseH1() {
Settings.set(HarvesterSettings.HERITRIX_CONTROLLER_CLASS, "dk.netarkivet.harvester.harvesting.controller.JMXHeritrixController");
Settings.set(HarvesterSettings.HERITRIX_LAUNCHER_CLASS, "dk.netarkivet.harvester.harvesting.controller.BnfHeritrixLauncher");
}

/**
* Use Heritrix3.
*/
public static void setUseH3() {
Settings.set(HarvesterSettings.HERITRIX_CONTROLLER_CLASS, "dk.netarkivet.harvester.heritrix3.controller.HeritrixController" );
Settings.set(HarvesterSettings.HERITRIX_LAUNCHER_CLASS, "dk.netarkivet.harvester.heritrix3.controller.HeritrixLauncher");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import dk.netarkivet.common.exceptions.ArgumentNotValid;
import dk.netarkivet.common.utils.SettingsFactory;
import dk.netarkivet.harvester.HarvesterSettings;

/**
* Factory class for instantiating a specific implementation of {@link HeritrixLauncher}. The implementation class is
Expand All @@ -41,7 +42,7 @@ public class HeritrixLauncherFactory extends SettingsFactory<HeritrixLauncher> {
* @throws ArgumentNotValid if the instance cannot be constructed.
*/
public static HeritrixLauncher getInstance(Object... args) throws ArgumentNotValid {
return SettingsFactory.getInstance(Heritrix1Settings.HERITRIX_LAUNCHER_CLASS, args);
return SettingsFactory.getInstance(HarvesterSettings.HERITRIX_LAUNCHER_CLASS, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import dk.netarkivet.common.exceptions.ArgumentNotValid;
import dk.netarkivet.common.utils.SettingsFactory;
import dk.netarkivet.harvester.HarvesterSettings;
import dk.netarkivet.harvester.harvesting.Heritrix1Settings;

/**
Expand All @@ -42,7 +43,7 @@ public class HeritrixControllerFactory extends SettingsFactory<HeritrixControlle
* @throws ArgumentNotValid if the instance cannot be constructed.
*/
public static HeritrixController getDefaultHeritrixController(Object... args) throws ArgumentNotValid {
return SettingsFactory.getInstance(Heritrix1Settings.HERITRIX_CONTROLLER_CLASS, args);
return SettingsFactory.getInstance(HarvesterSettings.HERITRIX_CONTROLLER_CLASS, args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import dk.netarkivet.common.utils.Settings;
import dk.netarkivet.common.utils.XmlUtils;
import dk.netarkivet.harvester.HarvesterSettings;
import dk.netarkivet.harvester.HeritrixConfigurator;
import dk.netarkivet.harvester.datamodel.H1HeritrixTemplate;
import dk.netarkivet.harvester.datamodel.HarvestDefinitionInfo;
import dk.netarkivet.harvester.datamodel.Job;
Expand Down Expand Up @@ -74,6 +75,7 @@ public class HarvestControllerTester {
@Before
public void setUp() throws Exception, IllegalAccessException, IOException {
rs.setUp();
HeritrixConfigurator.setUseH1();
JMSConnectionMockupMQ.useJMSConnectionMockupMQ();
JMSConnectionMockupMQ.clearTestQueues();
TestFileUtils.copyDirectoryNonCVS(
Expand Down Expand Up @@ -243,6 +245,8 @@ public void testWritePreharvestMetadata() throws Exception {
* 'dk.netarkivet.harvester.harvesting.controller.BnfHeritrixLauncher'.
*/
@Test
@Ignore("This is a badly formulated test. The runHarvest() command must throw either one exception or the other. Two catch "
+ "clauses can't be the right answer.")
public void testRunHarvest() throws Exception {
//FIXME hardwired to H1 HeritrixFiles
HeritrixFiles files = HeritrixFiles.getH1HeritrixFilesWithDefaultJmxFiles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package dk.netarkivet.harvester.harvesting;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

Expand All @@ -39,6 +40,7 @@
import dk.netarkivet.common.utils.FileUtils;
import dk.netarkivet.common.utils.Settings;
import dk.netarkivet.harvester.HarvesterSettings;
import dk.netarkivet.harvester.HeritrixConfigurator;
import dk.netarkivet.harvester.harvesting.controller.BnfHeritrixController;
import dk.netarkivet.harvester.harvesting.controller.HeritrixController;
import dk.netarkivet.harvester.harvesting.controller.HeritrixControllerFactory;
Expand All @@ -60,6 +62,7 @@ public HeritrixControllerFactoryTester() {

@Before
public void setUp() throws IOException {
HeritrixConfigurator.setUseH1();
mtf.setUp();
dummyLuceneIndex = mtf.newTmpDir();
// Out commented to avoid reference to archive module from harvester module.
Expand Down Expand Up @@ -99,11 +102,10 @@ crawlDir, new JobInfoTestImpl(Long.parseLong(Heritrix1ControllerTestInfo.ARC_JOB
*/
@Test
public void testGetDefaultHeritrixControllerChangeDefaultSettigs() {
Settings.set(HarvesterSettings.HERITRIX_CONTROLLER_CLASS,
"dk.netarkivet.harvester.harvesting.HeritrixControllerFactoryTester$DummyHeritrixController");
final String controllerClass = "dk.netarkivet.harvester.harvesting.HeritrixControllerFactoryTester$DummyHeritrixController";
Settings.set(HarvesterSettings.HERITRIX_CONTROLLER_CLASS, controllerClass);
HeritrixController hc = HeritrixControllerFactory.getDefaultHeritrixController("hello world");
assertTrue("Should have got a DummyHeritrixController, not " + hc, hc instanceof DummyHeritrixController);

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import dk.netarkivet.common.utils.Settings;
import dk.netarkivet.common.utils.XmlUtils;
import dk.netarkivet.harvester.HarvesterSettings;
import dk.netarkivet.harvester.HeritrixConfigurator;
import dk.netarkivet.harvester.datamodel.H1HeritrixTemplate;
import dk.netarkivet.harvester.datamodel.HeritrixTemplate;
import dk.netarkivet.testutils.TestResourceUtils;
Expand Down Expand Up @@ -90,6 +91,7 @@ public void initialize() {

@Before
public void setUp() throws IOException {
HeritrixConfigurator.setUseH1();
mtf = new MoveTestFiles(Heritrix1ControllerTestInfo.CRAWLDIR_ORIGINALS_DIR, WORKING_DIR);
mtf.setUp();
dummyLuceneIndex = mtf.newTmpDir();
Expand All @@ -102,6 +104,7 @@ public void setUp() throws IOException {

@After
public void tearDown() {
//Settings.set(Heritrix1Settings.HERITRIX_LAUNCHER_CLASS, "dk.netarkivet.harvester.heritrix3.controller.HeritrixLauncher");
mtf.tearDown();
}

Expand Down Expand Up @@ -230,7 +233,7 @@ public void testStartMissingDiskFieldOrderFile() {
*/

@Test
@Ignore("was commented out")
//@Ignore("was commented out")
public void testStartMissingARCsPathOrderFile() {
myTesterOfBadOrderfiles(Heritrix1ControllerTestInfo.MISSING_ARCS_PATH_ORDER_FILE);
}
Expand All @@ -247,7 +250,7 @@ public void testStartMissingSeedsfileOrderFile() {
* Test that the launcher handles heritrix dying on a order file missing the seedsfile node correctly.
*/
@Test
@Ignore("was commented out")
//@Ignore("was commented out")
public void testStartMissingPrefixOrderFile() {
myTesterOfBadOrderfiles(Heritrix1ControllerTestInfo.MISSING_PREFIX_FIELD_ORDER_FILE);
}
Expand Down

0 comments on commit 5c6e916

Please sign in to comment.