Search in sources :

Example 6 with EzyZoneUserManagerImpl

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

the class EzyZoneUserManagerImplTest method newZoneUserManager.

private EzyZoneUserManagerImpl newZoneUserManager() {
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(serverContext.getZoneContext(1)).thenReturn(zoneContext);
    TestBlockingSocketUserRemovalQueue queue = new TestBlockingSocketUserRemovalQueue();
    EzySimpleUserDelegate userDelegate = new EzySimpleUserDelegate(serverContext, queue);
    return (EzyZoneUserManagerImpl) EzyZoneUserManagerImpl.builder().idleValidationDelay(10).idleValidationInterval(10).idleValidationThreadPoolSize(1).userDelegate(userDelegate).build();
}
Also used : EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzySimpleUserDelegate(com.tvd12.ezyfoxserver.delegate.EzySimpleUserDelegate) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyZoneUserManagerImpl(com.tvd12.ezyfoxserver.wrapper.impl.EzyZoneUserManagerImpl) TestBlockingSocketUserRemovalQueue(com.tvd12.ezyfoxserver.testing.socket.TestBlockingSocketUserRemovalQueue)

Example 7 with EzyZoneUserManagerImpl

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

the class EzyZoneUserManagerImplTest method newAndAddIdleUser.

private void newAndAddIdleUser(EzyZoneUserManagerImpl manager) {
    EzyAbstractSession session = mock(EzyAbstractSession.class);
    EzySimpleUser user = new EzySimpleUser();
    user.setZoneId(1);
    user.setName("user3");
    user.setMaxIdleTime(Integer.MAX_VALUE);
    manager.addUser(session, user);
    user.removeSession(session);
    user.setMaxIdleTime(0);
}
Also used : EzySimpleUser(com.tvd12.ezyfoxserver.entity.EzySimpleUser) EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession)

Example 8 with EzyZoneUserManagerImpl

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

the class EzyZoneUserManagerImplTest method destroyWithIdleValidationService.

@Test
public void destroyWithIdleValidationService() {
    // given
    EzyZoneUserManagerImpl sut = newZoneUserManager();
    // when
    sut.destroy();
    // then
    Asserts.assertNull(FieldUtil.getFieldValue(sut, "idleValidationService"));
}
Also used : EzyZoneUserManagerImpl(com.tvd12.ezyfoxserver.wrapper.impl.EzyZoneUserManagerImpl) Test(org.testng.annotations.Test)

Aggregations

EzyZoneUserManagerImpl (com.tvd12.ezyfoxserver.wrapper.impl.EzyZoneUserManagerImpl)7 Test (org.testng.annotations.Test)6 EzyConstant (com.tvd12.ezyfox.constant.EzyConstant)3 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)3 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)2 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)2 EzySimpleUserDelegate (com.tvd12.ezyfoxserver.delegate.EzySimpleUserDelegate)2 EzyAbstractSession (com.tvd12.ezyfoxserver.entity.EzyAbstractSession)2 EzySimpleUser (com.tvd12.ezyfoxserver.entity.EzySimpleUser)2 EzyUser (com.tvd12.ezyfoxserver.entity.EzyUser)2 TestBlockingSocketUserRemovalQueue (com.tvd12.ezyfoxserver.testing.socket.TestBlockingSocketUserRemovalQueue)2