package thegroup.projectcddb.server;

import junit.framework.*;

public class TestServerProtocol extends TestCase{

	public TestServerProtocol( String testName ) { super(testName); }
    
    public static Test suite() 
    {
        TestSuite suite = new TestSuite( TestServerProtocol.class );
        return suite;
    }
    
    public static void main( String[] args ) 
    {       
        if (args.length > 0 && args[0].startsWith( "-g") ) 
        {
            // Graphical
            junit.swingui.TestRunner.run( TestServerProtocol.class );
        }      
        else 
        {
            // Textual
            junit.textui.TestRunner runner = new junit.textui.TestRunner();
            
            // get all the tests associated with this class
            Test test = runner.getTest( TestServerProtocol.class.getName() );
            
            // run the tests
            TestResult testResult = junit.textui.TestRunner.run( test );
            
            // exit according to whether there were any failures
            System.exit( testResult.wasSuccessful() ? 0 : 1 );
        }
    }
    
    /** Test of processInput method, of class thegroup.projectcddb.server.ServerProtocol. */
    public void testprocessInput() 
    {
        System.out.println("testprocessInput");
        ServerProtocol serverProtocol = new ServerProtocol();
        assertTrue( serverProtocol.processInput("cddb query 000e0c14 1 56 56") != null);
        assertTrue( serverProtocol.processInput("cddb read categ 9010850b") != null);
        assertTrue( serverProtocol.processInput("cddb write categ discid") == "401 permission denied");
        assertTrue( serverProtocol.processInput("get") == "401 permission denied." );
        
    }
}