Package test.mock.servlet

Examples of test.mock.servlet.MockHttpServletResponse


    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


    request.setRequestURI("/firefly/app/food/view1");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    request.setParameter("fruit", "apple");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatcher(request, response);
    Food food = (Food) request.getAttribute("fruit");
    Assert.assertThat(food.getName(), is("apple"));
    Assert.assertThat(food.getPrice(), is(5.3));
    Assert.assertThat(request.getDispatcherTarget(),
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.dispatch(request, response);
   
    System.out.println(response.getAsString());
    System.out.println(response.getHeader("Allow"));
  }
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.dispatch(request, response);
    Assert.assertThat(response.getHeader("Allow"), is("POST,GET"));
//    System.out.println(response.getAsString());
//    System.out.println(response.getHeader("Allow"));
  }
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.dispatch(request, response);
   
    Food food = (Food)request.getAttribute("fruit0");
    Assert.assertThat(food.getName(), is("apple"));
    Assert.assertThat(food.getPrice(), is(8.0));
   
    food = (Food)request.getAttribute("fruit1");
    Assert.assertThat(food.getName(), is("ananas"));
    Assert.assertThat(food.getPrice(), is(4.99));
   
    food = Json.toObject(response.getAsString(), Food.class);
    Assert.assertThat(food.getName(), is("banana"));
    Assert.assertThat(food.getPrice(), is(3.99));
  }
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.dispatch(request, response);
   
    Food food = (Food)request.getAttribute("fruit");
    Assert.assertThat(food.getName(), is("orange"));
    Assert.assertThat(food.getPrice(), is(3.5));
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.dispatch(request, response);
   
    Assert.assertThat(response.getStatus(), is(404));
  }
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.dispatch(request, response);
   
    Assert.assertThat(response.getHeader("Allow"), is("POST"));
    Assert.assertThat(request.getAttribute("book"), nullValue());
  }
View Full Code Here

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("/firefly/app/hello");
    request.setServletPath("/app");
    request.setContextPath("/firefly");
    request.setMethod("GET");
    MockHttpServletResponse response = new MockHttpServletResponse();
    dispatcherController.dispatch(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.dispatch(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

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.