@@ -0,0 +1,2706 @@
+/*%0A * Copyright 2014-2015 CyberVision, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.kaaproject.kaa.server.transports.http.transport.netty;%0A%0Aimport io.netty.channel.Channel;%0Aimport io.netty.channel.ChannelHandlerContext;%0Aimport io.netty.channel.ChannelPromise;%0Aimport io.netty.handler.codec.http.HttpHeaders;%0Aimport io.netty.handler.codec.http.HttpResponse;%0Aimport io.netty.handler.codec.http.HttpVersion;%0Aimport io.netty.util.Attribute;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.kaaproject.kaa.server.common.server.AbstractNettyServer;%0A%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class ResponseEncoderTest %7B%0A    private ResponseEncoder responseEncoder = new ResponseEncoder();%0A    private ChannelHandlerContext channelHandlerContext = mock(ChannelHandlerContext.class);%0A    private AbstractCommand abstractCommand = mock(AbstractCommand.class);%0A    private ChannelPromise promise = mock(ChannelPromise.class);%0A    private HttpResponse response = mock(HttpResponse.class);%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    @Before%0A    public void before() %7B%0A        Channel channel = mock(Channel.class);%0A        Attribute attribute = mock(Attribute.class);%0A        HttpHeaders headers = mock(HttpHeaders.class);%0A        when(response.headers()).thenReturn(headers);%0A        when(response.getProtocolVersion()).thenReturn(new HttpVersion(%22HTTP/1.1%22, true));%0A        when(channelHandlerContext.channel()).thenReturn(channel);%0A        when(headers.get(any(CharSequence.class))).thenReturn(null);%0A        when(channel.attr(AbstractNettyServer.UUID_KEY)).thenReturn(attribute);%0A        when(abstractCommand.getResponse()).thenReturn(response);%0A    %7D%0A%0A    @Test%0A    public void validHttpResponseWriteTest() throws Exception %7B%0A        responseEncoder.write(channelHandlerContext, abstractCommand, promise);%0A        verify(channelHandlerContext).writeAndFlush(response, promise);%0A    %7D%0A%0A    @Test%0A    public void invalidHttpResponseWriteTest() throws Exception %7B%0A        responseEncoder.write(channelHandlerContext, new Object(), promise);%0A        verify(channelHandlerContext, never()).writeAndFlush(response, promise);%0A    %7D%0A%7D%0A

add test for ResponseEncoder