예제 #1
0
  public String execute() {
    // Get the index of the item to remove
    int itemIndex = Integer.parseInt(request.getParameter("item"));
    HttpSession session = request.getSession();

    // Get the cart
    ShoppingCart cart = (ShoppingCart) session.getAttribute("ShoppingCart");

    cart.removeItem(itemIndex);

    return SUCCESS;
  }
예제 #2
0
 @Test
 public void testRemoveItem() throws Exception {
   cart.removeItem("9781430216407");
   assertEquals(1, cart.getItems().size());
   assertNull(cart.getItems().get("9781430216407"));
 }