File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes getRemoteAddr Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "getRemoteAddr" Watch "getRemoteAddr" New topic
Author

getRemoteAddr

Rowan Chattaway
Ranch Hand

Joined: Jan 18, 2002
Posts: 75
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.


The early bird may get the worm, but the second mouse gets the cheese.........<br /> <br />Sun Certified Programmer for Java 2 Platform<br />Sun Certified Web-Component Developer for J2EE Platform
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
You can always decorate it yourself .. or use some mock object framework. Fun stuff.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getRemoteAddr