forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent QuarkusTestResourceLifecycleManager from being run twice
This happened when the QuarkusTestResourceLifecycleManager was configured in a @QuarkusTestResource that was being used as a meta-annotation Fixes: quarkusio#16108
- Loading branch information
Showing
6 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
integration-tests/test-extension/src/test/java/io/quarkus/it/extension/Counter.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,9 @@ | ||
package io.quarkus.it.extension; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class Counter { | ||
|
||
public static final AtomicInteger startCounter = new AtomicInteger(0); | ||
public static final AtomicInteger endCounter = new AtomicInteger(0); | ||
} |
18 changes: 18 additions & 0 deletions
18
integration-tests/test-extension/src/test/java/io/quarkus/it/extension/CustomResource.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,18 @@ | ||
package io.quarkus.it.extension; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import javax.enterprise.inject.Stereotype; | ||
|
||
import io.quarkus.test.common.QuarkusTestResource; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@QuarkusTestResource(LifecycleManager.class) | ||
@Stereotype | ||
public @interface CustomResource { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
integration-tests/test-extension/src/test/java/io/quarkus/it/extension/EndTest.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,23 @@ | ||
package io.quarkus.it.extension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@CustomResource | ||
@QuarkusTest | ||
public class EndTest { | ||
|
||
@Test | ||
public void test1() { | ||
assertTrue(Counter.endCounter.get() <= 1); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
assertTrue(Counter.endCounter.get() <= 1); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
integration-tests/test-extension/src/test/java/io/quarkus/it/extension/LifecycleManager.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,21 @@ | ||
package io.quarkus.it.extension; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; | ||
|
||
public class LifecycleManager implements QuarkusTestResourceLifecycleManager { | ||
|
||
@Override | ||
public Map<String, String> start() { | ||
Counter.startCounter.incrementAndGet(); | ||
return Collections.emptyMap(); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
Counter.endCounter.incrementAndGet(); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
integration-tests/test-extension/src/test/java/io/quarkus/it/extension/StartTest.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,23 @@ | ||
package io.quarkus.it.extension; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@CustomResource | ||
@QuarkusTest | ||
public class StartTest { | ||
|
||
@Test | ||
public void test1() { | ||
assertTrue(Counter.startCounter.get() <= 1); | ||
} | ||
|
||
@Test | ||
public void test2() { | ||
assertTrue(Counter.startCounter.get() <= 1); | ||
} | ||
|
||
} |
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