KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > identity > hibernate > GroupDbTest


1 package org.jbpm.identity.hibernate;
2
3 import java.io.*;
4 import java.net.*;
5
6 import org.jbpm.identity.*;
7
8 public class GroupDbTest extends IdentityDbTestCase {
9
10   public void testGroup() {
11     Group group = new Group("people with read hair");
12     group = saveAndReload(group);
13     assertEquals("people with read hair", group.getName());
14   }
15
16   public void testGroupMemberships() {
17     Group chicagoBulls = new Group("chicago bulls");
18     User tyson = new User("tyson");
19     User eddy = new User("eddy");
20     User antonio = new User("antonio");
21     User chris = new User("chris");
22     
23     Membership.create(tyson, "F-C", chicagoBulls);
24     Membership.create(eddy, "C-F", chicagoBulls);
25     Membership.create(antonio, "F-C", chicagoBulls);
26     Membership.create(chris, "G", chicagoBulls);
27
28     chicagoBulls = saveAndReload(chicagoBulls);
29     assertEquals(4, chicagoBulls.getUsers().size());
30   }
31
32   public void testGroupPermissions() {
33     Group chicagoBulls = new Group("chicago bulls");
34     chicagoBulls.addPermission(new SocketPermission("basket", "connect"));
35     chicagoBulls.addPermission(new FilePermission("ticket", "write"));
36
37     chicagoBulls = saveAndReload(chicagoBulls);
38     
39     assertEquals(2, chicagoBulls.getPermissions().size());
40   }
41 }
42
Popular Tags