Search in sources :

Example 16 with NullOutputStream

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

the class SerializerTest method testUnmappableCharacterInComment.

@Test(expected = StreamException.class)
public void testUnmappableCharacterInComment() throws Exception {
    Serializer handler = new Serializer(new NullOutputStream(), "iso-8859-1");
    handler.startFragment();
    handler.startComment();
    handler.processCharacterData("€", false);
    handler.endComment();
    handler.completed();
}
Also used : NullOutputStream(org.apache.commons.io.output.NullOutputStream) Test(org.junit.Test)

Example 17 with NullOutputStream

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

the class TestWriteToIllegalState method runTest.

@Override
protected void runTest(WritableBlob blob) throws Throwable {
    try {
        blob.writeTo(new NullOutputStream());
        fail("Expected IllegalStateException");
    } catch (IllegalStateException ex) {
    // Expected
    }
}
Also used : NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 18 with NullOutputStream

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

the class HBaseVersion method main.

/**
   * Prints out the HBase {@link Version} enum value for the current version of HBase on the classpath.
   */
public static void main(String[] args) {
    // Suppress any output to stdout
    PrintStream stdout = System.out;
    System.setOut(new PrintStream(new NullOutputStream()));
    Version version = HBaseVersion.get();
    // Restore stdout
    System.setOut(stdout);
    System.out.println(version.getMajorVersion());
    if (args.length == 1 && "-v".equals(args[0])) {
        // Print versionString if verbose
        System.out.println("versionString=" + getVersionString());
    }
}
Also used : PrintStream(java.io.PrintStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 19 with NullOutputStream

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

the class BundleTest method entriesValid.

@Test
public void entriesValid() {
    assertEquals("Bundle entry lists must match in size", bundle.entries().size(), bundle.entryInfos().size());
    bundle.entries().forEach(uncheck(entry -> {
        CountingOutputStream cos = new CountingOutputStream(new NullOutputStream());
        IOUtils.copy(entry.inputStream(), cos);
        assertEquals("Entry size must match size of InputStream", entry.size(), cos.getCount());
    }));
}
Also used : ParameterizedUtils(info.ata4.test.ParameterizedUtils) IOConsumer.uncheck(info.ata4.util.function.IOConsumer.uncheck) Files(java.nio.file.Files) CountingOutputStream(com.google.common.io.CountingOutputStream) RunWith(org.junit.runner.RunWith) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) ArrayList(java.util.ArrayList) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Bundle(info.ata4.junity.bundle.Bundle) Paths(java.nio.file.Paths) NullOutputStream(org.apache.commons.io.output.NullOutputStream) After(org.junit.After) BundleReader(info.ata4.junity.bundle.BundleReader) BundleHeader(info.ata4.junity.bundle.BundleHeader) Path(java.nio.file.Path) Assert.assertEquals(org.junit.Assert.assertEquals) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) CountingOutputStream(com.google.common.io.CountingOutputStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream) Test(org.junit.Test)

Example 20 with NullOutputStream

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

the class S3DataStoreStatsTest 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) DigestOutputStream(java.security.DigestOutputStream) OutputStream(java.io.OutputStream) NullOutputStream(org.apache.commons.io.output.NullOutputStream) MessageDigest(java.security.MessageDigest) 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