wood burning stoves 2.0
The moose likes Testing and the fly likes Testing Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Testing Servlets" Watch "Testing Servlets" New topic

Testing Servlets

Manohar Karamballi
Ranch Hand

Joined: Jul 17, 2001
Posts: 227
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

I agree. Here's the link: http://aspose.com/file-tools
subject: Testing Servlets
It's not a secret anymore!