1 package org.melati.poem.test;
2
3 import org.melati.poem.Capability;
4 import org.melati.poem.Group;
5 import org.melati.poem.GroupCapability;
6
7
8
9
10
11 public class GroupCapabilityTest extends PoemTestCase {
12
13 public GroupCapabilityTest(String name) {
14 super(name);
15 }
16
17 protected void setUp() throws Exception {
18 super.setUp();
19 }
20
21 protected void tearDown() throws Exception {
22 super.tearDown();
23 }
24
25
26
27
28 public void testGroupCapability() {
29
30 }
31
32
33
34
35
36 public void testGroupCapabilityGroupCapability() {
37 Group g = getDb().getGroupTable().ensure("testgroup");
38 Capability c = getDb().getCapabilityTable().ensure("testing");
39 GroupCapability gc = new GroupCapability(g, c);
40 getDb().getGroupCapabilityTable().create(gc);
41 assertEquals("testgroup",gc.getGroup().getName());
42 assertEquals("testing",gc.getCapability().getName());
43 gc.delete();
44 c.delete();
45 try {
46 c = new Capability();
47 gc = new GroupCapability(g,c);
48
49 fail("Should have blown up");
50 } catch (IllegalArgumentException e) {
51 e = null;
52 }
53 g.delete();
54 try {
55 g = new Group();
56 c = new Capability();
57 gc = new GroupCapability(g,c);
58
59 fail("Should have blown up");
60 } catch (IllegalArgumentException e) {
61 e = null;
62 }
63 }
64
65
66
67
68
69 public void testEnsureGroupCapability() {
70 Group g = getDb().getGroupTable().ensure("testgroup");
71 Capability c = getDb().getCapabilityTable().ensure("testing");
72 GroupCapability gc = getDb().getGroupCapabilityTable().ensure(g,c);
73 assertEquals("testgroup",gc.getGroup().getName());
74 assertEquals("testing",gc.getCapability().getName());
75 gc.delete();
76 g.delete();
77 c.delete();
78
79 }
80
81 }