KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > store > gateway > EchoOrderArchiveTest


1 /*
2  * Created on Oct 12, 2004
3  */

4 package com.openedit.store.gateway;
5
6 import com.openedit.WebPageRequest;
7 import com.openedit.store.CreditCardType;
8 import com.openedit.store.CreditPaymentMethod;
9 import com.openedit.store.Order;
10 import com.openedit.store.StoreTestCase;
11
12 /**
13  * @author Dave Connerth
14  */

15 public class EchoOrderArchiveTest extends StoreTestCase {
16     public static final String JavaDoc ECHO_TEST_CARD_NUMBER = "4005550000000019";
17
18     /**
19      * @param name
20      */

21     public EchoOrderArchiveTest(String JavaDoc name) {
22         super(name);
23     }
24
25     /**
26      * @throws Exception
27      */

28     public void testEchoPaymentArchiveWithBadOrder() throws Exception JavaDoc {
29         EchoOrderArchive archiver = new EchoOrderArchive();
30         WebPageRequest context = getFixture().createPageRequest();
31         Order order = createOrder();
32         archiver.exportNewOrder(context, getStore(), order);
33         assertFalse(order.getOrderState().isOk());
34     }
35
36     /**
37      * @throws Exception
38      */

39     public void testEchoPaymentArchive() throws Exception JavaDoc {
40         CreditPaymentMethod paymentMethod = new CreditPaymentMethod();
41         CreditCardType type = new CreditCardType();
42         type.setName("Visa");
43         paymentMethod.setCreditCardType(type);
44         paymentMethod.setCardNumber(ECHO_TEST_CARD_NUMBER);
45         paymentMethod.setExpirationMonth(6);
46         paymentMethod.setExpirationYear(2006);
47         EchoOrderArchive archiver = new EchoOrderArchive();
48         archiver.setAddRandomAmountToTotal(true); //this prevents duplicate trans errors
49
WebPageRequest context = getFixture().createPageRequest();
50         Order order = createOrder();
51         order.setPaymentMethod(paymentMethod);
52         archiver.exportNewOrder(context, getStore(), order);
53         if (!order.getOrderState().isOk()) {
54             throw new Exception JavaDoc(order.getOrderState().getDescription());
55         }
56     }
57 }
Popular Tags