KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > scenario > standalone > authentication > VirtualDatabaseUserTest


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Mathieu Peltier.
22  * Contributor(s): ______________________________________.
23  */

24
25 package org.objectweb.cjdbc.scenario.standalone.authentication;
26
27 import org.objectweb.cjdbc.common.users.VirtualDatabaseUser;
28 import org.objectweb.cjdbc.scenario.templates.NoTemplate;
29
30 /**
31  * <code>VirtualDatabaseUser</code> test class.
32  *
33  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier</a>
34  * @see org.objectweb.cjdbc.common.users.VirtualDatabaseUser
35  */

36 public class VirtualDatabaseUserTest extends NoTemplate
37 {
38   /** Virtual databse user. */
39   private VirtualDatabaseUser user1, user2, user3, user4;
40
41   /**
42    * @see junit.framework.TestCase#setUp()
43    */

44   protected void setUp()
45   {
46     user1 = new VirtualDatabaseUser("login1", "password1");
47     user2 = new VirtualDatabaseUser("login1", "password1");
48     user3 = new VirtualDatabaseUser("login2", "password");
49     user4 = new VirtualDatabaseUser("login1", "password2");
50   }
51
52   /**
53    * @see org.objectweb.cjdbc.common.users.VirtualDatabaseUser#matches(String,
54    * String)
55    */

56   public void testMatches()
57   {
58     assertTrue(user1.matches("login1", "password1"));
59     assertFalse(user1.matches("login2", "password1"));
60     assertFalse(user1.matches("login1", "password2"));
61     assertFalse(user1.matches("", ""));
62     assertFalse(user1.matches(null, "password2"));
63     assertFalse(user1.matches("login1", null));
64     assertFalse(user1.matches(null, null));
65   }
66
67   /**
68    * @see org.objectweb.cjdbc.common.users.VirtualDatabaseUser#equals(Object)
69    */

70   public void testEquals()
71   {
72     assertTrue(user1.equals(user2));
73     assertFalse(user1.equals(user3));
74     assertFalse(user1.equals(user4));
75   }
76 }
77
Popular Tags