/****************************************************************
 * Licensed to the Apache Software Foundation (ASF) under one   *
 * or more contributor license agreements.  See the NOTICE file *
 * distributed with this work for additional information        *
 * regarding copyright ownership.  The ASF licenses this file   *
 * to you under the Apache License, Version 2.0 (the            *
 * "License"); you may not use this file except in compliance   *
 * with the License.  You may obtain a copy of the License at   *
 *                                                              *
 *   http://www.apache.org/licenses/LICENSE-2.0                 *
 *                                                              *
 * Unless required by applicable law or agreed to in writing,   *
 * software distributed under the License is distributed on an  *
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
 * KIND, either express or implied.  See the License for the    *
 * specific language governing permissions and limitations      *
 * under the License.                                           *
 ****************************************************************/

package org.apache.james.pop3server;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import org.apache.james.pop3server.core.ExtraDotInputStream;

import junit.framework.TestCase;

public class ExtraDotInputStreamTest extends TestCase{

    public void testExtraDot() throws IOException {
        String data = "This\r\n.\r\nThis.\r\n";
        String expectedOutput = "This\r\n..\r\nThis.\r\n";
        ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        
        int i = -1;
        while((i = in.read()) != -1) {
            out.write(i);
        }
        in.close();
        out.close();
        
        String output = new String(out.toByteArray());
        assertEquals(expectedOutput, output);
        
    }
}

@@ -2072,10 +2072,1582 @@
  %0A    %7D%0A
+    %0A    public void testNoDotCLRF() throws IOException %7B%0A        String data = %22ABCD%5Cr%5Cn%22;%0A        ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        %0A        int i = -1;%0A        while((i = in.read()) != -1) %7B%0A            out.write(i);%0A        %7D%0A        in.close();%0A        out.close();%0A        %0A        String output = new String(out.toByteArray());%0A        assertEquals(data, output);%0A    %7D%0A    %0A    public void testNoDot() throws IOException %7B%0A        String data = %22ABCD%22;%0A        ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        %0A        int i = -1;%0A        while((i = in.read()) != -1) %7B%0A            out.write(i);%0A        %7D%0A        in.close();%0A        out.close();%0A        %0A        String output = new String(out.toByteArray());%0A        assertEquals(data, output);%0A    %7D%0A    // Proof of BUG JAMES-1152%0A    public void testNoDotHeaderBody() throws IOException %7B%0A        String data = %22Subject: test%5Cr%5Cn%5Cr%5CnABCD%5Cr%5Cn%22;%0A        ExtraDotInputStream in = new ExtraDotInputStream(new ByteArrayInputStream(data.getBytes()));%0A        ByteArrayOutputStream out = new ByteArrayOutputStream();%0A        %0A        int i = -1;%0A        while((i = in.read()) != -1) %7B%0A            out.write(i);%0A        %7D%0A        in.close();%0A        out.close();%0A        %0A        String output = new String(out.toByteArray());%0A        assertEquals(data, output);%0A    %7D%0A
 %7D%0A

Add unit test which is a proof of BUG JAMES-1152