@@ -0,0 +1,2852 @@
+package com.rackspacecloud.blueflood.http;%0A%0Aimport io.netty.channel.Channel;%0Aimport io.netty.channel.ChannelFuture;%0Aimport io.netty.channel.ChannelHandlerContext;%0Aimport io.netty.handler.codec.http.*;%0Aimport org.junit.Test;%0Aimport static org.junit.Assert.*;%0Aimport static org.mockito.Mockito.*;%0A%0A/**%0A *%0A */%0Apublic class HttpResponderTest %7B%0A%0A    @Test%0A    public void testDefaultHttpConnIdleTimeout_RequestKeepAlive_ShouldHaveResponseKeepAlive() %7B%0A        HttpResponder responder = new HttpResponder();%0A%0A        ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);%0A        FullHttpRequest request = mock(FullHttpRequest.class);%0A        FullHttpResponse response = mock(FullHttpResponse.class);%0A        HttpHeaders headers = mock(HttpHeaders.class);%0A        Channel channel = mock(Channel.class);%0A%0A        when(ctx.channel()).thenReturn(channel);%0A%0A        when(request.content()).thenReturn(null);%0A        when(request.headers()).thenReturn(headers);%0A        when(headers.get(HttpHeaders.Names.CONNECTION)).thenReturn(HttpHeaders.Values.KEEP_ALIVE);%0A        when(request.getProtocolVersion()).thenReturn(HttpVersion.HTTP_1_1);%0A%0A        HttpHeaders responseHeaders = new DefaultHttpHeaders();%0A        when(response.headers()).thenReturn(responseHeaders);%0A%0A        responder.respond(ctx, request, response);%0A%0A        assertEquals(%22Connection: response header%22, HttpHeaders.Values.KEEP_ALIVE, responseHeaders.get(HttpHeaders.Names.CONNECTION));%0A    %7D%0A%0A    @Test%0A    public void testNonZeroHttpConnIdleTimeout_RequestKeepAlive_ShouldHaveResponseKeepAliveTimeout() %7B%0A        int idleTimeout = 300;%0A        HttpResponder responder = new HttpResponder(idleTimeout);%0A%0A        ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);%0A        FullHttpRequest request = mock(FullHttpRequest.class);%0A        FullHttpResponse response = mock(FullHttpResponse.class);%0A        HttpHeaders headers = mock(HttpHeaders.class);%0A        Channel channel = mock(Channel.class);%0A        ChannelFuture future = mock(ChannelFuture.class);%0A%0A        when(ctx.channel()).thenReturn(channel);%0A        when(ctx.writeAndFlush(any())).thenReturn(future);%0A%0A        when(request.content()).thenReturn(null);%0A        when(request.headers()).thenReturn(headers);%0A        when(headers.get(HttpHeaders.Names.CONNECTION)).thenReturn(HttpHeaders.Values.KEEP_ALIVE);%0A        when(request.getProtocolVersion()).thenReturn(HttpVersion.HTTP_1_1);%0A%0A        HttpHeaders responseHeaders = new DefaultHttpHeaders();%0A        when(response.headers()).thenReturn(responseHeaders);%0A%0A        responder.respond(ctx, request, response);%0A%0A        assertEquals(%22Connection: response header%22, HttpHeaders.Values.KEEP_ALIVE, responseHeaders.get(HttpHeaders.Names.CONNECTION));%0A        assertEquals(%22Keep-Alive: response header%22, %22timeout=%22+idleTimeout, responseHeaders.get(%22Keep-Alive%22));%0A    %7D%0A%7D%0A

add HttpResponderTest unit test