Examples of ExtraDotOutputStream


Examples of org.apache.james.util.stream.ExtraDotOutputStream

   
    public void testMixedSizeChunks() throws IOException {
        String[] data = new String[] {".","This is a test","","\r\n","of the thing.\r","\nWe should not have much trouble.\r","\n",".","doubled?\r\n","or not?\n.","double","d\nor not?\r","\n\r\n","\n\n\r","\r\r\n"};
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        OutputStream os = new ExtraDotOutputStream(bOut);
        for(int i = 0; i < data.length; i++) {
            os.write(data[i].getBytes());
            os.flush();
        }
        String expected = "..This is a test\r\nof the thing.\r\nWe should not have much trouble.\r\n..doubled?\r\nor not?\r\n..doubled\r\nor not?\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
        assertEquals(expected,bOut.toString());
    }
View Full Code Here

Examples of org.apache.james.util.stream.ExtraDotOutputStream


    public void testBytePerByte() throws IOException {
        String data = ".This is a test\r\nof the thing.\r\nWe should not have much trouble.\r\n.doubled?\r\nor not?\n.doubled\nor not?\r\n\r\n\n\n\r\r\r\n";
        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        OutputStream os = new ExtraDotOutputStream(bOut);
        byte[] buffer = data.getBytes();
        for (int i = 0; i < buffer.length; i++) {
            os.write(buffer[i]);
        }
        os.flush();
        String expected = "..This is a test\r\nof the thing.\r\nWe should not have much trouble.\r\n..doubled?\r\nor not?\r\n..doubled\r\nor not?\r\n\r\n\r\n\r\n\r\n\r\n\r\n";
        assertEquals(expected,bOut.toString());
    }
View Full Code Here

Examples of org.subethamail.smtp.io.ExtraDotOutputStream

      this.reader = new BufferedReader(new InputStreamReader(this.socket.getInputStream()));

      this.rawOutput = this.socket.getOutputStream();
      this.dotTerminatedOutput = new DotTerminatedOutputStream(this.rawOutput);
      this.dataOutput = new ExtraDotOutputStream(this.dotTerminatedOutput);
      this.writer = new PrintWriter(this.rawOutput, true);
    }
    catch (IOException e)
    {
      close();
View Full Code Here

Examples of org.subethamail.smtp.io.ExtraDotOutputStream

        InputStream mailAsStream =
                session.getMaildrop().getMailAsStream(messageNumber);
        try {
            session.getThread().sendResponse("+OK");
            ExtraDotOutputStream dotOutputStream =
                    new ExtraDotOutputStream(session.getThread()
                            .getOutputStream());
            CrLfInputStream in = new CrLfInputStream(mailAsStream);
            byte[] buffer = new byte[1000];
            int cRead;
            // read headers
            while (true) {
                cRead = in.readLineWithEol(buffer);
                if (cRead == -1)
                    break; // no body
                dotOutputStream.write(buffer, 0, cRead);
                if (buffer[0] == '\r' || buffer[0] == '\n')
                    break;
            }
            // read body
            int cLines = 0;
            while (cLines < lines) {
                try {
                    cRead = in.readLineWithEol(buffer);
                } catch (MaxLineLengthException e) {
                    // not a big problem, some body lines will be missing
                    break;
                }
                if (cRead == -1)
                    break; // end of mail
                dotOutputStream.write(buffer, 0, cRead);
                cLines++;
            }

            dotOutputStream.flush();
        } finally {
            mailAsStream.close();
        }
        session.getThread().sendResponse(".");
    }
View Full Code Here

Examples of org.subethamail.smtp.io.ExtraDotOutputStream

            session.getThread().sendResponse(
                    "+OK " + scanListing.length + " octets");
            DotTerminatedOutputStream dotTerminatedOutputStream =
                    new DotTerminatedOutputStream(session.getThread()
                            .getOutputStream());
            ExtraDotOutputStream dotOutputStream =
                    new ExtraDotOutputStream(dotTerminatedOutputStream);
            byte[] buffer = new byte[4096];
            int cRead;
            while (-1 != (cRead = mailAsStream.read(buffer))) {
                dotOutputStream.write(buffer, 0, cRead);
            }
            dotOutputStream.flush();
            dotTerminatedOutputStream.writeTerminatingSequence();
            dotTerminatedOutputStream.flush();
            logger.debug("Message sent");
        } finally {
            mailAsStream.close();
View Full Code Here

Examples of org.subethamail.smtp.io.ExtraDotOutputStream

    this.socket = new Socket(host, port);
    this.reader = new BufferedReader(new InputStreamReader(this.socket.getInputStream()));

    this.rawOutput = this.socket.getOutputStream();
    this.dataOutput = new ExtraDotOutputStream(this.rawOutput);
    this.writer = new PrintWriter(this.rawOutput, true);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.