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

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

Introduction

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

Prototype

@Override
    @Nullable
    public String getMethod() 

Source Link

Usage

From source file:ar.com.zauber.commons.spring.test.impl.TamperdataHttpServletRequestFactoryTest.java

/** testea */
public final void testFoo() {
    final HttpServletRequestFactory f = new TamperdataHttpServletRequestFactory();

    final MockHttpServletRequest request = (MockHttpServletRequest) f.create(getClass().getClassLoader()
            .getResourceAsStream("ar/com/zauber/commons/spring/test/impl/tamperdata-0.xml"));

    assertEquals("gzip,deflate", request.getHeader("Accept-Encoding"));
    assertEquals("carlos", request.getParameter("username"));
    assertEquals("POST", request.getMethod());
}

From source file:org.jtalks.jcommune.web.exception.PrettyLogExceptionResolverTest.java

@Test
public void testLogExceptionWithIncomingNotFoundException() throws Exception {
    Log mockLog = replaceLoggerWithMock(prettyLogExceptionResolver);
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
    NotFoundException notFoundException = new NotFoundException("Entity not found");
    String logMessage = String.format("[%s][%s][%s][%s]", request.getMethod(),
            request.getRequestURL().toString(), request.getHeader("Cookie"), "Entity not found");
    request.setContent("".getBytes());
    prettyLogExceptionResolver.logException(notFoundException, request);

    verify(mockLog).info(logMessage);/*ww  w.ja v  a2s. com*/
}

From source file:org.jtalks.jcommune.web.exception.PrettyLogExceptionResolverTest.java

@Test
public void testLogExceptionWithIncomingTypeMismatchException() throws Exception {
    Log mockLog = replaceLoggerWithMock(prettyLogExceptionResolver);
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
    TypeMismatchException typeMismatchException = new TypeMismatchException("Not a number", Number.class);
    String logMessage = String.format("[%s][%s][%s][%s]", request.getMethod(),
            request.getRequestURL().toString(), request.getHeader("Cookie"),
            typeMismatchException.getMessage());
    request.setContent("".getBytes());
    prettyLogExceptionResolver.logException(typeMismatchException, request);

    verify(mockLog).info(logMessage);/*from  w  w  w  .j  a  v a 2  s .  com*/
}