List of usage examples for org.apache.commons.io.output WriterOutputStream flush
@Override public void flush() throws IOException
From source file:com.fitbur.core.core.el.mvel.MvelTemplateService.java
@Override public void eval(String name, Reader template, Writer output, Object context) { try {/*from ww w . j a v a2s. c om*/ validate(name, template, output, context); CompiledTemplate compiled = compile(name, template); WriterOutputStream stream = new WriterOutputStream(output); TemplateRuntime.execute(compiled, context, stream); stream.flush(); } catch (IOException e) { } }
From source file:org.deventropy.junithelper.derby.SimpleDerbyScriptRunnerTest.java
@Test public void testLoggingChanges() throws SQLException, IOException { final StringWriter logData1 = new StringWriter(); final WriterOutputStream wos1 = new WriterOutputStream(logData1, Charset.defaultCharset()); final StringWriter logData2 = new StringWriter(); final WriterOutputStream wos2 = new WriterOutputStream(logData2, Charset.defaultCharset()); Connection connection = null; try {/*w ww.j a v a 2 s .c o m*/ connection = DriverManager.getConnection(embeddedDerbyResource.getJdbcUrl()); final DerbyScriptRunner scriptRunner = new DerbyScriptRunner(connection); scriptRunner.setDefaultScriptLogStream(wos1); // Run one with a output stream here scriptRunner.executeScript("classpath:/org/deventropy/junithelper/derby/simple01/ddl.sql", wos2, true); logData2.flush(); assertTrue("Expected log doesnt exist", logData2.toString().contains("rows inserted/updated/deleted")); assertTrue("Should have nothing in the default", logData1.toString().isEmpty()); scriptRunner.executeScript("classpath:/org/deventropy/junithelper/derby/simple01/dml.sql"); wos1.flush(); logData1.flush(); assertTrue("Expected log doesnt exist", logData1.toString().contains("row inserted/updated/deleted")); } finally { DerbyUtils.closeQuietly(connection); } }