001: /*
002: jGuard is a security framework based on top of jaas (java authentication and authorization security).
003: it is written for web applications, to resolve simply, access control problems.
004:
005: http://sourceforge.net/projects/jguard/
006:
007: Copyright (C) 2004 Charles GAY
008:
009: This library is free software; you can redistribute it and/or
010: modify it under the terms of the GNU Lesser General Public
011: License as published by the Free Software Foundation; either
012: version 2.1 of the License, or (at your option) any later version.
013:
014: This library is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: Lesser General Public License for more details.
018:
019: You should have received a copy of the GNU Lesser General Public
020: License along with this library; if not, write to the Free Software
021: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022:
023:
024: jGuard project home page:
025: http://sourceforge.net/projects/jguard/
026:
027: */
028: package net.sf.jguard.core.authorization.permissions;
029:
030: import junit.framework.TestCase;
031: import net.sf.jguard.core.authorization.permissions.URLParameter;
032:
033: /**
034: * @author <a href="mailto:diabolo512@users.sourceforge.net ">Charles Gay</a>
035: *
036: */
037: public class URLParameterTest extends TestCase {
038:
039: public static void main(String[] args) {
040: }
041:
042: /*
043: * @see TestCase#setUp()
044: */
045: protected void setUp() throws Exception {
046: super .setUp();
047: }
048:
049: /*
050: * @see TestCase#tearDown()
051: */
052: protected void tearDown() throws Exception {
053: super .tearDown();
054: }
055:
056: /**
057: * Constructor for URLParameter.
058: * @param arg0
059: */
060: public URLParameterTest(String arg0) {
061: super (arg0);
062: }
063:
064: /*
065: * Class under test for Object clone()
066: */
067: public void testClone() {
068: URLParameter urlp1 = new URLParameter();
069: urlp1.setKey("document");
070: String[] value1 = new String[] { "a", "b" };
071: urlp1.setValue(value1);
072: urlp1.setPermissionName("parent");
073: URLParameter urlp2 = null;
074: try {
075: urlp2 = (URLParameter) urlp1.clone();
076: } catch (CloneNotSupportedException e) {
077: TestCase.fail(e.getMessage());
078: }
079:
080: assertTrue(urlp2.equals(urlp1));
081: }
082:
083: /*
084: * Class under test for boolean equals(Object)
085: */
086: public void testEqualsObject() {
087: URLParameter urlp1 = new URLParameter();
088: urlp1.setKey("document");
089: String[] value1 = new String[] { "a", "b" };
090: urlp1.setValue(value1);
091: urlp1.setPermissionName("parent");
092:
093: URLParameter urlp2 = new URLParameter();
094: urlp2.setKey("document");
095: String[] value2 = new String[] { "a", "b" };
096: urlp2.setValue(value2);
097: urlp2.setPermissionName("parent");
098: assertTrue(urlp1.equals(urlp2));
099:
100: URLParameter urlp3 = new URLParameter();
101: urlp3.setKey("toto");
102: String[] value3 = new String[] { "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[] value4 = new String[] { "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[] value5 = new String[] { "a", "c" };
117: urlp5.setValue(value5);
118: urlp5.setPermissionName("parent");
119: assertFalse(urlp1.equals(urlp5));
120:
121: }
122:
123: }
|