Examples of IndexFactory


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

  }

  final public void testUpdateDocuments() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    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 documentsModifierControl = MockControl.createStrictControl(DocumentsModifier.class);
    DocumentsModifier documentsModifier = (DocumentsModifier)documentsModifierControl.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");
    List documents = new ArrayList();
   
    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    indexReader.createSearcher();
    indexReaderControl.setReturnValue(searcher);
   
    searcher.search(new TermQuery(term));
    searcherControl.setReturnValue(hits);
   
    documentsModifier.updateDocuments(hits);
    documentsModifierControl.setReturnValue(documents, 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);
   
    indexWriter.addDocument(document);
    indexWriterControl.setVoidCallable();
   
View Full Code Here

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

  }

  final public void testOptimize() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
   
    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    indexWriter.optimize();
    indexWriterControl.setVoidCallable(1);
   
View Full Code Here

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

   * Test for Object read(ReaderCallback)
   */
  final public void testRead() 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();
    MockControl readerCallbackControl = MockControl.createStrictControl(ReaderCallback.class);
    ReaderCallback readerCallback = (ReaderCallback)readerCallbackControl.getMock();
   
    indexFactory.getIndexReader();
    indexFactoryControl.setReturnValue(indexReader, 1);
   
    readerCallback.doWithReader(indexReader);
    readerCallbackControl.setReturnValue("return", 1);
   
View Full Code Here

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

   * Test for Object write(WriterCallback)
   */
  final public void testWrite() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl writerCallbackControl = MockControl.createStrictControl(WriterCallback.class);
    WriterCallback writerCallback = (WriterCallback)writerCallbackControl.getMock();
   
    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    writerCallback.doWithWriter(indexWriter);
    writerCallbackControl.setReturnValue("return", 1);
   
View Full Code Here

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

    this.template = null;
  }

  final public void testRegisterDocumentHandler() {
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

    indexFactoryControl.replay();
   
    //Indexer
    DefaultDatabaseIndexer indexer = new DefaultDatabaseIndexer(indexFactory);
View Full Code Here

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

    assertNotNull(indexer.getDocumentHandler(request));
  }

  final public void testUnregisterDocumentHandler() {
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

    indexFactoryControl.replay();
   
    //Indexer
    DefaultDatabaseIndexer indexer = new DefaultDatabaseIndexer(indexFactory);
View Full Code Here

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

    indexFactoryControl.verify();
  }

  final public void testAddListener() {
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

    indexFactoryControl.replay();
   
    //Indexer
    DefaultDatabaseIndexer indexer = new DefaultDatabaseIndexer(indexFactory);
View Full Code Here

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

    indexFactoryControl.verify();
  }

  final public void testRemoveListener() {
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

    indexFactoryControl.replay();
   
    //Indexer
    DefaultDatabaseIndexer indexer = new DefaultDatabaseIndexer(indexFactory);
View Full Code Here

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

    indexFactoryControl.verify();
  }

  final public void testIndexDataSource() throws Exception {
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl listenerControl = MockControl.createControl(DatabaseIndexingListener.class);
    DatabaseIndexingListener listener = (DatabaseIndexingListener)listenerControl.getMock();

    //requests
    SqlRequest request1 = new SqlRequest("select * from test");
    SqlRequest request2 = new SqlRequest("select * from test");

    //documents
    final Document document1 = new Document();
    document1.add(new Field("contents", "test_name", Field.Store.NO, Field.Index.TOKENIZED));
    final Document document2 = new Document();
    document2.add(new Field("contents", "test_name", Field.Store.NO, Field.Index.TOKENIZED));

    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    listener.beforeIndexingRequest(request1);
    listenerControl.setVoidCallable(1);
   
View Full Code Here

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

    listenerControl.verify();
  }

  final public void testIndexDataSourceWithSqlError() throws Exception {
    MockControl indexFactoryControl = MockControl.createStrictControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createStrictControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl listenerControl = MockControl.createControl(DatabaseIndexingListener.class);
    DatabaseIndexingListener listener = (DatabaseIndexingListener)listenerControl.getMock();
   
    //requests
    SqlRequest request1 = new SqlRequest("select * from test1");

    //documents
    final Document document1 = new Document();
    document1.add(new Field("contents", "test_name", Field.Store.NO, Field.Index.TOKENIZED));
   
    //exception
    BadSqlGrammarException ex = new BadSqlGrammarException("arg1", "arg2", null);

    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    listener.beforeIndexingRequest(request1);
    listenerControl.setVoidCallable(1);
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.