您的位置:首页 > 其它

Any Substitute Of Cactus? How To Use Cactus?

2012-03-11 20:07 399 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: