Package test.mixed

Examples of test.mixed.Food


@Controller
public class FoodController {

  @RequestMapping(value = "/food")
  public String getFood(HttpServletRequest request) {
    Food food = new Food();
    food.setName("orange");
    food.setPrice(3.5);
    request.setAttribute("fruit", food);
    return "/food.jsp";
  }
View Full Code Here


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

      "mixed-config.xml");

  @Test
  public void testInject() {
    FoodService2 foodService2 = applicationContext.getBean("foodService2");
    Food food = foodService2.getFood("apple");
    log.debug(food.getName());
    Assert.assertThat(food.getPrice(), is(5.3));
   
    FoodService foodService = applicationContext.getBean(FoodService.class);
    food = foodService.getFood("strawberry");
    log.debug(food.getName());
    Assert.assertThat(food.getPrice(), is(10.00));
  }
View Full Code Here

  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

    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.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

    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

    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

  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

    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

TOP

Related Classes of test.mixed.Food

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.