I am using struts2-junit-plugin for writing test cases for struts2 web application my issue is that in my action classes there are some database related queries which uses data source(jndi) how can i simulate this in my test case.
EDIT
In this test i am setting the remote user.
public void testexecute()
{
try
{
ActionProxy proxy = getActionProxy("/index");
IndexAction action = (IndexAction) proxy.getAction();
request.setRemoteUser("Haider");
assertTrue(action.execute().equals(ActionSupport.SUCCESS));
assertTrue(true);
}
catch(Exception ex)
{
assertTrue(false);
}
}
and in IndexAction (implements PrincipalAware) I have this
public String execute()
{
try
{
if(principleProxy != null)
{
userModel = new UserModel();
userModel.setUserName(principleProxy.getRemoteUser());
}
else
{
return ERROR;
}
................................
.................................
}
in index ation principleProxy is null when i run the test.
You can look into using Dbunit