• Post Reply Bookmark Topic Watch Topic
  • New Topic

Testing Servlets  RSS feed

Manohar Karamballi
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have newbie these testing Unit world..
I am facing following problem in using servlet unit.
my testcase code..

public class ODDSControllerSTest extends TestCase
public static void main(String args[])
junit.textui.TestRunner.run( suite() );
public static Test suite()
return new TestSuite( ODDSControllerSTest.class );

public ODDSControllerSTest( String name )
super( name );
public void testHeader() throws Exception
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest( "http://localhost:8080/LNT/ODDSControllerS" );
WebResponse response = conversation.getResponse( request );
assertEquals("Response failed",200,response.getResponseCode());


//import junit related classes
import com.meterware.servletunit.*;
import com.meterware.httpunit.*;
import junit.framework.*;
//import javax related classes
import javax.servlet.ServletOutputStream;
//import java related classes
import java.io.*;
public class LNTControllerSTest extends TestCase
public void testForwardToRetrieveJSP() throws Exception
ServletRunner sr = new ServletRunner( "web.xml" );
ServletUnitClient client = sr.newClient();
@ line2 that is getting client ,am getting error
pls help me out

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!