-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClassCastException at running JUnit-Test with Annocation @QuarkusTest #21031
Comments
/cc @evanchooly |
Does the same thing happen if you convert the code to Java? |
Hi, I transformed the test into java:
and got another error:
|
Do you have a reproducer? |
I have the same exception for type private static final Predicate<Resource<?>> EXIST = IngressControllerTest::checkExists;
private static final BiPredicate<HasMetadata, Resource<? extends HasMetadata>> OWNER = IngressControllerTest::checkOwner;
private static final BiPredicate<HasMetadata, Resource<? extends HasMetadata>> NEW = OWNER.and(wrap(EXIST));
private static <T> BiPredicate<HasMetadata, T> wrap(Predicate<T> resourcePredicate) {
return (i, o) -> resourcePredicate.test(o);
}
|
This is a known issue with parameterised tests. Because JUnit does not directly have support alternate class loaders we have to basically proxy the requests into a new class loader, so for parameterized tests we attempt to clone the parameters into the new class loader, which is not always possible. If junit-team/junit5#2579 is resolved we should be able to fix this. |
If somebody will face the same issue with instead of private static Stream<Arguments> testCreate() {
return Stream.of(
Arguments.of(getIngress(NAME_ISTIO, TEST_NAMESPACE, true), NEW, NEW),
Arguments.of(getIngress(NAME_ISTIO, TEST_NAMESPACE, true), NEW_GW, NEW));
}
@ParameterizedTest
@MethodSource
@DisplayName("Should create Istio GW and VS for provided ingress")
void testCreate(Ingress testIngress, BiPredicate<? super Ingress, ? super Gateway> testGatevay, BiPredicate<? super Ingress, ? super VirtualService> testVirtualService) {
//test body
} I use the @Getter
@AllArgsConstructor
private static enum Params {
SET01(getIngress(NAME_ISTIO, TEST_NAMESPACE, true), NEW, NEW),
SET02(getIngress(NAME_ISTIO, TEST_NAMESPACE, true), NEW_GW, NEW),
;
private Ingress testIngress;
private BiPredicate<? super Ingress, ? super Gateway> testGatevay;
private BiPredicate<? super Ingress, ? super VirtualService> testVirtualService;
}
@ParameterizedTest
@EnumSource
@DisplayName("Should create Istio GW and VS for provided ingress")
void testCreate(Params testData) {
var testIngressIstio = testData.getTestIngress();
var testGatevay = testData.getTestGatevay();
var testVirtualService = testData.getTestVirtualService();
//test body
} |
There is a chance this has since been addressed. Can someone let us know if this is still an issue or not? Thanks |
Closing for lack of feedback |
Describe the bug
I have a junit parameterized test (written in Kotlin) that is annotated as a @QuarkusTest. My IDE can compile my test, but at the runtime i get a ClassCastException:
java.lang.ClassCastException: class io.restassured.internal.ValidatableResponseImpl cannot be cast to class io.restassured.response.ValidatableResponse (io.restassured.internal.ValidatableResponseImpl is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @74960bfa; io.restassured.response.ValidatableResponse is in unnamed module of loader 'app')
My Test Class:
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.2.3.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)apache maven 3.8.1
Additional information
No response
The text was updated successfully, but these errors were encountered: