FileDocCategorySizeDatePackage
RentABikeTest.javaAPI DocExample1495Sun Apr 24 16:53:38 BST 2005None

RentABikeTest

public class RentABikeTest extends TestCase

Fields Summary
private com.springbook.RentABike
rentaBike
Constructors Summary
Methods Summary
public voidsetUp()

      rentaBike = new ArrayListRentABike("Bruce's Bikes");
   
public voidtestDeleteBike()

      List bikes = rentaBike.getBikes();
      assertEquals(3, bikes.size());
      Bike bike = (Bike)bikes.get(0);
      rentaBike.deleteBike(bike);
      bikes = rentaBike.getBikes();
      assertEquals(2, bikes.size());
   
public voidtestGetBike()

      Bike bike = rentaBike.getBike("11111");
      assertNotNull(bike);
      assertEquals("Shimano", bike.getManufacturer());
   
public voidtestGetBikes()

      List bikes = rentaBike.getBikes();
      assertNotNull(bikes);
      assertEquals(3, bikes.size());
   
public voidtestGetName()

      assertEquals("Bruce's Bikes", rentaBike.getStoreName());
   
public voidtestSaveBike()

      Bike bike = (Bike)rentaBike.getBikes().get(0);
      assertEquals("Shimano", bike.getManufacturer());
      bike.setManufacturer("Royal");
      rentaBike.saveBike(bike);
      Iterator iter = rentaBike.getBikes().iterator();
      boolean found = false;
      while(iter.hasNext()) {
         Bike b = (Bike)iter.next();
         if(b.getManufacturer().equals("Royal")) found = true;
      }
      assertTrue(found);