1
1
package io .quarkus .redis .devservices .continuoustesting .it ;
2
2
3
+ import static io .restassured .RestAssured .when ;
4
+ import static org .hamcrest .Matchers .is ;
3
5
import static org .junit .jupiter .api .Assertions .assertEquals ;
6
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
4
7
import static org .junit .jupiter .api .Assertions .assertTrue ;
5
8
6
9
import java .util .ArrayList ;
22
25
import io .quarkus .redis .devservices .it .PlainQuarkusTest ;
23
26
import io .quarkus .test .ContinuousTestingTestUtils ;
24
27
import io .quarkus .test .QuarkusDevModeTest ;
28
+ import io .quarkus .test .devservices .redis .TestResource ;
25
29
26
30
public class DevServicesRedisContinuousTestingTest {
27
31
@@ -37,7 +41,7 @@ public class DevServicesRedisContinuousTestingTest {
37
41
@ RegisterExtension
38
42
public static QuarkusDevModeTest test = new QuarkusDevModeTest ()
39
43
.setArchiveProducer (() -> ShrinkWrap .create (JavaArchive .class )
40
- .addClasses ()
44
+ .addClasses (TestResource . class )
41
45
.addAsResource (new StringAsset (ContinuousTestingTestUtils .appProperties ("" )),
42
46
"application.properties" ))
43
47
.setTestArchiveProducer (() -> ShrinkWrap .create (JavaArchive .class ).addClass (PlainQuarkusTest .class ));
@@ -59,6 +63,33 @@ public void testContinuousTestingDisablesDevServicesWhenPropertiesChange() {
59
63
// We could check the container goes away, but we'd have to check slowly, because ryuk can be slow
60
64
}
61
65
66
+ @ Test
67
+ public void testDevModeServiceConfigRefresh () {
68
+ List <Container > started = getRedisContainers ();
69
+ ping ();
70
+
71
+ assertFalse (started .isEmpty ());
72
+ Container container = started .get (0 );
73
+ assertTrue (Arrays .stream (container .getPorts ()).noneMatch (p -> p .getPublicPort () == 6377 ),
74
+ "Expected random port 6377, but got: " + Arrays .toString (container .getPorts ()));
75
+
76
+ test .modifyResourceFile ("application.properties" ,
77
+ s -> ContinuousTestingTestUtils .appProperties ("quarkus.redis.devservices.port=6377" ));
78
+
79
+ ping ();
80
+ List <Container > newContainers = getRedisContainersExcludingExisting (started );
81
+ assertEquals (1 , newContainers .size ()); // this can be wrong
82
+ Container newContainer = newContainers .get (0 );
83
+ assertTrue (Arrays .stream (newContainer .getPorts ()).anyMatch (p -> p .getPublicPort () == 6377 ),
84
+ "Expected port 6377, but got: " + Arrays .toString (newContainer .getPorts ()));
85
+ }
86
+
87
+ void ping () {
88
+ when ().get ("/ping" ).then ()
89
+ .statusCode (200 )
90
+ .body (is ("PONG" ));
91
+ }
92
+
62
93
@ Test
63
94
public void testContinuousTestingReusesInstanceWhenPropertiesAreNotChanged () {
64
95
0 commit comments