SLING-6947 add setPathInfo method to allow setting a custom pathinfo

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1798814 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequest.java b/src/main/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequest.java
index 66c9f69..94a2ba6 100644
--- a/src/main/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequest.java
+++ b/src/main/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequest.java
@@ -89,6 +89,7 @@
     private String serverName = "localhost";
     private int serverPort = 80;
     private String servletPath = StringUtils.EMPTY;
+    private String pathInfo = null;
     private String method = HttpConstants.METHOD_GET;
     private final HeaderSupport headerSupport = new HeaderSupport();
     private final CookieSupport cookieSupport = new CookieSupport();
@@ -658,6 +659,10 @@
 
     @Override
     public String getPathInfo() {
+        if (this.pathInfo != null) {
+            return this.pathInfo; 
+        }
+        
         RequestPathInfo requestPathInfo = this.getRequestPathInfo();
 
         if (StringUtils.isEmpty(requestPathInfo.getResourcePath())) {
@@ -684,6 +689,10 @@
 
         return pathInfo.toString();
     }
+    
+    public void setPathInfo(String pathInfo) {
+        this.pathInfo = pathInfo;
+    }
 
     @Override
     public String getRequestURI() {
diff --git a/src/main/java/org/apache/sling/servlethelpers/package-info.java b/src/main/java/org/apache/sling/servlethelpers/package-info.java
index 7e1c68d..e8477bd 100644
--- a/src/main/java/org/apache/sling/servlethelpers/package-info.java
+++ b/src/main/java/org/apache/sling/servlethelpers/package-info.java
@@ -19,5 +19,5 @@
 /**
  * Mock implementation of selected Servlet-related Sling APIs.
  */
-@org.osgi.annotation.versioning.Version("1.1")
+@org.osgi.annotation.versioning.Version("1.2")
 package org.apache.sling.servlethelpers;
diff --git a/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequestTest.java b/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequestTest.java
index e1bd3b6..26e5f51 100644
--- a/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequestTest.java
+++ b/src/test/java/org/apache/sling/servlethelpers/MockSlingHttpServletRequestTest.java
@@ -387,4 +387,21 @@
         assertEquals(1234, request.getRemotePort());
     }
 
+    @Test
+    public void testServletPathWithPathInfo() throws Exception {
+        request.setServletPath("/my/path");
+        request.setPathInfo("/myinfo");;
+
+        assertEquals("/my/path", request.getServletPath());
+        assertEquals("/myinfo", request.getPathInfo());
+    }
+
+    @Test
+    public void testServletPathWithOutPathInfo() throws Exception {
+        request.setServletPath("/my/path");
+
+        assertEquals("/my/path", request.getServletPath());
+        assertNull(request.getPathInfo());
+    }
+
 }