Skip to content

Commit 064bfd6

Browse files
committed
HSEARCH-1950 Integration tests should not hardcode the module slot
1 parent d01318b commit 064bfd6

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

integrationtest/wildfly/src/test/java/org/hibernate/search/test/integration/VersionTestHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private VersionTestHelper() {
4141
/**
4242
* @return the slot version of the Hibernate Search modules generated by this project
4343
*/
44-
private static synchronized String getModuleSlotString() {
44+
public static synchronized String getModuleSlotString() {
4545
if ( hibernateSearchModuleSlot == null ) {
4646
String versionHibernateSearch = getDependencyVersionHibernateSearch();
4747
String[] split = versionHibernateSearch.split( "\\." );

integrationtest/wildfly/src/test/java/org/hibernate/search/test/integration/wildfly/ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
import static org.junit.Assert.assertNotNull;
1212
import static org.junit.Assert.assertTrue;
1313

14+
import java.io.IOException;
15+
import java.io.InputStream;
1416
import java.util.List;
17+
import java.util.Scanner;
1518

1619
import javax.inject.Inject;
1720

21+
import org.hibernate.search.test.integration.VersionTestHelper;
1822
import org.hibernate.search.test.integration.wildfly.controller.MemberRegistration;
1923
import org.hibernate.search.test.integration.wildfly.model.Member;
2024
import org.hibernate.search.test.integration.wildfly.util.Resources;
@@ -43,7 +47,7 @@
4347
public class ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT {
4448

4549
@Deployment
46-
public static Archive<?> createTestArchive() {
50+
public static Archive<?> createTestArchive() throws IllegalArgumentException, IOException {
4751
JavaArchive ejb = ShrinkWrap
4852
.create( JavaArchive.class, ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT.class.getSimpleName() + ".jar" )
4953
.addClasses( ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT.class, Member.class, MemberRegistration.class, Resources.class )
@@ -55,11 +59,22 @@ public static Archive<?> createTestArchive() {
5559
EnterpriseArchive ear = ShrinkWrap
5660
.create( EnterpriseArchive.class, ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT.class.getSimpleName() + ".ear" )
5761
.addAsModules( ejb )
58-
.addAsResource( "jboss-deployment-structure-ear.xml", "/jboss-deployment-structure.xml" )
62+
.addAsResource( jbossDeploymentXml(), "/jboss-deployment-structure.xml" )
5963
.setApplicationXML( new StringAsset( applicationXml ) );
6064
return ear;
6165
}
6266

67+
private static Asset jbossDeploymentXml() throws IOException {
68+
String text;
69+
try ( InputStream inputStream = ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT.class.getClassLoader().getResourceAsStream( "jboss-deployment-structure.xml" ) ) {
70+
try ( Scanner scanner = new Scanner( inputStream, "UTF-8" ) ) {
71+
text = scanner.useDelimiter( "\\A" ).next();
72+
}
73+
}
74+
String finalXml = text.replace( (CharSequence)"${project.slot}", (CharSequence)VersionTestHelper.getModuleSlotString() );
75+
return new StringAsset( finalXml );
76+
}
77+
6378
private static Asset persistenceXml() {
6479
String persistenceXml = Descriptors.create( PersistenceDescriptor.class )
6580
.version( "2.0" )

integrationtest/wildfly/src/test/resources/jboss-deployment-structure-ear.xml renamed to integrationtest/wildfly/src/test/resources/jboss-deployment-structure.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.1">
33
<deployment>
44
<dependencies>
5-
<!-- FIXME use properties rather than hardcode the slot -->
6-
<module name="org.hibernate.search.orm" services="export" export="true" slot="5.4"/>
5+
<module name="org.hibernate.search.orm" services="export" export="true" slot="${project.slot}"/>
76
</dependencies>
87
</deployment>
98
</jboss-deployment-structure>

0 commit comments

Comments
 (0)