mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
added unit test for HttpUtil.getCompleteUrl
This commit is contained in:
@@ -87,4 +87,30 @@ public class HttpUtilTest
|
||||
config.setBaseUrl("http://www.scm-manager.org:8080");
|
||||
assertTrue(HttpUtil.getServerPort(config, request) == 8080);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void getStrippedURITest()
|
||||
{
|
||||
HttpServletRequest request = mock(HttpServletRequest.class);
|
||||
|
||||
when(request.getRequestURI()).thenReturn("/scm/test/path");
|
||||
when(request.getContextPath()).thenReturn("/scm");
|
||||
assertEquals("/test/path",
|
||||
HttpUtil.getStrippedURI(request, "/scm/test/path"));
|
||||
assertEquals("/test/path", HttpUtil.getStrippedURI(request));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getCompleteUrlTest()
|
||||
{
|
||||
ScmConfiguration config = new ScmConfiguration();
|
||||
config.setBaseUrl("http://www.scm-manager.org/scm");
|
||||
|
||||
assertEquals("http://www.scm-manager.org/scm/test/path", HttpUtil.getCompleteUrl(config, "test/path"));
|
||||
assertEquals("http://www.scm-manager.org/scm/test/path", HttpUtil.getCompleteUrl(config, "/test/path"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user