Hi Josep,

I can help you.  Here is something from the mailing list from a while ago:

http://appfuse.547863.n4.nabble.com/Spring-Autowiring-during-Unit-testing-tp575190p575196.html

I can send you some examples of how we are using a Struts2 BaseTest class like 
you describe in a little bit.  You may have to email me to remind me in case I 
get distracted.

-D


On Dec 14, 2010, at 7:19 AM, Josep García wrote:

> This seems to be based on servletunit and it looks like it only supports 
> Struts 1.x.
> 
> I'd like to write a test like:
> 
> public void testSearchByBondName() throws Exception {
>     HashMap params = new HashMap();
> 
>     ActionProxy proxy = createActionProxy(NAMESPACE, ACTION, parrams);
>     assertEquals("success", proxy.invoke());
>     assertTrue(action.getActionErrors().isEmpty());
>   }
> 
> I was trying some solutions for this, based on what I found on the net, like:
> http://depressedprogrammer.wordpress.com/2007/06/18/unit-testing-struts-2-actions-spring-junit/
> 
> but with no luck when accessing the persistent objects in my actions.
> 
> org.hibernate.LazyInitializationException: could not initialize proxy - no 
> Session
>     at 
> org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
>     at 
> org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
>     at 
> org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
> 
> Incidentally, I found a org.apache.struts2.StrutsTestCase class, but there 
> seems to be no examples on how to use it.
> 
> Josep
> 
> 2010/12/14 Matt Raible <m...@raibledesigns.com>
> 
> 
> On Tue, Dec 14, 2010 at 5:47 AM, Josep García <jgar...@isigma.es> wrote:
> I have found this while doing some search:
> 
> 
> /**
>  * This class is extended by all ActionTests. It basically
>  * contains common methods that they might use.
>  *
>  * <p>
>  * <a href="BaseStrutsTestCase.java.html"><i>View Source</i></a>
>  *
>  * @author <a href="mailto:m...@raibledesigns.com";>Matt Raible</a>
>  */
> public abstract class BaseStrutsTestCase extends MockStrutsTestCase {
> 
> However, in my AppFuse 2.0.2, ActionTests extend BaseActionTestCase. This 
> lacks the possibility of testing action messages, struts validation, etc.
> 
> Where is this appfuse BaseStrutsTestCase availble? Can it be used to test 
> struts validation and so on?
> 
> Yes, you should be able to test these things. What does your test case look 
> like and what's not working?
> 
> 
> 

Reply via email to