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

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

Introduction

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

Prototype

public void setQueryString(@Nullable String queryString) 

Source Link

Usage

From source file:fi.okm.mpass.shibboleth.authn.impl.BaseInitializeWilmaContextTest.java

/**
 * Initializes the servlet request.//  w ww  .  j av  a2  s .  c o  m
 * @return
 */
protected MockHttpServletRequest initializeServletRequest() {
    final MockHttpServletRequest servletRequest = new MockHttpServletRequest();
    servletRequest.setScheme("https");
    servletRequest.setServerName("mock-proxy.mpass.id");
    servletRequest.setServerPort(443);
    servletRequest.setRequestURI("/idp/profile/SAML2/Redirect/SSO");
    servletRequest.setQueryString("execution=e1s1");
    return servletRequest;
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithParamsCas() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);//w  w  w .j  a  v  a 2 s  .com
    request.setQueryString("service=this&ticket=that&custom=custom");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com",
            Protocol.CAS3.getServiceParameterName(), Protocol.CAS3.getArtifactParameterName(), false);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl);
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithParamsSaml() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);/*from  w w  w  .  j a va2 s .  c  o  m*/
    request.setQueryString("TARGET=this&SAMLart=that&custom=custom");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com",
            Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), false);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl);
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithEncodedParamsSaml() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);//from   w ww.j  av  a  2s.com
    request.setQueryString("TARGET%3Dthis%26SAMLart%3Dthat%26custom%3Dcustom");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com",
            Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), false);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl);
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithNoServiceParametersPassed() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);/*from  w  w  w .ja  v  a2s  .c  o m*/
    request.setQueryString("TARGET=Test1&service=Test2&custom=custom");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com",
            Protocol.SAML11.getArtifactParameterName(), true);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl);
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithParamsCasAndServerNameWithSchema() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);/*from  www . ja  v  a  2  s  .c  om*/
    request.setQueryString("service=this&ticket=that&custom=custom");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null,
            "https://www.myserver.com", Protocol.CAS3.getServiceParameterName(),
            Protocol.CAS3.getArtifactParameterName(), false);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom", constructedUrl);
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithEncodedParams2Saml() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);//from   w  w  w .j ava2 s.c  om
    request.setQueryString("TARGET%3Dthis%26SAMLart%3Dthat%26custom%3Dcustom%20value%20here%26another%3Dgood");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com",
            Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), true);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom+value+here&another=good",
            constructedUrl);
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithoutEncodedParamsSamlAndNoEncoding() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);//  ww  w . ja va 2 s  . c  o  m
    request.setQueryString("TARGET=this&SAMLart=that&custom=custom value here&another=good");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com",
            Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), false);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom value here&another=good",
            constructedUrl);
}

From source file:org.jasig.cas.client.util.CommonUtilsTests.java

public void testConstructServiceUrlWithEncodedParamsSamlAndNoEncoding() {
    final String CONST_MY_URL = "https://www.myserver.com/hello/hithere/";
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hello/hithere/");
    request.setScheme("https");
    request.setSecure(true);/*from   w  ww  .  ja v  a 2  s.  c om*/
    request.setQueryString("TARGET=this&SAMLart=that&custom=custom+value+here&another=good");

    final MockHttpServletResponse response = new MockHttpServletResponse();
    final String constructedUrl = CommonUtils.constructServiceUrl(request, response, null, "www.myserver.com",
            Protocol.SAML11.getServiceParameterName(), Protocol.SAML11.getArtifactParameterName(), true);

    assertEquals("https://www.myserver.com/hello/hithere/?custom=custom+value+here&another=good",
            constructedUrl);
}

From source file:com.tasktop.c2c.server.common.service.tests.ajp.AjpProtocolTest.java

@Test
public void testGet() throws IOException {
    Payload payload = new Payload(HttpServletResponse.SC_OK, "some content\none two three\n\nfour");
    payload.getResponseHeaders().put("foo", "bar");
    TestServlet.setResponsePayload(payload);

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setMethod("GET");
    request.setRequestURI("/test");
    request.setQueryString("a=b");
    request.setParameter("a", new String[] { "b" });
    request.addHeader("c", "d ef");
    MockHttpServletResponse response = new MockHttpServletResponse();
    protocol.forward(request, response);

    assertRequestIsExpected(request, TestServlet.getLastRequest());
    assertResponseIsExpected(payload, response);
}