mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
added unit test for HttpUtil.getServerPortTest
This commit is contained in:
@@ -37,8 +37,16 @@ package sonia.scm.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import sonia.scm.config.ScmConfiguration;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -61,4 +69,22 @@ public class HttpUtilTest
|
||||
HttpUtil.getPortFromUrl("http://www.scm-manager.org:8181/test/folder")
|
||||
== 8181);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void getServerPortTest()
|
||||
{
|
||||
HttpServletRequest request = mock(HttpServletRequest.class);
|
||||
|
||||
when(request.getServerPort()).thenReturn(443);
|
||||
|
||||
ScmConfiguration config = new ScmConfiguration();
|
||||
|
||||
assertTrue(HttpUtil.getServerPort(config, request) == 443);
|
||||
config.setBaseUrl("http://www.scm-manager.org:8080");
|
||||
assertTrue(HttpUtil.getServerPort(config, request) == 8080);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user