|
From: <ath...@us...> - 2014-03-26 15:55:02
|
Revision: 1586
http://sourceforge.net/p/webassembletool/code/1586
Author: athaveau
Date: 2014-03-26 15:54:59 +0000 (Wed, 26 Mar 2014)
Log Message:
-----------
#289 : new parameter stripMappingPath to perform the mapping path removal
Added Paths:
-----------
trunk/esigate-servlet/src/test/java/org/esigate/servlet/impl/RequestUrlTest.java
Added: trunk/esigate-servlet/src/test/java/org/esigate/servlet/impl/RequestUrlTest.java
===================================================================
--- trunk/esigate-servlet/src/test/java/org/esigate/servlet/impl/RequestUrlTest.java (rev 0)
+++ trunk/esigate-servlet/src/test/java/org/esigate/servlet/impl/RequestUrlTest.java 2014-03-26 15:54:59 UTC (rev 1586)
@@ -0,0 +1,45 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.esigate.servlet.impl;
+
+import junit.framework.TestCase;
+import org.esigate.impl.UriMapping;
+import org.mockito.Mockito;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author Alexis Thaveau.
+ */
+public class RequestUrlTest extends TestCase {
+ public void testGetRelativeUrl() throws Exception {
+ HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
+ Mockito.when(request.getContextPath()).thenReturn("/context");
+ Mockito.when(request.getServletPath()).thenReturn("/servlet");
+ Mockito.when(request.getRequestURI()).thenReturn("/context/servlet/resource");
+ assertEquals("/servlet/resource",RequestUrl.getRelativeUrl(request,false));
+ assertEquals("/resource",RequestUrl.getRelativeUrl(request,true));
+ }
+
+ public void testStripMappingPath() throws Exception {
+ UriMapping mapping = UriMapping.create("/url/to/resource");
+ String relUrl = RequestUrl.stripMappingPath("/mapping/path/test", mapping);
+ assertEquals("/mapping/path/test", relUrl);
+
+ mapping = UriMapping.create("/mapping/path/test");
+ relUrl = RequestUrl.stripMappingPath("/mapping/path/test/url/to/resource",mapping);
+ assertEquals("/url/to/resource", relUrl);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|