You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by fp...@apache.org on 2020/01/20 09:40:19 UTC

[shiro] branch master updated: [SHIRO-735] Add tests

This is an automated email from the ASF dual-hosted git repository.

fpapon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shiro.git


The following commit(s) were added to refs/heads/master by this push:
     new 93142c5  [SHIRO-735] Add tests
     new 4329f2a  Merge pull request #196 from fpapon/ASYNC_TEST
93142c5 is described below

commit 93142c55d355b5df617ca383915284d0245335d3
Author: Francois Papon <fp...@apache.org>
AuthorDate: Mon Jan 20 09:59:50 2020 +0100

    [SHIRO-735] Add tests
---
 .../apache/shiro/samples/jaxrs/resources/HelloResource.java    | 10 ++++++++++
 .../org/apache/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 400f503..6ba4d64 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.GET;
 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 84899d7..f55d37d 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
@@ -37,6 +37,16 @@ public class ContainerIntegrationIT extends AbstractContainerIT {
     }
 
     @Test
+    void testNoAuthResourceAsync() {
+
+        get(getBaseUri() + "say/async")
+                .then()
+                .assertThat()
+                .statusCode(is(200)).and()
+                .body(equalTo("Hello!"))
+    }
+
+    @Test
     void testSecuredRequiresAuthentication() {
 
         get(getBaseUri() + "secure/RequiresAuthentication")