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:
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
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
Solution: Place the cactus.properties file under the
WEB-INF/classes. If you clean and rebuild projects, you should check whether it exists now.
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.
相关文章推荐
- How to use XY chart of JFreeChart? Or any other choice?!
- Question 33: How can a C++ developer use the placement new syntax to make new allocate an object of class SomeClass at a particu
- The best manual of how to use "The easiest Xdebug" addon for Firefox
- How to block use of USB Storage on RHEL.
- A tutorial of how to use Microsoft CMAB, Part 2
- How to use "man" effectively in the development of Linux
- [Maven]How do I tell Maven to use the latest version of a dependency?
- How to use Reflector to see the code of .net framework
- Managing Compiler Toolchains How to manage XDCtools use of your compiler toolchain
- How to use the function of assembly.
- [Ubuntu / Firefox] How to use Advanced Video Upload feature of YouTube
- How to use Fiddler and HTTP replay to have an offline copy of your site
- Example of how to use both JDK 7 and JDK 8 in one build.--reference
- OA Framework - How to Find the Correct Version of JDeveloper to Use with E-Business Suite 11i or Release 12.x (Doc ID 416708.1)
- 【转】How to use LINQ methods to compare objects of custom types
- Xcode 6 allows VECTOR image assets… any idea how to use them?
- How to use InterfaceInterceptor of Unity with configuration file
- How to use USB to do charger detection instead of PMIC?
- INF: How To Enable Analysis Server to Use 3 GB of RAM
- Xcode 6 allows VECTOR image assets… any idea how to use them?