Example usage for org.apache.solr.client.solrj SolrRequest getContentStreams

List of usage examples for org.apache.solr.client.solrj SolrRequest getContentStreams

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj SolrRequest getContentStreams.

Prototype

@Deprecated
public Collection<ContentStream> getContentStreams() throws IOException 

Source Link

Usage

From source file:org.springframework.data.solr.core.SolrTemplateTests.java

License:Apache License

/**
 * @throws IOException//from   w  ww  .jav a  2  s .  com
 * @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());
}