Example #1
0
 private String runFitnesseMainWith(String... args) throws Exception {
   PrintStream err = System.err;
   ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
   System.setErr(new PrintStream(outputBytes));
   Arguments arguments = new Arguments(args);
   Integer exitCode = new FitNesseMain().launchFitNesse(arguments);
   assertThat(exitCode, is(0));
   System.setErr(err);
   String response = outputBytes.toString();
   return response;
 }
Example #2
0
 @Override
 protected String run(final String... args) throws IOException {
   try {
     final ArrayOutput ao = new ArrayOutput();
     System.setOut(new PrintStream(ao));
     System.setErr(NULL);
     new BaseX(args);
     return ao.toString();
   } finally {
     System.setOut(OUT);
     System.setErr(ERR);
   }
 }
Example #3
0
  /**
   * Runs a request with the specified arguments and server arguments.
   *
   * @param args command-line arguments
   * @param sargs server arguments
   * @return result
   * @throws IOException I/O exception
   */
  private static String run(final String[] args, final String[] sargs) throws IOException {
    final BaseXServer server = createServer(sargs);
    final ArrayOutput ao = new ArrayOutput();
    System.setOut(new PrintStream(ao));
    System.setErr(NULL);

    final StringList sl = new StringList();
    sl.add("-p9999").add("-U" + Text.S_ADMIN).add("-P" + Text.S_ADMIN).add(args);
    try {
      new BaseXClient(sl.finish());
      return ao.toString();
    } finally {
      System.setErr(ERR);
      stopServer(server);
    }
  }
 @Test
 public void shouldWriteToSystemErrByDefault() {
   PrintStream originalErrStream = System.err;
   try {
     ByteArrayOutputStream out = new ByteArrayOutputStream();
     System.setErr(new PrintStream(out));
     enricher.printStackTrace(exception);
     String output = new String(out.toByteArray());
     assertTrue(
         "JUnit jar "
             + JUNIT_JAR_PATTERN
             + " not found in stack trace written to default System.err stream",
         output.contains(JUNIT_JAR_PATTERN));
   } finally {
     System.setErr(originalErrStream);
   }
 }
 @Before
 public void setUpStreams() {
   System.setOut(new PrintStream(outContent));
   System.setErr(new PrintStream(errContent));
   jcon = JConsole.instance();
   jcon.setCurrentDir(curDir);
   LSCom.setConsole(jcon);
 }
Example #6
0
 @Test(expected = Exception.class)
 public void testGraph() throws IOException {
   System.setErr(null);
   try {
     G = new Graph("/src/tinyEWG.txt", 0.3, true);
   } catch (IOException e) {
     throw e;
   }
 }
Example #7
0
 @Test
 public void testErr() {
   // prepare mock STDERR
   PrintStream err = System.err;
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   System.setErr(new PrintStream(bos));
   // main
   PathIterator x = PathIterator.of(Paths.get(""));
   x.err(new IOException("test1"), Paths.get("."));
   assertEquals("potf: '.': test1 (IOException)", StringUtils.chomp(bos.toString()));
   bos.reset();
   x.err(new AccessDeniedException("test2"), Paths.get("."));
   assertEquals("potf: '.': access denied", StringUtils.chomp(bos.toString()));
   bos.reset();
   x.err(new NoSuchFileException("test3"), Paths.get("."));
   assertEquals("potf: '.': no such file or directory", StringUtils.chomp(bos.toString()));
   // restore STDERR
   System.setErr(err);
 }
Example #8
0
  @Before
  public void init() {
    alist.add(a1);
    alist.add(a2);
    alist.add(a3);
    alist.add(a4);
    alist.add(a5);
    alist.add(a6);
    alist.add(a7);
    alist.add(a8);
    alist.add(a9);

    System.setOut(new PrintStream(outContent));
    System.setErr(new PrintStream(errContent));
  }
Example #9
0
 @After
 public void cleanUpStreams() {
   System.setOut(null);
   System.setErr(null);
 }
Example #10
0
 @Before
 public void setUpStreams() {
   System.setOut(new PrintStream(outContent));
   System.setErr(new PrintStream(errContent));
 }