urlpathhelpertests.java

来自「spring,z几 塞积极 决撒 积极上经济歼击机就 将计就计经济年毫毫毫毫毫毫」· Java 代码 · 共 33 行

JAVA
33
字号
package org.springframework.web.util;

import junit.framework.TestCase;

import org.springframework.mock.web.MockHttpServletRequest;

/**
 * @author Rob Harrop
 */
public class UrlPathHelperTests extends TestCase {

	public void testGetPathWithinApplication() {
		UrlPathHelper helper = new UrlPathHelper();

		MockHttpServletRequest request = new MockHttpServletRequest();
		request.setContextPath("/petclinic");
		request.setRequestURI("/petclinic/welcome.html");

		assertEquals("Incorrect path returned", "/welcome.html", helper.getPathWithinApplication(request));
	}

	public void testGetPathWithinApplicationForRootWithNoLeadingSlash() {
		UrlPathHelper helper = new UrlPathHelper();

		MockHttpServletRequest request = new MockHttpServletRequest();
		request.setContextPath("/petclinic");
		request.setRequestURI("/petclinic");

		assertEquals("Incorrect root path returned", "/", helper.getPathWithinApplication(request));
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?