List of usage examples for org.apache.commons.io.input NullReader NullReader
public NullReader(long size)
From source file:edu.cornell.med.icb.io.TestTSVReader.java
/** * Test a stream has no data./*from ww w. j a v a 2s .co m*/ */ @Test public void testEmptyStream() throws IOException { final TSVReader reader = new TSVReader(new NullReader(0)); assertFalse("Null reader should have no lines", reader.hasNext()); }
From source file:net.krotscheck.dfr.text.AbstractTextDecoderTest.java
/** * Assert that the input field may be set. * * @throws Exception Should not throw an exception. *//*w ww. j av a 2 s . co m*/ @Test public void testGetSetInput() throws Exception { ITextDecoder decoder = new TestTextDecoder(testData); Assert.assertNull(decoder.getReader()); // Test input reader Reader reader = new NullReader(100); decoder.setReader(reader); Assert.assertEquals(reader, decoder.getReader()); }
From source file:edu.cornell.med.icb.io.TestTSVReader.java
/** * Test close functionality./*from www .j av a 2 s .c o m*/ */ @Test public void testClose() throws IOException { final TSVReader reader = new TSVReader(new NullReader(42)); assertTrue("There should be something here", reader.hasNext()); reader.close(); try { assertFalse("Reader should be closed", reader.hasNext()); } catch (IOException e) { // this is good... return; } fail("TSVReader should be closed"); }
From source file:edu.cornell.med.icb.clustering.TestMCLClusterer.java
/** * Validate that reading from an empty MCL output file does not cause errors. * @throws IOException if the {@link edu.cornell.med.icb.clustering.MCLClusterer} * cannot access the reader passed to it. *///from w ww . j av a 2 s . co m @Test public void testEmptyMCLOutputFile() throws IOException { Reader reader = null; try { reader = new NullReader(0); final Clusterer clusterer = new MCLClusterer(reader); final List<int[]> clusters = clusterer.getClusters(); assertEquals("there should be 0 clusters", 0, clusters.size()); } finally { IOUtils.closeQuietly(reader); } }
From source file:com.galeoconsulting.leonardinius.rest.service.ScriptRunner.java
private ConsoleOutputBean eval(ScriptEngine engine, String evalScript, Map<String, ?> bindings, final ConsoleOutputBean consoleOutputBean) throws ScriptException { updateBindings(engine, ScriptContext.ENGINE_SCOPE, new HashMap<String, Object>() { {/* ww w .j ava 2 s. com*/ put("out", new PrintWriter(consoleOutputBean.getOut(), true)); put("err", new PrintWriter(consoleOutputBean.getErr(), true)); } }); if (bindings != null && !bindings.isEmpty()) { updateBindings(engine, ScriptContext.ENGINE_SCOPE, bindings); } engine.getContext().setWriter(consoleOutputBean.getOut()); engine.getContext().setErrorWriter(consoleOutputBean.getErr()); engine.getContext().setReader(new NullReader(0)); consoleOutputBean.setEvalResult(engine.eval(evalScript, engine.getContext())); return consoleOutputBean; }
From source file:org.artifactory.traffic.read.TrafficStreamParserTest.java
/** * Supply the parser with null objects instead of dates * * @throws IOException//from www . j av a 2 s . c o m */ @Test(expectedExceptions = IllegalArgumentException.class) public void testNullDates() throws IOException { TrafficStreamParser.parse(new NullReader(0), null, null); }
From source file:org.artifactory.traffic.read.TrafficStreamParserTest.java
/** * Supply the parser with invalid dates//from www . j a va 2s.c om * * @throws IOException */ @Test(expectedExceptions = IllegalArgumentException.class) public void testInvalidDates() throws IOException { long currentTime = System.currentTimeMillis(); Date startDate = new Date(currentTime + 1000); Date endDate = new Date(currentTime); TrafficStreamParser.parse(new NullReader(0), startDate, endDate); }