public void validateRecord(DocumentRecord record, Format type) {

    assertNotNull("DocumentRecord should never be null", record);
    assertNotNull("Document uri should never be null", record.getUri());
    assertTrue(
        "Document uri should start with " + DIRECTORY, record.getUri().startsWith(DIRECTORY));
    assertEquals("All records are expected to be in same format", type, record.getFormat());
    //        System.out.println(record.getMimetype());

  }
  @Test
  public void testBulkSearchSQDwithDifferentPageSizes()
      throws IOException, ParserConfigurationException, SAXException, TransformerException {
    int count;
    loadXMLDocuments();
    // Creating a txt document manager for bulk search
    TextDocumentManager docMgr = client.newTextDocumentManager();
    // using QueryManger for query definition and set the search criteria
    StructuredQueryBuilder qb = new StructuredQueryBuilder();
    StructuredQueryDefinition qd = qb.and(qb.term("foo", "bar"));

    // set  document manager level settings for search response
    System.out.println("Default Page length setting on docMgr :" + docMgr.getPageLength());
    docMgr.setPageLength(1);
    docMgr.setSearchView(QueryView.RESULTS);
    docMgr.setNonDocumentFormat(Format.XML);
    assertEquals("format set on document manager", "XML", docMgr.getNonDocumentFormat().toString());
    assertEquals(
        "Queryview set on document manager ", "RESULTS", docMgr.getSearchView().toString());
    assertEquals("Page length ", 1, docMgr.getPageLength());
    // Search for documents where content has bar and get first result record, get search handle on
    // it
    SearchHandle sh = new SearchHandle();
    DocumentPage page = docMgr.search(qd, 0);
    // test for page methods
    assertEquals("Number of records", 1, page.size());
    assertEquals("Starting record in first page ", 1, page.getStart());
    assertEquals("Total number of estimated results:", 102, page.getTotalSize());
    assertEquals("Total number of estimated pages :", 102, page.getTotalPages());
    // till the issue #78 get fixed
    assertTrue("Is this First page :", page.isFirstPage()); // this is bug
    assertFalse("Is this Last page :", page.isLastPage());
    assertTrue("Is this First page has content:", page.hasContent());
    //		Need the Issue #75 to be fixed
    assertFalse("Is first page has previous page ?", page.hasPreviousPage());
    //
    long pageNo = 1;
    do {
      count = 0;
      page = docMgr.search(qd, pageNo, sh);
      if (pageNo > 1) {
        assertFalse("Is this first Page", page.isFirstPage());
        assertTrue("Is page has previous page ?", page.hasPreviousPage());
      }
      while (page.hasNext()) {
        DocumentRecord rec = page.next();
        rec.getFormat();
        validateRecord(rec, Format.XML);
        //		System.out.println(rec.getUri());
        count++;
      }
      MatchDocumentSummary[] mds = sh.getMatchResults();
      assertEquals("Matched document count", 1, mds.length);
      // since we set the query view to get only results, facet count supposed be 0
      assertEquals("Matched Facet count", 0, sh.getFacetNames().length);

      assertEquals("document count", page.size(), count);
      //			assertEquals("Page Number #",pageNo,page.getPageNumber());
      pageNo = pageNo + page.getPageSize();
    } while (!page.isLastPage());
    //		assertTrue("page count is 101 ",pageNo > page.getTotalPages());
    assertTrue("Page has previous page ?", page.hasPreviousPage());
    assertEquals("page size", 1, page.getPageSize());
    assertEquals("document count", 102, page.getTotalSize());
    page = docMgr.search(qd, 103);
    assertFalse("Page has any records ?", page.hasContent());
  }