Package org.hibernate.search.spi

Examples of org.hibernate.search.spi.SearchFactoryBuilder$BuildContext


        .entity( Foo.class ).indexed()
    ;
    cfg.setProgrammaticMapping( mapping );

    try {
      new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
      fail( "Invalid configuration should have thrown an exception" );
    }
    catch (SearchException e) {
      assertTrue( e.getMessage().startsWith( "HSEARCH000177" ) );
    }
View Full Code Here


  @Test
  public void testGetIndexedTypesNoTypeIndexed() {
    SearchConfigurationForTest cfg = getManualConfiguration();

    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
    Set<Class<?>> indexedClasses = sf.getIndexedTypes();
    assertEquals( "Wrong number of indexed entities", 0, indexedClasses.size() );
  }
View Full Code Here

        .entity( Foo.class ).indexed()
        .property( "id", FIELD ).documentId()
    ;
    cfg.setProgrammaticMapping( mapping );

    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
    Set<Class<?>> indexedClasses = sf.getIndexedTypes();
    assertEquals( "Wrong number of indexed entities", 1, indexedClasses.size() );
    assertTrue( indexedClasses.iterator().next().equals( Foo.class ) );
  }
View Full Code Here

    if ( suffix != null ) {
      configuration.addProperty( Environment.JMX_BEAN_SUFFIX, suffix );
    }

    return new SearchFactoryBuilder().configuration( configuration ).buildSearchFactory();
  }
View Full Code Here

        .entity( Bar.class ).indexed()
        .property( "id", FIELD ).documentId()
    ;
    cfg.setProgrammaticMapping( mapping );

    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
    Set<Class<?>> indexedClasses = sf.getIndexedTypes();
    assertEquals( "Wrong number of indexed entities", 2, indexedClasses.size() );
  }
View Full Code Here

  @Test
  public void testGetTypeDescriptorForUnindexedType() {
    SearchConfigurationForTest cfg = getManualConfiguration();

    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
    IndexedTypeDescriptor indexedTypeDescriptor = sf.getIndexedTypeDescriptor( Foo.class);
    assertNotNull( indexedTypeDescriptor );
    assertFalse( indexedTypeDescriptor.isIndexed() );
  }
View Full Code Here

        .entity( Foo.class ).indexed()
        .property( "id", FIELD ).documentId()
    ;
    cfg.setProgrammaticMapping( mapping );

    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
    IndexedTypeDescriptor indexedTypeDescriptor = sf.getIndexedTypeDescriptor( Foo.class);
    assertNotNull( indexedTypeDescriptor );
    assertTrue( indexedTypeDescriptor.isIndexed() );
  }
View Full Code Here

*/
public class MutableFactoryTest {

  @Test
  public void testCreateEmptyFactory() throws Exception {
    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( new SearchConfigurationForTest() ).buildSearchFactory();
    sf.close();
  }
View Full Code Here

    sf.close();
  }

  @Test
  public void testAddingClassFullModel() throws Exception {
    SearchFactoryIntegrator sf = new SearchFactoryBuilder().configuration( new SearchConfigurationForTest() ).buildSearchFactory();
    final SearchFactoryBuilder builder = new SearchFactoryBuilder();
    sf = builder.currentFactory( sf )
        .addClass( A.class )
        .buildSearchFactory();

    TransactionContextForTest tc = new TransactionContextForTest();

    doIndexWork( new A( 1, "Emmanuel" ), 1, sf, tc );

    tc.end();

    QueryParser parser = new QueryParser(
        TestConstants.getTargetLuceneVersion(),
        "name",
        TestConstants.standardAnalyzer
    );
    Query luceneQuery = parser.parse( "Emmanuel" );

    IndexReader indexReader = sf.getIndexReaderAccessor().open( A.class );
    IndexSearcher searcher = new IndexSearcher( indexReader );
    TopDocs hits = searcher.search( luceneQuery, 1000 );
    assertEquals( 1, hits.totalHits );

    sf.getIndexReaderAccessor().close( indexReader );

    sf = builder.currentFactory( sf )
        .addClass( B.class )
        .buildSearchFactory();

    tc = new TransactionContextForTest();
View Full Code Here

    sf.close();
  }

  @Test
  public void testAddingClassSimpleAPI() throws Exception {
    SearchFactoryIntegrator sf = new SearchFactoryBuilder().configuration( new SearchConfigurationForTest() ).buildSearchFactory();

    sf.addClasses( A.class );

    TransactionContextForTest tc = new TransactionContextForTest();
View Full Code Here

TOP

Related Classes of org.hibernate.search.spi.SearchFactoryBuilder$BuildContext

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.