If you're unit testing and using the ActionProxy and your Action has a
ServletDispatcherResult, you'll need to mock up the Request, etc...

I would suggest that if you're unit testing you just set your properties
on your Action instance that you create yourself and execute it. You
don't need to unit test our framework, we do that for you :-)

Jason

> -----Original Message-----
> From: Jirong Hu [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, December 27, 2003 9:07 AM
> To: [EMAIL PROTECTED]
> Subject: [OS-webwork] java.lang.NullPointerException at 
> System.out.println(proxy.execute());
> 
> 
> Hi,
> 
> First touch with WebWork2. The ActionProxy is a good stuff 
> for unit testing. However, I got the above error when run a 
> simple action.
> 
> What is wrong?
> Jirong
> 
> ---error ----
> java.lang.NullPointerException
>       at
> com.opensymphony.webwork.dispatcher.ServletDispatcherResult.do
> Execute(ServletDispatcherResult.java:52)
>       at
> com.opensymphony.webwork.dispatcher.WebWorkResultSupport.execu
> te(WebWorkResultSupport.java:53)
>       at
> com.opensymphony.xwork.DefaultActionInvocation.executeResult(D
> efaultActionInvocation.java:269)
>       at
> com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA
> ctionInvocation.java:191)
>       at
> com.opensymphony.xwork.interceptor.AroundInterceptor.intercept
> (AroundInterceptor.java:37)
>       at
> com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA
> ctionInvocation.java:169)
>       at
> com.opensymphony.xwork.interceptor.AroundInterceptor.intercept
> (AroundInterceptor.java:37)
>       at
> com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA
> ctionInvocation.java:169)
>       at
> com.opensymphony.xwork.interceptor.AroundInterceptor.intercept
> (AroundInterceptor.java:37)
>       at
> com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA
> ctionInvocation.java:169)
>       at
> com.opensymphony.xwork.interceptor.TimerInterceptor.intercept(
> TimerInterceptor.java:66)
>       at
> com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultA
> ctionInvocation.java:169)
>       at
> com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActio
> nProxy.java:116)
>       at 
> acl.web.test.TestUserAction.testFindUser(TestUserAction.java:53)
>       at acl.web.test.TestUserAction.main(TestUserAction.java:28)
> 
> 
> 
> ----xwork.xml ----
>         <action name="findUserAction" 
> class="acl.web.UserAction" method="findUser">
>             <result name="success" type="dispatcher">
>                 <param name="location">/test.jsp</param>
>             </result>
>             <interceptor-ref name="defaultStack"/>
>         </action>        
> 
> ------- Action class -------------
>       public String execute() throws Exception {
> 
>               return Action.SUCCESS;
>       }
>       
>       public String findUser() throws Exception {
>               String method = "UserAction::findUser(): ";
>               System.out.println(method + "ENTRY");
> 
>               ACAdminBD acAdminBD = new ACAdminBD();
>               HashMap user = acAdminBD.findUser("AdminUser");
>               //System.out.println(method + "UserID:" + 
> user.get("ID") + " 
> GroupID:" + user.get("GROUPS"));
>               userId = (String) user.get("ID");
>               // ArrayList
>               groups = (ArrayList) user.get("GROUPS");
>               System.out.println(method + "userId:" + userId);
>               System.out.println(method + "EXIT");
>               return Action.SUCCESS;
>       }
> 
> 
> ----- JUnit test case -----
> public void testFindUser() throws Exception {
>               String method = "TestUserActioni::testFindUser(): ";
>               System.out.println(method + "ENTRY");
>               
>               ActionProxyFactory factory = 
> ActionProxyFactory.getFactory();
>               ActionProxy proxy = 
> factory.createActionProxy("", "findUserAction", null);
>               if (proxy != null)
>               System.out.println(method + "proxy is NOT null");
>               System.out.println(proxy.execute());            
>               UserAction userAction = (UserAction) proxy.getAction();
>               System.out.println(method + "UserId: " + 
> userAction.getUserId());
>               System.out.println(method + "EXIT");
>       
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing. 
http://photos.yahoo.com/


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for
IBM's Free Linux Tutorials.  Learn everything from the bash shell to sys
admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to