private void CheckOutput(string[] args, string pattern, TextWriter @out, Type clazz ) { ByteArrayOutputStream outBytes = new ByteArrayOutputStream(); try { PipedOutputStream pipeOut = new PipedOutputStream(); PipedInputStream pipeIn = new PipedInputStream(pipeOut, PipeBufferSize); if (@out == System.Console.Out) { Runtime.SetOut(new TextWriter(pipeOut)); } else { if (@out == System.Console.Error) { Runtime.SetErr(new TextWriter(pipeOut)); } } if (clazz == typeof(DelegationTokenFetcher)) { ExpectDelegationTokenFetcherExit(args); } else { if (clazz == typeof(JMXGet)) { ExpectJMXGetExit(args); } else { if (clazz == typeof(DFSAdmin)) { ExpectDfsAdminPrint(args); } } } pipeOut.Close(); ByteStreams.Copy(pipeIn, outBytes); pipeIn.Close(); NUnit.Framework.Assert.IsTrue(Sharpen.Runtime.GetStringForBytes(outBytes.ToByteArray ()).Contains(pattern)); } catch (Exception ex) { NUnit.Framework.Assert.Fail("checkOutput error " + ex); } }
public void Write(Stream outputStream) { ByteStreams.Copy(_inputStream, outputStream); }