List of usage examples for org.apache.commons.io.output WriterOutputStream WriterOutputStream
public WriterOutputStream(Writer writer)
From source file:edu.wpi.margrave.MCommunicator.java
public static void main(String[] args) { ArrayList<String> foo = new ArrayList<String>(); Set<String> argsSet = new HashSet<String>(); for (int ii = 0; ii < args.length; ii++) { argsSet.add(args[ii].toLowerCase()); }//from w w w. j a v a2s .com if (argsSet.contains("-log")) { // parser is in racket now. instead, require -log switch for logging //MEnvironment.debugParser = true; bDoLogging = true; } if (argsSet.contains("-min")) { bMinimalModels = true; } // Re-direct all System.err input to our custom buffer // Uses Apache Commons IO for WriterOutputStream. System.setErr(new PrintStream(new WriterOutputStream(MEnvironment.errorWriter), true)); // Re-direct all System.out input to our custom buffer. // (We have already saved System.out.) // This is useful in case we start getting GC messages from SAT4j. System.setOut(new PrintStream(new WriterOutputStream(MEnvironment.outWriter), true)); initializeLog(); writeToLog("\n\n"); // Inform the caller that we are ready to receive commands sendReadyReply(); while (true) { // Block until a command is received, handle it, and then return the result. handleXMLCommand(in); } // outLog will be closed as it goes out of scope }
From source file:io.restassured.itest.java.GivenWhenThenLoggingITest.java
@Test public void logsEverythingResponseUsingGivenWhenThenSyntax() throws Exception { final StringWriter writer = new StringWriter(); final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true); given().config(RestAssuredConfig.config() .logConfig(LogConfig.logConfig().defaultStream(captor).and().enablePrettyPrinting(false))) .pathParam("firstName", "John").pathParam("lastName", "Doe").when().get("/{firstName}/{lastName}") .then().log().all().body("fullName", equalTo("John Doe")); assertThat(writer.toString(), equalTo( "HTTP/1.1 200 OK\nContent-Type: application/json;charset=utf-8\nContent-Length: 59\nServer: Jetty(9.3.2.v20150730)\n\n{\"firstName\":\"John\",\"lastName\":\"Doe\",\"fullName\":\"John Doe\"}" + LINE_SEPARATOR));//from w w w.j av a2s.c o m }
From source file:com.silverpeas.export.ExportDescriptor.java
/** * Creates and initializes a new descriptor on an export process with the specified writer. The * output stream is initialized with the specified writer. * @param writer the writer to use for exporting the serializable resources. * @return an export descriptor.//from www .ja va 2 s . c o m */ public static ExportDescriptor withWriter(final Writer writer) { ExportDescriptor descriptor = new ExportDescriptor(); if (writer == null) { throw new IllegalArgumentException("The writer cannot be null!"); } descriptor.setWriter(writer); descriptor.setOutputStream(new WriterOutputStream(writer)); return descriptor; }
From source file:com.jayway.restassured.itest.java.GivenWhenThenLoggingITest.java
@Test public void logsEverythingResponseUsingGivenWhenThenSyntax() throws Exception { final StringWriter writer = new StringWriter(); final PrintStream captor = new PrintStream(new WriterOutputStream(writer), true); given().config(config().logConfig(logConfig().defaultStream(captor).and().enablePrettyPrinting(false))) .pathParam("firstName", "John").pathParam("lastName", "Doe").when().get("/{firstName}/{lastName}") .then().log().all().body("fullName", equalTo("John Doe")); assertThat(writer.toString(), equalTo( "HTTP/1.1 200 OK\nContent-Type: application/json;charset=utf-8\nContent-Length: 59\nServer: Jetty(9.3.2.v20150730)\n\n{\"firstName\":\"John\",\"lastName\":\"Doe\",\"fullName\":\"John Doe\"}" + LINE_SEPARATOR));//from ww w. ja v a2 s. co m }
From source file:com.sangupta.jerry.print.ConsoleTableWriter.java
/** * Output the data of the table as a JSON * // w ww. ja v a2 s. c o m * @param table * the {@link ConsoleTable} to output * * @param out * the {@link PrintWriter} to write to */ public void writeJson(ConsoleTable table, PrintWriter writer) { OutputStream os = new WriterOutputStream(writer); PrintStream ps = new PrintStream(os); try { writeJson(table, ps); } finally { ps.close(); } }
From source file:com.jayway.restassured.module.mockmvc.RequestLoggingTest.java
@Before public void given_config_is_stored_in_writer() { writer = new StringWriter(); PrintStream captor = new PrintStream(new WriterOutputStream(writer), true); RestAssuredMockMvc.config = new RestAssuredMockMvcConfig().logConfig(new LogConfig(captor, true)); }
From source file:com.fitbur.core.core.el.mvel.MvelTemplateService.java
@Override public void eval(String name, Reader template, Writer output, Object context) { try {// ww w .j a v a2 s. co m 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:io.restassured.module.mockmvc.PutTest.java
@Test public void doesnt_automatically_adds_x_www_form_urlencoded_as_content_type_when_putting_params() { StringWriter writer = new StringWriter(); PrintStream captor = new PrintStream(new WriterOutputStream(writer), true); RestAssuredMockMvc.given().config(newConfig().logConfig(new LogConfig(captor, true))).param("name", "Johan") .when().put("/greetingPut").then().log().all().statusCode(415); assertThat(writer.toString(),/*from w w w . j av a 2s.c o m*/ equalTo("415 Content type 'null' not supported\nAccept: application/x-www-form-urlencoded\n")); }
From source file:br.com.danielferber.ilogtoys.dados.DataSinkStringBuilder.java
@Override public void consumeData(IloOplModel oplModel) throws IOException { StringWriter sw = new StringWriter(); OutputStream os = new WriterOutputStream(sw); super.exportarStream(oplModel, os); stringBuilder.append(sw.getBuffer()); }
From source file:com.jayway.restassured.module.mockmvc.LoggingIfValidationFailsTest.java
@Before public void given_writer_and_captor_is_initialized() { writer = new StringWriter(); captor = new PrintStream(new WriterOutputStream(writer), true); }