KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jguard > core > authorization > permissions > URLParameterTest


1 /*
2 jGuard is a security framework based on top of jaas (java authentication and authorization security).
3 it is written for web applications, to resolve simply, access control problems.
4
5 http://sourceforge.net/projects/jguard/
6
7 Copyright (C) 2004 Charles GAY
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23
24 jGuard project home page:
25 http://sourceforge.net/projects/jguard/
26
27 */

28 package net.sf.jguard.core.authorization.permissions;
29
30 import junit.framework.TestCase;
31 import net.sf.jguard.core.authorization.permissions.URLParameter;
32
33 /**
34  * @author <a HREF="mailto:diabolo512@users.sourceforge.net ">Charles Gay</a>
35  *
36  */

37 public class URLParameterTest extends TestCase {
38
39     public static void main(String JavaDoc[] args) {
40     }
41
42     /*
43      * @see TestCase#setUp()
44      */

45     protected void setUp() throws Exception JavaDoc {
46         super.setUp();
47     }
48
49     /*
50      * @see TestCase#tearDown()
51      */

52     protected void tearDown() throws Exception JavaDoc {
53         super.tearDown();
54     }
55
56     /**
57      * Constructor for URLParameter.
58      * @param arg0
59      */

60     public URLParameterTest(String JavaDoc arg0) {
61         super(arg0);
62     }
63
64     /*
65      * Class under test for Object clone()
66      */

67     public void testClone() {
68         URLParameter urlp1 = new URLParameter();
69         urlp1.setKey("document");
70         String JavaDoc[] value1 = new String JavaDoc[]{"a","b"};
71         urlp1.setValue(value1);
72         urlp1.setPermissionName("parent");
73         URLParameter urlp2 = null;
74         try {
75             urlp2 = (URLParameter) urlp1.clone();
76         } catch (CloneNotSupportedException JavaDoc e) {
77             TestCase.fail(e.getMessage());
78         }
79
80         assertTrue(urlp2.equals(urlp1));
81     }
82
83     /*
84      * Class under test for boolean equals(Object)
85      */

86     public void testEqualsObject() {
87         URLParameter urlp1 = new URLParameter();
88         urlp1.setKey("document");
89         String JavaDoc[] value1 = new String JavaDoc[]{"a","b"};
90         urlp1.setValue(value1);
91         urlp1.setPermissionName("parent");
92
93         URLParameter urlp2 = new URLParameter();
94         urlp2.setKey("document");
95         String JavaDoc[] value2 = new String JavaDoc[]{"a","b"};
96         urlp2.setValue(value2);
97         urlp2.setPermissionName("parent");
98         assertTrue(urlp1.equals(urlp2));
99
100         URLParameter urlp3 = new URLParameter();
101         urlp3.setKey("toto");
102         String JavaDoc[] value3 = new String JavaDoc[]{"a","b"};
103         urlp3.setValue(value3);
104         urlp3.setPermissionName("parent");
105         assertFalse(urlp1.equals(urlp3));
106
107         URLParameter urlp4 = new URLParameter();
108         urlp4.setKey("document");
109         String JavaDoc[] value4 = new String JavaDoc[]{"b","a"};
110         urlp4.setValue(value4);
111         urlp4.setPermissionName("parent");
112         assertTrue(urlp1.equals(urlp4));
113
114         URLParameter urlp5 = new URLParameter();
115         urlp5.setKey("document");
116         String JavaDoc[] value5 = new String JavaDoc[]{"a","c"};
117         urlp5.setValue(value5);
118         urlp5.setPermissionName("parent");
119         assertFalse(urlp1.equals(urlp5));
120
121
122     }
123
124 }
125
Popular Tags