List of usage examples for java.lang System setOut
public static void setOut(PrintStream out)
From source file:org.arquillian.spacelift.task.os.ProcessNameTest.java
@Test public void outputDefaultPrefix() throws UnsupportedEncodingException { // run only on linux Assume.assumeThat(SystemUtils.IS_OS_LINUX, is(true)); final ByteArrayOutputStream errorOutput = new ByteArrayOutputStream(); System.setOut(new PrintStream(errorOutput)); exception = ExpectedException.none(); try {/* w w w . j ava 2 s.co m*/ exception.expectMessage(containsString("java -bar -baz")); Spacelift.task(CommandTool.class).programName("java").parameters("-bar", "-baz") .interaction(new ProcessInteractionBuilder().when(".*").printToOut()).execute().await(); } catch (ExecutionException e) { // ignore } String output = errorOutput.toString(Charset.defaultCharset().name()); Assert.assertThat(output, startsWith("(java):Unrecognized option: -bar")); }
From source file:com.complexible.stardog.ext.spring.TestDataSourceFactory.java
/** * TODO: perhaps not load 10k triples for each JUnit test * @throws java.lang.Exception//ww w . j ava 2s .c om */ @Before public void setUp() throws Exception { System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); assertNotNull(dataSource); SnarlTemplate tmp = new SnarlTemplate(); tmp.setDataSource(dataSource); DataImporter importer = new DataImporter(); importer.setSnarlTemplate(tmp); importer.inputFile(RDFFormat.N3, applicationContext.getResource("classpath:sp2b_10k.n3")); }
From source file:functionaltests.TagCommandsFunctTest.java
@Test public void testListJobTaskIdsWithTag() throws Exception { typeLine("listtasks(" + jobId.longValue() + ", 'LOOP-T2-1')"); runCli();//from ww w. java 2s . c o m String out = this.capturedOutput.toString(); System.setOut(stdOut); System.out.println("------------- testListJobTaskIdsWithTag:"); System.out.println(out); assertTrue(out.contains("T1#1")); assertTrue(out.contains("Print1#1")); assertTrue(out.contains("Print2#1")); assertTrue(out.contains("T2#1")); assertTrue(!out.contains("T1#2")); assertTrue(!out.contains("Print1#2")); assertTrue(!out.contains("Print2#2")); assertTrue(!out.contains("T2#2")); }
From source file:com.ibm.bi.dml.debug.DMLDebugger.java
/** * Sets STDOUT stream of a DML program running in debug mode *///from w w w . ja v a2s. c om @SuppressWarnings("unused") private void setStdOut() { originalOut = System.out; System.setOut(originalOut); }
From source file:cz.muni.fi.mir.mathmlunificator.MathMLUnificatorCommandLineToolTest.java
@Test public void testMain_latexml_operators() throws Exception { String testFile = "latexml"; 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 ww w . ja va 2s. c o m String output = stdoutContent.toString(StandardCharsets.UTF_8.toString()); System.out.println("testMain_latexml_operators operators output:\n" + output); assertEquals(IOUtils.toString(getExpectedXMLTestResource(testFile + ".operator"), StandardCharsets.UTF_8), output); }
From source file:org.apache.hive.beeline.TestSchemaTool.java
@Override protected void tearDown() throws Exception { File metaStoreDir = new File(testMetastoreDB); if (metaStoreDir.exists()) { FileUtils.forceDeleteOnExit(metaStoreDir); }/*from w w w .java 2 s . co m*/ System.setOut(outStream); System.setErr(errStream); if (conn != null) { conn.close(); } }
From source file:org.owasp.dependencycheck.cli.CliParserTest.java
/** * Test of parse method with jar and cpe args, of class CliParser. * * @throws Exception thrown when an exception occurs. */// www .ja va 2 s .c o m @Test public void testParse_unknown() throws Exception { String[] args = { "-unknown" }; PrintStream out = System.out; PrintStream err = System.err; ByteArrayOutputStream baos_out = new ByteArrayOutputStream(); ByteArrayOutputStream baos_err = new ByteArrayOutputStream(); System.setOut(new PrintStream(baos_out)); System.setErr(new PrintStream(baos_err)); CliParser instance = new CliParser(); try { instance.parse(args); } catch (ParseException ex) { Assert.assertTrue(ex.getMessage().contains("Unrecognized option")); } Assert.assertFalse(instance.isGetVersion()); Assert.assertFalse(instance.isGetHelp()); Assert.assertFalse(instance.isRunScan()); }
From source file:org.apache.solr.hadoop.MapReduceIndexerToolArgumentParserTest.java
@After public void tearDown() throws Exception { super.tearDown(); System.setOut(oldSystemOut); System.setErr(oldSystemErr); }
From source file:de.uni.bremen.monty.moco.CompileTestProgramsTest.java
@Test public void compileProgramTest() throws IOException, InterruptedException { final PrintStream bufferOut = System.out; final PrintStream bufferErr = System.err; final ByteArrayOutputStream outStream = setStdout(); final ByteArrayOutputStream errorStream = setStdErr(file); if (inputFileExists(file)) { System.setProperty("testrun.readFromFile", changeFileExtension(file, ".input")); }/*from ww w .j a v a2 s . c o m*/ Main.main(new String[] { "-e", file.getAbsolutePath() }); if (outputFileExists(file)) { assertThat(getOutput(errorStream), is(isEmptyString())); assertThat(getOutput(outStream), is(expectedResultFromFile(file))); } else { // chop the last char to not contain /n in the string assertThat(StringUtils.chop(getOutput(errorStream)), is(expectedErrorFromFile(file))); assertThat(getOutput(outStream), is(isEmptyString())); } System.clearProperty("testrun.readFromFile"); System.setOut(bufferOut); System.setErr(bufferErr); }
From source file:downloadwebpages.DownloadWebpages.java
/** * create a gui to mimic the output console *///www . j a v a2 s .c o m private void createGUI() { //Create and set up the window. JFrame frame = new JFrame(); frame.add(new JLabel(" Output"), BorderLayout.NORTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // add JTextArea to show console JTextArea ta = new JTextArea(30, 50); TextAreaOutputStream taos = new TextAreaOutputStream(ta, 60); PrintStream ps = new PrintStream(taos); System.setOut(ps); System.setErr(ps); frame.add(new JScrollPane(ta)); frame.pack(); frame.setVisible(true); }