Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-4336 Deprecate assigning the same index to multiple entity types
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...va/org/hibernate/search/test/configuration/MultipleTypesInSingleIndexDeprecationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.test.configuration; | ||
|
||
import org.hibernate.search.annotations.DocumentId; | ||
import org.hibernate.search.annotations.Field; | ||
import org.hibernate.search.annotations.Indexed; | ||
import org.hibernate.search.test.util.impl.ExpectedLog4jLog; | ||
import org.hibernate.search.testsupport.TestForIssue; | ||
import org.hibernate.search.testsupport.junit.SearchIntegratorResource; | ||
import org.hibernate.search.testsupport.setup.SearchConfigurationForTest; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import org.apache.log4j.Level; | ||
import org.hamcrest.CoreMatchers; | ||
|
||
@TestForIssue(jiraKey = "HSEARCH-4336") | ||
public class MultipleTypesInSingleIndexDeprecationTest { | ||
|
||
@Rule | ||
public final SearchIntegratorResource integratorResource = new SearchIntegratorResource(); | ||
|
||
@Rule | ||
public ExpectedLog4jLog logged = ExpectedLog4jLog.create(); | ||
|
||
@Test | ||
public void default_warning() { | ||
SearchConfigurationForTest cfg = new SearchConfigurationForTest(); | ||
cfg.addClass( RootEntityType.class ); | ||
cfg.addClass( DerivedEntityType.class ); | ||
|
||
logged.expectEvent( Level.WARN, CoreMatchers.nullValue(), | ||
"Index 'myIndex' is assigned to multiple entity types:", | ||
RootEntityType.class.getName(), | ||
DerivedEntityType.class.getName(), | ||
"Support for indexing multiple entity types in the same index is going to be removed in Hibernate Search 6" ); | ||
|
||
integratorResource.create( cfg ); | ||
} | ||
|
||
@Test | ||
public void property_noWarning() { | ||
SearchConfigurationForTest cfg = new SearchConfigurationForTest(); | ||
cfg.addClass( RootEntityType.class ); | ||
cfg.addClass( DerivedEntityType.class ); | ||
|
||
cfg.addProperty( "hibernate.search.v6_migration.deprecation_warnings", "false" ); | ||
|
||
logged.expectLevel( Level.WARN ).never(); | ||
|
||
integratorResource.create( cfg ); | ||
} | ||
|
||
@Indexed(index = "myIndex") | ||
public static class RootEntityType { | ||
@DocumentId | ||
private long id; | ||
@Field | ||
private String field; | ||
} | ||
|
||
@Indexed | ||
public static class DerivedEntityType extends RootEntityType { | ||
} | ||
|
||
} |