01 /*
02 * Created on Jun 28, 2004
03 *
04 * To change the template for this generated file go to
05 * Window - Preferences - Java - Code Generation - Code and Comments
06 */
07 package biz.xsoftware.examples.basic;
08
09 /**
10 * The SysUnderTest here is a WebStore or something which needs
11 * to authorize purchases.
12 */
13 public class SysUnderTest {
14
15 private CreditAuthorizationSvc creditSvc;
16 private GiftCardAccountSvc giftSvc;
17
18 /**
19 * @showcode
20 */
21 public SysUnderTest(CreditAuthorizationSvc c, GiftCardAccountSvc g) {
22 creditSvc = c;
23 giftSvc = g;
24 }
25
26 /**
27 * @showcode
28 */
29 public void buyGiftCard(String user, double usDollars) {
30 creditSvc.takeMoney(user, usDollars);
31
32 try {
33 giftSvc.putMoneyOnCard(456, usDollars);
34 } catch(Throwable e) {
35 creditSvc.returnMoney(user, usDollars);
36 throw new PurchaseException(e);
37 }
38 return;
39 }
40 }
|