'Did Quarkus 2.7.1.Final remove support for annotations?
Did Quarkus 2.7.1.Final remove support for annotations? Following code does not work, but worked in Quarkus 1.11. Code below.
Any suggestions/pointers are appreciated. Thanks
GreetingResource.java:
@Path("/hello")
public class GreetingResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
if (isGramMessageHandlerFound()){
return "Hello - GramMessageHandler method found!";
} else {
return "Sorry - no GramMessageHandler method found!";
}
}
@GramMessageHandler(type="firstGramMessageHandler")
void firstGramMessageHandler()
{
}
@GramMessageHandler(type="secondGramMessageHandler")
void secondGramMessageHandler()
{
}
boolean isGramMessageHandlerFound()
{
final Method[] methods = getClass().getMethods();
for (final Method method : methods) {
final GramMessageHandler gramMessageHandler = method.getAnnotation(GramMessageHandler.class);
if (gramMessageHandler != null){
return true;
}
}
return false;
}
}
And the annotation: GramMessageHandler.java:
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface GramMessageHandler
{
String type() default "java.lang.String";
}
GreetingResourceTest.java
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
@QuarkusTest
public class GreetingResourceTest {
@Test
public void testHelloEndpoint() {
given()
.when().get("/hello")
.then()
.statusCode(200)
.body(is("Hello - GramMessageHandler method found!"));
}
}
Running mvn clean test results in:
[ERROR] GreetingResourceTest.testHelloEndpoint:18 1 expectation failed.
Response body doesn't match expectation.
Expected: is "Hello - GramMessageHandler method found!"
Actual: Sorry - no GramMessageHandler method found!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
