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.
Add Reactive Routes support to @TestHTTPEndpoint
- Loading branch information
1 parent
bc68117
commit fddd2e1
Showing
5 changed files
with
45 additions
and
6 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
36 changes: 36 additions & 0 deletions
36
...eb/runtime/src/main/java/io/quarkus/vertx/web/runtime/ReactiveRoutesTestHttpProvider.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,36 @@ | ||
package io.quarkus.vertx.web.runtime; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.function.Function; | ||
|
||
import io.quarkus.runtime.test.TestHttpEndpointProvider; | ||
import io.quarkus.vertx.web.RouteBase; | ||
|
||
public class ReactiveRoutesTestHttpProvider implements TestHttpEndpointProvider { | ||
@Override | ||
public Function<Class<?>, String> endpointProvider() { | ||
return new Function<Class<?>, String>() { | ||
@Override | ||
public String apply(Class<?> aClass) { | ||
String value = null; | ||
for (Annotation annotation : aClass.getAnnotations()) { | ||
if (annotation.annotationType().getName().equals(RouteBase.class.getName())) { | ||
try { | ||
value = (String) annotation.annotationType().getMethod("path").invoke(annotation); | ||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} | ||
if ((value == null) || value.isEmpty()) { | ||
return null; | ||
} | ||
if (!value.startsWith("/")) { | ||
value = "/" + value; | ||
} | ||
return value; | ||
} | ||
}; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ime/src/main/resources/META-INF/services/io.quarkus.runtime.test.TestHttpEndpointProvider
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 @@ | ||
io.quarkus.vertx.web.runtime.ReactiveRoutesTestHttpProvider |
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