KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > client > test > DbReset


1 package hero.client.test;
2
3 import hero.interfaces.*;
4 import junit.framework.*;
5 import java.util.*;
6
7 public class DbReset extends TestCase {
8
9     private BnUserHome uhome;
10     private BnAuthRoleHome arhome;
11     private BnProjectHome pHome;
12         private BnUserHome uHome;
13         private BnAuthRoleHome aHome;
14
15     public DbReset(String JavaDoc testname) {
16     super(testname);
17     }
18     
19     public static TestSuite suite() {
20
21     return new TestSuite(DbReset.class);
22     }
23
24     public void setUp() throws Exception JavaDoc {
25     }
26
27     public void testDbReset() throws Exception JavaDoc {
28        
29         // Get all projects and remove them.
30
pHome = hero.interfaces.BnProjectUtil.getHome();
31         Collection projects = pHome.findAll();
32         Iterator pr = projects.iterator();
33         while (pr.hasNext())
34         {
35         BnProject project = (BnProject)pr.next();
36         project.remove();
37         }
38
39         // Get all users and remove them.
40
uHome = hero.interfaces.BnUserUtil.getHome();
41         Collection users = uHome.findAll();
42         Iterator ur = users.iterator();
43         while (ur.hasNext())
44         {
45         BnUser user = (BnUser)ur.next();
46         user.remove();
47         }
48
49         // Get all AuthRole and remove them.
50
aHome = hero.interfaces.BnAuthRoleUtil.getHome();
51         Collection auths = aHome.findAll();
52         Iterator au = auths.iterator();
53         while (au.hasNext())
54         {
55         BnAuthRole auth = (BnAuthRole)au.next();
56         auth.remove();
57         }
58                     
59         // Init default users and authRoles
60
InsertAuthRoleUserHome lHome = InsertAuthRoleUserUtil.getHome();
61         InsertAuthRoleUser lBean = (InsertAuthRoleUser) lHome.create();
62         lBean.initializeUser("admin","toto","toxic@loria.fr");
63         lBean.initializeUser("admin2","toto2","toxic@loria.fr");
64         lBean.initializeUser("nobody","nobody","toxic@loria.fr");
65         lBean.initializeAuthRole("BONITAUSER","BONITAUSER");
66         lBean.initializeAuthRole("nobody","nobody");
67         lBean.initialize("admin","BONITAUSER");
68         lBean.initialize("admin","nobody");
69         lBean.initialize("admin2","BONITAUSER");
70         lBean.initialize("admin2","nobody");
71         lBean.initialize("nobody","nobody");
72
73     }
74 }
75
Popular Tags