The idea is to focus attention on what is actually happening in your
code rather than what you suspect is happening.
I maybe a little more work in some cases to setup a list instead of the
map but the results can be worth it.
If you use a map you can write something like this.
String value = this.getAttribute("key1");
System.out.println("value = " + this.getAttribute("key1"));
and it will test the same as this
String value = this.getAttribute("key1");
System.out.println("value = " + value);
Now did I really mean to do it the first way or should I have done it
the second way. Chances are you really want the second, but if you have
a list you have to explicitly setup the extra values.
The other thing you get from using a list is left over objects. The list
in the MockHttpServletRequest will check that all the object in the list
have actually been used.
So
stuff.setupGetAttribute("key1", "Value");
...
System.out.println("Value");
// should be System.out.println(stuff.getAttribute("key1"));
would be fine but with the list this would fail as you've reached the
end of the test without using the value you setup to be used.
It's probably a good idea to mention that this is a fair new development
in the Mocks so it's use might be a little in consistent.
Hope this helps
As for patches. Please do send them in. I've got a strong policy of only
implementing those thing I use so I expect people to send me in patches
of the bits they use and I don't.
diff -ub IveChanged.java
On Tue, 2002-07-23 at 23:39, Shellman, Joel wrote:
> I'm trying to use the mock servlet objects. The getAttribute(String)
> implementation of ServletRequest just returns something from a list instead
> of looking up in a HashMap or something like that. Why is this? How can a
> servlet that may set/get attributes any number of times function correctly
> with this implementation?
>
> Also, I've put in some quick code so I can use RequestDispatcher as well. I
> might be able to contribute to the project (I would like to), though
> accessing CVS is difficult because our corporate firewall won't let me
> through.
>
> Thanks,
>
> Joel Shellman
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Mockobjects-java-users mailing list
> Moc...@li...
> https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users
--
Jeff Martin
Memetic Engineer
http://www.custommonkey.org/
|