Search in sources :

Example 1 with SolrServerFacadeImpl

use of cz.mzk.recordmanager.server.solr.SolrServerFacadeImpl in project RecordManager2 by moravianlibrary.

the class AbstractSolrTest method createEmbeddedSolrServer.

@BeforeMethod
protected void createEmbeddedSolrServer() throws Exception {
    server.deleteByQuery("*:*");
    server.commit();
    resetToNice(solrServerFactory);
    SolrIndexingExceptionHandler handler = new FaultTolerantIndexingExceptionHandler();
    expect(solrServerFactory.create(eq(SOLR_URL), anyObject(Mode.class), anyObject(SolrIndexingExceptionHandler.class))).andReturn(new SolrServerFacadeImpl(server, handler)).anyTimes();
    expect(solrServerFactory.create(eq(SOLR_URL))).andReturn(new SolrServerFacadeImpl(server, handler)).anyTimes();
    replay(solrServerFactory);
}
Also used : SolrIndexingExceptionHandler(cz.mzk.recordmanager.server.solr.SolrIndexingExceptionHandler) SolrServerFacadeImpl(cz.mzk.recordmanager.server.solr.SolrServerFacadeImpl) FaultTolerantIndexingExceptionHandler(cz.mzk.recordmanager.server.solr.FaultTolerantIndexingExceptionHandler) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with SolrServerFacadeImpl

use of cz.mzk.recordmanager.server.solr.SolrServerFacadeImpl in project RecordManager2 by moravianlibrary.

the class IndexRecordsToSolrJobTest method execute.

@Test
@SuppressWarnings("unchecked")
public void execute() throws Exception {
    resetToNice(solrServerFactory);
    reset(mockedSolrServer);
    expect(solrServerFactory.create(eq(SOLR_URL), anyObject())).andReturn(new SolrServerFacadeImpl(mockedSolrServer)).anyTimes();
    expect(solrServerFactory.create(eq(SOLR_URL), anyObject(), anyObject())).andReturn(new SolrServerFacadeImpl(mockedSolrServer)).anyTimes();
    expect(solrServerFactory.create(eq(SOLR_URL))).andReturn(new SolrServerFacadeImpl(mockedSolrServer)).anyTimes();
    expect(mockedSolrServer.add(and(capture(EasyMock.newCapture()), anyObject(SolrInputDocument.class)), anyInt())).andReturn(new UpdateResponse()).anyTimes();
    expect(mockedSolrServer.add(and(capture(EasyMock.newCapture()), (Collection<SolrInputDocument>) anyObject(Collection.class)), anyInt())).andReturn(new UpdateResponse()).anyTimes();
    expect(mockedSolrServer.commit()).andReturn(new UpdateResponse());
    expect(mockedSolrServer.commit()).andReturn(new UpdateResponse());
    replay(solrServerFactory, mockedSolrServer);
    Job job = jobRegistry.getJob("indexAllRecordsToSolrJob");
    Map<String, JobParameter> params = new HashMap<String, JobParameter>();
    params.put(Constants.JOB_PARAM_FROM_DATE, new JobParameter(dateFormat.parse("1. 1. 2010"), true));
    params.put(Constants.JOB_PARAM_UNTIL_DATE, new JobParameter(dateFormat.parse("1. 1. 2016"), true));
    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);
}
Also used : JobExecution(org.springframework.batch.core.JobExecution) UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse) SolrInputDocument(org.apache.solr.common.SolrInputDocument) HashMap(java.util.HashMap) SolrServerFacadeImpl(cz.mzk.recordmanager.server.solr.SolrServerFacadeImpl) JobParameters(org.springframework.batch.core.JobParameters) Job(org.springframework.batch.core.Job) JobParameter(org.springframework.batch.core.JobParameter) Test(org.testng.annotations.Test) AbstractTest(cz.mzk.recordmanager.server.AbstractTest)

Aggregations

SolrServerFacadeImpl (cz.mzk.recordmanager.server.solr.SolrServerFacadeImpl)2 AbstractTest (cz.mzk.recordmanager.server.AbstractTest)1 FaultTolerantIndexingExceptionHandler (cz.mzk.recordmanager.server.solr.FaultTolerantIndexingExceptionHandler)1 SolrIndexingExceptionHandler (cz.mzk.recordmanager.server.solr.SolrIndexingExceptionHandler)1 HashMap (java.util.HashMap)1 UpdateResponse (org.apache.solr.client.solrj.response.UpdateResponse)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 Job (org.springframework.batch.core.Job)1 JobExecution (org.springframework.batch.core.JobExecution)1 JobParameter (org.springframework.batch.core.JobParameter)1 JobParameters (org.springframework.batch.core.JobParameters)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1