Search in sources :

Example 1 with WebSocketInboundChannelAdapter

use of org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter in project spring-integration by spring-projects.

the class WebSocketServerTests method testBrokerIsNotPresented.

@Test
public void testBrokerIsNotPresented() throws Exception {
    WebSocketInboundChannelAdapter webSocketInboundChannelAdapter = new WebSocketInboundChannelAdapter(Mockito.mock(ServerWebSocketContainer.class));
    webSocketInboundChannelAdapter.setOutputChannel(new DirectChannel());
    webSocketInboundChannelAdapter.setUseBroker(true);
    webSocketInboundChannelAdapter.setBeanFactory(Mockito.mock(BeanFactory.class));
    webSocketInboundChannelAdapter.setApplicationContext(Mockito.mock(ApplicationContext.class));
    try {
        webSocketInboundChannelAdapter.afterPropertiesSet();
        fail("IllegalStateException expected");
    } catch (Exception e) {
        assertThat(e, instanceOf(IllegalStateException.class));
        assertThat(e.getMessage(), containsString("WebSocket Broker Relay isn't present in the application context;"));
    }
}
Also used : WebSocketInboundChannelAdapter(org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter) ApplicationContext(org.springframework.context.ApplicationContext) ServerWebSocketContainer(org.springframework.integration.websocket.ServerWebSocketContainer) DirectChannel(org.springframework.integration.channel.DirectChannel) BeanFactory(org.springframework.beans.factory.BeanFactory) Test(org.junit.Test)

Example 2 with WebSocketInboundChannelAdapter

use of org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter in project faf-java-server by FAForever.

the class WebsocketAdapterConfig method webSocketInboundChannelAdapter.

/**
 * WebSocket inbound adapter that accepts connections and messages from clients.
 */
@Bean
public WebSocketInboundChannelAdapter webSocketInboundChannelAdapter(IntegrationWebSocketContainer serverWebSocketContainer) {
    WebSocketInboundChannelAdapter adapter = new WebSocketInboundChannelAdapter(serverWebSocketContainer, new SubProtocolHandlerRegistry(new FafSubProtocolHandler(clientConnectionService)));
    adapter.setErrorChannelName(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME);
    return adapter;
}
Also used : WebSocketInboundChannelAdapter(org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter) SubProtocolHandlerRegistry(org.springframework.integration.websocket.support.SubProtocolHandlerRegistry) Bean(org.springframework.context.annotation.Bean)

Aggregations

WebSocketInboundChannelAdapter (org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter)2 Test (org.junit.Test)1 BeanFactory (org.springframework.beans.factory.BeanFactory)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Bean (org.springframework.context.annotation.Bean)1 DirectChannel (org.springframework.integration.channel.DirectChannel)1 ServerWebSocketContainer (org.springframework.integration.websocket.ServerWebSocketContainer)1 SubProtocolHandlerRegistry (org.springframework.integration.websocket.support.SubProtocolHandlerRegistry)1