import java.util.Set;
-
/**
* Tests the inmemory user set. Intended to be subclassed for other
* implementations of user set.
*/
public class InMemoryUserSetTest extends TestCase {
- /**
- * DOCUMENT ME!
- */
protected static final String PASSWORD = "abc123";
- /**
- * DOCUMENT ME!
- */
private UserSet users;
- /**
- * DOCUMENT ME!
- */
private GroupSet groups;
- /**
- * DOCUMENT ME!
- */
private Group group;
/**
* This method must be overriden in subclasses.
- *
+ *
* @return New user set object.
*/
protected UserSet createUserSet() {
return new InMemoryUserSet(new RegexpNameValidator(
- RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD,
- "Password must contain at least 6 characters"),
+ RegexpNameValidator.PASSWORD_PATTERN, Reason.INVALID_PASSWORD,
+ "Password must contain at least 6 characters"),
new Md5HexMessageDigester());
}
/**
* This method must be overriden in subclasses.
- *
+ *
* @return New group set object.
*/
protected GroupSet createGroupSet() {
return new InMemoryGroupSet();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.wamblee.test.SpringTestCase#setUp()
*/
- /**
- * DOCUMENT ME!
- *
- * @throws Exception DOCUMENT ME!
- */
@Override
protected void setUp() throws Exception {
super.setUp();
- users = createUserSet();
- groups = createGroupSet();
- group = new Group("group0");
+ users = createUserSet();
+ groups = createGroupSet();
+ group = new Group("group0");
groups.add(group);
checkUserCount(0);
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
protected UserSet getUsers() {
return users;
}
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
protected GroupSet getGroups() {
return groups;
}
- /**
- * DOCUMENT ME!
- *
- * @param aName DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
protected Group createGroup(String aName) {
return new Group(aName);
}
- /**
- * DOCUMENT ME!
- *
- * @param aName DOCUMENT ME!
- * @param aPassword DOCUMENT ME!
- * @param aGroup DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- *
- * @throws UserMgtException DOCUMENT ME!
- */
protected User createUser(String aName, String aPassword, Group aGroup)
throws UserMgtException {
return UsermgtTestUtils.createUser(aName, aPassword, aGroup);
}
- /**
- * DOCUMENT ME!
- *
- * @param aUser DOCUMENT ME!
- * @param aGroup DOCUMENT ME!
- *
- * @throws UserMgtException DOCUMENT ME!
- */
protected void addUserToGroup(User aUser, Group aGroup)
throws UserMgtException {
aUser.addGroup(aGroup);
}
- /**
- * DOCUMENT ME!
- *
- * @param aUser DOCUMENT ME!
- * @param aGroup DOCUMENT ME!
- *
- * @throws UserMgtException DOCUMENT ME!
- */
protected void removeUserFromGroup(User aUser, Group aGroup)
throws UserMgtException {
aUser.removeGroup(aGroup);
/**
* Additional check to be implemented by a subclass.
- *
- * @param aUser User to check for existence.
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @param aUser
+ * User to check for existence.
+ *
*/
protected void checkUserExists(String aUser) throws SQLException {
// Empty
/**
* Additional check to be implemented by a subclass.
- *
- * @param aUser User to check for non-existence.
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @param aUser
+ * User to check for non-existence.
+ *
*/
protected void checkUserNotExists(String aUser) throws SQLException {
// Empty
/**
* Additional check to be implemented by a subclass.
- *
- * @param aSize Expected number of users.
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @param aSize
+ * Expected number of users.
+ *
*/
protected void checkUserCount(int aSize) throws SQLException {
assertEquals(aSize, users.size());
/**
* Additional check to be implemented by a subclass.
- *
- * @param aUser User to check for existence.
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @param aUser
+ * User to check for existence.
+ *
*/
protected void checkGroupExists(String aUser) throws SQLException {
// Empty
/**
* Additional check to be implemented by a subclass.
- *
- * @param aUser User to check for non-existence.
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @param aUser
+ * User to check for non-existence.
+ *
*/
protected void checkGroupNotExists(String aUser) throws SQLException {
// Empty
/**
* Additional check to be implemented by a subclass.
- *
- * @param aSize Expected number of users.
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @param aSize
+ * Expected number of users.
+ *
*/
protected void checkGroupCount(int aSize) throws SQLException {
// Empty
}
/**
- * Adds a user and verifies that the user is added using find(),
- * list(), and contains().
- *
- * @throws SQLException DOCUMENT ME!
- * @throws UserMgtException DOCUMENT ME!
+ * Adds a user and verifies that the user is added using find(), list(), and
+ * contains().
+ *
*/
public void testAdd() throws SQLException, UserMgtException {
User user = createUser("user1", PASSWORD, group);
}
/**
- * Tries to find a non-existing user. Verifies that null is
- * returned.
- *
- * @throws SQLException DOCUMENT ME!
- * @throws UserMgtException DOCUMENT ME!
+ * Tries to find a non-existing user. Verifies that null is returned.
+ *
*/
public void testFindUnknownUser() throws SQLException, UserMgtException {
User user1 = createUser("user1", PASSWORD, group);
}
/**
- * Adds duplicate user. Verifies that the existing user is left
- * untouched.
- *
- * @throws SQLException DOCUMENT ME!
- * @throws UserMgtException DOCUMENT ME!
+ * Adds duplicate user. Verifies that the existing user is left untouched.
+ *
*/
public void testAddDuplicateUser() throws SQLException, UserMgtException {
User user1 = createUser("user1", PASSWORD, group);
}
/**
- * Removes a user. Verifies that the user is removed and the
- * return value is true.
- *
- * @throws SQLException DOCUMENT ME!
- * @throws UserMgtException DOCUMENT ME!
+ * Removes a user. Verifies that the user is removed and the return value is
+ * true.
+ *
*/
public void testRemoveUser() throws SQLException, UserMgtException {
User user1 = createUser("user1", PASSWORD, group);
}
/**
- * Removes a non-existing user. Verifies that no users are removed
- * an that the return value is true.
- *
- * @throws SQLException DOCUMENT ME!
- * @throws UserMgtException DOCUMENT ME!
+ * Removes a non-existing user. Verifies that no users are removed an that
+ * the return value is true.
+ *
*/
- public void testRemoveNonExistingUser()
- throws SQLException, UserMgtException {
+ public void testRemoveNonExistingUser() throws SQLException,
+ UserMgtException {
User user1 = createUser("user1", PASSWORD, group);
users.add(user1);
checkUserCount(1);
}
/**
- * Adds a number of users to the set and verifies that list()
- * returns them all.
- *
- * @throws SQLException DOCUMENT ME!
- * @throws UserMgtException DOCUMENT ME!
+ * Adds a number of users to the set and verifies that list() returns them
+ * all.
+ *
*/
public void testList() throws SQLException, UserMgtException {
User user1 = createUser("user1", PASSWORD, group);
}
/**
- * Adds several users to different groups and verifies that the
- * correct users are returned when looking for users in different groups.
- *
+ * Adds several users to different groups and verifies that the correct
+ * users are returned when looking for users in different groups.
+ *
* @throws SQLException
- * @throws UserMgtException DOCUMENT ME!
*/
public void testListByGroup() throws SQLException, UserMgtException {
Group group1 = new Group("group1");
groups.add(group2);
groups.add(group3);
- // user1 user2 user3
- // group1 y
- // group2 y y
- // group3 y y y
+ // user1 user2 user3
+ // group1 y
+ // group2 y y
+ // group3 y y y
User user1 = createUser("user1", PASSWORD, group1);
user1.addGroup(group2);
user1.addGroup(group3);
checkGroupExists(group3.getName());
checkUserCount(3);
- checkGroupCount(3 + 1); // also count the group that was created in the setUp().
+ checkGroupCount(3 + 1); // also count the group that was created in the
+ // setUp().
Set<User> list = users.list(group1);
assertTrue(list.contains(user1));