Am Mo, den 23.02.2004 schrieb Ann um 13:03:
> Hi
>
> I am new to cocoon and am trying to develop test cases for cocoon framwork. Can
> anybody guide me on how to go about developing test cases .I have been looking at
> the testcases written at src/test/ in cocoon package and still am not very clear.
> Working with cocoon -2.1.3
>
> Any suggestions on how to start writing testcases for the Action Class would be most
> welcome
You need two files. One .xtest files to declare the components, which
should be tested, and one java class, which extends the
SitemapComponentTestCase class.
You can test more than one sitemap component with one junit test.
Take RequestParamActionTestCase as example for a testcase of an action.
You define the action "request" by adding:
<actions logger="test">
<component-instance
class="org.apache.cocoon.acting.RequestParamAction"
name="request"/>
</actions>
and then you write a test method:
public void testRequestAction() throws Exception {
getRequest().setRequestURI("test.xml?abc=def&ghi=jkl");
getRequest().setQueryString("abc=def&ghi=jkl");
getRequest().setContextPath("servlet");
getRequest().addParameter("abc", "def");
Parameters parameters = new Parameters();
parameters.setParameter("parameters", "true");
Map result = act("request", null, parameters);
assertNotNull("Test if resource exists", result);
assertEquals("Test for parameter", "test.xml?abc=def&ghi=jkl",
result.get("requestURI"));
assertEquals("Test for parameter", "?abc=def&ghi=jkl",
result.get("requestQuery"));
assertEquals("Test for parameter", "servlet",
result.get("context"));
assertEquals("Test for parameter", "def", result.get("abc"));
assertNull("Test for parameter", result.get("ghi"));
}
Stephan.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]