From 93142c55d355b5df617ca383915284d0245335d3 Mon Sep 17 00:00:00 2001 From: Francois Papon Date: Mon, 20 Jan 2020 09:59:50 +0100 Subject: [PATCH] [SHIRO-735] Add tests --- .../shiro/samples/jaxrs/resources/HelloResource.java | 10 ++++++++++ .../shiro/web/jaxrs/ContainerIntegrationIT.groovy | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java b/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java index 400f5034e9..6ba4d64468 100644 --- a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java +++ b/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java @@ -24,6 +24,8 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import javax.ws.rs.container.AsyncResponse; +import javax.ws.rs.container.Suspended; @Path("say") public class HelloResource { @@ -34,4 +36,12 @@ public class HelloResource { public String saySomething(@QueryParam("words") @DefaultValue("Hello!") String words) { return words; } + + @Produces({"application/json","plain/text"}) + @GET + @Path("async") + public void saySomethingAsync(@QueryParam("words") @DefaultValue("Hello!") String words, + @Suspended AsyncResponse asyncResponse) { + asyncResponse.resume(words); + } } diff --git a/samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy b/samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy index 84899d7694..f55d37da5e 100644 --- a/samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy +++ b/samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy @@ -36,6 +36,16 @@ public class ContainerIntegrationIT extends AbstractContainerIT { .body(equalTo("Hello!")) } + @Test + void testNoAuthResourceAsync() { + + get(getBaseUri() + "say/async") + .then() + .assertThat() + .statusCode(is(200)).and() + .body(equalTo("Hello!")) + } + @Test void testSecuredRequiresAuthentication() {