Example usage for org.springframework.mock.web MockHttpServletRequest getServerName

List of usage examples for org.springframework.mock.web MockHttpServletRequest getServerName

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletRequest getServerName.

Prototype

@Override
    public String getServerName() 

Source Link

Usage

From source file:org.cateproject.test.functional.mockmvc.HtmlUnitRequestBuilder.java

private com.gargoylesoftware.htmlunit.util.Cookie createCookie(MockHttpServletRequest request,
        String sessionid) {//ww w  .j av a  2 s . c o  m
    return new com.gargoylesoftware.htmlunit.util.Cookie(request.getServerName(), "JSESSIONID", sessionid,
            request.getContextPath() + "/", null, request.isSecure(), true);
}

From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTest.java

@Test
public void buildRequestServerName() throws Exception {
    MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);

    assertThat(actualRequest.getServerName()).isEqualTo("example.com");
}

From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTests.java

@Test
public void buildRequestServerName() throws Exception {
    MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);

    assertThat(actualRequest.getServerName(), equalTo("example.com"));
}

From source file:org.osaf.cosmo.BaseMockServletTestCase.java

/**
 *//*  www.  jav a  2 s. c om*/
protected MockHttpServletRequest createMockRequest(String method, String pathInfo) {
    MockHttpServletRequest request = new MockHttpServletRequest(servletContext, method,
            getServletPath() + pathInfo);
    request.setServletPath(getServletPath());
    request.setPathInfo(pathInfo);
    request.addHeader("Host", request.getServerName() + ":" + request.getServerPort());
    return request;
}

From source file:org.osaf.cosmo.BaseMockServletTestCase.java

/** */
protected String toAbsoluteUrl(MockHttpServletRequest request, String path) {
    StringBuffer url = new StringBuffer(request.getScheme());
    url.append("://").append(request.getServerName());
    if ((request.isSecure() && request.getServerPort() != 443) || (request.getServerPort() != 80)) {
        url.append(":").append(request.getServerPort());
    }/*from w ww . ja v  a 2 s. c o  m*/
    if (!request.getContextPath().equals("/")) {
        url.append(request.getContextPath());
    }
    url.append(path);
    return url.toString();
}