Apache previously provided the cactus Eclipse plug-in, but since cactus is based on juint, there is no plug-in now.
In addition, the Apache documentation on how to integrate into eclipse has not changed.
Bytes
Org. Apache. Cactus. Integration. Eclipse _ [version] cannot be found on Apache.Bytes.
In addition, the above Quick Start has not been viewed:
Http://jakarta.apache.org/cactus/integration/howto_tomcat.html
Below is the paste: http://blog.csdn.net/eagle51998/archive/2006/07/10/899550.aspx
Note: If you only test servlet, you only need to configure servlet in Web. xml.
In addition
http://jakarta.apache.org/cactus/integration/manual/howto_config.html,
Except the cactus. contexturl attribute, cactus. properties is optional.
Cactus is an open-source testing framework of Apache. It is based on JUnit and has more powerful functions than JUnit. It can be used for server-side testing, especially in the container, it is an automatic testing framework. After some research, I will write down my experiences for your reference.
The required resources are as follows:
1. Eclipse SDK version: 3.1.2
2. The required class libraries are: aspectjrt-1.2.1.jar, cactus-1.7.1.jar, commons-httpclient-2.0.2.jar, commons-digester.jar, httpunit-1.6.jar, JUnit. jar.
3. Integrate the server with eclipse (Optional). The main purpose of integration is to implement debug)
Below are the file resources to be compiled:
1. Cactus. Properties
######################################## ########################################
# Configuration file for cactus.
# Each project using cactus need to have such a file put in the classpath
# (Meaning the directory containgin this file shocould Be In The classpath, not
# The file itself of course ...)
# Defines the URLs that will be used by cactus to call it's redirectors
# (Servlet and JSP). You need to specify in these URLs the webapp Context
# That you use for your application. In the example below, the context is
# "Test ".
Cactus. servletredirectorurl = http: // localhost: 7001/cactus/servletredirector
Cactus. jspredirectorurl = http: // localhost: 7001/cactus/jspredirector
Cactus. filterredirectorurl = http: /localhost: 7001/cactus/filterredirector
# Name of cactus property that specify the url up to the webapp context.
# This is the base URL to call for the redirectors. It is made up:
# "Http: //" + servername + port + "/" + contextname.
# Modify cactus. contexturl to the starting path of the webapp
Cactus. contexturl = http: // localhost: 7001/cactus
Cactus. servletredirectorname = servletredirector
Cactus. jspredirectorname = jspredirector
Cactus. filterredirectorname = filterredirector
# Name of the cactus property for defining an initializer (I. e. a class
# That is executed before the cactus tests start on the client side ).
Cactus. initializer =
Cactus. enablelogging = true
######################################## ########################################
Place cactus. properties in the classes directory under the project's WEB-INF so that the configuration file can be directly found at WebLogic startup.
2. Add the cactus test class to the Web. xml file. (similar to a router) The request is filtered by the web iner.
Web. xml
========================================================== ==========================================================
<! -- Config for cactus -->
<Context-param>
<Param-Name> param </param-Name>
<Param-value> value used for testing </param-value>
</Context-param>
<Servlet>
<Servlet-Name> servletredirector </servlet-Name>
<Servlet-class> org. Apache. Cactus. server. servlettestredirector </servlet-class>
<Init-param>
<Param-Name> param1 </param-Name>
<Param-value> value1 used for testing </param-value>
</Init-param>
</Servlet>
<Servlet>
<Servlet-Name> servletredirector_testoverride </servlet-Name>
<Servlet-class> org. Apache. Cactus. server. servlettestredirector </servlet-class>
<Init-param>
<Param-Name> param2 </param-Name>
<Param-value> value2 used for testing </param-value>
</Init-param>
</Servlet>
<Servlet>
<Servlet-Name> testjsp </servlet-Name>
<JSP-File>/test. jsp </JSP-File>
</Servlet>
<Servlet>
<Servlet-Name> jspredirector </servlet-Name>
<JSP-File>/test/jspredirector. jsp </JSP-File>
<Init-param>
<Param-Name> param1 </param-Name>
<Param-value> value1 used for testing </param-value>
</Init-param>
</Servlet>
<Servlet-mapping>
<Servlet-Name> servletredirector </servlet-Name>
<URL-pattern>/servletredirector </url-pattern>
</Servlet-mapping>
<Servlet>
<Servlet-Name> servlettestrunner </servlet-Name>
<Display-Name> servlettestrunner </display-Name>
<Servlet-class> org. Apache. Cactus. server. Runner. servlettestrunner </servlet-class>
</Servlet>
<Servlet-mapping>
<Servlet-Name> servlettestredirector </servlet-Name>
<URL-pattern>/servletredirector </url-pattern>
</Servlet-mapping>
<Servlet-mapping>
<Servlet-Name> servlettestrunner </servlet-Name>
<URL-pattern>/servlettestrunner </url-pattern>
</Servlet-mapping>
<Servlet-mapping>
<Servlet-Name> jspredirector </servlet-Name>
<URL-pattern>/jspredirector </url-pattern>
</Servlet-mapping>
<Servlet-mapping>
<Servlet-Name> servletredirector_testoverride </servlet-Name>
<URL-pattern>/servletredirectoroverride </url-pattern>
</Servlet-mapping>
<Filter>
<Filter-Name> filterredirector </filter-Name>
<Filter-class> org. Apache. Cactus. server. filtertestredirector </filter-class>
</Filter>
<Filter-mapping>
<Filter-Name> filterredirector </filter-Name>
<URL-pattern>/filterredirector </url-pattern>
</Filter-mapping>
========================================================== ==========================================================
3. Compile a test class
Public class testdelegate extends servlettestcase
{
Private testdelegate delegate = new testdelegate ();
Public void setup () throws exception
{
// Begin some initial work
// Construct some context
}
Public void testadd () throws businessexception
{
Dto DTO = new DTO ();
Delegate. Add (DTO );
Delegate. Update (DTO );
Delegate. Delete (DTO );
}
}
Procedure:
Start WebLogic to ensure that servlets such as servletredirector can be found under Web container.
You can use JUnit to run the program and test suit to run the test suite.
========================================================== ==========================================================
Public class testall
{
Public Static Test Suite ()
{
Testsuite suite = new testsuite (
"Cactus unit tests for J2EE 1.3 ");
// Add shared tests
// Suite. addtest (testevery all. Suite ());
// Test cases specific to J2EE 1.3 only
Suite. addtestsuite (testhello. Class );
Suite. addtestsuite (testworld. Class );
Suite. addtestsuite (testdelegate. Class );
Suite. addtestsuite (testejb. Class );
Suite. addtestsuite (testother. Class );
Return suite;
}
}