6
6
import java .io .File ;
7
7
import java .io .FileNotFoundException ;
8
8
import java .io .IOException ;
9
- import java .nio .file .Files ;
10
9
import java .nio .file .Path ;
11
- import java .nio .file .Paths ;
12
- import java .util .ArrayList ;
13
- import java .util .Arrays ;
14
- import java .util .Collections ;
15
10
import java .util .List ;
11
+ import java .util .Map ;
16
12
import java .util .concurrent .TimeUnit ;
17
13
18
14
import org .apache .maven .shared .invoker .MavenInvocationException ;
19
15
import org .junit .jupiter .api .AfterEach ;
20
- import org .junit .jupiter .api .Assertions ;
21
16
22
17
import io .quarkus .maven .it .verifier .MavenProcessInvocationResult ;
23
18
import io .quarkus .maven .it .verifier .RunningInvoker ;
26
21
27
22
public class RunAndCheckWithAgentMojoTestBase extends MojoTestBase {
28
23
24
+ private static final String MUTABLE_JAR_TYPE_ARG = "-Dquarkus.package.jar.type=mutable-jar" ;
25
+ private static final String LIVE_RELOAD_PWD_ARG = "-Dquarkus.live-reload.password=qe" ;
26
+ private static final String LIVE_RELOAD_URL_ARG = "-Dquarkus.live-reload.url=http://localhost:8080" ;
27
+ private static final String DQUARKUS_ANALYTICS_DISABLED_TRUE = "-Dquarkus.analytics.disabled=true" ;
28
+
29
29
protected RunningInvoker runningAgent ;
30
30
private Process runningRemote ;
31
31
protected File agentDir ;
@@ -49,22 +49,32 @@ public void cleanup() throws IOException {
49
49
}
50
50
}
51
51
52
- protected void runAndCheck (String ... options ) throws FileNotFoundException , MavenInvocationException {
52
+ protected void runAndCheck () throws FileNotFoundException , MavenInvocationException {
53
+ runAndCheckModule (null );
54
+ }
55
+
56
+ protected void runAndCheckModule (String module ) {
53
57
try {
54
58
RunningInvoker running = new RunningInvoker (testDir , false );
55
59
56
60
MavenProcessInvocationResult result = running
57
- .execute (Arrays .asList ("package" , "-DskipTests" , "-Dquarkus.analytics.disabled=true" ),
58
- Collections .emptyMap ());
61
+ .execute (
62
+ List .of ("package" , "-DskipTests" , MUTABLE_JAR_TYPE_ARG , DQUARKUS_ANALYTICS_DISABLED_TRUE ),
63
+ Map .of ());
59
64
60
65
await ().atMost (1 , TimeUnit .MINUTES ).until (() -> result .getProcess () != null && !result .getProcess ().isAlive ());
61
66
assertThat (running .log ()).containsIgnoringCase ("BUILD SUCCESS" );
62
67
running .stop ();
63
68
64
- Path jar = testDir .toPath ().toAbsolutePath ()
65
- .resolve (Paths .get ("target/quarkus-app/quarkus-run.jar" ));
66
- Assertions .assertTrue (Files .exists (jar ));
67
- File output = new File (testDir , "target/output.log" );
69
+ Path runnerTargetDir = testDir .toPath ().toAbsolutePath ();
70
+ if (module != null ) {
71
+ runnerTargetDir = runnerTargetDir .resolve (module );
72
+ }
73
+ runnerTargetDir = runnerTargetDir .resolve ("target" );
74
+
75
+ Path jar = runnerTargetDir .resolve ("quarkus-app/quarkus-run.jar" );
76
+ assertThat (jar ).exists ();
77
+ File output = runnerTargetDir .resolve ("output.log" ).toFile ();
68
78
output .createNewFile ();
69
79
70
80
runningRemote = doLaunch (jar , output );
@@ -75,8 +85,10 @@ protected void runAndCheck(String... options) throws FileNotFoundException, Mave
75
85
.atMost (1 , TimeUnit .MINUTES ).until (() -> devModeClient .getHttpResponse ("/" , 200 ));
76
86
77
87
runningAgent = new RunningInvoker (agentDir , false );
78
- runningAgent .execute (Arrays .asList ("compile" , "quarkus:remote-dev" , "-Dquarkus.analytics.disabled=true" ),
79
- Collections .emptyMap ());
88
+ runningAgent .execute (
89
+ List .of ("compile" , "quarkus:remote-dev" , MUTABLE_JAR_TYPE_ARG , LIVE_RELOAD_PWD_ARG ,
90
+ LIVE_RELOAD_URL_ARG , DQUARKUS_ANALYTICS_DISABLED_TRUE ),
91
+ Map .of ());
80
92
81
93
Thread .sleep (1000 );
82
94
await ().pollDelay (100 , TimeUnit .MILLISECONDS )
@@ -86,15 +98,16 @@ protected void runAndCheck(String... options) throws FileNotFoundException, Mave
86
98
} catch (Exception e ) {
87
99
throw new RuntimeException (e );
88
100
}
89
-
90
101
}
91
102
92
103
private Process doLaunch (Path jar , File output ) throws IOException {
93
- List <String > commands = new ArrayList <>();
94
- commands .add (JavaBinFinder .findBin ());
95
- commands .add ("-jar" );
96
- commands .add (jar .toString ());
97
- ProcessBuilder processBuilder = new ProcessBuilder (commands .toArray (new String [0 ]));
104
+ final String [] commands = {
105
+ JavaBinFinder .findBin (),
106
+ LIVE_RELOAD_PWD_ARG ,
107
+ "-jar" ,
108
+ jar .toString ()
109
+ };
110
+ ProcessBuilder processBuilder = new ProcessBuilder (commands );
98
111
processBuilder .redirectOutput (output );
99
112
processBuilder .redirectError (output );
100
113
processBuilder .environment ().put ("QUARKUS_LAUNCH_DEVMODE" , "true" );
0 commit comments