Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getRemoteAddr

 
Rowan Chattaway
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm implementing the StrutsTestCase into my current project to provide a suite of JUnit tests for the core Struts actions.

However, the ProcessLoginAction implements ipaddress checking for screening of dubious users. This uses HttpServletrequest.getRemoteAddr().

For my JUnit test - because it's run within my IDE and therefore outside the servlet container, this isn't set and returns null. Because of this the struts action forwards to failure.

Obvioulsy I don't want to change to project code to suit the test.
Can I set remoteAddr someway? or get around this?

Any help would be much appreciated.
Thanks.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always decorate it yourself .. or use some mock object framework. Fun stuff.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic