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; import org.junit.contrib.java.lang.system.TextFromStandardInputStream; public class UnitTests { private Mockery context = new Mockery() {{ setImposteriser(ClassImposteriser.INSTANCE); }}; private main mn; @Before mn = context.mock(main.class); //System.setIn(mockIn); } @After public void reset() { //System.setOut(oldOut); //System.setIn(oldIn); } // @Rule // public final TextFromStandardInputStream selectF = new TextFromStandardInputStream("F\nDNE\n"); @Test out.write("F\n".getBytes()); 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); } }
Standard input is empty
Main.java:25: class UnitTests is public, should be declared in a file named UnitTests.java public class UnitTests { ^ Main.java:3: package org.junit does not exist import static org.junit.Assert.fail; ^ Main.java:3: static import only from classes and interfaces import static org.junit.Assert.fail; ^ Main.java:16: package org.jmock does not exist import org.jmock.Expectations; ^ Main.java:17: package org.jmock does not exist import org.jmock.Mockery; ^ Main.java:18: package org.jmock.lib.legacy does not exist import org.jmock.lib.legacy.ClassImposteriser; ^ Main.java:19: package org.junit does not exist import org.junit.After; ^ Main.java:20: package org.junit does not exist import org.junit.Before; ^ Main.java:21: package org.junit does not exist import org.junit.Rule; ^ Main.java:22: package org.junit does not exist import org.junit.Test; ^ Main.java:23: package org.junit.contrib.java.lang.system does not exist import org.junit.contrib.java.lang.system.TextFromStandardInputStream; ^ Main.java:26: cannot find symbol symbol : class Mockery location: class UnitTests private Mockery context = new Mockery() {{ ^ Main.java:29: cannot find symbol symbol : class main location: class UnitTests private main mn; ^ Main.java:38: cannot find symbol symbol : class Before location: class UnitTests @Before ^ Main.java:50: cannot find symbol symbol : class After location: class UnitTests @After ^ Main.java:58: cannot find symbol symbol : class Test location: class UnitTests @Test ^ Main.java:26: cannot find symbol symbol : class Mockery location: class UnitTests private Mockery context = new Mockery() {{ ^ Main.java:40: cannot find symbol symbol : class main location: class UnitTests mn = context.mock(main.class); ^ Main.java:68: cannot find symbol symbol : class Expectations location: class UnitTests Expectations exp; ^ Main.java:69: cannot find symbol symbol : class Expectations location: class UnitTests exp = new Expectations() {{ ^ Main.java:79: cannot find symbol symbol : variable main location: class UnitTests main.main(null); ^ 21 errors
Standard output is empty