Package org.apache.wss4j.common.util

Examples of org.apache.wss4j.common.util.CRLFOutputStream


public class CRLFOutputStreamTest {

    @org.junit.Test
    public void testBytePerByte() throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        CRLFOutputStream crlfOutputStream = new CRLFOutputStream(baos);
        crlfOutputStream.write('\n');
        crlfOutputStream.write('\r');
        crlfOutputStream.write('\r');
        crlfOutputStream.write('\n');
        crlfOutputStream.write('\n');
        crlfOutputStream.write('\n');
        crlfOutputStream.write('\r');
        crlfOutputStream.write('\r');
        crlfOutputStream.write('\r');
        crlfOutputStream.write('a');
        crlfOutputStream.write('\n');
        crlfOutputStream.write('\r');
        crlfOutputStream.write('\n');
        crlfOutputStream.write('a');
        crlfOutputStream.write('a');
        crlfOutputStream.write('a');
        crlfOutputStream.close();
        Assert.assertArrayEquals("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\na\r\n\r\naaa".getBytes(), baos.toByteArray());
    }
View Full Code Here


    }

    @org.junit.Test
    public void testBytes() throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        CRLFOutputStream crlfOutputStream = new CRLFOutputStream(baos);
        crlfOutputStream.write("\n\r\r\n\n\n\r\r\ra\n\r\naaa".getBytes());
        crlfOutputStream.close();
        Assert.assertArrayEquals("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\na\r\n\r\naaa".getBytes(), baos.toByteArray());
    }
View Full Code Here

    }

    @org.junit.Test
    public void testBytes1() throws Exception {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        CRLFOutputStream crlfOutputStream = new CRLFOutputStream(baos);
        crlfOutputStream.write("aaaaaaaaaa".getBytes());
        crlfOutputStream.close();
        Assert.assertArrayEquals("aaaaaaaaaa".getBytes(), baos.toByteArray());
    }
View Full Code Here

    public void testRandom() throws Exception {
        byte[] pool = new byte[] {'\r', '\n', 'a'};
        Random random = new Random();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        CRLFOutputStream crlfOutputStream = new CRLFOutputStream(baos);

        ByteArrayOutputStream testString = new ByteArrayOutputStream();

        for (int h = 0; h < 10000; h++) {
            if (random.nextBoolean()) {
                byte b = pool[random.nextInt(pool.length)];
                testString.write(b);
                crlfOutputStream.write(b);
            } else {
                int byteCount = random.nextInt(1000);
                byte[] bytes = new byte[byteCount];
                for (int i = 0; i < byteCount; i++) {
                     bytes[i] = pool[random.nextInt(pool.length)];
                }
                testString.write(bytes);
                crlfOutputStream.write(bytes);
            }
        }

        crlfOutputStream.close();
        byte[] res = baos.toByteArray();
        for (int i = 0; i < res.length; i++) {
            byte re = res[i];
            if (re == '\r') {
                if (res[i + 1] != '\n') {
View Full Code Here

                throw new XMLStreamException(e);
            }
            canon.transform(inputStream);

        } else if (lowerCaseMimeType != null && lowerCaseMimeType.startsWith("text/")) {
            CRLFOutputStream crlfOutputStream = new CRLFOutputStream(getOutputStream());
            try {
                setOutputStream(crlfOutputStream);
            } catch (XMLSecurityException e) {
                throw new XMLStreamException(e);
            }
View Full Code Here

                XMLSignatureInput xmlSignatureInput = new XMLSignatureInput(inputStream);
                canon.canonicalizeXPathNodeSet(xmlSignatureInput.getNodeSet());

            } else if (lowerCaseMimeType != null && lowerCaseMimeType.startsWith("text/")) {
                CRLFOutputStream crlfOutputStream = new CRLFOutputStream(outputStream);
                int numBytes;
                byte[] buf = new byte[8192];
                while ((numBytes = inputStream.read(buf)) != -1) {
                    crlfOutputStream.write(buf, 0, numBytes);
                }

            } else {
                int numBytes;
                byte[] buf = new byte[8192];
View Full Code Here

TOP

Related Classes of org.apache.wss4j.common.util.CRLFOutputStream

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.