List of usage examples for org.apache.solr.client.solrj SolrRequest getPath
public String getPath()
From source file:com.idealista.solrmeter.mock.SolrClientMock.java
License:Apache License
@Override public NamedList<Object> request(SolrRequest request, String collection) throws SolrServerException, IOException { return requestsResponses.get(request.getPath()); }
From source file:com.plugtree.solrmeter.mock.SolrServerMock.java
License:Apache License
@Override public NamedList<Object> request(SolrRequest arg0) throws SolrServerException, IOException { return requestsResponses.get(arg0.getPath()); }
From source file:org.apache.jackrabbit.oak.plugins.index.solr.server.OakSolrServer.java
License:Apache License
private synchronized SolrServer getServer(SolrRequest request) throws Exception { boolean isIndex = request.getPath().contains("/update"); SolrServerRegistry.Strategy strategy = isIndex ? SolrServerRegistry.Strategy.INDEXING : SolrServerRegistry.Strategy.SEARCHING; SolrServer solrServer = SolrServerRegistry.get(solrServerConfiguration, strategy); if (solrServer == null) { if (solrServerConfiguration instanceof EmbeddedSolrServerConfiguration) { solrServer = solrServerProvider.getSolrServer(); // the same Solr server has to be used for both SolrServerRegistry.register(solrServerConfiguration, solrServer, SolrServerRegistry.Strategy.INDEXING); SolrServerRegistry.register(solrServerConfiguration, solrServer, SolrServerRegistry.Strategy.SEARCHING); } else {//from w ww . j a v a 2 s . co m solrServer = isIndex ? solrServerProvider.getIndexingSolrServer() : solrServerProvider.getSearchingSolrServer(); SolrServerRegistry.register(solrServerConfiguration, solrServer, strategy); } } return solrServer; }
From source file:org.springframework.data.solr.core.SolrTemplateTests.java
License:Apache License
/** * @throws IOException// w ww. ja v a 2 s . c om * @throws SolrServerException * @see DATASOLR-72 */ @Test public void schemaShouldBeUpdatedPriorToSavingEntity() throws SolrServerException, IOException { NamedList<Object> nl = new NamedList<Object>(); nl.add("json", "{ \"schema\" : {\"name\" : \"core1\" }, \"version\" : 1.5 }"); Mockito.when(solrServerMock.request(Mockito.any(SolrSchemaRequest.class))).thenReturn(nl); Mockito.when(solrServerMock.request(Mockito.any(SolrSchemaRequest.class))).thenReturn(nl); solrTemplate = new SolrTemplate(solrServerMock, "core1"); solrTemplate.setSchemaCreationFeatures(Collections.singletonList(Feature.CREATE_MISSING_FIELDS)); solrTemplate.afterPropertiesSet(); solrTemplate.saveBean(new DocumentWithIndexAnnotations()); ArgumentCaptor<SolrRequest> requestCaptor = ArgumentCaptor.forClass(SolrRequest.class); Mockito.verify(solrServerMock, Mockito.times(3)).request(requestCaptor.capture()); SolrRequest capturedRequest = requestCaptor.getValue(); Assert.assertThat(capturedRequest.getMethod(), IsEqual.equalTo(SolrRequest.METHOD.POST)); Assert.assertThat(capturedRequest.getPath(), IsEqual.equalTo("/schema/fields")); Assert.assertThat(capturedRequest.getContentStreams(), IsNull.notNullValue()); }