Tabnine Logo
System.setOut
Code IndexAdd Tabnine to your IDE (free)

How to use
setOut
method
in
java.lang.System

Best Java code snippets using java.lang.System.setOut (Showing top 20 results out of 4,887)

origin: stackoverflow.com

 private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();

@Before
public void setUpStreams() {
  System.setOut(new PrintStream(outContent));
  System.setErr(new PrintStream(errContent));
}

@After
public void cleanUpStreams() {
  System.setOut(null);
  System.setErr(null);
}
origin: EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

@After
public void tearDown() {
  System.setOut(this.out);
}
origin: eclipse-vertx/vert.x

public void stop() {
 if (System.out != originalOutputPrintStream) {
  System.setOut(originalOutputPrintStream);
 }
 if (System.err != originalErrorPrintStream) {
  System.setErr(originalErrorPrintStream);
 }
}
origin: apache/flink

@After
public void restoreStreams() {
  if (out != null) {
    System.setOut(out);
  }
  if (err != null) {
    System.setOut(err);
  }
}
origin: eclipse-vertx/vert.x

public void record() {
 os = new PrintStream(output);
 err = new PrintStream(error);
 System.setOut(os);
 System.setErr(err);
}
origin: apache/flink

private static void replaceStdOutAndStdErr() {
  stdOut = System.out;
  stdErr = System.err;
  buffer = new ByteArrayOutputStream();
  PrintStream capture = new PrintStream(buffer);
  System.setOut(capture);
  System.setErr(capture);
}
origin: eclipse-vertx/vert.x

@After
public void tearDown() {
 System.setOut(out);
}
origin: apache/flink

@Before
public void setUp() {
  System.setOut(new PrintStream(arrayOutputStream));
  System.setErr(new PrintStream(arrayErrorStream));
}
origin: apache/flink

protected static void resetStreamsAndSendOutput() {
  System.setOut(ORIGINAL_STDOUT);
  System.setErr(ORIGINAL_STDERR);
  System.setIn(ORIGINAL_STDIN);
  LOG.info("Sending stdout content through logger: \n\n{}\n\n", outContent.toString());
  LOG.info("Sending stderr content through logger: \n\n{}\n\n", errContent.toString());
}
origin: apache/flink

@After
public void tearDown() {
  if (System.out != originalSystemOut) {
    System.out.close();
  }
  if (System.err != originalSystemErr) {
    System.err.close();
  }
  System.setOut(originalSystemOut);
  System.setErr(originalSystemErr);
}
origin: apache/flink

@Before
public void setUp() {
  System.setOut(new PrintStream(arrayOutputStream));
  System.setErr(new PrintStream(arrayErrorStream));
}
origin: EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

private void doFizzBuzz(final int n, final String s) throws IOException {
  final ByteArrayOutputStream baos = new ByteArrayOutputStream();
  final BufferedOutputStream bos = new BufferedOutputStream(baos);
  System.setOut(new PrintStream(bos));
  this.fb.fizzBuzz(n);
  System.out.flush();
  String platformDependentExpectedResult = s.replaceAll("\\n", System.getProperty("line.separator"));
  assertEquals(platformDependentExpectedResult, baos.toString());
}
origin: eclipse-vertx/vert.x

@Test
public void testCommandUsageForGoodbye() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("bye", "--help");
 assertThat(baos.toString())
   .contains("A command saying goodbye.") // Summary
   .contains("-n <value>"); // Option
}
origin: eclipse-vertx/vert.x

@Test
public void testCommandUsageForHello() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("hello", "--help");
 assertThat(baos.toString())
   .contains("Usage: ")
   .contains("A command saying hello.") // Summary
   .contains("A simple command to wish you a good day.") // Description
   .contains("-n,--name <name>") // Option
   .contains("your name"); // Option description
}
origin: eclipse-vertx/vert.x

@Test
public void testMissingOption() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("hello");
 assertThat(baos.toString())
   .contains("The option", "name", "is required");
}
origin: eclipse-vertx/vert.x

@Test
public void testInvalidValue() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("hidden", "-n", "vert.x", "-c", "hello");
 assertThat(baos.toString())
   .contains("The value 'hello' is not accepted by 'count'");
}
origin: eclipse-vertx/vert.x

@Test
public void testMissingValue() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("hello", "-n");
 assertThat(baos.toString())
   .contains("The option 'name' requires a value");
}
origin: eclipse-vertx/vert.x

@Test
public void testCommandNotFound() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("missing");
 assertThat(baos.toString()).contains("The command", "missing", "See", "--help");
 baos.reset();
 itf.execute("missing", "--help");
 assertThat(baos.toString()).contains("The command", "missing", "See", "--help");
}
origin: eclipse-vertx/vert.x

@Test
public void testUsage() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("--help");
 assertThat(baos.toString()).contains("hello").contains("bye")
   .doesNotContain("hidden").contains("A command saying hello");
}
origin: eclipse-vertx/vert.x

@Test
public void testHiddenCommandUsage() {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 PrintStream stream = new PrintStream(baos);
 System.setOut(stream);
 itf.execute("hidden", "-h");
 assertThat(baos.toString())
   .contains("-n <value>")
   .doesNotContain("-c ")
   .doesNotContain("count");
}
java.langSystemsetOut

Javadoc

Sets the standard output stream to the given user defined output stream.

Popular methods of System

  • currentTimeMillis
    Returns the current time in milliseconds. Note that while the unit of time of the return value is a
  • getProperty
    Returns the value of a particular system property. The defaultValue will be returned if no such prop
  • arraycopy
  • exit
  • setProperty
    Sets the value of a particular system property.
  • nanoTime
    Returns the current timestamp of the most precise timer available on the local system, in nanosecond
  • getenv
    Returns the value of the environment variable with the given name, or null if no such variable exist
  • getProperties
    Returns the system properties. Note that this is not a copy, so that changes made to the returned Pr
  • identityHashCode
    Returns an integer hash code for the parameter. The hash code returned is the same one that would be
  • getSecurityManager
    Gets the system security interface.
  • gc
    Indicates to the VM that it would be a good time to run the garbage collector. Note that this is a h
  • lineSeparator
    Returns the system's line separator. On Android, this is "\n". The value comes from the value of the
  • gc,
  • lineSeparator,
  • clearProperty,
  • setErr,
  • console,
  • loadLibrary,
  • load,
  • setSecurityManager,
  • mapLibraryName

Popular in Java

  • Making http requests using okhttp
  • setScale (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now