Esempio n. 1
0
  /** Add some new accounts and customers. */
  protected final void setUp() {
    // get context and facade
    ApplicationContext ctx = new FileSystemXmlApplicationContext("build/applicationContext.xml");
    bank = (BankingFacade) ctx.getBean("bankManager");

    // create test accounts and customers
    try {
      bank.addCustomer("120", "Mr", "A", "Customer");
      bank.addCustomer("130", "Mr", "Ano", "Customer");
      bank.addAccount("120-2001", "120", "Checking");
      bank.addAccount("120-2002", "120", "Savings");
      bank.addAccount("120-2010", "130", "Checking");
      bank.addAccount("120-2011", "130", "Savings");
      bank.addAccount("120-2012", "130", "Savings");
      bank.deposit("120-2002", new BigDecimal("100.00"));
      delay(5);
      bank.deposit("120-2002", new BigDecimal("50.00"));
      delay(5);
      bank.deposit("120-2010", new BigDecimal("1000.45"));
      delay(5);
      bank.deposit("120-2011", new BigDecimal("123.69"));
    } catch (BankException ex) {
      ex.printStackTrace();
    }
  } // setUp
Esempio n. 2
0
 /** Test depositing funds. */
 public final void testDeposit() {
   // deposit
   try {
     BigDecimal balance = bank.deposit("120-2002", new BigDecimal("50.00"));
     assertEquals(balance, new BigDecimal("200.00"));
   } catch (BankException e) {
     e.printStackTrace();
   }
   // force exception
   try {
     BigDecimal balance = bank.deposit("120-999", new BigDecimal("50.00"));
     fail("deposit hasn't caused an exception as it should");
   } catch (BankException ex) {
     // ignore
   }
 } // testDeposit