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:io.jmnarloch.spring.request.correlation.feign.FeignCorrelationInterceptorTest.java

@Before
public void setUp() throws Exception {

    instance = new FeignCorrelationInterceptor(new RequestCorrelationProperties());
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(new MockHttpServletRequest()));
}

From source file:org.eclipse.virgo.apps.repository.web.RepositoryControllerTests.java

@Test
public void getIndex() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();

    request.setRequestURI("http://localhost:8080/org.eclipse.virgo.server.repository/my-repo");
    request.setMethod("GET");

    byte[] indexBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };

    RepositoryIndex repositoryIndex = createMock(RepositoryIndex.class);
    expect(repositoryIndex.getInputStream()).andReturn(new ByteArrayInputStream(indexBytes)).anyTimes();
    expect(repositoryIndex.getETag()).andReturn("123456789").anyTimes();
    expect(repositoryIndex.getLength()).andReturn(indexBytes.length).anyTimes();

    expect(this.repositoryManager.getIndex("my-repo")).andReturn(repositoryIndex);

    replay(this.repositoryManager, repositoryIndex);

    repositoryController.getIndex(request, response);

    verify(this.repositoryManager, repositoryIndex);

    assertEquals("application/org.eclipse.virgo.repository.Index", response.getContentType());
    assertArrayEquals(indexBytes, response.getContentAsByteArray());
}

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

public void testNormalGetScopedDataMultiple() {
    request = new MockHttpServletRequest();
    request.addParameter("foo", "bar");
    request.addParameter("a.foo", "a bar");
    request.addParameter("a.extra.foo", "a extra bar");
    request.addParameter("a.extra.foo2", "a extra bar2");

    input.pushScope("a");
    input.pushScope("extra");
    assertEquals("a extra bar2", input.getScopedData().get("foo2"));
}

From source file:com.google.api.server.spi.request.AttributeTest.java

@Before
public void setUp() {
    request = new MockHttpServletRequest();
}

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

@Test
public void testNullPointerException() {
    assertNull(this.resolver.resolveException(new MockHttpServletRequest(), new MockHttpServletResponse(), null,
            new NullPointerException()));
}

From source file:com.gantzgulch.taglibs.html.BodyTagRunner.java

public BodyTagRunner(BodyTag bodyTag, String contextPath) throws JspException {

    servletRequest = new MockHttpServletRequest();
    servletResponse = new MockHttpServletResponse();
    servletContext = new MockServletContext();
    servletContext.setContextPath(contextPath);
    pageContext = new MockPageContext(servletContext, servletRequest, servletResponse);

    this.bodyTag = bodyTag;
    state = doInitializeState.execute();
}

From source file:gov.nih.nci.cabig.ctms.web.WebToolsTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();

    request = new MockHttpServletRequest();
    request.setServerName("www.neuromice.org");
    request.setContextPath("/");

    session = new MockHttpSession();
}

From source file:org.araneaframework.tests.framework.filter.StandardStatisticFilterServiceTests.java

public void setUp() throws Exception {
    service = new StandardStatisticFilterService();
    child = new MockEventfulBaseService();
    service.setChildService(child);/*w w w  .  ja  v a  2s.  com*/
    MockLifeCycle.begin(service);

    req = new MockHttpServletRequest();
    res = new MockHttpServletResponse();

    input = new StandardServletInputData(req);
    output = new StandardServletOutputData(req, res);
}

From source file:org.araneaframework.tests.framework.filter.StandardSynchronizingFilterServiceTests.java

public void setUp() throws Exception {
    service = new StandardSynchronizingFilterService();
    child = new MockEventfulBaseService();
    service.setChildService(child);//from w  w w .j a  v  a  2s.c o m
    MockLifeCycle.begin(service);

    req = new MockHttpServletRequest();
    res = new MockHttpServletResponse();

    input = new StandardServletInputData(req);
    output = new StandardServletOutputData(req, res);
}

From source file:org.gwtwidgets.server.spring.test.BaseTest.java

@Before
public void setUp() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    MockHttpServletResponse response = new MockHttpServletResponse();
    // need to override our own request
    RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
    ServletUtils.setResponse(response);//from  www .  j a v a  2  s.  c  o  m
}