[opencms-dev] unit testing without DB (CmsJspBean)
Achim Westermann
achim.westermann at questico.de
Tue Feb 16 14:21:00 CET 2010
Hi Martin,
I'd recommend to use Powermock. I once wrote testcases with it that covered CmsJspActionElements. Although you have to fiddle a little bit
to mix in the right expectations and reactions on it: it is possible.
http://code.google.com/p/powermock/
The classic approach: Look at the OpenCmsTestcase / the unit tests of OpenCms: They set up a temp db, import demo content and run against
the cms shell.
HTH,
Achim
Martin Zibricky wrote:
> Hi all,
>
> I'm trying write unit tests for an OpenCms module what uses classes
> inherited from CmsJspActionElement.
>
> For writting tests I'm using some mock objects (page context, http
> session, ...) from spring framework.
>
> When I execute a unit test for class inherited from CmsJspActionElement,
> I'm getting this CmsRuntimeException:
>
>
> "org.opencms.jsp.CmsJspBean" is usable only on a OpenCms controlled JSP
> page.
>
>
> Is there any workaround to write unit tests for classes inherited from
> CmsJspBean and without using DB connection and servlet container?
>
>
> Thanks in advance for any answer,
> Martin Z.
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
More information about the opencms-dev
mailing list