FileDocCategorySizeDatePackage
UserTest.javaAPI DocGlassfish v2 API4669Fri May 04 22:25:30 BST 2007com.sun.enterprise.cli.framework

UserTest

public class UserTest extends TestCase
author
Toby H Ferguson
version
$Revision: 1.5 $

Fields Summary
Constructors Summary
public UserTest(String name)

        super(name);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        if (args.length == 0){
            junit.textui.TestRunner.run(UserTest.class);
        } else {
            junit.textui.TestRunner.run(makeSuite(args));
        }
    
private static junit.framework.TestSuitemakeSuite(java.lang.String[] args)

        final TestSuite ts = new TestSuite();
        for (int i = 0; i < args.length; i++){
            ts.addTest(new UserTest(args[i]));
        }
        return ts;
    
private voidnyi()

        fail("Not Yet Implemented");
    
protected voidsetUp()

    
protected voidtearDown()

    
public voidtestUser()

        final Pipe toUser = new Pipe();
        final Pipe fromUser = new Pipe();
        final String quit = "q";
        final String prompt = "Press return to continue, q then return to quit";
        
        final User user = new User( toUser.getReader(), fromUser.getWriter(), quit, prompt);
        toUser.writeLine("");
        assertTrue(user.wantsToContinue());
        assertEquals(prompt, fromUser.readLine());
        toUser.writeLine("123");
        assertTrue(user.wantsToContinue());
        assertEquals(prompt, fromUser.readLine());
        toUser.writeLine("123" + quit);
        assertTrue(user.wantsToContinue());
        assertEquals(prompt, fromUser.readLine());
        toUser.writeLine(quit + "1234");
        assertTrue(!user.wantsToContinue());
        assertEquals(prompt, fromUser.readLine());