Skip to content

Commit

Permalink
HSEARCH-4947 Fix incomplete configuration in *SchemaManagerExporterIT
Browse files Browse the repository at this point in the history
Not strictly necessary, but while we're at it...
  • Loading branch information
yrodiere committed Sep 20, 2023
1 parent 0ae6c7a commit 7be2065
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jakarta.persistence.EntityManagerFactory;

import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings;
import org.hibernate.search.integrationtest.mapper.orm.realbackend.testsupport.BackendConfigurations;
import org.hibernate.search.integrationtest.mapper.orm.realbackend.util.Article;
import org.hibernate.search.integrationtest.mapper.orm.realbackend.util.Book;
import org.hibernate.search.mapper.orm.Search;
import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings;
import org.hibernate.search.util.impl.integrationtest.backend.elasticsearch.dialect.ElasticsearchTestDialect;
import org.hibernate.search.util.impl.integrationtest.mapper.orm.OrmSetupHelper;

Expand All @@ -35,7 +38,10 @@ public class ElasticsearchSchemaManagerExporterIT {
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() );
public OrmSetupHelper setupHelper = OrmSetupHelper.withMultipleBackends(
BackendConfigurations.simple(),
Map.of( Article.BACKEND_NAME, BackendConfigurations.simple() )
);

private EntityManagerFactory entityManagerFactory;

Expand All @@ -51,15 +57,11 @@ public void elasticsearch() throws IOException {
String version = ElasticsearchTestDialect.getActualVersion().toString();
entityManagerFactory = setupHelper.start()
// so that we don't try to do anything with the schema and allow to run without ES being up:
.withProperty( "hibernate.search.schema_management.strategy", "none" )

.withProperty( "hibernate.search.backend.type", "elasticsearch" )
.withProperty( "hibernate.search.backend.version_check.enabled", false )
.withProperty( "hibernate.search.backend.version", version )

.withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".type", "elasticsearch" )
.withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".version_check.enabled", false )
.withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".version", version )
.withProperty( HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, "none" )
.withBackendProperty( ElasticsearchBackendSettings.VERSION_CHECK_ENABLED, false )
.withBackendProperty( ElasticsearchBackendSettings.VERSION, version )
.withBackendProperty( Article.BACKEND_NAME, ElasticsearchBackendSettings.VERSION_CHECK_ENABLED, false )
.withBackendProperty( Article.BACKEND_NAME, ElasticsearchBackendSettings.VERSION, version )
.setup( Book.class, Article.class );

Path directory = temporaryFolder.newFolder().toPath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -31,17 +32,16 @@ public class LuceneSchemaManagerExporterIT {
@Rule
public final TemporaryFolder temporaryFolder = new TemporaryFolder();
@Rule
public OrmSetupHelper setupHelper = OrmSetupHelper.withSingleBackend( BackendConfigurations.simple() );
public OrmSetupHelper setupHelper = OrmSetupHelper.withMultipleBackends(
BackendConfigurations.simple(),
Map.of( Article.BACKEND_NAME, BackendConfigurations.simple() )
);

private EntityManagerFactory entityManagerFactory;

@Test
public void lucene() throws IOException {
entityManagerFactory = setupHelper.start()
.withProperty( "hibernate.search.backend.type", "lucene" )

.withProperty( "hibernate.search.backends." + Article.BACKEND_NAME + ".type", "lucene" )
.setup( Book.class, Article.class );
entityManagerFactory = setupHelper.start().setup( Book.class, Article.class );

Path directory = temporaryFolder.newFolder().toPath();
Search.mapping( entityManagerFactory ).scope( Object.class ).schemaManager().exportExpectedSchema( directory );
Expand Down

0 comments on commit 7be2065

Please sign in to comment.