KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > identity > xml > IdentityXmlParsingTest


1 package org.jbpm.identity.xml;
2
3 import java.util.Set JavaDoc;
4
5 import junit.framework.TestCase;
6
7 import org.jbpm.identity.Group;
8 import org.jbpm.identity.User;
9
10 public class IdentityXmlParsingTest extends TestCase {
11   
12   IdentityXmlParser identityXmlParser;
13   
14   public void setUp() {
15     identityXmlParser = new IdentityXmlParser();
16     identityXmlParser.parse("org/jbpm/identity/xml/identity.xml");
17   }
18
19   public void testUser() {
20     User ernie = (User) identityXmlParser.users.get("ernie");
21     assertEquals("ernie", ernie.getName());
22     assertEquals("ernie@sesamestreet.tv", ernie.getEmail());
23     assertEquals("canthereyoubert,theresabananainmyear", ernie.getPassword());
24   }
25
26   public void testGroup() {
27     Group bananalovers = (Group) identityXmlParser.groups.get("bananalovers");
28     assertEquals("bananalovers", bananalovers.getName());
29     assertEquals("fruitpreference", bananalovers.getType());
30   }
31
32   public void testGroupParent() {
33     Group sesameinhabitants = (Group) identityXmlParser.groups.get("sesameinhabitants");
34     Group bananalovers = (Group) identityXmlParser.groups.get("bananalovers");
35     assertSame(sesameinhabitants, bananalovers.getParent());
36     assertEquals(1, sesameinhabitants.getChildren().size());
37     assertSame(bananalovers, sesameinhabitants.getChildren().iterator().next());
38   }
39
40   public void testUserMembership() {
41     User ernie = (User) identityXmlParser.users.get("ernie");
42     Group bananalovers = (Group) identityXmlParser.groups.get("bananalovers");
43     Set JavaDoc erniesMemberships = ernie.getMemberships();
44     assertEquals(1, erniesMemberships.size());
45     Set JavaDoc bananaloversMemberships = bananalovers.getMemberships();
46     assertEquals(1, bananaloversMemberships.size());
47     assertSame(bananaloversMemberships.iterator().next(), erniesMemberships.iterator().next());
48   }
49 }
50
Popular Tags