private static ScriptRunner newScriptRunner(Connection connection) { ScriptRunner scriptRunner = new ScriptRunner(connection); scriptRunner.setDelimiter(";"); scriptRunner.setStopOnError(true); scriptRunner.setLogWriter(new PrintWriter(new NullWriter())); return scriptRunner; } }
@Test public void testCloseUnderlyingWriter() throws Exception { // given NullWriter underlyingWriter = mock(NullWriter.class); ModifyingWriter writer = new ModifyingWriter(underlyingWriter, new IdleModifier()); // when writer.append("some text"); // then verify(underlyingWriter, never()).close(); // when writer.flush(); // then verify(underlyingWriter, never()).close(); // when writer.close(); // then verify(underlyingWriter).close(); // when writer.close(); // then // calling close() a second time must not have an effect // when try { writer.write("anything"); fail(IOException.class.getSimpleName() + " expected"); } catch (IOException e) { // then expect IOException } }
@Test public void testCloseUnderlyingWriter() throws Exception { // given NullWriter underlyingWriter = mock(NullWriter.class); ModifyingWriter writer = new ModifyingWriter(underlyingWriter, new IdleModifier()); // when writer.append("some text"); // then verify(underlyingWriter, never()).close(); // when writer.flush(); // then verify(underlyingWriter, never()).close(); // when writer.close(); // then verify(underlyingWriter).close(); // when writer.close(); // then // calling close() a second time must not have an effect // when try { writer.write("anything"); fail(IOException.class.getSimpleName() + " expected"); } catch (IOException e) { // then expect IOException } }
@Test public void nullCharSequencec() throws Exception { final ProxyWriter proxy = new ProxyWriter(new NullWriter()); proxy.append(null); proxy.close(); }
@Test public void testCopy_readerToWriter_IO84() throws Exception { final long size = (long)Integer.MAX_VALUE + (long)1; final Reader reader = new NullReader(size); final Writer writer = new NullWriter(); // Test copy() method assertEquals(-1, IOUtils.copy(reader, writer)); // reset the input reader.close(); // Test copyLarge() method assertEquals("copyLarge()", size, IOUtils.copyLarge(reader, writer)); }
@Test public void nullString() throws Exception { final ProxyWriter proxy = new ProxyWriter(new NullWriter()); proxy.write((String) null); proxy.write((String) null, 0, 0); proxy.close(); }
@Test public void nullCharArray() throws Exception { final ProxyWriter proxy = new ProxyWriter(new NullWriter()); proxy.write((char[]) null); proxy.write((char[]) null, 0, 0); proxy.close(); }
/** * @param gazetteerOutWriter */ public HgnetMergerFakeWriter(GazetteerOutWriter gazetteerOutWriter) { super(new NullWriter()); this.gazetteerOutWriter = gazetteerOutWriter; }
public PrintWriter getStdOutWriter() { if(roll) return new PrintWriter(new NullWriter()); else return out; } }
/** * @param resultOutput IO Writer for result output * @param messageOutput IO Writer for message output */ public WriterCommandOutput(Writer resultOutput, Writer messageOutput) { Validate.notNull(resultOutput, "Result output can't be NULL"); this.resultOutput = resultOutput; this.messageOutput = messageOutput == null ? new NullWriter() : messageOutput; }
/** * Shortcut for Null Writer * @param id */ public ProcessLog(String id) { this("processLog.", id, ProcessLog.LogLevel.FATAL, false, new PrintWriter(new NullWriter()) ,true); }
/** * @param resultOutput IO Writer for result output * @param messageOutput IO Writer for message output */ public WriterCommandOutput( Writer resultOutput, Writer messageOutput ) { Validate.notNull( resultOutput, "Result output can't be NULL" ); this.resultOutput = resultOutput; this.messageOutput = messageOutput == null ? new NullWriter() : messageOutput; }
/** * Create the Print Writer output */ protected void createOut() { try { out = new PrintWriter(new FileWriter(file, true)); } catch (IOException e) { out = new PrintWriter(new NullWriter()); LOG.error("Error while creating process log", e); } }
Source source=new Source("<a>I forgot to close my link!"); source.setLogger(myListeningLogger); source.getSourceFormatter().writeTo(new NullWriter()); // myListeningLogger has now had all the HTML flaws written to it
PmdRenderer() { super("", ""); super.setWriter(new NullWriter()); }
PmdRenderer() { super("", ""); super.setWriter(new NullWriter()); }
private PrintWriter getSqlWriter(String outputFile, boolean append) { final Writer sqlWriter; if (StringUtils.trimToNull(outputFile) != null) { try { // Insure any parent directories are created so we don't fail creating the SQL file. File file = new File(outputFile); if (!file.exists()) { file.getParentFile().mkdirs(); } sqlWriter = Files.newBufferedWriter( file.toPath(), UTF_8, append ? new StandardOpenOption[] {CREATE, APPEND} : new StandardOpenOption[] {CREATE}); } catch (IOException e) { throw new RuntimeException("", e); } } else { sqlWriter = new NullWriter(); } return new PrintWriter(sqlWriter); } }
final PrintWriter nullWriter = new PrintWriter(new NullWriter()); final List<String> javadocArgs = new ArrayList<String>(Arrays.asList("-classpath", flatClasspath,
private static ScriptRunner newScriptRunner(Connection connection) { ScriptRunner scriptRunner = new ScriptRunner(connection); scriptRunner.setDelimiter(";"); scriptRunner.setStopOnError(true); scriptRunner.setLogWriter(new PrintWriter(new NullWriter())); return scriptRunner; } }