You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by UV <uv...@googlemail.com> on 2011/06/17 02:08:31 UTC

Problem with configured action method names and Testing Framework

Hi,

When I try to test an action with a method="actionMethod" attribute 
configured in a  StrutsTestCase
the AnnotationValidationInterceptor fails in getActionMethod#75 cause it 
cannot find the method
using the configured name on the proxy used in the testing framework.

My only workaround so far was using execute() method on actions only and 
split all actions up into separate files.

Is this a known bug?

Is there a better workaround?

Thanks for any pointers.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with configured action method names and Testing Framework - Action Testing with configured method names is broken in struts-2.2.3

Posted by UV <uv...@googlemail.com>.
Of course I configured a method with the same name and returning String?!?

But this is about using the action test framework of struts on actions 
configured with a method name
in the XML instead of using the default execute()
(which I  use as a workaround now)

So changing the names I use in the xml configuration should have nothing 
to do with it, as the reflection code only seems to be able to find the 
execute() method which is part of the action interface.

I have been deep in this with the debugger and I am actually pretty sure 
by now
that this is a defect in the testing framework which has not been 
addressed yet.

So for now: Action Testing with configured method names is NOT WORKING 
in struts-2.2.3

On 17/06/2011 07:24, Lukasz Lenart wrote:
> 2011/6/17 UV<uv...@googlemail.com>:
>> When I try to test an action with a method="actionMethod" attribute
>> configured in a  StrutsTestCase
>> the AnnotationValidationInterceptor fails in getActionMethod#75 cause it
>> cannot find the method
> Try to name your method actionMethod instead of getActionMethod and of
> return type String
>
>
> Regards


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with configured action method names and Testing Framework

Posted by Lukasz Lenart <lu...@googlemail.com>.
2011/6/17 UV <uv...@googlemail.com>:
> When I try to test an action with a method="actionMethod" attribute
> configured in a  StrutsTestCase
> the AnnotationValidationInterceptor fails in getActionMethod#75 cause it
> cannot find the method

Try to name your method actionMethod instead of getActionMethod and of
return type String


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with configured action method names and Testing Framework ===> StrutsTestCase cannot handle actions not calling execute()

Posted by UV <uv...@googlemail.com>.
Hi,

the setup is unit testing with maven + spring + struts using 
StrutsSpringTestCase super class
(which is an extended org.apache.struts2.StrutsTestCase with access to 
spring config).

So this is working well with actions not having the methodname configured.

Whenever I do configure such a method the code in 
AnnotationValidationInterceptor(struts-core-2.2.3) fails in line 83++
after failing to instantiate the method which is NOT named "execute" 
this time from the proxy.

Environment:
1. struts action configured using a method name.
2. action test based on a StrutsTestCase (using those mock objects)
3. set a breakpoint on line 83 in the annotationvalidationinterceptor.

However, the same code exists in DefaultActionInvocation line 437 and is 
used to instantiate the method for executing the action, so disabling 
the validation simply postpones the very same issue to a later point in 
the code
as you can see in the stacktrace below!

It seems that the StrustTestcase cannot handle actions with a method 
name configured!


Thread [main] (Suspended)
     DefaultActionInvocation.invokeAction(Object, ActionConfig) line: 433
     DefaultActionInvocation.invokeActionOnly() line: 291
     DefaultActionInvocation.invoke() line: 254
     DefaultWorkflowInterceptor.doIntercept(ActionInvocation) line: 176
     
DefaultWorkflowInterceptor(MethodFilterInterceptor).intercept(ActionInvocation) 
line: 98
     DefaultActionInvocation.invoke() line: 248
     
StrutsConversionErrorInterceptor(ConversionErrorInterceptor).intercept(ActionInvocation) 
line: 133
     DefaultActionInvocation.invoke() line: 248
     ParametersInterceptor.doIntercept(ActionInvocation) line: 207
     
ParametersInterceptor(MethodFilterInterceptor).intercept(ActionInvocation) 
line: 98
     DefaultActionInvocation.invoke() line: 248
     
ActionMappingParametersInteceptor(ParametersInterceptor).doIntercept(ActionInvocation) 
line: 207
     
ActionMappingParametersInteceptor(MethodFilterInterceptor).intercept(ActionInvocation) 
line: 98
     DefaultActionInvocation.invoke() line: 248
     StaticParametersInterceptor.intercept(ActionInvocation) line: 190
     DefaultActionInvocation.invoke() line: 248
     MultiselectInterceptor.intercept(ActionInvocation) line: 75
     DefaultActionInvocation.invoke() line: 248
     CheckboxInterceptor.intercept(ActionInvocation) line: 94
     DefaultActionInvocation.invoke() line: 248
     ModelDrivenInterceptor.intercept(ActionInvocation) line: 100
     DefaultActionInvocation.invoke() line: 248
     ScopedModelDrivenInterceptor.intercept(ActionInvocation) line: 141
     DefaultActionInvocation.invoke() line: 248
     DebuggingInterceptor.intercept(ActionInvocation) line: 270
     DefaultActionInvocation.invoke() line: 248
     ChainingInterceptor.intercept(ActionInvocation) line: 145
     DefaultActionInvocation.invoke() line: 248
     PrepareInterceptor.doIntercept(ActionInvocation) line: 171
     
PrepareInterceptor(MethodFilterInterceptor).intercept(ActionInvocation) 
line: 98
     DefaultActionInvocation.invoke() line: 248
     I18nInterceptor.intercept(ActionInvocation) line: 176
     DefaultActionInvocation.invoke() line: 248
     ServletConfigInterceptor.intercept(ActionInvocation) line: 164
     DefaultActionInvocation.invoke() line: 248
     AliasInterceptor.intercept(ActionInvocation) line: 190
     DefaultActionInvocation.invoke() line: 248
     ExceptionMappingInterceptor.intercept(ActionInvocation) line: 187
     DefaultActionInvocation.invoke() line: 248
     StrutsActionProxy.execute() line: 52
     ContentActionTest.doContentDelete() line: 158
     ContentActionTest.testContentLifeCycle() line: 179
     NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: 
not available [native method]
     NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
     DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
     Method.invoke(Object, Object...) line: 597
     FrameworkMethod$1.runReflectiveCall() line: 44
     FrameworkMethod$1(ReflectiveCallable).run() line: 15
     FrameworkMethod.invokeExplosively(Object, Object...) line: 41
     InvokeMethod.evaluate() line: 20
     RunBefores.evaluate() line: 28
     RunBeforeTestMethodCallbacks.evaluate() line: 74
     RunAfterTestMethodCallbacks.evaluate() line: 82
     SpringRepeat.evaluate() line: 72
     SpringJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) 
line: 240
     SpringJUnit4ClassRunner(BlockJUnit4ClassRunner).runChild(Object, 
RunNotifier) line: 50
     ParentRunner$3.run() line: 193
     ParentRunner$1.schedule(Runnable) line: 52
     SpringJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) 
line: 191
     ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 42
     ParentRunner$2.evaluate() line: 184
     RunBeforeTestClassCallbacks.evaluate() line: 61
     RunAfterTestClassCallbacks.evaluate() line: 70
     SpringJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 236
     SpringJUnit4ClassRunner.run(RunNotifier) line: 180
     JUnit4TestSet.execute(Class, RunNotifier, String) line: 53
     JUnit4Provider.executeTestSet(Class, RunListener, ClassLoader, 
RunNotifier) line: 119
     JUnit4Provider.invoke(Object) line: 101
     NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: 
not available [native method]
     NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
     DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
     Method.invoke(Object, Object...) line: 597
     ProviderFactory$ClassLoaderProxy.invoke(Object, Method, Object[]) 
line: 103
     $Proxy0.invoke(Object) line: not available
     SurefireStarter.invokeProvider(Object, ClassLoader, ClassLoader) 
line: 150
     SurefireStarter.runSuitesInProcess() line: 91
     ForkedBooter.main(String[]) line: 69

On 17/06/2011 02:17, Maurizio Cucchiara wrote:
> Hi,
> could you send the stacktrace exception/error?
> What are you using to execute your test (f.i. maven, eclipse, etc)?
>
> Maurizio Cucchiara
>
> Il giorno 17/giu/2011 02.09, "UV"<uv...@googlemail.com>  ha scritto:
>> Hi,
>>
>> When I try to test an action with a method="actionMethod" attribute
>> configured in a StrutsTestCase
>> the AnnotationValidationInterceptor fails in getActionMethod#75 cause it
>> cannot find the method
>> using the configured name on the proxy used in the testing framework.
>>
>> My only workaround so far was using execute() method on actions only and
>> split all actions up into separate files.
>>
>> Is this a known bug?
>>
>> Is there a better workaround?
>>
>> Thanks for any pointers.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Problem with configured action method names and Testing Framework

Posted by Maurizio Cucchiara <mc...@apache.org>.
Hi,
could you send the stacktrace exception/error?
What are you using to execute your test (f.i. maven, eclipse, etc)?

Maurizio Cucchiara

Il giorno 17/giu/2011 02.09, "UV" <uv...@googlemail.com> ha scritto:
> Hi,
>
> When I try to test an action with a method="actionMethod" attribute
> configured in a StrutsTestCase
> the AnnotationValidationInterceptor fails in getActionMethod#75 cause it
> cannot find the method
> using the configured name on the proxy used in the testing framework.
>
> My only workaround so far was using execute() method on actions only and
> split all actions up into separate files.
>
> Is this a known bug?
>
> Is there a better workaround?
>
> Thanks for any pointers.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>