01: package com.ecyrd.jspwiki.auth.permissions;
02:
03: import junit.framework.TestCase;
04:
05: /**
06: * @author Andrew Jaquith
07: */
08: public class AllPermissionTest extends TestCase {
09:
10: /*
11: * Class under test for boolean equals(Object)
12: */
13: public void testEqualsObject() {
14: AllPermission p1 = new AllPermission("*");
15: AllPermission p2 = new AllPermission("*");
16: AllPermission p3 = new AllPermission("myWiki");
17: assertTrue(p1.equals(p2));
18: assertTrue(p2.equals(p1));
19: assertFalse(p1.equals(p3));
20: assertFalse(p3.equals(p1));
21: }
22:
23: public void testImpliesAllPermission() {
24: AllPermission p1 = new AllPermission("*");
25: AllPermission p2 = new AllPermission("*");
26: assertTrue(p1.equals(p2));
27: assertTrue(p2.equals(p1));
28:
29: p2 = new AllPermission("myWiki");
30: assertTrue(p1.implies(p2));
31: assertFalse(p2.implies(p1));
32: }
33:
34: public void testImpliesPagePermission() {
35: AllPermission p1 = new AllPermission("*");
36: PagePermission p2 = new PagePermission("*:TestPage", "delete");
37: assertTrue(p1.implies(p2));
38: assertFalse(p2.implies(p1));
39:
40: p2 = new PagePermission("myWiki:TestPage", "delete");
41: assertTrue(p1.implies(p2));
42: assertFalse(p2.implies(p1));
43:
44: p2 = new PagePermission("*:GroupTest", "delete");
45: assertTrue(p1.implies(p2));
46: assertFalse(p2.implies(p1));
47:
48: p2 = new PagePermission("myWiki:GroupTest", "delete");
49: assertTrue(p1.implies(p2));
50: assertFalse(p2.implies(p1));
51: }
52:
53: public void testImpliesWikiPermission() {
54: AllPermission p1 = new AllPermission("*");
55: WikiPermission p2 = new WikiPermission("*", "createPages");
56: assertTrue(p1.implies(p2));
57: assertFalse(p2.implies(p1));
58:
59: p2 = new WikiPermission("myWiki", "createPages");
60: assertTrue(p1.implies(p2));
61: assertFalse(p2.implies(p1));
62: }
63:
64: /*
65: * Class under test for String toString()
66: */
67: public void testToString() {
68: AllPermission p = new AllPermission("myWiki");
69: String result = "(\"com.ecyrd.jspwiki.auth.permissions.AllPermission\",\"myWiki\")";
70: assertEquals(result, p.toString());
71:
72: p = new AllPermission("*");
73: result = "(\"com.ecyrd.jspwiki.auth.permissions.AllPermission\",\"*\")";
74: assertEquals(result, p.toString());
75: }
76:
77: }
|