Skip to content

[Gradle] ServiceLoader issues in test cases #9017

@roguexz

Description

@roguexz

Describe the bug
If a test case pulls in a library that provides a SPI for a service used by Quarkus test configuration (e.g., FileSystemProvider), then the test cases fail during boot time with a ClassCastException due to the classloader separation introduced in 1.3

Consider the following scenario,

  • In order to setup a mock SSH server, the project declares a test dependency on org.apache.sshd:sshd-sftp
  • This library provides an implementation for a virtual file system, SftpFileSystemProvider
  • In the project you define a QuarkusTestResource for configuring the mock SSH server
  • When you run the test case, it fails with a ClassCastException during boot time.

Expected behavior
The mock SSH server should have started up properly.

Actual behavior
We observe a ClassCastException instead.

To Reproduce
Steps to reproduce the behavior:

  1. Clone the quarkus-sample repository
  2. Run ./gradlew clean build

Configuration

N/A

Screenshots
N/A

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin LM-SJN-40002334 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64
  • Output of java -version: openjdk version "1.8.0_232"
  • GraalVM version (if different from Java): N/A
  • Quarkus version or git rev: 1.4.1.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): Gradle 6.3

Additional context
N/A

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions