Package org.springmodules.lucene.index.factory

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


import org.springmodules.lucene.index.factory.concurrent.LockIndexFactory;

public class ConcurrentDefaultResourceManagerTests extends DefaultResourceManagerTests {

  protected IndexFactory createIndexFactory(RAMDirectory directory) throws Exception {
    IndexFactory targetIndexFactory = super.createIndexFactory(directory);
    LockIndexFactory indexFactory = new LockIndexFactory();
    indexFactory.setTargetIndexFactory(targetIndexFactory);
    indexFactory.afterPropertiesSet();
    return indexFactory;
  }
View Full Code Here


  }

  final public void testRegisterDocumentHandler() {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

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

  }

  final public void testUnregisterDocumentHandler() {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

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

  }

  final public void testAddListener() {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

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

  }

  final public void testRemoveListener() {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

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

   * Test pour void index(String)
   */
  final public void testIndexString() 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 listenerControl = MockControl.createStrictControl(FileDocumentIndexingListener.class);
    FileDocumentIndexingListener listener = (FileDocumentIndexingListener)listenerControl.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));

    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    listener.beforeIndexingDirectory(getBaseDirectoryToIndex());
    listenerControl.setVoidCallable(1);

View Full Code Here

   * Test for void index(String) with document handler registered
   */
  final public void testIndexStringDocumentHandler() 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 listenerControl = MockControl.createStrictControl(FileDocumentIndexingListener.class);
    FileDocumentIndexingListener listener = (FileDocumentIndexingListener)listenerControl.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));

    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    listener.beforeIndexingDirectory(getBaseDirectoryToIndex());
    listenerControl.setVoidCallable(1);

View Full Code Here

   * Test pour void index(String) with document handler registered
   */
  final public void testIndexStringListener() 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 listener1Control = MockControl.createStrictControl(FileDocumentIndexingListener.class);
    FileDocumentIndexingListener listener1 = (FileDocumentIndexingListener)listener1Control.getMock();
    MockControl listener2Control = MockControl.createStrictControl(FileDocumentIndexingListener.class);
    FileDocumentIndexingListener listener2 = (FileDocumentIndexingListener)listener2Control.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));

    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    listener1.beforeIndexingDirectory(getBaseDirectoryToIndex());
    listener1Control.setVoidCallable(1);

View Full Code Here

   * Test pour void index(String, boolean)
   */
  final public void testIndexStringboolean() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createNiceControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();
    MockControl indexWriterControl = MockControl.createNiceControl(LuceneIndexWriter.class);
    LuceneIndexWriter indexWriter = (LuceneIndexWriter)indexWriterControl.getMock();
    MockControl listenerControl = MockControl.createNiceControl(FileDocumentIndexingListener.class);
    FileDocumentIndexingListener listener = (FileDocumentIndexingListener)listenerControl.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));

    indexFactory.getIndexWriter();
    indexFactoryControl.setReturnValue(indexWriter, 1);
   
    listener.beforeIndexingDirectory(getBaseDirectoryToIndex());
    listenerControl.setVoidCallable(1);

View Full Code Here

   * Test pour void index(String)
   */
  final public void testIndexStringIfDirectoryNotExist() throws Exception {
    SimpleAnalyzer analyzer = new SimpleAnalyzer();
    MockControl indexFactoryControl = MockControl.createControl(IndexFactory.class);
    IndexFactory indexFactory = (IndexFactory)indexFactoryControl.getMock();

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

TOP

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

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.