forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#42852 from geoand/@WithTestResource-fixed
Change default behavior of `@WithTestResource`
- Loading branch information
Showing
15 changed files
with
772 additions
and
294 deletions.
There are no files selected for viewing
543 changes: 399 additions & 144 deletions
543
test-framework/common/src/main/java/io/quarkus/test/common/TestResourceManager.java
Large diffs are not rendered by default.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
test-framework/common/src/main/java/io/quarkus/test/common/TestResourceScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.quarkus.test.common; | ||
|
||
/** | ||
* Defines how Quarkus behaves with regard to the application of the resource to this test and the testsuite in general | ||
*/ | ||
public enum TestResourceScope { | ||
|
||
/* | ||
* The declaration order must be from the narrowest scope to the widest | ||
*/ | ||
|
||
/** | ||
* Means that Quarkus will run the test in complete isolation, i.e. it will restart every time it finds such a resource | ||
*/ | ||
RESTRICTED_TO_CLASS, | ||
/** | ||
* Means that Quarkus will not restart when running consecutive tests that use the same resource | ||
*/ | ||
MATCHING_RESOURCE, | ||
|
||
/** | ||
* Means the resource applies to all tests in the testsuite | ||
*/ | ||
GLOBAL | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...-framework/common/src/test/java/io/quarkus/test/common/TestResourceManagerReloadTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package io.quarkus.test.common; | ||
|
||
import static io.quarkus.test.common.TestResourceManager.testResourcesRequireReload; | ||
import static io.quarkus.test.common.TestResourceScope.*; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.common.TestResourceManager.TestResourceComparisonInfo; | ||
|
||
public class TestResourceManagerReloadTest { | ||
|
||
@Test | ||
public void emptyResources() { | ||
assertFalse(testResourcesRequireReload(Collections.emptySet(), Set.of())); | ||
} | ||
|
||
@Test | ||
public void differentCount() { | ||
assertTrue(testResourcesRequireReload(Collections.emptySet(), | ||
Set.of(new TestResourceComparisonInfo("test", RESTRICTED_TO_CLASS)))); | ||
|
||
assertTrue(testResourcesRequireReload(Set.of(new TestResourceComparisonInfo("test", RESTRICTED_TO_CLASS)), | ||
Collections.emptySet())); | ||
} | ||
|
||
@Test | ||
public void sameSingleRestrictedToClassResource() { | ||
assertTrue(testResourcesRequireReload( | ||
Set.of(new TestResourceComparisonInfo("test", RESTRICTED_TO_CLASS)), | ||
Set.of(new TestResourceComparisonInfo("test", RESTRICTED_TO_CLASS)))); | ||
} | ||
|
||
@Test | ||
public void sameSingleMatchingResource() { | ||
assertFalse(testResourcesRequireReload( | ||
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)), | ||
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)))); | ||
} | ||
|
||
@Test | ||
public void differentSingleMatchingResource() { | ||
assertTrue(testResourcesRequireReload( | ||
Set.of(new TestResourceComparisonInfo("test", MATCHING_RESOURCE)), | ||
Set.of(new TestResourceComparisonInfo("test2", MATCHING_RESOURCE)))); | ||
} | ||
|
||
@Test | ||
public void sameMultipleMatchingResource() { | ||
assertFalse(testResourcesRequireReload( | ||
Set.of( | ||
new TestResourceComparisonInfo("test", MATCHING_RESOURCE), | ||
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), | ||
new TestResourceComparisonInfo("test3", GLOBAL)), | ||
Set.of(new TestResourceComparisonInfo("test3", GLOBAL), | ||
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), | ||
new TestResourceComparisonInfo("test", MATCHING_RESOURCE)))); | ||
} | ||
|
||
@Test | ||
public void differentMultipleMatchingResource() { | ||
assertTrue(testResourcesRequireReload( | ||
Set.of( | ||
new TestResourceComparisonInfo("test", MATCHING_RESOURCE), | ||
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), | ||
new TestResourceComparisonInfo("test3", GLOBAL)), | ||
Set.of(new TestResourceComparisonInfo("test3", GLOBAL), | ||
new TestResourceComparisonInfo("test2", MATCHING_RESOURCE), | ||
new TestResourceComparisonInfo("TEST", MATCHING_RESOURCE)))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.