Examples of Food


Examples of test.mixed.Food

  private FoodService foodService;

  public String before(HttpServletRequest request, HttpServletResponse response) {
    log.info("before 0 [{}]", request.getRequestURI());
    String fruit = request.getParameter("fruit");
    Food food = foodService.getFood(fruit);
    if(food != null) {
      request.setAttribute("fruit", food);
      return "/food.jsp";
    } else
      return null;
View Full Code Here

Examples of test.mixed.Food

    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"));
    String returnView = (String) request.getAttribute("returnView");
    Assert.assertThat(returnView, is("/food.jsp"));
    String str2 = (String) request.getAttribute("str2");
    Assert.assertThat(str2, nullValue());
View Full Code Here

Examples of test.mixed.Food

    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

Examples of test.mixed.Food

    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));
    Assert.assertThat(request.getDispatcherTarget(),
        is("/WEB-INF/page/foodView.jsp"));

  }
View Full Code Here

Examples of test.mixed.Food

    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(),
        is("/WEB-INF/page/food.jsp"));
  }
View Full Code Here

Examples of test.mixed.Food

    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

Examples of test.mixed.Food

    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));
   
    food = (Food)request.getAttribute("fruit0");
    Assert.assertThat(food.getName(), is("apple"));
    Assert.assertThat(food.getPrice(), is(8.0));
   
    food = (Food)request.getAttribute("strawberry");
    Assert.assertThat(food.getName(), is("strawberry"));
    Assert.assertThat(food.getPrice(), is(10.0));
  }
View Full Code Here

Examples of test.mixed.Food

  private static Log log = LogFactory.getInstance().getLog("firefly-system");
  @Inject
  private FoodService foodService;

  public View dispose(HttpServletResponse response, HttpServletRequest request, HandlerChain chain) {
    Food food = new Food();
    food.setName("ananas");
    food.setPrice(4.99);
    request.setAttribute("fruit1", food);
    log.info("start food interceptor 1");
    View view = chain.doNext(request, response, chain);
    log.info("end food interceptor 1 : {}", food);
    return view;
View Full Code Here

Examples of test.mixed.Food

 
  @Inject
  private FoodService foodService;
 
  public View dispose(HandlerChain chain, HttpServletRequest request, HttpServletResponse response) {
    Food food = new Food();
    food.setName("apple");
    food.setPrice(8.0);
    request.setAttribute("fruit0", food);
   
    food = foodService.getFood("strawberry");
    request.setAttribute("strawberry", food);
    log.info("food interceptor 0 : {}", food);
View Full Code Here

Examples of test.mixed.Food

@Interceptor(uri = "/*/view*", order = 2)
public class FoodInterceptor3 {
  private static Log log = LogFactory.getInstance().getLog("firefly-system");

  public View dispose(HttpServletRequest request, HttpServletResponse response) {
    Food food = new Food();
    food.setName("banana");
    food.setPrice(3.99);
    log.info("food interceptor 2 : {}", food);
    return new JsonView(food);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.