KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ce > auction > test > UserTest


1 package org.hibernate.ce.auction.test;
2
3 import junit.framework.Test;
4 import junit.framework.TestSuite;
5 import junit.textui.TestRunner;
6 import org.hibernate.ce.auction.dao.UserDAO;
7 import org.hibernate.ce.auction.model.CreditCard;
8 import org.hibernate.ce.auction.model.CreditCardType;
9 import org.hibernate.ce.auction.model.User;
10 import org.hibernate.ce.auction.persistence.HibernateUtil;
11
12 public class UserTest extends TestCaseWithData {
13
14     // ********************************************************** //
15

16     public void testBillingDetails() throws Exception JavaDoc {
17         initData();
18
19         UserDAO userDAO= new UserDAO();
20
21         User user1 = userDAO.getUserById(u1.getId(), false);
22
23         // load() trick to retrieve the subclass instance instead of a superclass proxy
24
CreditCard cc =
25                 (CreditCard)HibernateUtil.getSession().load(CreditCard.class, user1.getDefaultBillingDetails().getId());
26         assertEquals( cc.getType(), CreditCardType.MASTERCARD);
27
28         HibernateUtil.commitTransaction();
29         HibernateUtil.closeSession();
30     }
31
32     // ********************************************************** //
33

34     public UserTest(String JavaDoc x) {
35         super(x);
36     }
37
38     public static Test suite() {
39         return new TestSuite(UserTest.class);
40     }
41
42     public static void main(String JavaDoc[] args) throws Exception JavaDoc {
43         TestRunner.run( suite() );
44     }
45
46 }
47
Popular Tags