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

UserInputTest

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

Fields Summary
ByteArrayInputStream
in
UserInput
ui
Constructors Summary
public UserInputTest(String name)

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

        if (args.length == 0){
            junit.textui.TestRunner.run(UserInputTest.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 UserInputTest(args[i]));
        }
        return ts;
    
private voidnyi()

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

        in = new ByteArrayInputStream(new byte[0]);
        ui = new UserInput(in);    
    
protected voidtearDown()

    
public voidtestEncoding()

        in = new ByteArrayInputStream("one\ntwo\nthree".getBytes());
        ui = new UserInput(in);
        ui.setEncoding("ISO-8859-1");
        assertEquals('o", ui.getChar());
        assertEquals("ne", ui.getLine());
        assertEquals("two", ui.getLine());
        assertEquals("three", ui.getLine());
    
public voidtestEncodingProblem()

        try {
            ui.setEncoding("fee");
            fail("Expected an exception");
        }
        catch (IOException ie){
            assertEquals("fee", ie.getMessage());
        }
    
public voidtestReading()

        in = new ByteArrayInputStream("one\ntwo\nthree".getBytes());
        ui = new UserInput(in);
        assertEquals('o", ui.getChar());
        assertEquals("ne", ui.getLine());
        assertEquals("two", ui.getLine());
        assertEquals("three", ui.getLine());
    
public voidtestSimpleCase()

        assertTrue(ui.isInteractive());
        ui.close();