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.
Don't ignore Spring Rest controllers interfaces if contains errors
Related to quarkusio#43704
- Loading branch information
1 parent
c326bec
commit a7dd34c
Showing
13 changed files
with
203 additions
and
8 deletions.
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
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
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,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-common-spi-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-resteasy-common-deployment-spi</artifactId> | ||
<name>Quarkus - Resteasy - SPI - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-core-deployment</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.smallrye</groupId> | ||
<artifactId>jandex</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
33 changes: 33 additions & 0 deletions
33
...ain/java/io/quarkus/resteasy/common/deployment/EndpointValidationPredicatesBuildItem.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,33 @@ | ||
package io.quarkus.resteasy.common.deployment; | ||
|
||
import java.util.function.Predicate; | ||
|
||
import org.jboss.jandex.ClassInfo; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* A build item that provides a {@link Predicate} to detect and validate classes defining REST endpoints. | ||
* <p> | ||
* This can include resources in RESTEasy or controllers in the Spring ecosystem. | ||
* It acts as a Service Provider Interface (SPI) to allow customization of the validation logic for endpoint detection, | ||
* enabling integration with various frameworks or specific application needs. | ||
* </p> | ||
* | ||
* <p> | ||
* The {@link Predicate} evaluates {@link ClassInfo} instances to determine whether a class defines a REST endpoint | ||
* according to the provided logic. | ||
* </p> | ||
*/ | ||
public final class EndpointValidationPredicatesBuildItem extends MultiBuildItem { | ||
|
||
private final Predicate<ClassInfo> predicate; | ||
|
||
public EndpointValidationPredicatesBuildItem(Predicate<ClassInfo> predicate) { | ||
this.predicate = predicate; | ||
} | ||
|
||
public Predicate<ClassInfo> getPredicate() { | ||
return predicate; | ||
} | ||
} |
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,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>quarkus-extensions-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-resteasy-common-spi-parent</artifactId> | ||
<name>Quarkus - RESTEasy Common SPI - Parent</name> | ||
<description>This module provides reusable abstraction for use with both RESTEasy Classic and Quarkus REST (formerly RESTEasy Reactive)</description> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>deployment-spi</module> | ||
</modules> | ||
|
||
</project> |
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
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
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
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
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
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
48 changes: 48 additions & 0 deletions
48
...arkus/spring/web/resteasy/reactive/test/UnbuildableSpringRestControllerInterfaceTest.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,48 @@ | ||
package io.quarkus.spring.web.resteasy.reactive.test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.fail; | ||
|
||
import jakarta.ws.rs.QueryParam; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import io.quarkus.test.QuarkusProdModeTest; | ||
|
||
public class UnbuildableSpringRestControllerInterfaceTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusProdModeTest config = new QuarkusProdModeTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(UnbuildableControllerInterface.class)) | ||
.setApplicationName("unbuildable-rest-controller-interface") | ||
.setApplicationVersion("0.1-SNAPSHOT") | ||
.assertBuildException(throwable -> { | ||
assertThat(throwable).isInstanceOf(RuntimeException.class); | ||
assertThat(throwable).hasMessageContaining( | ||
"Cannot have more than one of @PathParam, @QueryParam, @HeaderParam, @FormParam, @CookieParam, @BeanParam, @Context on method"); | ||
}); | ||
|
||
@Test | ||
public void testBuildLogs() { | ||
fail("Should not be called"); | ||
} | ||
|
||
@RestController | ||
@RequestMapping("/unbuildable") | ||
public interface UnbuildableControllerInterface { | ||
@GetMapping("/ping") | ||
String ping(); | ||
|
||
@PostMapping("/hello") | ||
String hello(@RequestParam(required = false) @QueryParam("dung") String params); | ||
|
||
} | ||
|
||
} |
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