Package org.hibernate.search.spi

Examples of org.hibernate.search.spi.SearchFactoryBuilder


      SearchConfigurationForTest configuration = new SearchConfigurationForTest()
          .addClass( C.class )
          .addClass( AbstractC.class )
          .addClass( D.class );

      new SearchFactoryBuilder().configuration( configuration ).buildSearchFactory();
      fail( "Invalid configuration should throw an exception" );
    }
    catch (SearchException e) {
      assertTrue( "Invalid exception code", e.getMessage().startsWith( "HSEARCH000216" ) );
    }
View Full Code Here


   */
  private void storeBooksViaProvidedId(SearchConfigurationForTest cfg, String fieldName, boolean matchTitle) {
    SearchFactoryImplementor sf = null;
    try {
      //Should fail right here when @ProvidedId is not enabled:
      sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();

      Book book = new Book();
      book.title = "Less is nice";
      book.text = "When using Infinispan Query, users have to always remember to add @ProvidedId on their classes" +
          " or a nasty exception will remind them. Can't we just assume it's always annotated?";
View Full Code Here

        .property( "id", ElementType.FIELD ).documentId()
        .property( "title", ElementType.FIELD ).field();

    cfg.setProgrammaticMapping( mapping );
    cfg.addClass( Document.class );
    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
    try {
      Assert.assertEquals( expectedIndexManagerClass, extractDocumentIndexManagerClassName( sf, "documents" ) );
      // trigger a SearchFactory rebuild:
      sf.addClasses( Dvd.class );
      // and verify the option is not lost:
View Full Code Here

    for ( Map.Entry<String, String> entry : shardingProperties.entrySet() ) {
      configuration.addProperty( entry.getKey(), entry.getValue() );
    }
    configuration.addClass( Foo.class );

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

      .property( "id", ElementType.FIELD ).documentId()
      .property( "title", ElementType.FIELD ).field()
      ;
    cfg.setProgrammaticMapping( mapping );
    cfg.addClass( Document.class );
    SearchFactoryImplementor sf = new SearchFactoryBuilder().configuration( cfg ).buildSearchFactory();
    try {
      EntityIndexBinding indexBindingForEntity = sf.getIndexBinding( Document.class );
      DirectoryBasedIndexManager indexManager = (DirectoryBasedIndexManager) indexBindingForEntity.getIndexManagers()[0];
      OptimizerStrategy optimizerStrategy = indexManager.getOptimizerStrategy();
      Assert.assertTrue( type.isAssignableFrom( optimizerStrategy.getClass() ) );
View Full Code Here

  }

  @Test
  public void testDefaultWorker() {
    SearchFactoryImplementor searchFactoryImplementor =
        new SearchFactoryBuilder().configuration( manualConfiguration ).buildSearchFactory();
    assertNotNull( "Worker should have been created", searchFactoryImplementor.getWorker() );
    assertTrue( "Wrong worker class", searchFactoryImplementor.getWorker() instanceof TransactionalWorker );
  }
View Full Code Here

  @Test
  public void testExplicitTransactionalWorker() {
    manualConfiguration.addProperty( "hibernate.search.worker.scope", "transaction" );
    SearchFactoryImplementor searchFactoryImplementor =
        new SearchFactoryBuilder().configuration( manualConfiguration ).buildSearchFactory();
    assertNotNull( "Worker should have been created", searchFactoryImplementor.getWorker() );
    assertTrue( "Wrong worker class", searchFactoryImplementor.getWorker() instanceof TransactionalWorker );
  }
View Full Code Here

  @Test
  public void testCustomWorker() {
    manualConfiguration.addProperty( "hibernate.search.worker.scope", CustomWorker.class.getName() );
    SearchFactoryImplementor searchFactoryImplementor =
        new SearchFactoryBuilder().configuration( manualConfiguration ).buildSearchFactory();
    assertNotNull( "Worker should have been created", searchFactoryImplementor.getWorker() );
    assertTrue( "Wrong worker class", searchFactoryImplementor.getWorker() instanceof CustomWorker );
  }
View Full Code Here

  public void testCustomWorkerWithProperties() {
    manualConfiguration.addProperty( "hibernate.search.worker.scope", CustomWorkerExpectingFooAndBar.class.getName() );
    manualConfiguration.addProperty( "hibernate.search.worker.foo", "foo" );
    manualConfiguration.addProperty( "hibernate.search.worker.bar", "bar" );
    SearchFactoryImplementor searchFactoryImplementor =
        new SearchFactoryBuilder().configuration( manualConfiguration ).buildSearchFactory();
    assertNotNull( "Worker should have been created", searchFactoryImplementor.getWorker() );
    assertTrue( "Wrong worker class", searchFactoryImplementor.getWorker() instanceof CustomWorkerExpectingFooAndBar );
  }
View Full Code Here

  @Test
  public void testUnknownWorkerImplementationClass() {
    manualConfiguration.addProperty( "hibernate.search.worker.scope", "foo" );
    try {
      new SearchFactoryBuilder().configuration( manualConfiguration ).buildSearchFactory();
      fail();
    }
    catch (SearchException e) {
      assertTrue(
          "Unexpected error message",
View Full Code Here

TOP

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

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.