Skip to content

Commit

Permalink
Ensure that dev services properties are cleared in QuarkusIntegration…
Browse files Browse the repository at this point in the history
…TestExtension

This is needed to ensure the subsequent tests that need to relaunch dev-services
because of the use a different test profile

Fixes: quarkusio#27075
  • Loading branch information
geoand committed Aug 2, 2022
1 parent 786d767 commit a6a2c5d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.quarkus.it.mongodb;

import io.quarkus.test.junit.QuarkusTestProfile;

public class DummyTestProfile implements QuarkusTestProfile {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkus.it.mongodb;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class OtherProfileBookResourceIT extends OtherProfileBookResourceTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.quarkus.it.mongodb;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;

@QuarkusTest
@TestProfile(DummyTestProfile.class)
public class OtherProfileBookResourceTest {

@Test
public void testBlockingClient() {
Utils.callTheEndpoint("/books");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ private IntegrationTestExtensionState doNativeStart(ExtensionContext context, Cl
Class<?> requiredTestClass = context.getRequiredTestClass();

Map<String, String> sysPropRestore = getSysPropsToRestore();
for (String devServicesProp : devServicesProps.keySet()) {
sysPropRestore.put(devServicesProp, null); // used to signal that the property needs to be cleared
}
TestProfileAndProperties testProfileAndProperties = determineTestProfileAndProperties(profile, sysPropRestore);

testResourceManager = new TestResourceManager(requiredTestClass, quarkusTestProfile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ private IntegrationTestExtensionState doProcessStart(Properties quarkusArtifactP
Class<?> requiredTestClass = context.getRequiredTestClass();

Map<String, String> sysPropRestore = getSysPropsToRestore();
for (String devServicesProp : devServicesProps.keySet()) {
sysPropRestore.put(devServicesProp, null); // used to signal that the property needs to be cleared
}
TestProfileAndProperties testProfileAndProperties = determineTestProfileAndProperties(profile, sysPropRestore);

testResourceManager = new TestResourceManager(requiredTestClass, quarkusTestProfile,
Expand All @@ -175,7 +178,8 @@ private IntegrationTestExtensionState doProcessStart(Properties quarkusArtifactP
System.setProperty(i.getKey(), i.getValue());
}
}
context.getStore(ExtensionContext.Namespace.GLOBAL).put(QuarkusIntegrationTestExtension.class.getName() + ".systemProps",
context.getStore(ExtensionContext.Namespace.GLOBAL).put(
QuarkusIntegrationTestExtension.class.getName() + ".systemProps",
new ExtensionContext.Store.CloseableResource() {
@Override
public void close() throws Throwable {
Expand Down

0 comments on commit a6a2c5d

Please sign in to comment.