Skip to content

Commit ef75a40

Browse files
authored
Merge pull request #53400 from radcortez/fix-53394
Optional ListeningAddress when vertx-http is not present
2 parents 15e7067 + 1a4ad8e commit ef75a40

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test-framework/junit/src/main/java/io/quarkus/test/junit/QuarkusIntegrationTestExtension.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static io.quarkus.runtime.LaunchMode.NORMAL;
44
import static io.quarkus.runtime.configuration.ConfigSourceOrdinal.INTEGRATION_TEST;
5+
import static io.quarkus.test.common.ListeningAddress.LISTENING_ADDRESS;
56
import static io.quarkus.test.junit.ArtifactTypeUtil.isContainer;
67
import static io.quarkus.test.junit.ArtifactTypeUtil.isJar;
78
import static io.quarkus.test.junit.IntegrationTestUtil.activateLogging;
@@ -14,6 +15,7 @@
1415
import static io.quarkus.test.junit.IntegrationTestUtil.readQuarkusArtifactProperties;
1516
import static io.quarkus.test.junit.IntegrationTestUtil.startLauncher;
1617
import static io.quarkus.test.junit.TestResourceUtil.TestResourceManagerReflections.copyEntriesFromProfile;
18+
import static java.util.Optional.empty;
1719

1820
import java.io.Closeable;
1921
import java.io.File;
@@ -129,7 +131,7 @@ public void beforeEach(ExtensionContext context) throws Exception {
129131
// Inject of ValueRegistry and Config done IntegrationTestUtil.doProcessTestInstance
130132

131133
ValueRegistry valueRegistry = ValueRegistryInjector.get(context);
132-
Optional<ListeningAddress> listeningAddress = valueRegistry.get(ListeningAddress.LISTENING_ADDRESS);
134+
Optional<ListeningAddress> listeningAddress = valueRegistry.get(LISTENING_ADDRESS);
133135
listeningAddress.ifPresent(new Consumer<ListeningAddress>() {
134136
@Override
135137
public void accept(ListeningAddress listeningAddress) {
@@ -314,10 +316,12 @@ private QuarkusTestExtensionState doProcessStart(Class<? extends QuarkusTestProf
314316

315317
// Start Quarkus, capture the listening port if available and register it in ValueRegistry
316318
Optional<ListeningAddress> listeningAddress = startLauncher(launcher, additionalProperties);
317-
listeningAddress.ifPresent(address -> {
318-
address.register(valueRegistry, newConfig);
319-
valueRegistry.register(ListeningAddress.LISTENING_ADDRESS, listeningAddress);
320-
});
319+
if (listeningAddress.isPresent()) {
320+
listeningAddress.get().register(valueRegistry, newConfig);
321+
valueRegistry.register(LISTENING_ADDRESS, listeningAddress);
322+
} else {
323+
valueRegistry.register(LISTENING_ADDRESS, Optional.empty());
324+
}
321325

322326
testHttpEndpointProviders = TestHttpEndpointProvider.load();
323327

0 commit comments

Comments
 (0)