use of org.mockserver.closurecallback.websocketregistry.WebSocketClientRegistry in project mockserver by mock-server.
the class MockServerMatcherBasicResponsesTest method prepareTestFixture.
@Before
public void prepareTestFixture() {
Scheduler scheduler = mock(Scheduler.class);
WebSocketClientRegistry webSocketClientRegistry = mock(WebSocketClientRegistry.class);
requestMatchers = new RequestMatchers(configuration(), new MockServerLogger(), scheduler, webSocketClientRegistry);
}
use of org.mockserver.closurecallback.websocketregistry.WebSocketClientRegistry in project mockserver by mock-server.
the class MockServerMatcherClearAndResetTest method prepareTestFixture.
@Before
public void prepareTestFixture() {
configuration = configuration();
mockServerLogger = new MockServerLogger();
WebSocketClientRegistry webSocketClientRegistry = mock(WebSocketClientRegistry.class);
requestMatchers = new RequestMatchers(configuration(), mockServerLogger, new Scheduler(configuration(), mockServerLogger, true), webSocketClientRegistry);
}
use of org.mockserver.closurecallback.websocketregistry.WebSocketClientRegistry in project mockserver by mock-server.
the class MockServerMatcherSequentialResponsesTest method prepareTestFixture.
@Before
public void prepareTestFixture() {
MockServerLogger mockLogFormatter = mock(MockServerLogger.class);
Scheduler scheduler = mock(Scheduler.class);
WebSocketClientRegistry webSocketClientRegistry = mock(WebSocketClientRegistry.class);
requestMatchers = new RequestMatchers(configuration(), mockLogFormatter, scheduler, webSocketClientRegistry);
}
use of org.mockserver.closurecallback.websocketregistry.WebSocketClientRegistry in project mockserver by mock-server.
the class HttpForwardObjectCallbackActionHandlerTest method shouldReturnNotFound.
@Test
public void shouldReturnNotFound() throws ExecutionException, InterruptedException {
// given
HttpActionHandler mockActionHandler = mock(HttpActionHandler.class);
HttpState mockHttpStateHandler = mock(HttpState.class);
WebSocketClientRegistry mockWebSocketClientRegistry = mock(WebSocketClientRegistry.class);
HttpObjectCallback httpObjectCallback = new HttpObjectCallback().withClientId("some_clientId");
HttpRequest request = request().withBody("some_body");
ResponseWriter mockResponseWriter = mock(ResponseWriter.class);
when(mockHttpStateHandler.getWebSocketClientRegistry()).thenReturn(mockWebSocketClientRegistry);
when(mockHttpStateHandler.getMockServerLogger()).thenReturn(new MockServerLogger());
when(mockWebSocketClientRegistry.sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull())).thenReturn(false);
// when
new HttpForwardObjectCallbackActionHandler(mockHttpStateHandler, null).handle(mockActionHandler, httpObjectCallback, request, mockResponseWriter, true, null);
// then
verify(mockWebSocketClientRegistry).registerForwardCallbackHandler(any(String.class), any(WebSocketRequestCallback.class));
verify(mockWebSocketClientRegistry).sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull());
ArgumentCaptor<HttpForwardActionResult> httpForwardActionResultArgumentCaptor = ArgumentCaptor.forClass(HttpForwardActionResult.class);
verify(mockActionHandler).writeForwardActionResponse(httpForwardActionResultArgumentCaptor.capture(), same(mockResponseWriter), same(request), same(httpObjectCallback), eq(true));
assertThat(httpForwardActionResultArgumentCaptor.getValue().getHttpResponse().get(), is(notFoundResponse()));
}
use of org.mockserver.closurecallback.websocketregistry.WebSocketClientRegistry in project mockserver by mock-server.
the class HttpResponseObjectCallbackActionHandlerTest method shouldReturnNotFound.
@Test
public void shouldReturnNotFound() {
// given
HttpActionHandler mockActionHandler = mock(HttpActionHandler.class);
HttpState mockHttpStateHandler = mock(HttpState.class);
WebSocketClientRegistry mockWebSocketClientRegistry = mock(WebSocketClientRegistry.class);
HttpObjectCallback httpObjectCallback = new HttpObjectCallback().withClientId("some_clientId");
HttpRequest request = request().withBody("some_body");
ResponseWriter mockResponseWriter = mock(ResponseWriter.class);
when(mockHttpStateHandler.getWebSocketClientRegistry()).thenReturn(mockWebSocketClientRegistry);
when(mockHttpStateHandler.getMockServerLogger()).thenReturn(new MockServerLogger());
when(mockWebSocketClientRegistry.sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull())).thenReturn(false);
// when
new HttpResponseObjectCallbackActionHandler(mockHttpStateHandler).handle(mockActionHandler, httpObjectCallback, request, mockResponseWriter, true, null);
// then
verify(mockWebSocketClientRegistry).registerResponseCallbackHandler(any(String.class), any(WebSocketResponseCallback.class));
verify(mockWebSocketClientRegistry).sendClientMessage(eq("some_clientId"), any(HttpRequest.class), isNull());
verify(mockActionHandler).writeResponseActionResponse(notFoundResponse().removeHeader(WEB_SOCKET_CORRELATION_ID_HEADER_NAME), mockResponseWriter, request, httpObjectCallback, true);
}
Aggregations