aspose file tools*
The moose likes Struts and the fly likes JUnit problem with addRequestParameter . HELP * * * Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JUnit problem with addRequestParameter . HELP * * * " Watch "JUnit problem with addRequestParameter . HELP * * * " New topic
Author

JUnit problem with addRequestParameter . HELP * * *

Nivan scorp
Greenhorn

Joined: Dec 06, 2004
Posts: 23
I am running into one peculiar error with JUnit.

I have three test methods namely
1. testSetup,
2. testSubmit and
3. testApply.

When I run my Test class, each of my test methods enter the method named
"unspecified" in my Action file which always point to the setup() method.


I have correctly used the addRequestParameter(PARAM_DISPATCH_METHOD, METHOD_SETUP)function.
The problem I just defined occurs only when my Action extends BaseLookupDispatchAction.

If I make my Action extends BaseDispatchAction, then my test runs through
fine and it enters all the methods in order!!!

Is there an alternative to addRequestParameter while using BaseLookupDispatchAction?

Doesnt anyone have a clue on the difference betweeen handling the problem I stated between BaseDispatchAction and BaseLookupDispatchAction.

Am justhoping someone knows it!!

Thanks,
Nivan.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Hmm. I just looked and I can't find BaseLookupDispatchAction from the Struts API -- is that a WebLogic extension of the "standard" org.apache.struts.actions.LookupDispatchAction?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Nivan scorp
Greenhorn

Joined: Dec 06, 2004
Posts: 23
Oh!
Its not in the Struts API but this guy has been derived from the
"org.apache.struts.actions.LookupDispatchAction". I see that they have introduced an abstract method in this BaseLookupDispatchAction class called getKeyMethodMap() which returns a Map and its implementation in
my Action Class looks as under

-----------------------CODE-----------------------
protected Map getKeyMethodMap() {
Map map = new HashMap();
map.put("setup", "setup");
map.put("xxx.selectbutton", "selectedAccount");
map.put("xxx.submitbutton", "submit");
map.put("xxx.cancelbutton", "cancel");
return map;
}
-----------------------CODE-----------------------

The new class has been derived to handle multiple buttons on web pages.

Can you get anything from this?

Thanks,
Nivan.
Nivan scorp
Greenhorn

Joined: Dec 06, 2004
Posts: 23
Hi,
Doesnt my last mail give any clue on how I need to use
addRequestParameter() in my JUnit Test file?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JUnit problem with addRequestParameter . HELP * * *