Package test.mock.servlet

Examples of test.mock.servlet.MockHttpServletResponse


    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/firefly/app/hello");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    Assert.assertThat(request.getAttribute("hello").toString(),
        is("你好 firefly!"));
  }
View Full Code Here


    request.setContextPath("/firefly");
    request.setMethod("GET");
    request.setParameter("text", "ddd");
    request.setParameter("id", "345");
    request.setParameter("price", "23.3");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    Book book = (Book) request.getAttribute("book");
    Assert.assertThat(book.getText(), is("ddd"));
    Assert.assertThat(book.getPrice(), is(23.3));
    Assert.assertThat(book.getId(), is(345));
View Full Code Here

    request.setParameter("title", "good book");
    request.setParameter("text", "一本好书");
    request.setParameter("id", "330");
    request.setParameter("price", "79.9");
    request.setParameter("sell", "true");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    Book book = (Book) request.getAttribute("book");
    Assert.assertThat(book.getText(), is("一本好书"));
    Assert.assertThat(book.getPrice(), is(79.9));
    Assert.assertThat(book.getId(), is(330));
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/firefly/app/hello/text");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    Assert.assertThat(response.getAsString(), is("文本输出"));
  }
View Full Code Here

    request.setParameter("title", "good book");
    request.setParameter("text", "very good");
    request.setParameter("id", "331");
    request.setParameter("price", "10.0");
    request.setParameter("sell", "false");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    log.info(response.getAsString());
    Assert.assertThat(
        response.getAsString().length(),
        greaterThan(10));
  }
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/firefly/app/hello/redirect");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    log.info(response.getHeader("Location"));
    Assert.assertThat(response.getHeader("Location"),
        is("/firefly/app/hello"));
  }
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/firefly/app/food");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    log.info(request.getDispatcherTarget());
    Food food = (Food) request.getAttribute("fruit");
    Assert.assertThat(food.getName(), is("orange"));
View Full Code Here

    request.setRequestURI("/firefly/app/food");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    request.setParameter("fruit", "apple");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    log.info(request.getDispatcherTarget());
    Food food = (Food) request.getAttribute("fruit");
    Assert.assertThat(food.getName(), is("apple"));
    Assert.assertThat(food.getPrice(), is(5.3));
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/firefly/app/food/view1");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    log.info(request.getDispatcherTarget());
    Assert.assertThat(request.getDispatcherTarget(),
        is("/WEB-INF/page/foodView1.jsp"));
    Assert.assertThat(request.getAttribute("into").toString(), is("2"));
View Full Code Here

    request.setRequestURI("/firefly/app/food/view1");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    request.setParameter("strawberry", "strawberry");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    log.info(request.getDispatcherTarget());
    Food food = (Food) request.getAttribute("fruit");
    Assert.assertThat(food.getName(), is("strawberry"));
    Assert.assertThat(food.getPrice(), is(10.00));
View Full Code Here

TOP

Related Classes of test.mock.servlet.MockHttpServletResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.