Skip to content

Commit

Permalink
Merge pull request #20223 from geoand/#20205
Browse files Browse the repository at this point in the history
Make @testprofile work with integration tests
  • Loading branch information
geoand authored Sep 18, 2021
2 parents 6de7b3f + 3221e8e commit 15c2f12
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.acme.quickstart.lra;

import java.util.List;

import io.quarkus.test.junit.QuarkusTestProfile;

// we use a QuarkusTestProfile to ensure that QuarkusIntegrationTest works properly with them
public class AppTestProfile implements QuarkusTestProfile {

@Override
public List<TestResourceEntry> testResources() {
return List.of(new TestResourceEntry(LRAParticipantTestResourceLifecycle.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.restassured.response.Response;

@QuarkusTest
@QuarkusTestResource(LRAParticipantTestResourceLifecycle.class)
@TestProfile(AppTestProfile.class)
@TestHTTPEndpoint(TransactionalResource.class)
public class LRAParticipantTest {
private String coordinatorEndpoint;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.acme.quickstart.lra;

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

@QuarkusIntegrationTest
@TestProfile(AppTestProfile.class)
public class LRAParticipantTestNativeIT extends LRAParticipantTest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties;
import static io.quarkus.test.junit.IntegrationTestUtil.doProcessTestInstance;
import static io.quarkus.test.junit.IntegrationTestUtil.ensureNoInjectAnnotationIsUsed;
import static io.quarkus.test.junit.IntegrationTestUtil.getAdditionalTestResources;
import static io.quarkus.test.junit.IntegrationTestUtil.getSysPropsToRestore;
import static io.quarkus.test.junit.IntegrationTestUtil.handleDevServices;
import static io.quarkus.test.junit.IntegrationTestUtil.readQuarkusArtifactProperties;
Expand Down Expand Up @@ -132,7 +133,9 @@ private IntegrationTestExtensionState doProcessStart(Properties quarkusArtifactP
TestProfileAndProperties testProfileAndProperties = determineTestProfileAndProperties(profile, sysPropRestore);

testResourceManager = new TestResourceManager(requiredTestClass, quarkusTestProfile,
Collections.emptyList(), testProfileAndProperties.testProfile != null
getAdditionalTestResources(testProfileAndProperties.testProfile,
context.getRequiredTestClass().getClassLoader()),
testProfileAndProperties.testProfile != null
&& testProfileAndProperties.testProfile.disableGlobalTestResources(),
devServicesProps);
testResourceManager.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import static io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory;
import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties;
import static io.quarkus.test.junit.IntegrationTestUtil.getAdditionalTestResources;
import static io.quarkus.test.junit.IntegrationTestUtil.getSysPropsToRestore;
import static io.quarkus.test.junit.IntegrationTestUtil.handleDevServices;
import static io.quarkus.test.junit.IntegrationTestUtil.readQuarkusArtifactProperties;

import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -114,7 +114,9 @@ private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, S
TestProfileAndProperties testProfileAndProperties = determineTestProfileAndProperties(profile, sysPropRestore);

testResourceManager = new TestResourceManager(requiredTestClass, profile,
Collections.emptyList(), testProfileAndProperties.testProfile != null
getAdditionalTestResources(testProfileAndProperties.testProfile,
context.getRequiredTestClass().getClassLoader()),
testProfileAndProperties.testProfile != null
&& testProfileAndProperties.testProfile.disableGlobalTestResources());
testResourceManager.init();
Map<String, String> additionalProperties = new HashMap<>(testProfileAndProperties.properties);
Expand Down

0 comments on commit 15c2f12

Please sign in to comment.