Search in sources :

Example 1 with SolrDocumentListIterator

use of org.apache.solr.handler.dataimport.SolrEntityProcessor.SolrDocumentListIterator in project lucene-solr by apache.

the class TestSolrEntityProcessorUnit method testCursorQuery.

public void testCursorQuery() {
    SolrEntityProcessor processor = new NoNextMockProcessor();
    HashMap<String, String> entityAttrs = new HashMap<String, String>() {

        {
            put(SolrEntityProcessor.SOLR_SERVER, "http://route:66/no");
            put(CursorMarkParams.CURSOR_MARK_PARAM, "true");
        }
    };
    processor.init(getContext(null, null, null, null, Collections.emptyList(), entityAttrs));
    try {
        processor.buildIterator();
        SolrQuery query = new SolrQuery();
        ((SolrDocumentListIterator) processor.rowIterator).passNextPage(query);
        assertNull(query.get(CommonParams.START));
        assertEquals(CursorMarkParams.CURSOR_MARK_START, query.get(CursorMarkParams.CURSOR_MARK_PARAM));
        assertNull(query.get(CommonParams.TIME_ALLOWED));
    } finally {
        processor.destroy();
    }
}
Also used : SolrDocumentListIterator(org.apache.solr.handler.dataimport.SolrEntityProcessor.SolrDocumentListIterator) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Example 2 with SolrDocumentListIterator

use of org.apache.solr.handler.dataimport.SolrEntityProcessor.SolrDocumentListIterator in project lucene-solr by apache.

the class TestSolrEntityProcessorUnit method testPagingQuery.

public void testPagingQuery() {
    SolrEntityProcessor processor = new NoNextMockProcessor();
    HashMap<String, String> entityAttrs = new HashMap<String, String>() {

        {
            put(SolrEntityProcessor.SOLR_SERVER, "http://route:66/no");
            if (random().nextBoolean()) {
                //only 'true' not '*'
                List<String> noCursor = Arrays.asList("", "false", CursorMarkParams.CURSOR_MARK_START);
                Collections.shuffle(noCursor, random());
                put(CursorMarkParams.CURSOR_MARK_PARAM, noCursor.get(0));
            }
        }
    };
    processor.init(getContext(null, null, null, null, Collections.emptyList(), entityAttrs));
    try {
        processor.buildIterator();
        SolrQuery query = new SolrQuery();
        ((SolrDocumentListIterator) processor.rowIterator).passNextPage(query);
        assertEquals("0", query.get(CommonParams.START));
        assertNull(query.get(CursorMarkParams.CURSOR_MARK_PARAM));
        assertNotNull(query.get(CommonParams.TIME_ALLOWED));
    } finally {
        processor.destroy();
    }
}
Also used : SolrDocumentListIterator(org.apache.solr.handler.dataimport.SolrEntityProcessor.SolrDocumentListIterator) SolrQuery(org.apache.solr.client.solrj.SolrQuery)

Aggregations

SolrQuery (org.apache.solr.client.solrj.SolrQuery)2 SolrDocumentListIterator (org.apache.solr.handler.dataimport.SolrEntityProcessor.SolrDocumentListIterator)2