Package org.apache.james.mime4j.io

Examples of org.apache.james.mime4j.io.BufferedLineReaderInputStream


            "DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS\r\n" +
            "DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS DoS\r\n";
        byte[] raw = message.getBytes("US-ASCII");
        ByteArrayInputStream instream = new ByteArrayInputStream(raw);
        LineNumberInputStream lineInput = new LineNumberInputStream(instream);
        BufferedLineReaderInputStream rawstream = new BufferedLineReaderInputStream(lineInput, 12);

        MimeConfig config = new MimeConfig();
        config.setMaxContentLen(100);
        MimeEntity entity = new MimeEntity(
                lineInput,
View Full Code Here


            "\r\n" +
            "a very important message";
        byte[] raw = message.getBytes("US-ASCII");
        ByteArrayInputStream instream = new ByteArrayInputStream(raw);
        LineNumberInputStream lineInput = new LineNumberInputStream(instream);
        BufferedLineReaderInputStream rawstream = new BufferedLineReaderInputStream(lineInput, 12);

        DefaultFieldBuilder fieldBuilder = new DefaultFieldBuilder(-1) {

            @Override
            public RawField build() throws MimeException {
View Full Code Here

    }

    public void testBasicOperations() throws Exception {
        String text = "bla bla yada yada haha haha";
        byte[] b1 = text.getBytes("US-ASCII");
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        assertEquals(0, inbuffer.pos());
        assertEquals(27, inbuffer.limit());
        assertEquals(27, inbuffer.length());

        inbuffer.read();
        inbuffer.read();

        assertEquals(2, inbuffer.pos());
        assertEquals(27, inbuffer.limit());
        assertEquals(25, inbuffer.length());

        byte[] tmp1 = new byte[3];
        assertEquals(3, inbuffer.read(tmp1));

        assertEquals(5, inbuffer.pos());
        assertEquals(27, inbuffer.limit());
        assertEquals(22, inbuffer.length());

        byte[] tmp2 = new byte[22];
        assertEquals(22, inbuffer.read(tmp2));

        assertEquals(27, inbuffer.pos());
        assertEquals(27, inbuffer.limit());
        assertEquals(0, inbuffer.length());

        assertEquals(-1, inbuffer.read(tmp1));
        assertEquals(-1, inbuffer.read(tmp1));
        assertEquals(-1, inbuffer.read());
        assertEquals(-1, inbuffer.read());
    }
View Full Code Here

    public void testPatternMatching1() throws Exception {
        String text = "blabla d is the word";
        String pattern = "d";
        byte[] b1 = text.getBytes("US-ASCII");
        byte[] b2 = pattern.getBytes("US-ASCII");
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        int i = inbuffer.indexOf(b2);
        assertEquals(7, i);
    }
View Full Code Here

    public void testPatternMatching2() throws Exception {
        String text = "disddisdissdsidsidsiid";
        String pattern = "siid";
        byte[] b1 = text.getBytes("US-ASCII");
        byte[] b2 = pattern.getBytes("US-ASCII");
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        int i = inbuffer.indexOf(b2);
        assertEquals(18, i);
    }
View Full Code Here

    public void testPatternMatching3() throws Exception {
        String text = "bla bla yada yada haha haha";
        String pattern = "blah";
        byte[] b1 = text.getBytes("US-ASCII");
        byte[] b2 = pattern.getBytes("US-ASCII");
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        int i = inbuffer.indexOf(b2);
        assertEquals(-1, i);
    }
View Full Code Here

    public void testPatternMatching4() throws Exception {
        String text = "bla bla yada yada haha haha";
        String pattern = "bla";
        byte[] b1 = text.getBytes("US-ASCII");
        byte[] b2 = pattern.getBytes("US-ASCII");
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        int i = inbuffer.indexOf(b2);
        assertEquals(0, i);
    }
View Full Code Here

    public void testPatternOutOfBound() throws Exception {
        String text = "bla bla yada yada haha haha";
        String pattern1 = "bla bla";
        byte[] b1 = text.getBytes("US-ASCII");
        byte[] b2 = pattern1.getBytes("US-ASCII");
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        byte[] tmp = new byte[3];
        inbuffer.read(tmp);
        int i = inbuffer.indexOf(b2, inbuffer.pos(), inbuffer.length());
        assertEquals(-1, i);
        i = inbuffer.indexOf(b2, inbuffer.pos(), inbuffer.length() - 1);
        assertEquals(-1, i);
    }
View Full Code Here

    }

    public void testCharOutOfBound() throws Exception {
        String text = "zzz blah blah blah ggg";
        byte[] b1 = text.getBytes("US-ASCII");
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        byte[] tmp = new byte[3];
        inbuffer.read(tmp);
        int i = inbuffer.indexOf((byte)'z', inbuffer.pos(), inbuffer.length());
        assertEquals(-1, i);
        i = inbuffer.indexOf((byte)'g', inbuffer.pos(), inbuffer.length() - 3);
        assertEquals(-1, i);
    }
View Full Code Here

    }

    public void test0xFFInBinaryStream() throws Exception {
        byte[] b1 = new byte[] {1, 2, 3, (byte) 0xff, 10, 1, 2, 3};
        byte[] b2 = new byte[] {10};
        BufferedLineReaderInputStream inbuffer = new BufferedLineReaderInputStream(new ByteArrayInputStream(b1), 4096);
        inbuffer.fillBuffer();
        int i = inbuffer.indexOf(b2);
        assertEquals(4, i);
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.io.BufferedLineReaderInputStream

Copyright © 2018 www.massapicom. 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.