Thanks for the code.  Could you please include the imports, because I'm not 
sure what is related to your mock class and what is part of struts 2 (like 
expect(), is that part of struts 2 or is it internal to your mock class?).

Thanks,
Session


> This uses easyMock @Test public void
> should_log_before_and_after_action_execution() throws Exception {
> 
> Logger mockLogger = createMock(Logger.class);
> 
> String actionName = "mockAction"; String actionResult = "Success"; 
> ActionInvocation mockInvocation createMock(ActionInvocation.class); 
> ActionProxy mockProxy = createMock(ActionProxy.class);
> 
> expect(mockInvocation.getProxy()).andReturn(mockProxy); 
> expect(mockProxy.getActionName()).andReturn(actionName);
> 
> mockLogger.info("Start execution of " + actionName);
> 
> expect(mockInvocation.invoke()).andReturn(actionResult); 
> mockLogger.info("End execution of " + actionName + " with result " +
> actionResult);
> 
> replay(mockLogger); replay(mockInvocation); replay(mockProxy);
> 
> LoggingInterceptor interceptor = new LoggingInterceptor(mockLogger); String
> result = interceptor.intercept(mockInvocation);
> 
> verify(mockLogger); verify(mockInvocation); verify(mockProxy); 
> assertEquals("Should return result from inner action", actionResult,
> result); }
> 
> -----Original Message----- From: Session A Mwamufiya
> [mailto:[EMAIL PROTECTED] Sent: Thursday, 5 July 2007 6:23 PM To:
> Struts Users Mailing List Subject: unit testing interceptors
> 
> Hi,
> 
> Has anyone created unit tests (with JUnit) for interceptors?  I'd like to
> have an easy example to follow in order to unit test mine.
> 
> Thanks, Session
> 
> 
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: [EMAIL PROTECTED] For additional
> commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> "This e-mail and any attachments to it (the "Communication") is, unless
> otherwise stated, confidential,  may contain copyright material and is
> for the use only of the intended recipient. If you receive the
> Communication in error, please notify the sender immediately by return
> e-mail, delete the Communication and the return e-mail, and do not read,
> copy, retransmit or otherwise deal with it. Any views expressed in the
> Communication are those of the individual sender only, unless expressly
> stated to be those of Australia and New Zealand Banking Group Limited ABN
> 11 005 357 522, or any of its related entities including ANZ National
> Bank Limited (together "ANZ"). ANZ does not accept liability in
> connection with the integrity of or errors in the Communication, computer
> virus, data corruption, interference or delay arising from or in respect
> of the Communication."
> 
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: [EMAIL PROTECTED] For additional
> commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to