List of usage examples for java.lang System setOut
public static void setOut(PrintStream out)
From source file:org.g_node.crawler.LKTLogbook.LKTLogCliToolControllerTest.java
/** * Ensure a fresh {@link LKTLogCliToolController} at the beginning of each test. * Set up Logger and tmp folder.// w ww. j a v a 2 s.com * @throws Exception */ @Before public void setUp() throws Exception { this.logCtrl = new LKTLogCliToolController(new LKTLogParser()); this.stdout = System.out; this.outStream = new ByteArrayOutputStream(); System.setOut(new PrintStream(this.outStream)); this.rootLogger = Logger.getRootLogger(); this.rootLogger.setLevel(Level.INFO); this.rootLogger.addAppender(new ConsoleAppender(new PatternLayout("[%-5p] %m%n"))); final String tmpRoot = System.getProperty("java.io.tmpdir"); final String testFolderName = "fileservicetest"; final String testFileName = "test.txt"; this.testFileFolder = Paths.get(tmpRoot, testFolderName); this.currTestFile = this.testFileFolder.resolve(testFileName).toFile(); FileUtils.write(this.currTestFile, "This is a normal test file"); }
From source file:de.haber.xmind2latex.XMindToLatexExporterTest.java
/** * Tests the showHelp() method. Additionally exports the help message into file * target/app/doc/commands.txt that is used in the documentation. * /*w w w .ja v a2 s .c o m*/ * @throws IOException */ @Test public void testShowHelp() throws IOException { File result = new File("target/app/doc/commands.txt"); result.delete(); result.getParentFile().mkdirs(); result.createNewFile(); FileOutputStream os = new FileOutputStream(result); PrintStream out = new PrintStream(os); PrintStream old_out = System.out; System.setOut(out); CliParameters.showHelp(); String resultContent = FileUtils.readFileToString(result); assertFalse(resultContent.isEmpty()); System.setOut(old_out); os.close(); }
From source file:org.apache.tika.cli.TikaCLITest.java
@Before public void setUp() throws Exception { outContent = new ByteArrayOutputStream(); resourcePrefix = testDataURI.toString(); stdout = System.out;/* ww w . j av a 2 s.c o m*/ System.setOut(new PrintStream(outContent, true, UTF_8.name())); }
From source file:de.langmi.spring.batch.examples.basics.purejava.jobruns.PureJavaJobRunTest.java
@Before public void setup() throws Exception { // catch and set new system out oldSysOut = System.out;/*from ww w . ja v a 2 s. c o m*/ System.setOut(new PrintStream(newSysOut)); setupBatchInfrastructure(); }
From source file:CraftAPI.java
/** * Construct the object./*w w w. ja v a 2s . co m*/ */ public CraftAPI() { eventDispatcher = new EventDispatcher(); listener = new CraftAPIListener(eventDispatcher); try { System.setOut(new PrintStream(new CopyingEventOuputStream(System.out, eventDispatcher))); System.setErr(new PrintStream(new CopyingEventOuputStream(System.err, eventDispatcher))); // Logger.GLOBAL_LOGGER_NAME doesn't seem to work Logger.getLogger("Minecraft").addHandler(new LoggingEventHandler(eventDispatcher, new LogFormat())); } catch (Throwable t) { logger.log(Level.WARNING, "CraftAPI: Could not redirect stdout/stderr"); t.printStackTrace(); } }
From source file:cpd3314.project.CPD3314ProjectTest.java
@Before public void setUp() { outContent = new ByteArrayOutputStream(); errContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); }
From source file:org.g_node.mergers.LktMergerJenaTest.java
/** * Set up test RDF files for the merge within the test folder and redirect stdout to an outstream. * @throws Exception/*from w w w . j a va 2 s. co m*/ */ @Before public void setUp() throws Exception { this.stdout = System.out; this.outStream = new ByteArrayOutputStream(); System.setOut(new PrintStream(this.outStream)); final String miniMainTTL = "@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name \"MainName\""; FileUtils.write(this.testMainRdfFile, miniMainTTL); final String miniMergeTTL = "@prefix foaf: <http://xmlns.com/foaf/0.1/> . _:a foaf:name \"MergeName\""; FileUtils.write(this.testMergeRdfFile, miniMergeTTL); Logger rootLogger = Logger.getRootLogger(); rootLogger.setLevel(Level.INFO); rootLogger.addAppender(new ConsoleAppender(new PatternLayout("[%-5p] %m%n"))); }
From source file:b2s.idea.mavenize.AppTest.java
@After public void tearDown() throws Exception { System.setOut(originalSysOut); }
From source file:org.apache.hadoop.gateway.util.KnoxCLITest.java
@Before public void setup() throws Exception { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); }
From source file:cz.muni.fi.mir.mathmlunificator.MathMLUnificatorCommandLineToolTest.java
@Test public void testMain_multiple_formulae_operators() throws Exception { String testFile = "multiple-formulae"; String[] argv = { "-p", getTestResourceAsFilepath(testFile + ".input.xml") }; ByteArrayOutputStream stdoutContent = new ByteArrayOutputStream(); PrintStream stdout = System.out; System.setOut(new PrintStream(stdoutContent)); MathMLUnificatorCommandLineTool.main(argv); System.setOut(stdout);//from w ww . j a v a 2 s .co m String output = stdoutContent.toString(StandardCharsets.UTF_8.toString()); System.out.println("testMain_multiple_formulae_operators operators output:\n" + output); assertEquals(IOUtils.toString(getExpectedXMLTestResource(testFile + ".operator"), StandardCharsets.UTF_8), output); }