Skip to content

Commit

Permalink
Recalculate config property names during tests
Browse files Browse the repository at this point in the history
(cherry picked from commit a1cf7a0)
  • Loading branch information
radcortez authored and gsmet committed Feb 4, 2025
1 parent 1292be5 commit ec92a71
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import java.io.IOException;
import java.util.Map;

import org.eclipse.microprofile.config.ConfigProvider;

import io.quarkus.test.common.TestResourceManager;
import io.smallrye.config.SmallRyeConfig;

public class IntegrationTestExtensionState extends QuarkusTestExtensionState {

Expand All @@ -28,5 +31,7 @@ protected void doClose() throws IOException {
System.setProperty(entry.getKey(), val);
}
}
// recalculate the property names that may have changed with the restore
ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getLatestPropertyNames();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.quarkus.test.common.TestClassIndexer;
import io.quarkus.test.common.TestResourceManager;
import io.quarkus.test.common.http.TestHTTPResourceManager;
import io.smallrye.config.SmallRyeConfig;

public final class IntegrationTestUtil {

Expand Down Expand Up @@ -146,6 +147,8 @@ static TestProfileAndProperties determineTestProfileAndProperties(Class<? extend
System.setProperty(i.getKey(), i.getValue());
}
}
// recalculate the property names that may have changed
ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getLatestPropertyNames();
return new TestProfileAndProperties(testProfile, properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,14 @@ public void close() throws Throwable {
} else {
System.setProperty(i.getKey(), i.getValue());
}
// recalculate the property names that may have changed with the restore
ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getLatestPropertyNames();
}
}
});
additionalProperties.putAll(resourceManagerProps);
// recalculate the property names that may have changed with testProfileAndProperties.properties
ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getLatestPropertyNames();

ArtifactLauncher<?> launcher;
String testHost = System.getProperty("quarkus.http.test-host");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, S
}
}
additionalProperties.putAll(resourceManagerProps);
// recalculate the property names that may have changed with testProfileAndProperties.properties
ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getLatestPropertyNames();

testResourceManager.inject(context.getRequiredTestInstance());

Expand Down Expand Up @@ -187,6 +189,8 @@ private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, S
System.setProperty(i.getKey(), i.getValue());
}
}
// recalculate the property names that may have changed with the restore
ConfigProvider.getConfig().unwrap(SmallRyeConfig.class).getLatestPropertyNames();
try {
if (testResourceManager != null) {
testResourceManager.close();
Expand Down

0 comments on commit ec92a71

Please sign in to comment.