-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QuarkusComponentTest: support repeated tests
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
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
46 changes: 46 additions & 0 deletions
46
...t/src/test/java/io/quarkus/test/component/paraminject/ParameterInjectionRepeatedTest.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,46 @@ | ||
package io.quarkus.test.component.paraminject; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import jakarta.annotation.PreDestroy; | ||
import jakarta.enterprise.context.Dependent; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.RepeatedTest; | ||
import org.junit.jupiter.api.RepetitionInfo; | ||
|
||
import io.quarkus.test.component.QuarkusComponentTest; | ||
|
||
@QuarkusComponentTest | ||
public class ParameterInjectionRepeatedTest { | ||
@RepeatedTest(10) | ||
public void testParamsInjection( | ||
// component under test | ||
Converter converter, | ||
// ignored automatically, no need for `@SkipInject` | ||
RepetitionInfo info) { | ||
assertEquals(10, info.getTotalRepetitions()); | ||
assertEquals("FOOBAR", converter.convert("fooBar")); | ||
} | ||
|
||
@AfterAll | ||
public static void afterAll() { | ||
assertEquals(10, Converter.DESTROYED.get()); | ||
} | ||
|
||
@Dependent | ||
public static class Converter { | ||
static final AtomicInteger DESTROYED = new AtomicInteger(); | ||
|
||
String convert(String param) { | ||
return param.toUpperCase(); | ||
} | ||
|
||
@PreDestroy | ||
void destroy() { | ||
DESTROYED.incrementAndGet(); | ||
} | ||
} | ||
} |