Skip to content
Permalink
Browse files

Backported code to java7, where jetty 6 still works

  • Loading branch information...
svcarlsen committed Nov 9, 2015
1 parent c1cadfd commit 89cef909ef64b026d15bf4bbae8a312907d7791f
Showing with 557 additions and 35 deletions.
  1. +8 −2 ...dk/netarkivet/archive/arcrepository/bitpreservation/DatabaseBasedActiveBitPreservationTester.java
  2. +5 −1 ...ava/dk/netarkivet/archive/arcrepository/bitpreservation/FileBasedActiveBitPreservationTester.java
  3. +14 −3 ...chive-test/src/test/java/dk/netarkivet/archive/arcrepositoryadmin/ReplicaCacheDatabaseTester.java
  4. +33 −5 common/common-core/pom.xml
  5. +14 −0 common/common-test/src/main/java/dk/netarkivet/common/webinterface/WebinterfaceTestCase.java
  6. +40 −1 harvester/harvest-scheduler/src/main/java/dk/netarkivet/harvester/scheduler/HarvestJobManager.java
  7. +46 −8 ...-scheduler/src/test/java/dk/netarkivet/harvester/scheduler/HarvestSchedulerMonitorServerTest.java
  8. +2 −1 harvester/harvest-scheduler/src/test/java/dk/netarkivet/harvester/scheduler/JobDispatcherTest.java
  9. +11 −1 harvester/harvest-scheduler/src/test/java/dk/netarkivet/harvester/scheduler/JobSupervisorTest.java
  10. +41 −1 harvester/harvester-core/src/main/java/dk/netarkivet/harvester/datamodel/dao/DAOProviderFactory.java
  11. +1 −1 ...ester/harvester-core/src/test/java/dk/netarkivet/harvester/datamodel/DomainConfigurationTest.java
  12. +1 −1 harvester/harvester-core/src/test/java/dk/netarkivet/harvester/datamodel/JobTest.java
  13. +270 −0 harvester/harvester-test/derby.log
  14. +7 −0 harvester/harvester-test/src/test/java/dk/netarkivet/harvester/datamodel/JobDAOTester.java
  15. +38 −4 ...ster-test/src/test/java/dk/netarkivet/harvester/webinterface/SnapshotHarvestDefinitionTester.java
  16. +2 −2 ...heritrix3/heritrix3-controller/src/test/java/dk/netarkivet/harvester/harvesting/H3LaunchTest.java
  17. +3 −0 pom-versions
  18. +2 −2 pom.xml
  19. +19 −2 wayback/wayback-test/src/test/java/dk/netarkivet/wayback/aggregator/AggregationWorkerTest.java
@@ -478,8 +478,14 @@ public BatchStatus batch(FileBatchJob job, String locationName, String... args)
FileOutputStream os = new FileOutputStream(output);
new BatchLocalFiles(in_files).run(job, os);
os.close();
return new BatchStatus("BA1", Collections.<File>emptyList(), in_files.length,
RemoteFileFactory.getMovefileInstance(output), new ArrayList<>(0));
// java 8
//return new BatchStatus("BA1", Collections.<File>emptyList(), in_files.length,
// RemoteFileFactory.getMovefileInstance(output), new ArrayList<>(0));
return new BatchStatus("BA1", Collections.<File>emptyList(),
in_files.length,
RemoteFileFactory.getMovefileInstance(output),
new ArrayList<FileBatchJob.ExceptionOccurrence>(0));

} catch (IOException e) {
fail("IO error during test");
return null;
@@ -88,6 +88,7 @@
import dk.netarkivet.common.utils.batch.BatchLocalFiles;
import dk.netarkivet.common.utils.batch.ChecksumJob;
import dk.netarkivet.common.utils.batch.FileBatchJob;
import dk.netarkivet.common.utils.batch.FileBatchJob.ExceptionOccurrence;
import dk.netarkivet.common.utils.batch.FileListJob;
import dk.netarkivet.testutils.LogbackRecorder;
import dk.netarkivet.testutils.ReflectUtils;
@@ -392,8 +393,11 @@ public void testRunFileListJob() throws IOException, NoSuchMethodException, Invo

// Check that wrong counts are caught
File unsortedFile = new File(TestInfo.WORKING_DIR, "test_file_list_output/filelistOutput/unsorted.txt");
// requires Java 8
//MockupArcRepositoryClient.getInstance().overrideBatch = new BatchStatus("AP1", Collections.<File>emptyList(),
// 17, RemoteFileFactory.getMovefileInstance(unsortedFile), new ArrayList<>(0));
MockupArcRepositoryClient.getInstance().overrideBatch = new BatchStatus("AP1", Collections.<File>emptyList(),
17, RemoteFileFactory.getMovefileInstance(unsortedFile), new ArrayList<>(0));
17, RemoteFileFactory.getMovefileInstance(unsortedFile), new ArrayList(0));
runFilelistJob.invoke(abp, replica);

abp.close();
@@ -40,6 +40,8 @@
import java.util.Spliterators;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.commons.collections.IteratorUtils;


import org.junit.After;
import org.junit.Before;
@@ -153,7 +155,8 @@ public void testAll() throws Exception {
cache.getNumberOfMissingFilesInLastUpdate(Replica.getReplicaFromId("THREE")));

// check that the getMissingFilesInLastUpdate works appropriately.
List<String> misFiles = toArrayList(cache.getMissingFilesInLastUpdate(
//List<String> misFiles = toArrayList(cache.getMissingFilesInLastUpdate(
List<String> misFiles = IteratorUtils.toList(cache.getMissingFilesInLastUpdate(
Replica.getReplicaFromId("THREE")).iterator());

List<String> allFilenames = new ArrayList<String>();
@@ -192,7 +195,9 @@ public void testAll() throws Exception {
FileUtils.countLines(csFile2), cache.getNumberOfFiles(Replica.getReplicaFromId("THREE")));

// Check that all files are wrong for replica 'THREE'
List<String> wrongFiles = toArrayList(cache.getWrongFilesInLastUpdate(

//List<String> wrongFiles = toArrayList(cache.getWrongFilesInLastUpdate(
List<String> wrongFiles = IteratorUtils.toList(cache.getWrongFilesInLastUpdate(
Replica.getReplicaFromId("THREE")).iterator());

assertEquals("All the files should be wrong for replica 'THREE': " + wrongFiles + " == " + allFilenames,
@@ -384,9 +389,15 @@ private File makeTemporaryChecksumFile2() throws Exception {

return res;
}




/*
JAVA 8 syntax used
private static <T> ArrayList<T> toArrayList(final Iterator<T> iterator) {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.ORDERED), false)
.collect(Collectors.toCollection(ArrayList::new));
}
Using IteratorUtils.toList insteaf
*/
}
@@ -102,16 +102,29 @@
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0.20100224</version>
</dependency>
<!--
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5-20081211</version>
</dependency>
-->

<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api-2.5</artifactId>
<version>6.1.14</version>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<version>2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -124,6 +137,11 @@
<artifactId>jsp-2.1-jetty</artifactId>
<version>6.1.26</version>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.1.14</version>
</dependency>

<dependency>
<groupId>org.mortbay.jetty</groupId>
@@ -156,10 +174,20 @@
<version>1.2.1</version>
</dependency>

<!--dependency> <groupId>org.mortbay.jetty</groupId> <artifactId>jsp-2.1-glassfish</artifactId> <version>2.1.v20100127</version>
<exclusions> <exclusion> <groupId>org.eclipse.jdt.core.compiler</groupId> <artifactId>ecj</artifactId> </exclusion> </exclusions>
</dependency -->
<!-- dependency for jetty 6.1.26 -->
<!--
<dependency> <groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1-glassfish</artifactId>
<version>2.1.v20100127</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
</exclusion>
</exclusions>
</dependency>
-->
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
@@ -38,6 +38,8 @@
import java.util.Set;



import javax.el.ELContext;
//import javax.el.ELContext;
//import javax.servlet.AsyncContext;
//import javax.servlet.DispatcherType;
@@ -763,6 +765,12 @@ public ELContext getELContext() {
// Settings | File Templates.
}
*/

@Override
public ELContext getELContext() {
// TODO Auto-generated method stub
return null;
}
}

public static PageContext getDummyPageContext(final Locale l, final ServletRequest request) {
@@ -923,6 +931,12 @@ public ELContext getELContext() {
return null;
}
*/

@Override
public ELContext getELContext() {
// TODO Auto-generated method stub
return null;
}
};
}
}
@@ -71,7 +71,7 @@ public void shutdown() {
super.shutdown();
HarvestDBConnection.cleanup();
}

/* Requires java 8
public static Provider<JMSConnection> getJMSConnectionProvider() {
return () -> JMSConnectionFactory.getInstance();
}
@@ -84,4 +84,43 @@ public void shutdown() {
public static Provider<Notifications> getNotificationsProvider() {
return () -> NotificationsFactory.getInstance();
}
*/
public static Provider<JMSConnection> getJMSConnectionProvider() {
return new Provider<JMSConnection>() {

@Override
public JMSConnection get() {
// TODO Auto-generated method stub
return JMSConnectionFactory.getInstance();
}};
}
public static Provider<JobDAO> getJobDAOProvider() {
return new Provider<JobDAO>() {

@Override
public JobDAO get() {
// TODO Auto-generated method stub
return JobDAO.getInstance();
}};
}
public static Provider<HarvestDefinitionDAO> getHarvestDefinitionDAOProvider() {
return new Provider<HarvestDefinitionDAO>() {

@Override
public HarvestDefinitionDAO get() {
// TODO Auto-generated method stub
return HarvestDefinitionDAO.getInstance();
}};
}
public static Provider<Notifications> getNotificationsProvider() {
return new Provider<Notifications>() {

@Override
public Notifications get() {
// TODO Auto-generated method stub
return NotificationsFactory.getInstance();
}};
}


}
@@ -58,16 +58,52 @@

public class HarvestSchedulerMonitorServerTest {
private final JMSConnection jmsConnectionMock = mock(JMSConnection.class);
private final Provider<JMSConnection> jmsConnectionProvider = () -> jmsConnectionMock;

//private final Provider<JMSConnection> jmsConnectionProvider = () -> jmsConnectionMock;
private final Provider<JMSConnection> jmsConnectionProvider = new Provider<JMSConnection>() {

@Override
public JMSConnection get() {
// TODO Auto-generated method stub
return jmsConnectionMock;
}

};

private JobDAO jobDAOMock = mock(JobDAO.class);
private final Provider<JobDAO> jobDAOProvider = () -> jobDAOMock;
//private final Provider<JobDAO> jobDAOProvider = () -> jobDAOMock;
private final Provider<JobDAO> jobDAOProvider = new Provider<JobDAO>() {

@Override
public JobDAO get() {
// TODO Auto-generated method stub
return jobDAOMock;
}

};

private final HarvestDefinitionDAO harvestDefinitionDAOMock = mock(HarvestDefinitionDAO.class);
private final Provider<HarvestDefinitionDAO> harvestDefinitionDAOProvider = () -> harvestDefinitionDAOMock;
//private final Provider<HarvestDefinitionDAO> harvestDefinitionDAOProvider = () -> harvestDefinitionDAOMock;
private final Provider<HarvestDefinitionDAO> harvestDefinitionDAOProvider = new Provider<HarvestDefinitionDAO>(){

@Override
public HarvestDefinitionDAO get() {
// TODO Auto-generated method stub
return harvestDefinitionDAOMock;
}

};

private final Notifications notificationsMock = mock(Notifications.class);
private final Provider<Notifications> notificationsProvider = () -> notificationsMock;
//private final Provider<Notifications> notificationsProvider = () -> notificationsMock;
private final Provider<Notifications> notificationsProvider = new Provider<Notifications>() {

@Override
public Notifications get() {
// TODO Auto-generated method stub
return notificationsMock;
}

};

private final HarvestSchedulerMonitorServer harvestStatusMonitor = new HarvestSchedulerMonitorServer(
jmsConnectionProvider, jobDAOProvider, harvestDefinitionDAOProvider, notificationsProvider
@@ -292,8 +328,9 @@ public void testFailedToStarted() {
public void testDomainHarvestReportPostProcessing() {
List<JobStatus> crawlMessageStatusesToTest = Arrays.asList(new JobStatus[]
{JobStatus.DONE, JobStatus.FAILED});

crawlMessageStatusesToTest.forEach((status) -> {

//crawlMessageStatusesToTest.forEach((status) -> { // java 8 required
for (JobStatus status: crawlMessageStatusesToTest) {
job1.setStatus(JobStatus.STARTED);
HarvestReport harvestReport = mock(HarvestReport.class);
CrawlStatusMessage crawlStatusMessage = mock(CrawlStatusMessage.class);
@@ -307,7 +344,8 @@ public void testDomainHarvestReportPostProcessing() {
ArgumentCaptor<Job> jobArgumentCaptor = ArgumentCaptor.forClass(Job.class);
verify(harvestReport).postProcess(jobArgumentCaptor.capture());
assertEquals(job1.getJobID(), jobArgumentCaptor.getValue().getJobID());
});
}
//});
}

/**
@@ -182,7 +182,8 @@ public void testSendingToCorrectQueue() {
public void testNullJob() {
try {
jobDispatcher.doOneCrawl((Job) null, "test", "test", "test", SELECTIVE_HARVEST_CHANNEL, "unittesters",
new ArrayList<>());
//new ArrayList<>());
new ArrayList());
fail("Should throw ArgumentNotValid on NULL job");
} catch (ArgumentNotValid e) {
// expected case
@@ -43,7 +43,17 @@
public class JobSupervisorTest {
private JobSupervisor jobSupervisor;
private JobDAO jobDaoMock = mock(JobDAO.class);
private Provider<JobDAO> jobDAOProvider = () -> jobDaoMock;
// JAVA 8 required
//private Provider<JobDAO> jobDAOProvider = () -> jobDaoMock;
private Provider<JobDAO> jobDAOProvider = new Provider<JobDAO>() {

@Override
public JobDAO get() {
// TODO Auto-generated method stub
return jobDaoMock;
}

};

@Test
public void testCleanOldJobsMultipleJobs() {

0 comments on commit 89cef90

Please sign in to comment.
You can’t perform that action at this time.