Search in sources :

Example 1 with EzySimpleUserManager

use of com.tvd12.ezyfoxserver.wrapper.EzySimpleUserManager in project ezyfox-server by youngmonkeys.

the class EzySimpleUserManagerTest method fromConstructorTest.

@Test
public void fromConstructorTest() {
    EzySimpleUserManager manager = new EzySimpleUserManager(1);
    assert manager.getMaxUsers() == 1;
    assert manager.available();
    EzySimpleUser user1 = new EzySimpleUser();
    user1.setName("user1");
    manager.addUser(user1);
    try {
        EzySimpleUser user2 = new EzySimpleUser();
        user2.setName("user2");
        manager.addUser(user2);
    } catch (Exception e) {
        assert e instanceof EzyMaxUserException;
    }
    assert !manager.available();
    manager.getLock(user1.getName());
    manager.clear();
    manager.destroy();
}
Also used : EzyMaxUserException(com.tvd12.ezyfoxserver.exception.EzyMaxUserException) EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzySimpleUserManager(com.tvd12.ezyfoxserver.wrapper.EzySimpleUserManager) EzyMaxUserException(com.tvd12.ezyfoxserver.exception.EzyMaxUserException) Test(org.testng.annotations.Test)

Example 2 with EzySimpleUserManager

use of com.tvd12.ezyfoxserver.wrapper.EzySimpleUserManager in project ezyfox-server by youngmonkeys.

the class EzySimpleUserManagerTest method fromBuilderTest.

@Test
public void fromBuilderTest() {
    int maxUsers = RandomUtil.randomSmallInt() + 3;
    EzySimpleUserManager manager = (EzySimpleUserManager) EzySimpleUserManager.builder().maxUsers(maxUsers).build();
    assert manager.getMaxUsers() == maxUsers;
    assert manager.available();
    EzySimpleUser user1 = new EzySimpleUser();
    user1.setName("user1");
    manager.addUser(user1);
    try {
        EzySimpleUser user2 = new EzySimpleUser();
        user2.setName("user2");
        manager.addUser(user2);
    } catch (Exception e) {
        assert e instanceof EzyMaxUserException;
    }
    assert manager.available();
    manager.getLock(user1.getName());
    manager.clear();
    manager.destroy();
}
Also used : EzyMaxUserException(com.tvd12.ezyfoxserver.exception.EzyMaxUserException) EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzySimpleUserManager(com.tvd12.ezyfoxserver.wrapper.EzySimpleUserManager) EzyMaxUserException(com.tvd12.ezyfoxserver.exception.EzyMaxUserException) Test(org.testng.annotations.Test)

Aggregations

EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)2 EzyMaxUserException (com.tvd12.ezyfoxserver.exception.EzyMaxUserException)2 EzySimpleUserManager (com.tvd12.ezyfoxserver.wrapper.EzySimpleUserManager)2 Test (org.testng.annotations.Test)2