You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by 진태식 <ma...@icols.com> on 2002/05/14 13:21:43 UTC

Cactus TestCase. Please, Help me.

Good morning?
Glad to meet you.
I'm a Cactus beginner. And can't English well. So, I'm sorry.

I'm studing Apache's TestCase(http://jakarta.apache.org/cactus/howto_testcase.html).
I did work below.

I made cactustest webapp. Tomcat 4.0.

folder : file.
cactustest : jspRedirector.jsp ,
cactustest/WEB-INF : web.xml ,
cactustest/WEB-INF/classes : SampleServlet.class, TestSampleServlet.class ,
cactustest/WEB-INF/lib : cactus.jar, junit.jar, log4j-1.2rc1.jar 

Start Tomcat Server.

http://localhost:8080/cactustest/servlet/SampleServlet --> Good.
But, http://localhost:8080/cactustest/servlet/TestSampleServlet --> Not Good. Error.

Is wrong this my test?
Next, what will I do?

I want your help.
Thank you.


Below is source of TestSampleServlet.java.
--------------------------------------------------

import org.apache.cactus.* ;
import junit.framework.* ;

public class TestSampleServlet extends ServletTestCase
{

 public TestSampleServlet(String theName)
 {
     super(theName);
 }
 
 public static void main(String[] theArgs)
 {
     junit.swingui.TestRunner.main(new String[] {TestSampleServlet.class.getName()});
 }
 
 public static Test suite()
 {
     return new TestSuite(TestSampleServlet.class);
 }
 
 public void testXXX()
 {
     // Initialize class to test
     SampleServlet servlet = new SampleServlet();
 
     // Set a variable in session as the doSomething() method that we are testing need
     // this variable to be present in the session (for example)
     session.setAttribute("name", "value");
 
     // Call the method to test, passing an HttpServletRequest object (for example)
     String result = servlet.doSomething(request);
 
     // Perform verification that test was successful
     assertEquals("something", result);
     assertEquals("otherValue", session.getAttribute("otherName"));
 }
}