Package org.springmodules.lucene.index.factory

Examples of org.springmodules.lucene.index.factory.LuceneIndexReader


    try {
      indexFactory = new LockIndexFactory();
      indexFactory.setTargetIndexFactory(targetIndexFactory);
      indexFactory.afterPropertiesSet();
   
      LuceneIndexReader indexReader = indexFactory.getIndexReader();
      indexReader.hasDeletions();
      indexReader.close();
   
      LuceneIndexWriter indexWriter = indexFactory.getIndexWriter();
      Document document = new Document();
      document.add(new Field("id", "1", Field.Store.YES, Field.Index.UN_TOKENIZED));
      document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
View Full Code Here


    try {
      holder.getIndexWriter();
      fail();
    } catch(LuceneIndexingException ex) {}
   
    LuceneIndexReader indexReader = holder.getIndexReader();
   
    try {
      indexReader.deleteDocument(2);
      fail();
    } catch(LuceneIndexingException ex) {}

    try {
      indexReader.deleteDocuments(new Term("id", "1"));
      fail();
    } catch(LuceneIndexingException ex) {}

    try {
      indexReader.setNorm(2, null, 2);
      fail();
    } catch(LuceneIndexingException ex) {}

    try {
      indexReader.undeleteAll();
      fail();
    } catch(LuceneIndexingException ex) {}
   
    resourceManager.releaseResources();
  }
View Full Code Here

  final public void testDeleteDocumentint() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.deleteDocument(0);
    indexReaderControl.setVoidCallable(1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactoryControl.replay();
    indexReaderControl.replay();
   
View Full Code Here

  final public void testDeleteDocumentTerm() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.deleteDocuments(new Term("field","lucene"));
    indexReaderControl.setReturnValue(1, 1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactoryControl.replay();
    indexReaderControl.replay();
   
View Full Code Here

  final public void testUndeleteDocuments() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.undeleteAll();
    indexReaderControl.setVoidCallable(1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactoryControl.replay();
    indexReaderControl.replay();
   
View Full Code Here

  final public void testIsDeleted() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.isDeleted(0);
    indexReaderControl.setReturnValue(true, 1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactoryControl.replay();
    indexReaderControl.replay();
   
View Full Code Here

  final public void testHasDeletions() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.hasDeletions();
    indexReaderControl.setReturnValue(true, 1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactoryControl.replay();
    indexReaderControl.replay();
   
View Full Code Here

  final public void testGetMaxDoc() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.maxDoc();
    indexReaderControl.setReturnValue(3, 1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactoryControl.replay();
    indexReaderControl.replay();
   
View Full Code Here

  final public void testGetNumDocs() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.numDocs();
    indexReaderControl.setReturnValue(3, 1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactoryControl.replay();
    indexReaderControl.replay();
   
View Full Code Here

    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl indexReaderControl = MockControl.createStrictControl(LuceneIndexReader.class);
    LuceneIndexReader indexReader = (LuceneIndexReader)indexReaderControl.getMock();
    MockControl searcherControl = MockControl.createStrictControl(LuceneSearcher.class);
    LuceneSearcher searcher = (LuceneSearcher)searcherControl.getMock();
    MockControl documentModifierControl = MockControl.createStrictControl(DocumentModifier.class);
    DocumentModifier documentModifier = (DocumentModifier)documentModifierControl.getMock();
    MockControl hitsControl = MockControl.createStrictControl(LuceneHits.class);
    LuceneHits hits = (LuceneHits)hitsControl.getMock();
   
    //document
    Document document = new Document();
    document.add(new Field("field", "a sample", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("filter", "a sample filter", Field.Store.YES, Field.Index.TOKENIZED));
    document.add(new Field("sort", "2", Field.Store.YES, Field.Index.UN_TOKENIZED));

    Term term = new Term("id","2");
   
    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.createSearcher();
    indexReaderControl.setReturnValue(searcher);
   
    searcher.search(new TermQuery(term));
    searcherControl.setReturnValue(hits);
   
    hits.length();
    hitsControl.setReturnValue(1, 2);
   
    hits.doc(0);
    hitsControl.setReturnValue(document);
   
    documentModifier.updateDocument(document);
    documentModifierControl.setReturnValue(document, 1);
   
    searcher.close();
    searcherControl.setVoidCallable(1);

    indexReader.close();
    indexReaderControl.setVoidCallable(1);

    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.deleteDocuments(term);
    indexReaderControl.setReturnValue(1, 1);
   
    indexReader.close();
    indexReaderControl.setVoidCallable(1);
   
    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
View Full Code Here

TOP

Related Classes of org.springmodules.lucene.index.factory.LuceneIndexReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.