import static java.
lang.
System.
in; import static java.
lang.
System.
setIn; import static org.junit.Assert.fail;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.PrintStream;
import java.nio.channels.Pipe;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.legacy.ClassImposteriser;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
public class UnitTests {
private Mockery context = new Mockery() {{
setImposteriser(ClassImposteriser.INSTANCE);
}};
private main mn;
@Before
public void setMinimalMockingExpectations
() throws IOException { mn = context.mock(main.class);
//System.setIn(mockIn);
}
@After
public void reset() {
//System.setIn(oldIn);
}
@Test
public void EnsureFileCheckExists
() throws IOException { out.write("F\n".getBytes());
pipeInput.mark(2);
out.write("DNE!\n".getBytes());
Expectations exp;
exp = new Expectations() {{
one(mockOut).println("Do you want to process standard (I)nput, or a (F)ile? I/F");
one(mockOut).println("Enter filename: ");
//System.setIn(new ByteArrayInputStream("DNE".getBytes()));
//one(mn).readInput(); will(returnValue("-1"));
//one(mn).readInput(); will(returnValue(DNE));
//one(mn).ensureFileExists(DNE); will(returnValue(false));
}};
context.checking(exp);
main.main(null);
}
}