Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate Quarkus related failsafe system properties #31465

Merged
merged 1 commit into from Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions integration-tests/test-extension/tests/pom.xml
Expand Up @@ -109,6 +109,7 @@
<systemPropertyVariables>
<!-- See io.quarkus.extest.runtime.classpath.RecordedClasspathEntries -->
<classpathEntriesRecordingFile>${project.build.directory}/recorded-classpath-entries-failsafe.txt</classpathEntriesRecordingFile>
<quarkus.dymmy>test</quarkus.dymmy>
</systemPropertyVariables>
</configuration>
</plugin>
Expand Down
@@ -0,0 +1,18 @@
package io.quarkus.it.extension;

import java.io.IOException;

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

@WebServlet(name = "SystemPropertyTestEndpoint", urlPatterns = "/core/sysprop")
public class SystemPropertyTestEndpoint extends HttpServlet {

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.getWriter().write(System.getProperty("quarkus.dymmy", "unset"));
}

}
@@ -0,0 +1,18 @@
package io.quarkus.it.extension;

import static io.restassured.RestAssured.when;
import static org.hamcrest.Matchers.is;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class SystemPropertyGraalITCase {

@Test
public void test() {
when().get("/core/sysprop").then()
.body(is("test"));
}
}
Expand Up @@ -213,7 +213,17 @@ private QuarkusTestExtensionState doProcessStart(Properties quarkusArtifactPrope
populateCallbacks(requiredTestClass.getClassLoader());
}

Map<String, String> additionalProperties = new HashMap<>(testProfileAndProperties.properties);
Map<String, String> additionalProperties = new HashMap<>();

// propagate Quarkus properties set from the build tool
Properties existingSysProps = System.getProperties();
for (String name : existingSysProps.stringPropertyNames()) {
if (name.startsWith("quarkus.")) {
additionalProperties.put(name, existingSysProps.getProperty(name));
}
}

additionalProperties.putAll(testProfileAndProperties.properties);
Map<String, String> resourceManagerProps = new HashMap<>(testResourceManager.start());
//we also make the dev services config accessible from the test itself
resourceManagerProps.putAll(QuarkusIntegrationTestExtension.devServicesProps);
Expand Down
Expand Up @@ -126,7 +126,18 @@ private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, S
testResourceManager.init(
testProfileAndProperties.testProfile != null ? testProfileAndProperties.testProfile.getClass().getName()
: null);
Map<String, String> additionalProperties = new HashMap<>(testProfileAndProperties.properties);

Map<String, String> additionalProperties = new HashMap<>();

// propagate Quarkus properties set from the build tool
Properties existingSysProps = System.getProperties();
for (String name : existingSysProps.stringPropertyNames()) {
if (name.startsWith("quarkus.")) {
additionalProperties.put(name, existingSysProps.getProperty(name));
}
}

additionalProperties.putAll(testProfileAndProperties.properties);
Map<String, String> resourceManagerProps = new HashMap<>(testResourceManager.start());
//also make the dev services props accessible from the test
resourceManagerProps.putAll(QuarkusMainIntegrationTestExtension.devServicesProps);
Expand Down