KickJava   Java API By Example, From Geeks To Geeks.

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


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.DatabaseBackendUser;
28 import org.objectweb.cjdbc.scenario.templates.NoTemplate;
29
30 /**
31  * <code>DatabaseBackendUser</code> test class.
32  *
33  * @author <a HREF="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier</a>
34  * @see org.objectweb.cjdbc.common.users.DatabaseBackendUser
35  */

36 public class DatabaseBackendUserTest extends NoTemplate
37 {
38   DatabaseBackendUser user1, user2, user3, user4, user5;
39
40   /**
41    * @see junit.framework.TestCase#setUp()
42    */

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

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

72   public void testEquals()
73   {
74     assertEquals(user1, user1);
75     assertEquals(user1, user2);
76     assertFalse(user1.equals(user3));
77     assertFalse(user1.equals(user4));
78     assertFalse(user1.equals(user4));
79   }
80 }
81
Popular Tags