Coverage Report - org.webslinger.servlet.WrappedHttpServletRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
WrappedHttpServletRequest
36%
8/22
0%
0/1
1.5
 
 1  
 package org.webslinger.servlet;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.security.Principal;
 5  
 import javax.servlet.RequestDispatcher;
 6  
 import javax.servlet.http.HttpServletRequest;
 7  
 import javax.servlet.http.HttpServletRequestWrapper;
 8  
 
 9  
 public class WrappedHttpServletRequest extends HttpServletRequestWrapper {
 10  
     protected final FakeServletContext context;
 11  
     protected final FakeResource resource;
 12  
     protected final Principal user;
 13  
 
 14  
     public WrappedHttpServletRequest(FakeServletContext context, HttpServletRequest request, FakeResource resource) {
 15  531
         this(context, request, resource, null);
 16  531
     }
 17  
 
 18  
     public WrappedHttpServletRequest(FakeServletContext context, HttpServletRequest request, FakeResource resource, Principal user) {
 19  531
         super(request);
 20  531
         this.context = context;
 21  531
         this.resource = resource;
 22  531
         this.user = user;
 23  531
     }
 24  
 
 25  
     public FakeResource getFakeResource() {
 26  0
         return resource;
 27  
     }
 28  
 
 29  
     public RequestDispatcher getRequestDispatcher(String path) {
 30  
         try {
 31  0
             return context.getRequestDispatcher(context.resolveResource(resource, path));
 32  0
         } catch (IOException e) {
 33  0
             context.log(resource + ":getRequestDispatcher(" + path + ")", e);
 34  0
             return null;
 35  
         }
 36  
     }
 37  
 
 38  
     public String getContextPath() {
 39  102
         return ((HttpServletRequest) getRequest()).getContextPath();
 40  
     }
 41  
 
 42  
     public String getPathInfo() {
 43  0
         String pathInfo = getFakeResource().getPathInfo();
 44  0
         if (pathInfo.length() == 0) return null;
 45  0
         return pathInfo;
 46  
     }
 47  
 
 48  
     public String getPathTranslated() {
 49  0
         throw new UnsupportedOperationException();
 50  
     }
 51  
 
 52  
     public String getRequestURI() {
 53  0
         return getContextPath() + getServletPath() + getPathInfo();
 54  
     }
 55  
 
 56  
     public StringBuffer getRequestURL() {
 57  0
         throw new UnsupportedOperationException();
 58  
     }
 59  
 
 60  
     /** @deprecated */
 61  
     public String getServletPath() {
 62  0
         return getFakeResource().getServletPath();
 63  
     }
 64  
 
 65  
     public Principal getUserPrincipal() {
 66  0
         return user;
 67  
     }
 68  
 
 69  
     public boolean isUserInRole(String role) {
 70  0
         return context.isUserInRole(getUserPrincipal(), role);
 71  
     }
 72  
 }