@@ -0,0 +1,1856 @@
+/*%0A * Copyright 2011 The Netty Project%0A *%0A * The Netty Project licenses this file to you under the Apache License,%0A * version 2.0 (the %22License%22); you may not use this file except in compliance%0A * with the License. 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, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and limitations%0A * under the License.%0A */package org.jboss.netty.channel.handler.stream;%0A%0Aimport java.io.ByteArrayInputStream;%0A%0Aimport junit.framework.Assert;%0A%0Aimport org.jboss.netty.buffer.ChannelBuffer;%0Aimport org.jboss.netty.handler.codec.embedder.EncoderEmbedder;%0Aimport org.jboss.netty.handler.stream.ChunkedStream;%0Aimport org.jboss.netty.handler.stream.ChunkedWriteHandler;%0Aimport org.junit.Test;%0A%0Apublic class ChunkedWriteHandlerTest %7B%0A    private static final byte%5B%5D BYTES = new byte%5B1024 * 64%5D;%0A    static %7B%0A        for (int i = 0; i %3C BYTES.length; i++) %7B%0A            BYTES%5Bi%5D = (byte) i;%0A        %7D%0A    %7D%0A%0A    // See #310%0A    @Test%0A    public void testChunkedStream() %7B%0A        EncoderEmbedder%3CChannelBuffer%3E embedder = new EncoderEmbedder%3CChannelBuffer%3E(new ChunkedWriteHandler());%0A        embedder.offer(new ChunkedStream(new ByteArrayInputStream(BYTES)));%0A%0A        Assert.assertTrue(embedder.finish());%0A%0A        int i = 0;%0A        for (;;) %7B%0A            ChannelBuffer buffer = embedder.poll();%0A            if (buffer == null) %7B%0A                break;%0A            %7D%0A            while (buffer.readable()) %7B%0A                Assert.assertEquals(BYTES%5Bi++%5D, buffer.readByte());%0A            %7D%0A        %7D%0A%0A        Assert.assertEquals(BYTES.length, i);%0A    %7D%0A%7D%0A

Add test for fix of regression in ChunkedWriteHandler. See #310