FileDocCategorySizeDatePackage
MultiDBFacadeTest.javaAPI DocExample2558Mon Apr 25 09:41:42 BST 2005None

MultiDBFacadeTest

public class MultiDBFacadeTest extends TestCase

Fields Summary
private org.springframework.context.ApplicationContext
ctx
RentABike
store
Constructors Summary
Methods Summary
public voidsetUp()


         
        ctx = new FileSystemXmlApplicationContext("/war/WEB-INF/rentaBikeApp-servlet.xml");
        store = (RentABike)ctx.getBean("RentABike");
    
public voidtestAddBike()

        Bike bike = new Bike(-1, "MyMan", "MyBike", 12, "12312312", 12.00, "New");
        store.saveBike(bike);
        bike = store.getBike("12312312");
        assertNotNull(bike);
        assertEquals("MyMan", bike.getManufacturer());
        store.deleteBike(bike);
        List bikes = store.getBikes();
        assertEquals(3, bikes.size());

    
public voidtestAddCustomer()

        Customer c = new Customer(-1, "Roger", "Clemons");
        store.saveCustomer(c);
        store.deleteCustomer(c);
    
public voidtestAddRes()

        Reservation newres = new Reservation(-1, store.getBike(1), store.getCustomer(2), new Date());
        try {
            store.addReservation(newres, 120.00);
        } catch (AddReservationException are) {
            System.out.println("Error. Rolling back tx.");
        }

    
public voidtestCustomer()

        Customer c = store.getCustomer(1);
        assertNotNull(c);
        assertEquals("Justin", c.getFirstName());
    
public voidtestDate()


        List l = store.getReservations(new Date(Date.parse("9/15/2004")));
        assertNotNull(l);
        assertTrue(0<l.size());

    
public voidtestGetBike()

        Bike bike = store.getBike(2);
        assertNotNull(bike);
        assertEquals("Cannondale", bike.getManufacturer());
        assertNotNull(bike.getReservations());
        assertTrue(0<bike.getReservations().size());
    
public voidtestGetBikes()

        List bikes = store.getBikes();
        assertNotNull(bikes);
        assertTrue(bikes.size() > 0);
    
public voidtestReservation()

        Reservation r = store.getReservation(1);
        assertNotNull(r);
        assertNotNull(r.getBike());
        assertNotNull(r.getCustomer());