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

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

Introduction

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

Prototype

public MockHttpServletRequest() 

Source Link

Document

Create a new MockHttpServletRequest with a default MockServletContext .

Usage

From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.ConceptDescriptionControllerTest.java

@Before
public void before() throws Exception {
    this.service = Context.getConceptService();
    this.controller = new ConceptDescriptionController();
    this.request = new MockHttpServletRequest();
    this.response = new MockHttpServletResponse();
}

From source file:org.synyx.hades.extensions.web.PageableArgumentResolverUnitTest.java

@Before
public void setUp() throws SecurityException, NoSuchMethodException {

    correctMethod = SampleController.class.getMethod("correctMethod", Pageable.class, Pageable.class);
    failedMethod = SampleController.class.getMethod("failedMethod", Pageable.class, Pageable.class);
    invalidQualifiers = SampleController.class.getMethod("invalidQualifiers", Pageable.class, Pageable.class);

    defaultsMethod = SampleController.class.getMethod("defaultsMethod", Pageable.class);

    request = new MockHttpServletRequest();

    // Add pagination info for foo table
    request.addParameter("foo_page.size", "50");
    request.addParameter("foo_page.sort", "foo");
    request.addParameter("foo_page.sort.dir", "asc");

    // Add pagination info for bar table
    request.addParameter("bar_page.size", "60");
}

From source file:fi.okm.mpass.idp.authn.impl.AbstractSpringSocialOAuth2IdentityTest.java

@Test
public void testAccessGrantNoCode() throws Exception {
    identity = new AbstractSpringSocialOAuth2Identity() {
    };/*from   w  w w.j  a v a2  s .c om*/
    final MockHttpServletRequest httpRequest = new MockHttpServletRequest();
    Assert.assertNull(identity.getAccessGrant(httpRequest));
}

From source file:com.gopivotal.cla.security.AdminEmailDomainFilterTest.java

@Test(expected = AccessDeniedException.class)
public void attemptAuthenticationNonVerifiedEmail() throws IOException, ServletException {
    Emails emails = new Emails();
    when(this.gitHubClient.getEmails()).thenReturn(emails);
    emails.add(new Email("email@test.domain", false, false));

    this.filter.doFilter(new MockHttpServletRequest(), new MockHttpServletResponse(), new MockFilterChain());
}

From source file:org.soybeanMilk.test.unit.web.TestDefaultWebObjectSource.java

@Before
public void setUp() {
    request = new MockHttpServletRequest();
    response = new MockHttpServletResponse();
    application = new MockServletContext();

    webObjectSource = new DefaultWebObjectSource(request, response, application, new WebGenericConverter());
}

From source file:org.araneaframework.tests.StandardServletOutputDataTests.java

public void testSetRequest() {
    req = new MockHttpServletRequest();
    out.setRequest(req);
    assertEquals(req, out.getRequest());
}

From source file:org.sventon.web.ctrl.template.GetFileHistoryControllerTest.java

@Before
public void setUp() throws Exception {
    logEntries.add(new LogEntry(3, null, null));
    logEntries.add(new LogEntry(2, null, null));
    logEntries.add(new LogEntry(1, null, null));

    repositoryName = new RepositoryName("test");
    command.setPath("/trunk/test");
    command.setName(repositoryName);/*from w  w w  .j  a va 2s .c  om*/
    command.setRevision(Revision.create(12));

    mockService = EasyMock.createMock(RepositoryService.class);
    request = new MockHttpServletRequest();
    ctrl = new GetFileHistoryController();
    ctrl.setRepositoryService(mockService);
}

From source file:org.jasig.cas.web.ProxyControllerTests.java

@Test
public void testNoParams() throws Exception {
    assertEquals("INVALID_REQUEST",
            this.proxyController
                    .handleRequestInternal(new MockHttpServletRequest(), new MockHttpServletResponse())
                    .getModel().get("code"));
}

From source file:com.google.api.server.spi.auth.GoogleOAuth2AuthenticatorTest.java

private void initializeRequest(String bearerString) {
    request = new MockHttpServletRequest();
    attr = Attribute.from(request);
    attr.set(Attribute.API_METHOD_CONFIG, config);
    attr.set(Attribute.ENABLE_CLIENT_ID_WHITELIST, true);
    request.addHeader(GoogleAuth.AUTHORIZATION_HEADER, bearerString);
    authenticator = createAuthenticator(EMAIL, CLIENT_ID, SCOPES, USER_ID);
}

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

public void testWrappedRequest() throws Exception {
    final HttpServletRequestWrapperFilter filter = new HttpServletRequestWrapperFilter();
    filter.init(new MockFilterConfig());
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final MockHttpSession session = new MockHttpSession();

    session.setAttribute(AbstractCasFilter.CONST_CAS_ASSERTION, new AssertionImpl("test"));
    request.setSession(session);/*from ww w. ja  va  2  s.  c o m*/

    filter.doFilter(request, new MockHttpServletResponse(), createFilterChain());
    assertEquals("test", this.mockRequest.getRemoteUser());

    filter.destroy();
}