11
11
import static org .junit .Assert .assertNotNull ;
12
12
import static org .junit .Assert .assertTrue ;
13
13
14
+ import java .io .IOException ;
15
+ import java .io .InputStream ;
14
16
import java .util .List ;
17
+ import java .util .Scanner ;
15
18
16
19
import javax .inject .Inject ;
17
20
21
+ import org .hibernate .search .test .integration .VersionTestHelper ;
18
22
import org .hibernate .search .test .integration .wildfly .controller .MemberRegistration ;
19
23
import org .hibernate .search .test .integration .wildfly .model .Member ;
20
24
import org .hibernate .search .test .integration .wildfly .util .Resources ;
43
47
public class ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT {
44
48
45
49
@ Deployment
46
- public static Archive <?> createTestArchive () {
50
+ public static Archive <?> createTestArchive () throws IllegalArgumentException , IOException {
47
51
JavaArchive ejb = ShrinkWrap
48
52
.create ( JavaArchive .class , ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT .class .getSimpleName () + ".jar" )
49
53
.addClasses ( ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT .class , Member .class , MemberRegistration .class , Resources .class )
@@ -55,11 +59,22 @@ public static Archive<?> createTestArchive() {
55
59
EnterpriseArchive ear = ShrinkWrap
56
60
.create ( EnterpriseArchive .class , ModuleMemberRegistrationEarArchiveWithJbossDeploymentIT .class .getSimpleName () + ".ear" )
57
61
.addAsModules ( ejb )
58
- .addAsResource ( "jboss-deployment-structure-ear.xml" , "/jboss-deployment-structure.xml" )
62
+ .addAsResource ( jbossDeploymentXml () , "/jboss-deployment-structure.xml" )
59
63
.setApplicationXML ( new StringAsset ( applicationXml ) );
60
64
return ear ;
61
65
}
62
66
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
+
63
78
private static Asset persistenceXml () {
64
79
String persistenceXml = Descriptors .create ( PersistenceDescriptor .class )
65
80
.version ( "2.0" )
0 commit comments