This commit is contained in:
@@ -1,33 +1,57 @@
|
|||||||
package org.yacos.tests.core;
|
package org.yacos.tests.core;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
import javax.naming.NamingException;
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.yacos.core.conferences.IConferenceManager;
|
||||||
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
import org.yacos.core.exceptions.PKAlreadyUsedException;
|
||||||
import org.yacos.core.users.IUserManager;
|
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 {
|
public class UserManagerTest {
|
||||||
static IUserManager um;
|
private static IUserManager um;
|
||||||
|
private static IConferenceManager cm;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpManager() throws NamingException, PKAlreadyUsedException {
|
public static void setUpManager() throws NamingException {
|
||||||
Context context = new InitialContext();
|
Context context = new InitialContext();
|
||||||
|
|
||||||
um = (IUserManager) context.lookup("UserManagerBean/remote");
|
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
|
@After
|
||||||
public void ControleUser() throws PKAlreadyUsedException{
|
public void ControleUser() throws PKAlreadyUsedException{
|
||||||
if(!um.exists("max")){
|
if(um.exists("truc")){
|
||||||
um.addUser("max","pw","maxime","dagn","ipint", "e@e.fr");
|
um.removeUser("truc");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user