Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

does not contain handler parameter named 'method'. This may be caused by whitespace

 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am testing ACTION class using JUNIT(WSAD5.1.2) ,I am getting a bug whle testing it

JUNIT is throwing an error as given below
servletunit.struts.ExceptionDuringTestError: An uncaught exception was thrown during actionExecute()
at servletunit.struts.CactusStrutsTestCase.actionPerform(CactusStrutsTestCase.java:546)
at com.sbc.dcomm.ui.cart.pa.actions.PAActionTest.testSession(PAActionTest.java:73)


Console output is as given below :
ServletRedirector: init
DispatchActio E org.apache.struts.actions.DispatchAction Request[/pricingAnalysis] does not contain handler parameter named 'method'. This may be

caused by whitespace in the label text.
RequestProces W org.apache.struts.action.RequestProcessor Unhandled Exception thrown: class javax.servlet.ServletException

JAVASCRIPT CODE for opening the screen :

function openPricingAnalysis()
{
var id= document.pAActionForm.id.value;
var str = 'pricingAnalysis.do?method=createPricingAnalysis&id='+id;
window.open(str,"PAT","scrollbars=yes,status=no,statusbar=no,width=800,height=600");
}

CODE FROM CONFIG FILE :
<action path="/pricingAnalysis" name="popUpForm" scope="request" type="com.sbc.dcomm.ui.cart.pa.actions.PAAction" parameter="method">
<forward name="success" path="/cart/pa/paAnalysis.jsp"/>
</action>

CODE FROM ACTION CLASS :

public Map getKeyMethodMap() {
Map map = new HashMap();
map.put("pricing.createPricingAnalysis", "createPricingAnalysis");

Could you please look into this issue and find out the solution as fast as possible.
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Further to above ,I am using struts framework for my application
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TEST CASE CLASS :

public void testPricing()
{

setConfigFile("/WEB-INF/struts-config-pa.xml");
setRequestPathInfo("/pricingAnalysis");
//setRequestPathInfo("/pricingAnalysis.do");
addRequestParameter("id","1097");
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward("success");


}
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the JavaScript function takes method as a parameter with value of method name.I have added one more line of code in the method for method parameter.

addRequestParameter("method","createPricingAnalysis");

public void testPricing()
{

setConfigFile("/WEB-INF/struts-config-pa.xml");
setRequestPathInfo("/pricingAnalysis");
addRequestParameter("method","createPricingAnalysis");
addRequestParameter("id","1097");
actionPerform();
verifyNoActionErrors();
verifyNoActionMessages();
verifyForward("success");


}
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now the error does not say "Request[/pricingAnalysis] does not contain handler parameter named 'method'. This may be caused by whitespace in the label text."

But it does throw following error :

JUNIT console says:
servletunit.struts.ExceptionDuringTestError: An uncaught exception was thrown during actionExecute()
at servletunit.struts.CactusStrutsTestCase.actionPerform(CactusStrutsTestCase.java:546)
at com.sbc.dcomm.ui.cart.pa.actions.PAActionTest.testSession(PAActionTest.java:73)



Application (Server)Console output is as given below :
[dcomm-ui] [/dcomm-ui] [Servlet.LOG]: ServletRedirector: init

RequestProces W org.apache.struts.action.RequestProcessor Unhandled Exception thrown: class javax.servlet.ServletException
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solution :
I have not set method name in my test case method ,I have set it as follows :
addRequestParameter("method", "createPricingAnalysis");

Problem got solved
 
thomas davis
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junit does not work with LookUpDispatchAction,it would work with DispatchAction instead.Hence you need to extend DispatchAction instead of LookUpDispatchAction
 
Barry Hawkins
ranger
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thomas,
It looks like you posted a solution followed by a statement that you could not find a solution and therefore had to abandon the use of LookupDispatchAction; which was it?

Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic