|
One concern for any developer is unit testing, and being able to test in an
environment that mimicks as closely as possible the target runtime environment. To this end, a MockServer has been written and is shipped with Gracelets Tools. It has mock implementations of most of the crucial javax.servlet classes and has many helper classes to get you going with JSF/Facelets/Gracelets and the like. You simply setup a Servlet Context programatically and it will take care of the rest. You can look at the source code of the StaticContentGenerator for an example of how to use the MockServer. The MockServer class resides in the gracelets.tools.mockserver package. Since JSF, Facelets and other servlet frameworks are really designed to run in any servlet container, this allows them to run rather seamlessly in the MockServer. It generally takes only a few seconds to boot up and then you can write an implementation that will call the primary processing method. If you use the mock server for unit testing purposes, you can then easily analyze the output to verify that it is producing correctly. To make this even more transparent and a more realistic environment, there is also a Mock Browser that works with the Mock Server classes in a single thread allowing one "browse" gracelet pages and do testing on the output. The browser holds cookies and so forth and thus simulates the request/response entirely. The two tools together make an execelent simulation environment for the entire Gracelets code base. These tools will soon be integrated with something like HtmlUnit and a Groovy environment in order to allow making writing and using unit tests a breeze. |
| Last Updated: 05/05/2009 09:43PM CDT | © Gracelets 2008-2009 |