Package test.mixed

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


    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

    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

    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

  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

 
  @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

@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

  public static ApplicationContext applicationContext = new XmlApplicationContext("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

@Controller
public class FoodController {

  @RequestMapping(value = "/food")
  public View getFood(HttpServletRequest request) {
    Food food = new Food();
    food.setName("orange");
    food.setPrice(3.5);
    request.setAttribute("fruit", food);
    return new JspView("/food.jsp");
  }
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.