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.
Testing: add reproducers for testing bugs
- Loading branch information
Showing
9 changed files
with
269 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
integration-tests/kotlin/src/test/kotlin/io/quarkus/it/testing/repro34099/Repro34099Test.kt
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.testing.repro34099 | ||
|
||
import io.quarkus.test.junit.QuarkusTest | ||
import java.time.Duration | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Disabled | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertTimeout | ||
|
||
@QuarkusTest | ||
class Repro34099Test { | ||
@Test | ||
fun javaAssertion() { | ||
Assertions.assertTimeout(Duration.ofSeconds(1)) {} | ||
} | ||
|
||
@Test | ||
@Disabled("https://github.com/quarkusio/quarkus/issues/34099") | ||
// fails with `Linkage loader constraint violation` | ||
fun kotlinAssertion() { | ||
assertTimeout(Duration.ofSeconds(1)) {} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
integration-tests/kotlin/src/test/kotlin/io/quarkus/it/testing/repro42000/Repro42000Test.kt
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,42 @@ | ||
package io.quarkus.it.testing.repro42000 | ||
|
||
import io.quarkus.test.junit.QuarkusTest | ||
import java.util.stream.Stream | ||
import org.junit.jupiter.api.Assertions.assertNotNull | ||
import org.junit.jupiter.api.Disabled | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.Arguments | ||
import org.junit.jupiter.params.provider.MethodSource | ||
|
||
@QuarkusTest | ||
class Repro42000Test { | ||
companion object { | ||
val lambda: (String) -> String = { s -> s } | ||
|
||
fun function(s: String) = s | ||
|
||
@JvmStatic | ||
fun lambdaProvider(): Stream<Arguments> { | ||
return Stream.of(Arguments.of(lambda)) | ||
} | ||
|
||
@JvmStatic | ||
fun functionProvider(): Stream<Arguments> { | ||
return Stream.of(Arguments.of(::function)) | ||
} | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("lambdaProvider") | ||
@Disabled("https://github.com/quarkusio/quarkus/issues/42000") | ||
// fails with `IllegalArgumentException: argument type mismatch` | ||
fun testLambdaProvider(function: (String) -> String) { | ||
assertNotNull(function) | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("functionProvider") | ||
fun testFunctionProvider(function: (String) -> String) { | ||
assertNotNull(function) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
integration-tests/main/src/main/java/io/quarkus/it/testing/repro44320/MyService.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,17 @@ | ||
package io.quarkus.it.testing.repro44320; | ||
|
||
import java.util.Set; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import io.quarkus.arc.Unremovable; | ||
import io.quarkus.runtime.Startup; | ||
|
||
@ApplicationScoped | ||
@Startup | ||
@Unremovable | ||
public class MyService { | ||
public Set<String> get() { | ||
return Set.of("a", "b", "c"); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ration-tests/main/src/test/java/io/quarkus/it/main/testing/repro13261/Repro13261Test.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,24 @@ | ||
package io.quarkus.it.main.testing.repro13261; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.io.TempDir; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@Disabled("https://github.com/quarkusio/quarkus/issues/13261") | ||
// fails with `expected: not <null>` | ||
@QuarkusTest | ||
public class Repro13261Test { | ||
@TempDir | ||
Path tempDir; | ||
|
||
@Test | ||
public void test() { | ||
assertNotNull(tempDir); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ration-tests/main/src/test/java/io/quarkus/it/main/testing/repro42006/Repro42006Test.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,43 @@ | ||
package io.quarkus.it.main.testing.repro42006; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.io.Serializable; | ||
import java.util.function.Supplier; | ||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.ArgumentsProvider; | ||
import org.junit.jupiter.params.provider.ArgumentsSource; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@Disabled("https://github.com/quarkusio/quarkus/issues/42006") | ||
// fails with `java.lang.ClassNotFoundException: io.quarkus.it.main.testing.repro42006.Repro42006Test$LambdaProvider$$Lambda$4007/0x000075d5017e8450` | ||
@QuarkusTest | ||
public class Repro42006Test { | ||
@ParameterizedTest | ||
@ArgumentsSource(LambdaProvider.class) | ||
void test(String type, Object lambda) { | ||
assertTrue(lambda.toString().contains("$$Lambda"), "Failed on " + type); | ||
} | ||
|
||
private static class LambdaProvider implements ArgumentsProvider { | ||
@Override | ||
public Stream<? extends Arguments> provideArguments(ExtensionContext context) { | ||
return Stream.of( | ||
Arguments.of("SerializableSupplier", (SerializableSupplier) () -> "foo"), | ||
Arguments.of("SerializableCustom", (SerializableCustom) () -> "bar")); | ||
} | ||
} | ||
|
||
public interface SerializableSupplier extends Supplier<String>, Serializable { | ||
} | ||
|
||
public interface SerializableCustom extends Serializable { | ||
String get(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ration-tests/main/src/test/java/io/quarkus/it/main/testing/repro44320/Repro44320Test.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,43 @@ | ||
package io.quarkus.it.main.testing.repro44320; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import io.quarkus.it.testing.repro44320.MyService; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@Disabled("https://github.com/quarkusio/quarkus/issues/44320") | ||
// fails with `You must configure at least one set of arguments for this @ParameterizedTest`, because the `set` is empty | ||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@QuarkusTest | ||
public class Repro44320Test { | ||
private static Set<String> set = new HashSet<>(); | ||
|
||
@Inject | ||
MyService service; | ||
|
||
@BeforeAll | ||
public void beforeAllTests() { | ||
set = service.get(); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("getData") | ||
public void test(String key) { | ||
assertNotNull(key); | ||
} | ||
|
||
public Set<String> getData() { | ||
return set; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
integration-tests/main/src/test/java/io/quarkus/it/main/testing/repro8446/Greeter.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,5 @@ | ||
package io.quarkus.it.main.testing.repro8446; | ||
|
||
public interface Greeter { | ||
String hello(); | ||
} |
52 changes: 52 additions & 0 deletions
52
...ation-tests/main/src/test/java/io/quarkus/it/main/testing/repro8446/GreeterExtension.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,52 @@ | ||
package io.quarkus.it.main.testing.repro8446; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
import org.junit.jupiter.api.extension.Extension; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.junit.jupiter.api.extension.ParameterContext; | ||
import org.junit.jupiter.api.extension.ParameterResolutionException; | ||
import org.junit.jupiter.api.extension.ParameterResolver; | ||
import org.junit.jupiter.api.extension.TestTemplateInvocationContext; | ||
import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; | ||
|
||
public class GreeterExtension implements TestTemplateInvocationContextProvider { | ||
@Override | ||
public boolean supportsTestTemplate(ExtensionContext context) { | ||
return context.getTestMethod().map(method -> { | ||
return Arrays.asList(method.getParameterTypes()).contains(Greeter.class); | ||
}).orElse(false); | ||
} | ||
|
||
@Override | ||
public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContexts(ExtensionContext context) { | ||
return Stream.of(new HelloTestTemplateInvocationContext(() -> "hello")); | ||
} | ||
|
||
private static class HelloTestTemplateInvocationContext implements TestTemplateInvocationContext, ParameterResolver { | ||
private final Greeter greeter; | ||
|
||
public HelloTestTemplateInvocationContext(Greeter greeter) { | ||
this.greeter = greeter; | ||
} | ||
|
||
@Override | ||
public List<Extension> getAdditionalExtensions() { | ||
return Collections.singletonList(this); | ||
} | ||
|
||
@Override | ||
public boolean supportsParameter(ParameterContext pc, ExtensionContext extensionContext) | ||
throws ParameterResolutionException { | ||
return pc.getParameter().getType() == Greeter.class; | ||
} | ||
|
||
@Override | ||
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) { | ||
return greeter; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
integration-tests/main/src/test/java/io/quarkus/it/main/testing/repro8446/Repro8446Test.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,20 @@ | ||
package io.quarkus.it.main.testing.repro8446; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.TestTemplate; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@Disabled("https://github.com/quarkusio/quarkus/issues/8446") | ||
// fails with `IllegalArgumentException: argument type mismatch` | ||
@QuarkusTest | ||
public class Repro8446Test { | ||
@TestTemplate | ||
@ExtendWith(GreeterExtension.class) | ||
public void test(Greeter greeter) { | ||
assertEquals("hello", greeter.hello()); | ||
} | ||
} |