List of usage examples for org.apache.solr.client.solrj SolrClient addBeans
public UpdateResponse addBeans(String collection, final Iterator<?> beanIterator) throws SolrServerException, IOException
From source file:net.yacy.cora.federate.solr.instance.ServerShard.java
License:Open Source License
/** * Adds a collection of beans specifying max time before they become committed * @param beans the collection of beans * @param commitWithinMs max time (in ms) before a commit will happen * @throws IOException If there is a low-level I/O error. * @since solr 3.5// w w w . j a v a2 s .c om */ @Override public UpdateResponse addBeans(Collection<?> beans, int commitWithinMs) throws SolrServerException, IOException { if (!this.writeEnabled) return _dummyOKResponse; UpdateResponse ur = null; for (SolrClient s : this.shards) ur = s.addBeans(beans, commitWithinMs); return ur; }
From source file:uk.co.flax.biosolr.ontology.storage.solr.SolrStorageEngineTest.java
License:Apache License
@Test(expected = uk.co.flax.biosolr.ontology.storage.StorageEngineException.class) public void storeOntologyEntries_serverThrowsIOException() throws Exception { final int commitWithMs = 60000; final SolrConfiguration config = mock(SolrConfiguration.class); when(config.getCommitWithinMs()).thenReturn(commitWithMs); OntologyEntryBean bean = mock(OntologyEntryBean.class); List<OntologyEntryBean> beans = Arrays.asList(bean); SolrClient server = mock(SolrClient.class); when(server.addBeans(beans, commitWithMs)).thenThrow(new IOException("Error")); SolrStorageEngine engine = new SolrStorageEngine(config, server); engine.storeOntologyEntries(beans);/*from ww w. j av a2 s . c o m*/ verify(server).addBeans(beans, commitWithMs); }
From source file:uk.co.flax.biosolr.ontology.storage.solr.SolrStorageEngineTest.java
License:Apache License
@Test(expected = uk.co.flax.biosolr.ontology.storage.StorageEngineException.class) public void storeOntologyEntries_serverThrowsSolrException() throws Exception { final int commitWithMs = 60000; final SolrConfiguration config = mock(SolrConfiguration.class); when(config.getCommitWithinMs()).thenReturn(commitWithMs); OntologyEntryBean bean = mock(OntologyEntryBean.class); List<OntologyEntryBean> beans = Arrays.asList(bean); SolrClient server = mock(SolrClient.class); when(server.addBeans(beans, commitWithMs)).thenThrow(new SolrServerException("Error")); SolrStorageEngine engine = new SolrStorageEngine(config, server); engine.storeOntologyEntries(beans);//from w w w. ja v a 2 s.c o m verify(server).addBeans(beans, commitWithMs); }
From source file:uk.co.flax.biosolr.ontology.storage.solr.SolrStorageEngineTest.java
License:Apache License
@Test(expected = uk.co.flax.biosolr.ontology.storage.StorageEngineException.class) public void storeOntologyEntries_responseNotOkay() throws Exception { final int commitWithMs = 60000; final SolrConfiguration config = mock(SolrConfiguration.class); when(config.getCommitWithinMs()).thenReturn(commitWithMs); OntologyEntryBean bean = mock(OntologyEntryBean.class); List<OntologyEntryBean> beans = Arrays.asList(bean); UpdateResponse response = mock(UpdateResponse.class); when(response.getStatus()).thenReturn(1); SolrClient server = mock(SolrClient.class); when(server.addBeans(beans, commitWithMs)).thenReturn(response); SolrStorageEngine engine = new SolrStorageEngine(config, server); engine.storeOntologyEntries(beans);// w ww. j a va 2 s . c o m verify(server).addBeans(beans, commitWithMs); verify(response).getStatus(); }
From source file:uk.co.flax.biosolr.ontology.storage.solr.SolrStorageEngineTest.java
License:Apache License
@Test public void storeOntologyEntries_responseOkay() throws Exception { final int commitWithMs = 60000; final SolrConfiguration config = mock(SolrConfiguration.class); when(config.getCommitWithinMs()).thenReturn(commitWithMs); OntologyEntryBean bean = mock(OntologyEntryBean.class); List<OntologyEntryBean> beans = Arrays.asList(bean); UpdateResponse response = mock(UpdateResponse.class); when(response.getStatus()).thenReturn(SolrStorageEngine.STATUS_OK); SolrClient server = mock(SolrClient.class); when(server.addBeans(beans, commitWithMs)).thenReturn(response); SolrStorageEngine engine = new SolrStorageEngine(config, server); engine.storeOntologyEntries(beans);/*www .ja va 2s .c om*/ verify(server).addBeans(beans, commitWithMs); verify(response).getStatus(); }