UnsupportedOperationException while running a QuarkusUnitTest with DevServices
See original GitHub issueDescribe the bug
Having a test like the following:
package io.quarkus.registry.app.services;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import io.quarkus.test.QuarkusUnitTest;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
public class RegistryDescriptorMavenResourceTest {
@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addAsResource(new StringAsset("quarkus.registry.groupId=foo"), "application.properties"));
@Test
void should_use_custom_group_id() {
given()
.get("/maven/foo/quarkus-registry-descriptor/1.0-SNAPSHOT/quarkus-registry-descriptor-1.0-SNAPSHOT.json")
.then()
.statusCode(200)
.header(HttpHeaders.CONTENT_TYPE, containsString(MediaType.APPLICATION_JSON))
.body("descriptor.artifact", is("foo:quarkus-registry-descriptor::json:1.0-SNAPSHOT"),
"platforms.artifact", is("foo:quarkus-platforms::json:1.0-SNAPSHOT"));
}
}
The following error is thrown when trying to run the test:
Caused by: java.lang.UnsupportedOperationException
at io.quarkus.test.junit.RunningAppConfigResolver$1.unwrap(RunningAppConfigResolver.java:57)
at io.quarkus.runtime.configuration.ConfigUtils.isPropertyPresent(ConfigUtils.java:208)
at io.quarkus.datasource.deployment.spi.DevServicesDatasourceConfigurationHandlerBuildItem$2.test(DevServicesDatasourceConfigurationHandlerBuildItem.java:68)
at io.quarkus.datasource.deployment.spi.DevServicesDatasourceConfigurationHandlerBuildItem$2.test(DevServicesDatasourceConfigurationHandlerBuildItem.java:64)
at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.startDevDb(DevServicesDatasourceProcessor.java:234)
at io.quarkus.datasource.deployment.devservices.DevServicesDatasourceProcessor.launchDatabases(DevServicesDatasourceProcessor.java:114)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:820)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2442)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1476)
at java.base/java.lang.Thread.run(Thread.java:829)
at org.jboss.threads.JBossThread.run(JBossThread.java:501)
Expected behavior
The test would run
Actual behavior
Test fails with UnsupportedOperationException
How to Reproduce?
Run the test above with a project containing:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
Output of uname -a
or ver
Fedora 34
Output of java -version
11
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.1.1.Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
Maven 3.8.1
Additional information
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Dev Services Overview - Quarkus
When DevServices is enabled Quarkus will attempt to automatically configure and start Keycloak when running in Dev or Test mode and when Docker...
Read more >How to Fix the Unsupported Operation Exception in Java
UnsupportedOperationException is a Java runtime exception that occurs when an unsupported operation is requested but could not be performed.
Read more >java.lang.UnsupportedOperationException in jUnit when ...
1 Answer 1 ... The list you are trying to sort - Database.arrayList - is an unmodifiable list, ie. all the methods that...
Read more >Solved: java.lang.UnsupportedOperationException in Junit t...
Looks like these methods are not supported yet with the wcm.io mocking library (see [1]). I would raise a ticket there and ask...
Read more >How to Solve Java List UnsupportedOperationException?
The UnsupportedOperationException is one of the common exceptions that occur when we are working with some API of list implementation.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The module does though, QuarkusTest starts quarkus once and leaves it running, QuarkusUnitTest starts/stops each time.
Mix how? The test doesn’t have any
@QuarkusTest
afaik