use of org.wso2.carbon.apimgt.gateway.inbound.websocket.InboundWebSocketProcessor in project carbon-apimgt by wso2.
the class WebsocketInboundHandlerTestCase method setup.
@Before
public void setup() throws Exception {
inboundWebSocketProcessor = Mockito.mock(InboundWebSocketProcessor.class);
channelHandlerContext = Mockito.mock(ChannelHandlerContext.class);
Channel channel = Mockito.mock(Channel.class);
ChannelId channelId = Mockito.mock(ChannelId.class);
Mockito.when(channelHandlerContext.channel()).thenReturn(channel);
Mockito.when(channel.id()).thenReturn(channelId);
Mockito.when(channelId.asLongText()).thenReturn(channelIdString);
Mockito.when(channel.attr(WebSocketUtils.WSO2_PROPERTIES)).thenReturn(getChannelAttributeMap());
PowerMockito.mockStatic(WebSocketUtils.class);
SocketAddress socketAddress = Mockito.mock(SocketAddress.class);
Mockito.when(channel.remoteAddress()).thenReturn(socketAddress);
PowerMockito.when(WebSocketUtils.getApiProperties(channelHandlerContext)).thenReturn(new HashMap<>());
APIMgtGoogleAnalyticsUtils apiMgtGoogleAnalyticsUtils = Mockito.mock(APIMgtGoogleAnalyticsUtils.class);
PowerMockito.whenNew(APIMgtGoogleAnalyticsUtils.class).withAnyArguments().thenReturn(apiMgtGoogleAnalyticsUtils);
Mockito.doNothing().when(apiMgtGoogleAnalyticsUtils).init("carbon.super");
Mockito.doNothing().when(apiMgtGoogleAnalyticsUtils).publishGATrackingData(Mockito.anyObject(), Mockito.anyObject(), Mockito.anyObject());
websocketInboundHandler = new WebsocketInboundHandler() {
@Override
protected String getRemoteIP(ChannelHandlerContext ctx) {
return remoteIP;
}
@Override
public InboundWebSocketProcessor initializeWebSocketProcessor() {
return inboundWebSocketProcessor;
}
};
websocketAPI = new API(UUID.randomUUID().toString(), 1, "admin", "WSAPI", "1.0.0", "/wscontext", "Unlimited", APIConstants.API_TYPE_WS, APIConstants.PUBLISHED_STATUS, false);
}
Aggregations