use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class OAIHarvestJobTest method testHarvestUntilDate.
@Test
public void testHarvestUntilDate() throws Exception {
reset(httpClient);
InputStream response0 = this.getClass().getResourceAsStream("/sample/Identify.xml");
InputStream response1 = this.getClass().getResourceAsStream("/sample/ListRecordsUntil.xml");
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=Identify")).andReturn(response0);
expect(httpClient.executeGet("http://aleph.mzk.cz/OAI?verb=ListRecords&metadataPrefix=marc21&until=2014-12-09T01%3A00%3A00Z")).andReturn(response1);
replay(httpClient);
Map<String, JobParameter> params = new HashMap<>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
params.put(Constants.JOB_PARAM_UNTIL_DATE, new JobParameter(new Date(1418083200000L)));
JobExecution exec = jobExecutor.execute("oaiHarvestJob", new JobParameters(params));
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class AdresarHarvestTest method harvestRecords.
@Test
public void harvestRecords() throws Exception {
reset(httpClient);
InputStream response1 = this.getClass().getResourceAsStream("/sample/adresar/adr000000001.xml");
InputStream response2 = this.getClass().getResourceAsStream("/sample/adresar/adr000000002.xml");
expect(httpClient.executeGet("http://aleph.nkp.cz/X?op=find-doc&doc_num=000000001&base=ADR")).andReturn(response1);
expect(httpClient.executeGet("http://aleph.nkp.cz/X?op=find-doc&doc_num=000000002&base=ADR")).andReturn(response2);
replay(httpClient);
Map<String, JobParameter> params = new HashMap<String, JobParameter>();
params.put(Constants.JOB_PARAM_CONF_ID, new JobParameter(300L));
params.put(Constants.JOB_PARAM_FIRST_ID, new JobParameter("1"));
params.put(Constants.JOB_PARAM_LAST_ID, new JobParameter("2"));
JobParameters jobParams = new JobParameters(params);
JobExecution exec = jobExecutor.execute(Constants.JOB_ID_HARVEST_ADRESAR, jobParams);
Assert.assertEquals(exec.getExitStatus(), ExitStatus.COMPLETED);
Assert.assertNotNull(hrDao.findByIdAndHarvestConfiguration("000000001", 300L));
Assert.assertNotNull(hrDao.findByIdAndHarvestConfiguration("000000002", 300L));
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class DeleteAllRecordsFromSolrJobTest method executeWithQuery.
@Test
public void executeWithQuery() throws Exception {
String query = "id:MZK.MZK01-000000117";
reset(solrServerFactory);
reset(mockedSolrServer);
expect(solrServerFactory.create(eq(SOLR_URL))).andReturn(mockedSolrServer).anyTimes();
mockedSolrServer.deleteByQuery(query);
mockedSolrServer.commit();
replay(solrServerFactory, mockedSolrServer);
Job job = jobRegistry.getJob("deleteAllRecordsFromSolrJob");
Map<String, JobParameter> params = new HashMap<String, JobParameter>();
params.put(Constants.JOB_PARAM_SOLR_URL, new JobParameter(SOLR_URL, true));
params.put(Constants.JOB_PARAM_SOLR_QUERY, new JobParameter(query, true));
JobParameters jobParams = new JobParameters(params);
JobExecution execution = jobLauncher.run(job, jobParams);
Assert.assertEquals(execution.getExitStatus(), ExitStatus.COMPLETED);
verify(solrServerFactory, mockedSolrServer);
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class DeleteAllRecordsFromSolrJobTest method executeWitouthQuery.
@Test
public void executeWitouthQuery() throws Exception {
reset(solrServerFactory);
reset(mockedSolrServer);
expect(solrServerFactory.create(eq(SOLR_URL))).andReturn(mockedSolrServer).anyTimes();
mockedSolrServer.deleteByQuery("*:*");
mockedSolrServer.commit();
replay(solrServerFactory, mockedSolrServer);
Job job = jobRegistry.getJob("deleteAllRecordsFromSolrJob");
Map<String, JobParameter> params = new HashMap<String, JobParameter>();
params.put(Constants.JOB_PARAM_SOLR_URL, new JobParameter(SOLR_URL, true));
JobParameters jobParams = new JobParameters(params);
JobExecution execution = jobLauncher.run(job, jobParams);
Assert.assertEquals(execution.getExitStatus(), ExitStatus.COMPLETED);
verify(solrServerFactory, mockedSolrServer);
}
use of org.springframework.batch.core.JobExecution in project RecordManager2 by moravianlibrary.
the class IndexIndividualRecordsToSolrJobTest method execute.
@Test
public void execute() throws Exception {
SolrServerFacade server = solrServerFactory.create(SOLR_URL);
Job job = jobRegistry.getJob("indexIndividualRecordsToSolrJob");
Map<String, JobParameter> params = new HashMap<String, JobParameter>();
params.put(Constants.JOB_PARAM_SOLR_URL, new JobParameter(SOLR_URL));
params.put(Constants.JOB_PARAM_RECORD_IDS, new JobParameter("MZK.MZK01-000000117"));
JobParameters jobParams = new JobParameters(params);
JobExecution execution = jobLauncher.run(job, jobParams);
Assert.assertEquals(execution.getExitStatus(), ExitStatus.COMPLETED);
{
SolrQuery allDocsQuery = new SolrQuery();
allDocsQuery.set("q", "id:60");
allDocsQuery.set("rows", 10000);
QueryResponse allDocsResponse = server.query(allDocsQuery);
Assert.assertEquals(allDocsResponse.getResults().size(), 1);
}
}
Aggregations