|
From: Steve F. <st...@m3...> - 2003-07-17 07:47:41
|
This implementation /is/ a little hazy. The idea is that you should preload your attributes in the order in which they are requested, and then they'll just be returned as the code runs. It's not actually doing a lookup. Checking which attributes are asked for is actually a separate concept and handled by a different expectation. There are some arguments for doing this but it does look a little clumsy. If you don't like this, I suggest you replace this part of the mock request with an ExpectationMap which might be closer to the behaviour you want. S. Bill Lynch wrote: > All, > > I haven't been able to figure out how to set attributes in a > MockHttpServletRequest. I searched the mailing list archives for clues, > but didn't find any (and there's no javadocs for that class!). > > The method that looks like it might work only takes one param: > > request.setupGetAttribute(Object) > > I'd expect that to be > > request.setupGetAttribute(String, Object) > > I've also tried passing in a vector of name/value pairs to that method, > but when I call getAttribute(String) on that request object I get this > error: > > There was 1 failure: > 1) > testGetAttribute(com.foo.util.MyTest)junit.framework.AssertionFailedError: > attributes has run out of objects. > at > com.mockobjects.ReturnObjectList.nextReturnObject(ReturnObjectList.java:61) > at > com.mockobjects.servlet.MockHttpServletRequest.getAttribute(MockHttpServletRequest.java:58) |