This commit is contained in:
Maxime Dagnicourt
2008-01-29 23:53:03 +00:00
parent 354d879a36
commit 10dcb5eb2b

View File

@@ -1,33 +1,57 @@
package org.yacos.tests.core;
import static org.junit.Assert.assertFalse;
import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.yacos.core.conferences.IConferenceManager;
import org.yacos.core.exceptions.PKAlreadyUsedException;
import org.yacos.core.users.IUserManager;
import org.yacos.core.users.Role;
import org.yacos.core.users.User;
import org.yacos.core.users.Role.RoleType;
public class UserManagerTest {
static IUserManager um;
private static IUserManager um;
private static IConferenceManager cm;
@BeforeClass
public static void setUpManager() throws NamingException, PKAlreadyUsedException {
public static void setUpManager() throws NamingException {
Context context = new InitialContext();
um = (IUserManager) context.lookup("UserManagerBean/remote");
cm = (IConferenceManager) context.lookup("ConferenceManagerBean/remote");
if(!um.exists("max")){
um.addUser("max","pw","maxime","dagn","ipint", "e@e.fr");
}
@Before
public void setup()throws PKAlreadyUsedException{
if(!um.exists("truc")){
um.addUser("truc","pw","maxime","dagn","ipint", "e@e.fr");
}
}
@Test
public void getUserByRoleType(){
Role role = cm.addRole(RoleType.PCMEMBER, "truc", 1);
List<User> list = um.getUsers(RoleType.PCMEMBER);
assertFalse(list.isEmpty());
cm.removeRole(role);
}
@After
public void ControleUser() throws PKAlreadyUsedException{
if(!um.exists("max")){
um.addUser("max","pw","maxime","dagn","ipint", "e@e.fr");
if(um.exists("truc")){
um.removeUser("truc");
}
}