use of org.apache.commons.io.input.NullInputStream in project hudson-2.x by hudson.
the class Run method getLogInputStream.
/**
* Returns an input stream that reads from the log file.
* It will use a gzip-compressed log file (log.gz) if that exists.
*
* @throws IOException
* @return an input stream from the log file, or null if none exists
* @since 1.349
*/
public InputStream getLogInputStream() throws IOException {
File logFile = getLogFile();
if (logFile.exists()) {
return new FileInputStream(logFile);
}
File compressedLogFile = new File(logFile.getParentFile(), logFile.getName() + ".gz");
if (compressedLogFile.exists()) {
return new GZIPInputStream(new FileInputStream(compressedLogFile));
}
return new NullInputStream(0);
}
use of org.apache.commons.io.input.NullInputStream in project jackrabbit by apache.
the class SQL2IndexingAggregateTest method testAsyncIndexQuery.
/**
* checks that while text extraction runs in the background, the node is
* available for query on any of its properties
*
* see <a href="https://issues.apache.org/jira/browse/JCR-2980">JCR-2980</a>
*
*/
public void testAsyncIndexQuery() throws Exception {
Node n = testRootNode.addNode("justnode", JcrConstants.NT_UNSTRUCTURED);
n.setProperty("type", "testnode");
n.setProperty("jcr:encoding", "UTF-8");
n.setProperty("jcr:mimeType", "text/plain");
n.setProperty("jcr:data", session.getValueFactory().createBinary(new NullInputStream(1024 * 40)));
testRootNode.getSession().save();
String sql = "SELECT * FROM [nt:unstructured] as f " + " WHERE ISCHILDNODE([" + testRoot + "]) and type = 'testnode' ";
checkResult(qm.createQuery(sql, JCR_SQL2).execute(), 1);
}
use of org.apache.commons.io.input.NullInputStream in project webservices-axiom by apache.
the class TestWriteToWithError method runTest.
@Override
protected void runTest(WritableBlob blob) throws Throwable {
blob.readFrom(new NullInputStream(size));
ExceptionOutputStream out = new ExceptionOutputStream(size / 2);
try {
blob.writeTo(out);
fail("Expected StreamCopyException");
} catch (StreamCopyException ex) {
assertThat(ex.getOperation()).isEqualTo(StreamCopyException.WRITE);
assertThat(ex.getCause()).isSameAs(out.getException());
}
}
use of org.apache.commons.io.input.NullInputStream in project webservices-axiom by apache.
the class TestAvailable method runTest.
@Override
protected void runTest(WritableBlob blob) throws Throwable {
blob.readFrom(new NullInputStream(1000));
InputStream in = blob.getInputStream();
try {
IOUtils.toByteArray(in, 200);
assertThat(in.available()).isEqualTo(800);
} finally {
in.close();
}
}
use of org.apache.commons.io.input.NullInputStream in project webservices-axiom by apache.
the class TestReadEOF method runTest.
@Override
protected void runTest(WritableBlob blob) throws Throwable {
blob.readFrom(new NullInputStream(100));
InputStream in = blob.getInputStream();
try {
IOUtils.toByteArray(in, 100);
assertThat(in.read()).isEqualTo(-1);
assertThat(in.read(new byte[10])).isEqualTo(-1);
} finally {
in.close();
}
}
Aggregations