Package org.springmodules.lucene.index.document.handler

Examples of org.springmodules.lucene.index.document.handler.DocumentHandlerManager


            = (DocumentHandlerManagerFactoryBean)context.getBean("&documentHandlerManager1");
    assertNotNull(documentHandlerManagerFB1);
    assertEquals(documentHandlerManagerFB1.getDocumentMatchingClass(), ExtensionDocumentMatching.class);
    assertEquals(documentHandlerManagerFB1.getDocumentHandlerManagerClass(), ExtensionDocumentHandlerManager.class);

    DocumentHandlerManager documentHandlerManager1
            = (DocumentHandlerManager)context.getBean("documentHandlerManager1");
    assertNotNull(documentHandlerManager1);
    assertTrue(documentHandlerManager1 instanceof ExtensionDocumentHandlerManager);
    assertNotNull(documentHandlerManager1.getDocumentHandler("test.txt"));
    assertNotNull(documentHandlerManager1.getDocumentHandler("test.properties"));

    DocumentHandlerManagerFactoryBean documentHandlerManagerFB2
            = (DocumentHandlerManagerFactoryBean)context.getBean("&documentHandlerManager2");
    assertNotNull(documentHandlerManagerFB2);
    assertEquals(documentHandlerManagerFB2.getDocumentMatchingClass(), IdentityDocumentMatching.class);
    assertEquals(documentHandlerManagerFB2.getDocumentHandlerManagerClass(), DefaultDocumentHandlerManager.class);

    DocumentHandlerManager documentHandlerManager2
            = (DocumentHandlerManager)context.getBean("documentHandlerManager2");
    assertNotNull(documentHandlerManager2);
  }
View Full Code Here


import org.springmodules.lucene.index.document.handler.DocumentHandlerManager;

public class MimeTypeDocumentHandlerManagerTests extends TestCase {

  public void testGetDocumentHandler() {
    DocumentHandlerManager manager = new MimeTypeDocumentHandlerManager();
    manager.registerDefaultHandlers();
    assertNotNull(manager.getDocumentHandler("test.txt"));
  }
View Full Code Here

    manager.registerDefaultHandlers();
    assertNotNull(manager.getDocumentHandler("test.txt"));
  }

  public void testGetDocumentHandlerNotFound() {
    DocumentHandlerManager manager = new MimeTypeDocumentHandlerManager();
    manager.registerDefaultHandlers();
    try {
      manager.getDocumentHandler("test.properties");
      fail();
    } catch (DocumentHandlerException e) {
    }
  }
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 documentHandlerManagerControl = MockControl.createStrictControl(DocumentHandlerManager.class);
    DocumentHandlerManager documentHandlerManager = (DocumentHandlerManager)documentHandlerManagerControl.getMock();
    MockControl documentHandlerControl = MockControl.createStrictControl(DocumentHandler.class);
    DocumentHandler documentHandler = (DocumentHandler)documentHandlerControl.getMock();
    MockControl inputStreamControl = MockClassControl.createStrictControl(InputStream.class);
    final InputStream inputStream = (InputStream)inputStreamControl.getMock();

    //file
    final File file = getFileFromClasspath("test.txt");
    final Map description = new HashMap();
    description.put(AbstractInputStreamDocumentHandler.FILENAME, file.getPath());
    //final FileInputStream inputStream = new FileInputStream(file);

    //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);

    //DocumentHandler documentHandler = documentHandlerManager.getDocumentHandler(getResourceName());
    documentHandlerManager.getDocumentHandler(file.getPath());
    documentHandlerManagerControl.setReturnValue(documentHandler, 1);
    //Document document = documentHandler.getDocument(getResourceDescription(),inputStream);
    documentHandler.getDocument(description, inputStream);
    documentHandlerControl.setReturnValue(document, 1);
   
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 documentHandlerManagerControl = MockControl.createStrictControl(DocumentHandlerManager.class);
    DocumentHandlerManager documentHandlerManager = (DocumentHandlerManager)documentHandlerManagerControl.getMock();
    MockControl documentHandlerControl = MockControl.createStrictControl(DocumentHandler.class);
    DocumentHandler documentHandler = (DocumentHandler)documentHandlerControl.getMock();
    MockControl inputStreamControl = MockClassControl.createStrictControl(InputStream.class);
    final InputStream inputStream = (InputStream)inputStreamControl.getMock();

    //file
    final File file = getFileFromClasspath("test.foo");
    final Map description = new HashMap();
    description.put(AbstractInputStreamDocumentHandler.FILENAME, file.getPath());
    //final FileInputStream inputStream = new FileInputStream(file);

    //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);

    //DocumentHandler documentHandler = documentHandlerManager.getDocumentHandler(getResourceName());
    documentHandlerManager.getDocumentHandler(file.getPath());
    documentHandlerManagerControl.setReturnValue(null, 1);
    //Document document = documentHandler.getDocument(getResourceDescription(),inputStream);
    /*documentHandler.getDocument(description, inputStream);
    documentHandlerControl.setReturnValue(document, 1);*/
   
 
View Full Code Here

TOP

Related Classes of org.springmodules.lucene.index.document.handler.DocumentHandlerManager

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.