Search in sources :

Example 6 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project jackrabbit-oak by apache.

the class ConsolidatedDataStoreStatsTest method getIdForInputStream.

private String getIdForInputStream(final InputStream in) throws Exception {
    MessageDigest digest = MessageDigest.getInstance("SHA-256");
    OutputStream output = new DigestOutputStream(new NullOutputStream(), digest);
    try {
        IOUtils.copyLarge(in, output);
    } finally {
        IOUtils.closeQuietly(output);
        IOUtils.closeQuietly(in);
    }
    return encodeHexString(digest.digest());
}
Also used : DigestOutputStream(java.security.DigestOutputStream) OutputStream(java.io.OutputStream) DigestOutputStream(java.security.DigestOutputStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream) MessageDigest(java.security.MessageDigest) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 7 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project jackrabbit-oak by apache.

the class CachingDataStoreTest method getIdForInputStream.

private String getIdForInputStream(File f) throws Exception {
    FileInputStream in = null;
    OutputStream output = null;
    try {
        in = new FileInputStream(f);
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        output = new DigestOutputStream(new NullOutputStream(), digest);
        IOUtils.copyLarge(in, output);
        return encodeHexString(digest.digest());
    } finally {
        IOUtils.closeQuietly(output);
        IOUtils.closeQuietly(in);
    }
}
Also used : DigestOutputStream(java.security.DigestOutputStream) OutputStream(java.io.OutputStream) DigestOutputStream(java.security.DigestOutputStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream) MessageDigest(java.security.MessageDigest) FileInputStream(java.io.FileInputStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 8 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project jackrabbit by apache.

the class BigFileReadTest method runTest.

public void runTest() throws Exception {
    Node file = root.getNode("file" + (i++ % FILE_COUNT));
    Node content = file.getNode("jcr:content");
    InputStream stream = content.getProperty("jcr:data").getStream();
    try {
        IOUtils.copy(stream, new NullOutputStream());
    } finally {
        stream.close();
    }
}
Also used : InputStream(java.io.InputStream) Node(javax.jcr.Node) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 9 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project jackrabbit by apache.

the class SmallFileReadTest method runTest.

public void runTest() throws Exception {
    for (int i = 0; i < FILE_COUNT; i++) {
        Node file = root.getNode("file" + i);
        Node content = file.getNode("jcr:content");
        InputStream stream = content.getProperty("jcr:data").getStream();
        try {
            IOUtils.copy(stream, new NullOutputStream());
        } finally {
            stream.close();
        }
    }
}
Also used : InputStream(java.io.InputStream) Node(javax.jcr.Node) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 10 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.

the class TestGetPrefixAfterWriteNamespace method runTest.

protected void runTest() throws Throwable {
    XMLStreamWriter writer = staxImpl.newNormalizedXMLOutputFactory().createXMLStreamWriter(new NullOutputStream());
    writer.writeStartElement("", "root", "");
    writer.writeNamespace("p", "urn:test");
    assertEquals("p", writer.getPrefix("urn:test"));
}
Also used : XMLStreamWriter(javax.xml.stream.XMLStreamWriter) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Aggregations

NullOutputStream (org.apache.commons.io.output.NullOutputStream)30 InputStream (java.io.InputStream)7 Test (org.junit.Test)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 OutputStream (java.io.OutputStream)5 DigestOutputStream (java.security.DigestOutputStream)5 MessageDigest (java.security.MessageDigest)5 FileInputStream (java.io.FileInputStream)3 PrintStream (java.io.PrintStream)3 DataHandler (javax.activation.DataHandler)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 PipedInputStream (java.io.PipedInputStream)2 ArrayList (java.util.ArrayList)2 Node (javax.jcr.Node)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)2 OMFactory (org.apache.axiom.om.OMFactory)2 ExceptionInputStream (org.apache.axiom.testutils.io.ExceptionInputStream)2