Well, I'm kind of stupid but I also found another issue.  So the reason my
java based test was passing was because no tests were being ran since the
method was private.  So it doesn't have anything to do with groovy.

That said, it still wasn't working.  The problem was due to my
BaseActionBean using a custom ActionBeanContext.  Using ActionBeanContext
directly rather than my subclass and everything works. Is this a known
issue?  Am I doing something wrong?  I've specified the extensions package
in my filter setup in the test.  And it works fine in a regular deployment.
Just not the test case.

Gregg

On Wed, Jan 21, 2009 at 6:34 PM, Gregg Bolinger
<[email protected]>wrote:

> I was playing around with groovy and stripes and decided to write some
> action bean tests in groovy to see if it saved me some typing.  So far it
> hasn't because I can't get it to work.  Groovy seems to use a pretty old
> version of JUnit (3.something) but I'm not sure if that can really be the
> problem.  Below is my groovy test case....
>
> public class GroovyHomeActionBeanTest extends GroovyTestCase {
>
>     void testDefaultHandler() {
>
>         def mockServletContext = new MockServletContext("oneupthis")
>         def params = ["ActionResolver.Packages":"com.oneupthis.web.action",
> "Extension.Packages":"com.oneupthis.web.extension"]
>         mockServletContext.addFilter(StripesFilter.class, "StripesFilter",
> params)
>         mockServletContext.setServlet(DispatcherServlet.class,
> "DispatcherServlet", null)
>         def mockSession = new MockHttpSession(mockServletContext)
>         MockRoundtrip trip = new MockRoundtrip(mockServletContext,
> HomeActionBean.class, mockSession)
>         trip.execute()
>         HomeActionBean bean = trip.getActionBean(HomeActionBean.class)
>         assertNotNull bean
>     }
> }
>
> I get the following exception:
>
> net.sourceforge.stripes.exception.StripesServletException: Could not create
> instance of ActionBean type [com.oneupthis.web.action.HomeActionBean].
>     at
> net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:367)
>     at
> net.sourceforge.stripes.controller.NameBasedActionResolver.getActionBean(NameBasedActionResolver.java:264)
>     at
> net.sourceforge.stripes.controller.AnnotatedClassActionResolver.getActionBean(AnnotatedClassActionResolver.java:292)
>     at
> net.sourceforge.stripes.controller.DispatcherHelper$1.intercept(DispatcherHelper.java:106)
>     at
> net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:158)
>     at
> net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor.intercept(BeforeAfterMethodInterceptor.java:113)
>     at
> net.sourceforge.stripes.controller.ExecutionContext.proceed(ExecutionContext.java:155)
>     at
> net.sourceforge.stripes.controller.ExecutionContext.wrap(ExecutionContext.java:74)
>     at
> net.sourceforge.stripes.controller.DispatcherHelper.resolveActionBean(DispatcherHelper.java:102)
>     at
> net.sourceforge.stripes.controller.DispatcherServlet.resolveActionBean(DispatcherServlet.java:238)
>     at
> net.sourceforge.stripes.controller.DispatcherServlet.service(DispatcherServlet.java:141)
>     at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
>     at
> net.sourceforge.stripes.mock.MockFilterChain.doFilter(MockFilterChain.java:66)
>     at
> net.sourceforge.stripes.controller.StripesFilter.doFilter(StripesFilter.java:247)
>     at
> net.sourceforge.stripes.mock.MockFilterChain.doFilter(MockFilterChain.java:63)
>     at
> net.sourceforge.stripes.mock.MockServletContext.acceptRequest(MockServletContext.java:255)
>     at
> net.sourceforge.stripes.mock.MockRoundtrip.execute(MockRoundtrip.java:245)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at
> org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
>     at
> org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
>     at
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43)
>     at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
>     at
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
>     at
> com.oneupthis.web.action.GroovyHomeActionBeanTest.testDefaultHandler(GroovyHomeActionBeanTest.groovy:23)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>     at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>     at
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
>
> Now, this code which is just plain java works fine
>
> public class HomeActionBeanTest {
>
>     @Test
>     private void testDefaultHandler() throws Exception {
>
>         MockServletContext mockServletContext = new
> MockServletContext("oneupthis");
>         final Map<String, String> params = new HashMap<String, String>();
>         params.put("ActionResolver.Packages", "com.oneupthis.web.action");
>         params.put("Extension.Packages", "com.oneupthis.web.extension");
>         mockServletContext.addFilter(StripesFilter.class, "StripesFilter",
> params);
>         mockServletContext.setServlet(DispatcherServlet.class,
> "DispatcherServlet", null);
>         MockHttpSession mockSession = new
> MockHttpSession(mockServletContext);
>         MockRoundtrip trip = new MockRoundtrip(mockServletContext,
> HomeActionBean.class, mockSession);
>         trip.execute();
>         HomeActionBean bean = trip.getActionBean(HomeActionBean.class);
>     }
> }
>
> Of course, with this I am using TestNG.   Anyone have any thoughts?
>
> Gregg
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to