Search in sources :

Example 36 with Request

use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.

the class EzyRequestAppControllerTest method testHasNotAccessed.

@Test
public void testHasNotAccessed() {
    EzyArray data = EzyEntityArrays.newArray(1, EzyEntityArrays.newArray());
    EzyRequestAppController controller = new EzyRequestAppController();
    MyTestUser user = new MyTestUser();
    user.setName("dungtv1");
    user.addSession(session);
    EzySimpleRequestAppRequest request = new EzySimpleRequestAppRequest();
    request.deserializeParams(data);
    request.setUser(user);
    request.setSession(session);
    EzyServerContext ctx = newServerContext();
    controller.handle(ctx, request);
}
Also used : EzyRequestAppController(com.tvd12.ezyfoxserver.controller.EzyRequestAppController) MyTestUser(com.tvd12.ezyfoxserver.testing.MyTestUser) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleRequestAppRequest(com.tvd12.ezyfoxserver.request.EzySimpleRequestAppRequest) Test(org.testng.annotations.Test) BaseCoreContextTest(com.tvd12.ezyfoxserver.testing.BaseCoreContextTest)

Example 37 with Request

use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.

the class EzyRequestAppControllerTest method test.

@Test
public void test() {
    EzyArray data = EzyEntityArrays.newArray(1, EzyEntityArrays.newArray());
    EzyRequestAppController controller = new EzyRequestAppController();
    EzySimpleRequestAppRequest request = new EzySimpleRequestAppRequest();
    request.deserializeParams(data);
    request.setUser(user);
    request.setSession(session);
    EzyServerContext ctx = newServerContext();
    controller.handle(ctx, request);
}
Also used : EzyRequestAppController(com.tvd12.ezyfoxserver.controller.EzyRequestAppController) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySimpleRequestAppRequest(com.tvd12.ezyfoxserver.request.EzySimpleRequestAppRequest) Test(org.testng.annotations.Test) BaseCoreContextTest(com.tvd12.ezyfoxserver.testing.BaseCoreContextTest)

Example 38 with Request

use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.

the class EzySocketRequestHandlerTest method test.

@Test
public void test() {
    ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
    EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
    EzySocketDataHandlerGroup handlerGroup = mock(EzySocketDataHandlerGroup.class);
    when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(handlerGroup);
    EzySession session = spy(EzyAbstractSession.class);
    session.setActivated(true);
    EzyRequestQueue requestQueue = new EzyNonBlockingRequestQueue();
    when(session.getExtensionRequestQueue()).thenReturn(requestQueue);
    EzyArray array = EzyEntityFactory.newArrayBuilder().append(10).build();
    EzySocketRequest request = new EzySimpleSocketRequest(session, array);
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
    handler.setSessionTicketsQueue(sessionTicketsRequestQueues.getExtensionQueue());
    sessionTicketsRequestQueues.addRequest(request);
    handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
    handler.handleEvent();
    handler.destroy();
}
Also used : EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test)

Example 39 with Request

use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.

the class EzySocketRequestHandlerTest method processRequestQueue0RemainTest.

@Test
public void processRequestQueue0RemainTest() {
    // given
    ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
    EzySocketDataHandlerGroup handlerGroup = mock(EzySocketDataHandlerGroup.class);
    EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
    when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(handlerGroup);
    EzySession session = spy(EzyAbstractSession.class);
    when(session.isActivated()).thenReturn(Boolean.TRUE);
    EzyRequestQueue requestQueue = new EzyNonBlockingRequestQueue();
    when(session.getExtensionRequestQueue()).thenReturn(requestQueue);
    EzyArray array = EzyEntityFactory.newArrayBuilder().append(10).build();
    EzySocketRequest request = new EzySimpleSocketRequest(session, array);
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
    handler.setSessionTicketsQueue(sessionTicketsRequestQueues.getExtensionQueue());
    sessionTicketsRequestQueues.addRequest(request);
    sessionTicketsRequestQueues.addRequest(request);
    handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
    // when
    handler.handleEvent();
    // then
    Asserts.assertEquals(sessionTicketsRequestQueues.getExtensionQueue().size(), 1);
}
Also used : EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test)

Example 40 with Request

use of com.tvd12.ezyhttp.client.request.Request in project ezyfox-server by youngmonkeys.

the class EzySocketRequestHandlerTest method handleGroupNullCaseTest.

@Test
public void handleGroupNullCaseTest() {
    ExEzySocketRequestHandler handler = new ExEzySocketRequestHandler();
    EzySocketDataHandlerGroupFetcher dataHandlerGroupFetcher = mock(EzySocketDataHandlerGroupFetcher.class);
    when(dataHandlerGroupFetcher.getDataHandlerGroup(any(EzySession.class))).thenReturn(null);
    EzySession session = spy(EzyAbstractSession.class);
    when(session.isActivated()).thenReturn(Boolean.TRUE);
    EzyRequestQueue requestQueue = new EzyNonBlockingRequestQueue();
    when(session.getExtensionRequestQueue()).thenReturn(requestQueue);
    EzyArray array = EzyEntityFactory.newArrayBuilder().append(10).build();
    EzySocketRequest request = new EzySimpleSocketRequest(session, array);
    EzySessionTicketsRequestQueues sessionTicketsRequestQueues = new EzySessionTicketsRequestQueues();
    handler.setSessionTicketsQueue(sessionTicketsRequestQueues.getExtensionQueue());
    sessionTicketsRequestQueues.addRequest(request);
    handler.setDataHandlerGroupFetcher(dataHandlerGroupFetcher);
    handler.handleEvent();
}
Also used : EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)128 HttpServletResponse (javax.servlet.http.HttpServletResponse)48 HttpServletRequest (javax.servlet.http.HttpServletRequest)45 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)37 BeforeTest (org.testng.annotations.BeforeTest)36 BaseTest (com.tvd12.test.base.BaseTest)31 EzyArray (com.tvd12.ezyfox.entity.EzyArray)30 ComponentManager (com.tvd12.ezyhttp.server.core.manager.ComponentManager)29 BlockingServlet (com.tvd12.ezyhttp.server.core.servlet.BlockingServlet)29 ToString (lombok.ToString)29 RequestURI (com.tvd12.ezyhttp.server.core.request.RequestURI)27 ServletOutputStream (javax.servlet.ServletOutputStream)25 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)24 RequestHandlerManager (com.tvd12.ezyhttp.server.core.manager.RequestHandlerManager)24 Cookie (javax.servlet.http.Cookie)24 HttpClientProxy (com.tvd12.ezyhttp.client.HttpClientProxy)22 RequestCookie (com.tvd12.ezyhttp.server.core.annotation.RequestCookie)22 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)21 HttpClient (com.tvd12.ezyhttp.client.HttpClient)21 PostRequest (com.tvd12.ezyhttp.client.request.PostRequest)21