TransactionTemplateTestpublic class TransactionTemplateTest extends TestCase
Fields Summary |
---|
private org.springframework.context.ApplicationContext | ctx | com.springbook.RentABike | store |
Methods Summary |
---|
public void | setUp()
ctx = new FileSystemXmlApplicationContext("/war/WEB-INF/rentaBikeApp-servlet.xml");
store = (RentABike)ctx.getBean("rentaBike");
| public void | testTx()
Reservation oldres = new Reservation(1234, store.getBike(1), store.getCustomer(1), new Date());
Reservation newres = new Reservation(-1, store.getBike(1), store.getCustomer(2), new Date());
int rescount = store.getReservations().size();
try {
store.transferReservation(oldres, newres);
} catch (ReservationTransferException rte) {
System.out.println("RTE caught.");
} catch (Exception ex) {
System.out.println("Just an exception.");
}
assertEquals(rescount, store.getReservations().size());
| public void | testTxSucceed()
Reservation oldres = store.getReservation(1);
Reservation newres = new Reservation(-1, store.getBike(1), store.getCustomer(2), new Date());
int rescount = store.getReservations().size();
try {
store.transferReservation(oldres, newres);
} catch (ReservationTransferException rte) {
fail("Should not have thrown an RTE, but did.");
} catch (Exception ex) {
fail("Threw an unexpected exception: " + ex.getMessage());
}
assertEquals(rescount, store.getReservations().size());
|
|