Any Substitute Of Cactus? How To Use Cactus?

Cactus has retired for some reason, however, I haven't found any competing substitute that could finish the same mission better. Inforseeable future, I would choose Cactus anyway for server-side in-container unit testing anyway.

How to configure Cactus? Below are several noteworthy key points:

1. Place the cactus.properties file under the WEB-INF/classes. Content Example:

cactus.contextURL = http://localhost.derek.com:9080/context

cactus.servletRedirectorName = ServletRedirector

cactus.enableLogging=false

2. Copy all the jars of Cactus 1.8 and commons-codec.jar to WEB-INF/lib.

3. Edit web.xml as <Struts Kick Start> told you. You can also reference Cactus's <20 minutes tutorial>.

4. Write testing code and run it just like junit. Pretty easy. An alternative to run Cactus's test cases is through direct HTTP request(URL). I prefer the former way personally.

 

Frequent Error You May Run Across:

1. NoClassDefFoundError

java.lang.NoClassDefFoundError:org/apache/cactus/server/ServletTestRedirector

Solution: you should copy your jars to not only WEB-INF/lib, but also somewhere of container's installation folder. For example, in my case, 'D:\Program Files\IBM\WebSphere\AppServer\lib\ext' for WebSphere, and 'D:\Program Files\Tomcat 7.0\lib' for Tomcat 7.

 

2. ChainedRuntimeException

org.apache.cactus.util.ChainedRuntimeException: Cannot read cactus configuration file

Solution: Place the cactus.properties file under the WEB-INF/classes.  If you clean and rebuild projects, you should check whether it exists now.

你可能感兴趣的:(Any Substitute Of Cactus? How To Use Cactus?)