Search in sources :

Example 6 with EzySimpleResponse

use of com.tvd12.ezyfoxserver.response.EzySimpleResponse in project ezyfox-server by youngmonkeys.

the class EzySendResponseImplTest method responseOneSuccessCaseTest.

@Test
public void responseOneSuccessCaseTest() {
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.setDebug(true);
    EzyResponseApi responseApi = spy(EzyAbstractResponseApi.class);
    EzySimpleServer server = new EzySimpleServer();
    server.setResponseApi(responseApi);
    server.setSettings(settings);
    EzySendResponseImpl cmd = new EzySendResponseImpl(server);
    EzyResponse response = new EzySimpleResponse(EzyCommand.APP_REQUEST);
    EzySession recipient = spy(EzyAbstractSession.class);
    cmd.execute(response, recipient, false, false, EzyTransportType.TCP);
}
Also used : EzySimpleResponse(com.tvd12.ezyfoxserver.response.EzySimpleResponse) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzySendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl) Test(org.testng.annotations.Test)

Example 7 with EzySimpleResponse

use of com.tvd12.ezyfoxserver.response.EzySimpleResponse in project ezyfox-server by youngmonkeys.

the class EzySendResponseImplTest method responseMultiSuccessCaseButNotDebug.

@Test
public void responseMultiSuccessCaseButNotDebug() throws Exception {
    // when
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.setDebug(false);
    EzyResponseApi responseApi = mock(EzyResponseApi.class);
    EzySimpleServer server = new EzySimpleServer();
    server.setResponseApi(responseApi);
    server.setSettings(settings);
    EzySendResponseImpl cmd = new EzySendResponseImpl(server);
    EzyResponse response = new EzySimpleResponse(EzyCommand.APP_REQUEST);
    EzySession recipient = spy(EzyAbstractSession.class);
    List<EzySession> recipients = Collections.singletonList(recipient);
    // when
    cmd.execute(response, recipients, false, false, EzyTransportType.TCP);
    // then
    verify(responseApi, times(1)).response(any(EzyPackage.class), anyBoolean());
}
Also used : EzySimpleResponse(com.tvd12.ezyfoxserver.response.EzySimpleResponse) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyPackage(com.tvd12.ezyfoxserver.response.EzyPackage) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzySendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl) Test(org.testng.annotations.Test)

Example 8 with EzySimpleResponse

use of com.tvd12.ezyfoxserver.response.EzySimpleResponse in project ezyfox-server by youngmonkeys.

the class EzySendResponseImplTest method responseMultiErrorTest.

@Test
public void responseMultiErrorTest() throws Exception {
    // given
    EzySimpleSettings settings = new EzySimpleSettings();
    settings.setDebug(true);
    EzyResponseApi responseApi = mock(EzyResponseApi.class);
    doThrow(new IllegalArgumentException()).when(responseApi).response(any(EzyPackage.class), anyBoolean());
    EzySimpleServer server = new EzySimpleServer();
    server.setResponseApi(responseApi);
    server.setSettings(settings);
    EzySendResponseImpl cmd = new EzySendResponseImpl(server);
    EzyResponse response = new EzySimpleResponse(EzyCommand.APP_REQUEST);
    EzySession recipient = spy(EzyAbstractSession.class);
    List<EzySession> recipients = Collections.singletonList(recipient);
    // when
    cmd.execute(response, recipients, false, false, EzyTransportType.TCP);
    // then
    verify(responseApi, times(1)).response(any(EzyPackage.class), anyBoolean());
}
Also used : EzySimpleResponse(com.tvd12.ezyfoxserver.response.EzySimpleResponse) EzySimpleServer(com.tvd12.ezyfoxserver.EzySimpleServer) EzyPackage(com.tvd12.ezyfoxserver.response.EzyPackage) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) EzyResponse(com.tvd12.ezyfoxserver.response.EzyResponse) EzyResponseApi(com.tvd12.ezyfoxserver.api.EzyResponseApi) EzySession(com.tvd12.ezyfoxserver.entity.EzySession) EzySendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl) Test(org.testng.annotations.Test)

Aggregations

EzySimpleServer (com.tvd12.ezyfoxserver.EzySimpleServer)8 EzyResponseApi (com.tvd12.ezyfoxserver.api.EzyResponseApi)8 EzySendResponseImpl (com.tvd12.ezyfoxserver.command.impl.EzySendResponseImpl)8 EzySession (com.tvd12.ezyfoxserver.entity.EzySession)8 EzyResponse (com.tvd12.ezyfoxserver.response.EzyResponse)8 EzySimpleResponse (com.tvd12.ezyfoxserver.response.EzySimpleResponse)8 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)8 Test (org.testng.annotations.Test)8 EzyPackage (com.tvd12.ezyfoxserver.response.EzyPackage)7