/*
- * Copyright 2005 the original author or authors.
- *
+ * Copyright 2005-2010 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- */
+ */
package org.wamblee.usermgt.hibernate;
import org.wamblee.cache.EhCache;
import java.util.Set;
-
/**
* Tests for {@link org.wamblee.usermgt.hibernate.HibernateGroupSet}
- *
+ *
* @author Erik Brakkee
*/
public class HibernateUserSetTest extends InMemoryUserSetTest {
- /**
- * DOCUMENT ME!
- */
private static final String USER_TABLE = "USERS";
- /**
- * DOCUMENT ME!
- */
private static final String GROUP_TABLE = "GROUPS";
- /**
- * DOCUMENT ME!
- */
- private static final String USER_QUERY = "select * from " + USER_TABLE
- + " where name = ?";
+ private static final String USER_QUERY = "select * from " + USER_TABLE +
+ " where name = ?";
- /**
- * DOCUMENT ME!
- */
- private static final String GROUP_QUERY = "select * from " + GROUP_TABLE
- + " where name = ?";
+ private static final String GROUP_QUERY = "select * from " + GROUP_TABLE +
+ " where name = ?";
- /**
- * DOCUMENT ME!
- */
private DefaultContainer container;
- /**
- * DOCUMENT ME!
- */
private Scope scope;
- /**
- * DOCUMENT ME!
- */
private UserSet userset;
- /**
- * DOCUMENT ME!
- */
private GroupSet groupset;
- /**
- * DOCUMENT ME!
- */
private EhCache<Serializable, Serializable> userCache;
- /**
- * DOCUMENT ME!
- */
private DatabaseTesterComponent databaseTester;
/*
* (non-Javadoc)
- *
+ *
* @see org.wamblee.usermgt.InMemoryUserSetTest#setUp()
*/
- /**
- * DOCUMENT ME!
- *
- * @throws Exception DOCUMENT ME!
- */
@Override
protected void setUp() throws Exception {
container = new UserMgtRepositoryTestContainer("top");
- ObjectConfiguration config = new ObjectConfiguration(HibernateUserSetTest.class);
+ ObjectConfiguration config = new ObjectConfiguration(
+ HibernateUserSetTest.class);
config.getSetterConfig().clear().add("setUserset").add("setGroupset")
- .add("setDatabaseTester").add("setUserCache");
+ .add("setDatabaseTester").add("setUserCache");
container.addComponent("testcase", this, config);
scope = container.start();
super.setUp();
}
- /**
- * DOCUMENT ME!
- *
- * @param aUserset DOCUMENT ME!
- */
public void setUserset(UserSet aUserset) {
userset = aUserset;
}
- /**
- * DOCUMENT ME!
- *
- * @param aGroupset DOCUMENT ME!
- */
public void setGroupset(GroupSet aGroupset) {
groupset = aGroupset;
}
- /**
- * DOCUMENT ME!
- *
- * @param aUserCache DOCUMENT ME!
- */
public void setUserCache(EhCache<Serializable, Serializable> aUserCache) {
userCache = aUserCache;
}
- /**
- * DOCUMENT ME!
- *
- * @param aDatabaseTester DOCUMENT ME!
- */
public void setDatabaseTester(DatabaseTesterComponent aDatabaseTester) {
databaseTester = aDatabaseTester;
}
- /**
- * DOCUMENT ME!
- *
- * @throws Exception DOCUMENT ME!
- */
@Override
protected void tearDown() throws Exception {
container.stop(scope);
/*
* (non-Javadoc)
- *
+ *
* @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupCount(int)
*/
- /**
- * DOCUMENT ME!
- *
- * @param aSize DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
@Override
protected void checkUserCount(int aSize) throws SQLException {
databaseTester.flush();
/*
* (non-Javadoc)
- *
- * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String)
- */
- /**
- * DOCUMENT ME!
- *
- * @param aUser DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @see
+ * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String
+ * )
*/
@Override
protected void checkUserExists(String aUser) throws SQLException {
/*
* (non-Javadoc)
- *
- * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang.String)
- */
- /**
- * DOCUMENT ME!
- *
- * @param aUser DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @see
+ * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang
+ * .String)
*/
@Override
protected void checkUserNotExists(String aUser) throws SQLException {
/*
* (non-Javadoc)
- *
+ *
* @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupCount(int)
*/
- /**
- * DOCUMENT ME!
- *
- * @param aSize DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
- */
@Override
protected void checkGroupCount(int aSize) throws SQLException {
databaseTester.flush();
/*
* (non-Javadoc)
- *
- * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String)
- */
- /**
- * DOCUMENT ME!
- *
- * @param aGroup DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @see
+ * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupExists(java.lang.String
+ * )
*/
@Override
protected void checkGroupExists(String aGroup) throws SQLException {
/*
* (non-Javadoc)
- *
- * @see org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang.String)
- */
- /**
- * DOCUMENT ME!
- *
- * @param aGroup DOCUMENT ME!
- *
- * @throws SQLException DOCUMENT ME!
+ *
+ * @see
+ * org.wamblee.usermgt.InMemoryGroupSetTest#checkGroupNotExists(java.lang
+ * .String)
*/
@Override
protected void checkGroupNotExists(String aGroup) throws SQLException {
/*
* (non-Javadoc)
- *
+ *
* @see org.wamblee.usermgt.InMemoryGroupSetTest#createGroupSet()
*/
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
@Override
protected UserSet createUserSet() {
return userset;
/*
* (non-Javadoc)
- *
+ *
* @see org.wamblee.usermgt.InMemoryUserSetTest#createGroupSet()
*/
- /**
- * DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
@Override
protected GroupSet createGroupSet() {
return groupset;
}
/**
- * Reproduction of a bug. Create a user which is in group1 Add it
- * to a second group group2. Remove the user from group1. Verify the user
- * is in group2.
- *
- * @throws SQLException DOCUMENT ME!
- * @throws UserMgtException DOCUMENT ME!
+ * Reproduction of a bug. Create a user which is in group1 Add it to a
+ * second group group2. Remove the user from group1. Verify the user is in
+ * group2.
+ *
*/
public void testVerifyAddRemove() throws SQLException, UserMgtException {
databaseTester.cleanDatabase(); // just to be sure.
getUsers().userModified(user);
clearUserCache();
- User user2 = getUsers().find("user");
+ User user2 = getUsers().find("user");
Set<Group> userGroups = user2.getGroups();
assertTrue(user2.isInGroup("group1"));
assertTrue(user2.isInGroup("group2"));
removeUserFromGroup(user, group1);
getUsers().userModified(user);
clearUserCache();
- user2 = getUsers().find("user");
- userGroups = user2.getGroups();
+ user2 = getUsers().find("user");
+ userGroups = user2.getGroups();
assertFalse(user2.isInGroup("group1"));
assertTrue(user2.isInGroup("group2"));
assertEquals(1, userGroups.size());