You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(30) |
Sep
(19) |
Oct
(3) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(11) |
Feb
(13) |
Mar
(10) |
Apr
(11) |
May
(7) |
Jun
(8) |
Jul
(5) |
Aug
(16) |
Sep
(14) |
Oct
(3) |
Nov
(9) |
Dec
|
2003 |
Jan
(5) |
Feb
(6) |
Mar
(9) |
Apr
(31) |
May
(25) |
Jun
(22) |
Jul
(28) |
Aug
(27) |
Sep
(19) |
Oct
(4) |
Nov
(7) |
Dec
(26) |
2004 |
Jan
(8) |
Feb
(13) |
Mar
(5) |
Apr
(8) |
May
(8) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(4) |
2005 |
Jan
|
Feb
(2) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(3) |
May
|
Jun
|
Jul
(6) |
Aug
|
Sep
(10) |
Oct
(6) |
Nov
|
Dec
(36) |
2009 |
Jan
(3) |
Feb
(14) |
Mar
(13) |
Apr
(18) |
May
(35) |
Jun
(18) |
Jul
(27) |
Aug
(6) |
Sep
(2) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(6) |
Feb
(1) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
From: <st...@m3...> - 2003-05-20 17:13:47
|
> I've been perusing the mailing list archives (I am not subscribed). I see > that there is supposed to be 0.09 release but on sourceforge, only 0.08 is > there. Is there a typo in 0.09? 0.09 is the pending release that we will do next. 0.08 is a recent lockdown= just to help us with a merge. Incorrect terminology. =20 > I see on the MO website that there is a package called EasyMocks which is > similar to DynaMocks. Do the two complement each other? Or is DynaMocks t= he > "official" version supported by the MO team while EasyMocks is a separate > project? They are two seperate (but equal?) projects. We talk to each other, but hav= e different paths. Once the new code is stable, I would hope that there is = more scope for merging. > The release of 0.08 contians only the compiled classes. I don't have acce= ss > to CVS. If I want the source code and the docs, how can I get them? That's a mistake. We should release an archive of the code. Let's see if we= can get around to it. Steve |
From: <lau...@mi...> - 2003-05-20 15:47:26
|
Hi, I've been perusing the mailing list archives (I am not subscribed). I see that there is supposed to be 0.09 release but on sourceforge, only 0.08 is there. Is there a typo in 0.09? I see on the MO website that there is a package called EasyMocks which is similar to DynaMocks. Do the two complement each other? Or is DynaMocks the "official" version supported by the MO team while EasyMocks is a separate project? The release of 0.08 contians only the compiled classes. I don't have access to CVS. If I want the source code and the docs, how can I get them? Thanks, L -- Laurent Duperval <lau...@mi...> FINSTER'S LAW A closed mouth gathers no feet. |
From: Vincent M. <vm...@pi...> - 2003-05-17 15:00:37
|
Changelog can be found on http://wiki.truemesh.com/mockobjects/ReleaseChanges Thanks -Vincent |
From: Steve F. <st...@m3...> - 2003-05-08 16:09:52
|
There are various approaches to use: - pass everything in each time. We sometimes do that to start with until we figure out where to hold on to some of the objects. - pass B,C & D through to A on A's construction, if their lifecycles match appropriately. - perhaps B, C & D should be packaged up in some containing object which, in turn, can be mocked up for testing against A. Using mocks rigorously does change your coding style. I'd suggest experimenting for a while until you get used to the idea. S. Eddie Post wrote: > Hellu, > > I am just starting with mock objects and was used to use stub object. > > I have a component A that contains three links to other components, > namely B, C and D. > To test this with mock, I have to submit the three stub objects B, C and > D to A. > Is that the way to do it ? Did I understood it correctly ? > That is, am not so font about passing all those stub objects/handlers, > as it makes the interface definition somewhat complex, not not ?? > > I could think about breaking up A in smaller parts, but that not logical > in my case. > > Please some feedback how to deal with this ? |
From: Eddie P. <pos...@ho...> - 2003-05-08 15:43:53
|
Hellu, I am just starting with mock objects and was used to use stub object. I have a component A that contains three links to other components, namely B, C and D. To test this with mock, I have to submit the three stub objects B, C and D to A. Is that the way to do it ? Did I understood it correctly ? That is, am not so font about passing all those stub objects/handlers, as it makes the interface definition somewhat complex, not not ?? I could think about breaking up A in smaller parts, but that not logical in my case. Please some feedback how to deal with this ? Ed _________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail |
From: Steve F. <st...@m3...> - 2003-05-08 09:37:30
|
All of these classes are works in progress, the whole API is just too big to finish at once. In the short ternm, I'd suggest just applying the fixes you need. We're working on a better solution. S. David Carlson wrote: > I am testing a custom jsp tag which uses the pageContext.getAttribute(...) > methods to find its data. Looking at the source of MockPageContext at > Sourceforge, very few methods are implemented. Even verify() does nothing! > Is this by design? > > It seems as though MockPageContext should have hashes for the different > scopes(page,req,session,app). Then the rest of the methods in PageContext > could be implemented, and my tests would run. > > Is there another way I should approach testing this tag? > Should these methods be implemented? > Should I just extend this class for now? > > Thanks! > David Carlson > > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users |
From: David C. <dav...@sh...> - 2003-05-07 15:59:23
|
I am testing a custom jsp tag which uses the pageContext.getAttribute(...) methods to find its data. Looking at the source of MockPageContext at Sourceforge, very few methods are implemented. Even verify() does nothing! Is this by design? It seems as though MockPageContext should have hashes for the different scopes(page,req,session,app). Then the rest of the methods in PageContext could be implemented, and my tests would run. Is there another way I should approach testing this tag? Should these methods be implemented? Should I just extend this class for now? Thanks! David Carlson |
From: <st...@m3...> - 2003-05-07 12:42:38
|
There are a couple of alternatives. One is to wrap the Socket class in a th= in veneer that implements just the functionality you need and which can the= n be mocked. That gives you a clear description of how /you/ use sockets, r= ather than the generic underlying library, and gives you somewhere to hang = all those helper methods. You then either have to take the interaction with= Socket on faith, test it with functional tests, or something like that. If you really want to get in there, you could look at AspectJ to allow you = to intercept the calls although, in practice, it's just an automated way to= implement the same idea. S. > Ah, think I see your point. The problem is Socket is a final class so > the only way to mock it is to wrap it in an object which is mockable. > This is what the alt classes are for these are interfaces which mirror > the Java API + wrappers for the Java API versions and mocks of the > wrappers. This allows you to provide a mock enviroment for testing > against things like Socket. >=20 > The draw back is that you to uses this method you have to write your > code to use the interfaces not the actually API classes. It does get a > bit ugly when you have to interface with a 3rd party class which > requires a java.net.Socket as you have to get the real socket from the > wrapper and pass it into these classes. You can make this neater by > wrapping the 3rd party classes up in as well though. |
From: Jeff M. <je...@cu...> - 2003-05-07 12:12:59
|
Ah, think I see your point. The problem is Socket is a final class so the only way to mock it is to wrap it in an object which is mockable. This is what the alt classes are for these are interfaces which mirror the Java API + wrappers for the Java API versions and mocks of the wrappers. This allows you to provide a mock enviroment for testing against things like Socket. The draw back is that you to uses this method you have to write your code to use the interfaces not the actually API classes. It does get a bit ugly when you have to interface with a 3rd party class which requires a java.net.Socket as you have to get the real socket from the wrapper and pass it into these classes. You can make this neater by wrapping the 3rd party classes up in as well though. On Wed, 2003-05-07 at 12:43, Jim Birchfield wrote: > THanks Jeff, but this still doesn't solve my problem. I am by no doubt > probably being thick-headed, but Socket is still of type > alt.java.net.Socket. My Constructor calls for a java.net.Socket and an > soTimeout int. > > Am I missing something? > > THanks! > > Birch > > On 7 May 2003, Jeff Martin wrote: > > > Try this > > http://www.mockobjects.com/javadoc/1.3/alt/java/net/SocketFactory.html > > > > On Wed, 2003-05-07 at 12:08, Jim Birchfield wrote: > > > Can some one provide a breif description of how to use the MockSocket > > > class? I have a server application that spawns off client threads as > > > clients connect. I want to do some functional testing to make sure I am > > > reading/writing over the socket appropriately. However, the MockSocket > > > implements alt.java.net.Socket, so simply creating one and attempting to > > > pass it to the coinstructor of my object does not work. > > > > > > Any ideas on how to do this? > > > > > > Thanks! > > > > > > Birch > > > > > > > > > > > > ------------------------------------------------------- > > > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > > > The only event dedicated to issues related to Linux enterprise solutions > > > www.enterpriselinuxforum.com > > > > > > _______________________________________________ > > > Mockobjects-java-users mailing list > > > Moc...@li... > > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > > -- > > Jeff Martin <je...@cu...> > > > > > > > > ------------------------------------------------------- > > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > > The only event dedicated to issues related to Linux enterprise solutions > > www.enterpriselinuxforum.com > > > > _______________________________________________ > > Mockobjects-java-users mailing list > > Moc...@li... > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > > -- Jeff Martin <je...@cu...> |
From: Jim B. <ji...@fl...> - 2003-05-07 11:43:26
|
THanks Jeff, but this still doesn't solve my problem. I am by no doubt probably being thick-headed, but Socket is still of type alt.java.net.Socket. My Constructor calls for a java.net.Socket and an soTimeout int. Am I missing something? THanks! Birch On 7 May 2003, Jeff Martin wrote: > Try this > http://www.mockobjects.com/javadoc/1.3/alt/java/net/SocketFactory.html > > On Wed, 2003-05-07 at 12:08, Jim Birchfield wrote: > > Can some one provide a breif description of how to use the MockSocket > > class? I have a server application that spawns off client threads as > > clients connect. I want to do some functional testing to make sure I am > > reading/writing over the socket appropriately. However, the MockSocket > > implements alt.java.net.Socket, so simply creating one and attempting to > > pass it to the coinstructor of my object does not work. > > > > Any ideas on how to do this? > > > > Thanks! > > > > Birch > > > > > > > > ------------------------------------------------------- > > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > > The only event dedicated to issues related to Linux enterprise solutions > > www.enterpriselinuxforum.com > > > > _______________________________________________ > > Mockobjects-java-users mailing list > > Moc...@li... > > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > -- > Jeff Martin <je...@cu...> > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users > |
From: Jeff M. <je...@cu...> - 2003-05-07 11:28:30
|
Try this http://www.mockobjects.com/javadoc/1.3/alt/java/net/SocketFactory.html On Wed, 2003-05-07 at 12:08, Jim Birchfield wrote: > Can some one provide a breif description of how to use the MockSocket > class? I have a server application that spawns off client threads as > clients connect. I want to do some functional testing to make sure I am > reading/writing over the socket appropriately. However, the MockSocket > implements alt.java.net.Socket, so simply creating one and attempting to > pass it to the coinstructor of my object does not work. > > Any ideas on how to do this? > > Thanks! > > Birch > > > > ------------------------------------------------------- > Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara > The only event dedicated to issues related to Linux enterprise solutions > www.enterpriselinuxforum.com > > _______________________________________________ > Mockobjects-java-users mailing list > Moc...@li... > https://lists.sourceforge.net/lists/listinfo/mockobjects-java-users -- Jeff Martin <je...@cu...> |
From: Jim B. <ji...@fl...> - 2003-05-07 11:08:42
|
Can some one provide a breif description of how to use the MockSocket class? I have a server application that spawns off client threads as clients connect. I want to do some functional testing to make sure I am reading/writing over the socket appropriately. However, the MockSocket implements alt.java.net.Socket, so simply creating one and attempting to pass it to the coinstructor of my object does not work. Any ideas on how to do this? Thanks! Birch |
From: Steve F. <st...@m3...> - 2003-05-05 20:15:17
|
You mean the suggested code rewrite? Point taken. I think the new dynamic mocks (out as soon as we can get it together) will simplify this whole situation. S. Jeff Duska wrote: > Steve: > > I have done this in my current program, but it very confusing to new > Mock Objects users. They are going to see valid code in their servlet > and wonder what's wrong. Personally, I doubt that many new users will > take the initiative to figure out the solution or issue. Instead, they > will give up on Mock Objects telling users that it is broken. > > Regards, > > Jeff > > |
From: Jeff D. <Jef...@no...> - 2003-05-05 20:03:55
|
Steve: I have done this in my current program, but it very confusing to new Mock Objects users. They are going to see valid code in their servlet and wonder what's wrong. Personally, I doubt that many new users will take the initiative to figure out the solution or issue. Instead, they will give up on Mock Objects telling users that it is broken. Regards, Jeff |
From: Steve F. <st...@m3...> - 2003-05-04 11:22:28
|
I realize that we're not quite solving your problems. We're working on a new version of the dynamic mock framework that should help with some of this. In the meantime, perhaps there's still something to be learned from this example. Would it be better to only do one lookup, and structured as a helper method? private String myAttribute() { Object objectAttribute = _session.getAttribute("myAttribute"); if (null == objectAttribute) { throw new missingException(); } return (String)objectAttribute; } S. Jeff Duska wrote: > I'm testing out my project I found that I getting an exception on the > following code that I think perfectly fine. The implementation of > MockHttpSession only allows you to access an attribute once in the > session. If you have the following code, an exception will thrown. > > if (_session.getAttribute("myAttribute") != null) { > myAttribute = (String) _session.getAttribute("myAttribute"); > } else { > throw new missingImportantDataExecption(); > } |
From: Jeff D. <Jef...@no...> - 2003-05-02 21:44:45
|
I'm testing out my project I found that I getting an exception on the following code that I think perfectly fine. The implementation of MockHttpSession only allows you to access an attribute once in the session. If you have the following code, an exception will thrown. if (_session.getAttribute("myAttribute") != null) { myAttribute = (String) _session.getAttribute("myAttribute"); } else { throw new missingImportantDataExecption(); } In my test, I have setupGetAttribute(myAttribute, "really important info"); The problem just by reading the _session.getAttribute("myAttribute") in the test condition will eliminate the value and cause an exception at myAttribute = (String) _ session.getAttribute("myAttribute"); I expect that what your intention is that I should have setupGetAttribute(myAttribute, "really important info"); setupGetAttribute(myAttribute, "really important info"); to show that I plan to access the attribute twice. I doubt that many users will anticipate this. It is just not how Servlet API works, so I think most developer will be surprised by this.. I look forward to your comments. Regards, Jeff Duska |
From: Jeff D. <Jef...@no...> - 2003-05-02 19:32:41
|
Jeff Martin wrote: > On Thu, 2003-05-01 at 22:04, Jeff Duska wrote: > > I don't see how MockHttpServlet.getAttribute can work correctly when > > setAttribute and the getAttribute looking at different collections. This > > will work fine, if you only plan to set an Attribute or get an > > Attribute. In my case, I'm chaining two objects implementing a command > > pattern together. The first command sets some attributes with the > > standard setAttribute() , but when the next command tries to use > > getAttribute(). This will call myAttributeValues.getNextReturnObject(), > > but setAttribute appeared to use myAttributes.addActual(new > > MapEntry(aKey, aValue)). I don't see how it will find my attribute ever > > in the second command. It would seem to me that needs to update both of > > these collections, so the getAttributes would work correctly. > The problem is how do I know which collection I should be using when. > When does getAttribute return an object from setAttribute and when does > it return one from setupGetAttribute? > I think, I'm still fishing in the code, that I would expect that getAttribute to see setting in both setupGetAttribute and setAttribute. What I would do different is have setAttribute add to both the myAttributes ExepctationSet and myAttributes ReturnObjectBag. This way the expections would still fire on wrong attributes, but the getAttribute would still work for the chained servlets tests. The only reason this would work, if you need to or wanted to track what the setupGetAttributes were. In this case, you'd need a new collection for only setup Attributes. I'm sure you thinking to yourself chained servlet? That not following TDD correctly. I should be only test the one servlet. This is true, but right now my design it a little brittle in that regard. I cannot change in this phase. I will most likely move this to Struts in the next phase to resolve issues like this. > The way I get around this is to make sure setupGetAttribute has all the > objects that I expect setAttribute to set. I should know this as I will > be setting up setExpectedAttribute. Basicly, I end up with something like this setupGetAttribute(IUser,USER_KEY, user); // need for getAttribute to work - adds to myAttributeValues setAttribute(IUser,USER_KEY, user); // need to pass ExpectionTests - adds to myActualItems The only reason I don't like this is that somewhat confusing to a new user. I expect that new developer will miss this step. The other option is to remove the execptation, but this would imply that I don't expect the user to be in the session. Since the point of unit test is to provide documenation, this doesn't seem like a good idea. > To be honest I really try and avoid using attributes as they're really > open to abuse. I use a single CustomSession object which contains all > the in scope objects I'm using. So get/setAttribute is something I > descourage from my projects. > This sounds quite intresting. Do you have an example that might be able to share? > > > > > Next, I not sure I that getAttribute should use getNetReturnObject, > > because it appears to requires that the attribute be in the collection. > > In my usage of the HttpSession, I have a couple places where I test for > > the existence of the attribute like this > > (_session.getAttributte("mykey")==null). This will not work, because it > > will fire off an exception due to the attribute not existing in the > > myAttributte ReturnObjectBag. > > session.setupGetAttribute(null); > There was CheckImmediateValue. I'm curious how do you use that in the process? I'm also curious if is better to use the specific libraries like these or the dynamic libraries using Mock proxy stuff. Intresting. I would have never thought to do that. Thanks for all the help Regards, Jeff Duska |
From: Jeff M. <je...@mk...> - 2003-05-02 11:11:53
|
On Thu, 2003-05-01 at 22:04, Jeff Duska wrote: > I don't see how MockHttpServlet.getAttribute can work correctly when > setAttribute and the getAttribute looking at different collections. This > will work fine, if you only plan to set an Attribute or get an > Attribute. In my case, I'm chaining two objects implementing a command > pattern together. The first command sets some attributes with the > standard setAttribute() , but when the next command tries to use > getAttribute(). This will call myAttributeValues.getNextReturnObject(), > but setAttribute appeared to use myAttributes.addActual(new > MapEntry(aKey, aValue)). I don't see how it will find my attribute ever > in the second command. It would seem to me that needs to update both of > these collections, so the getAttributes would work correctly. The problem is how do I know which collection I should be using when. When does getAttribute return an object from setAttribute and when does it return one from setupGetAttribute? The way I get around this is to make sure setupGetAttribute has all the objects that I expect setAttribute to set. I should know this as I will be setting up setExpectedAttribute. To be honest I really try and avoid using attributes as they're really open to abuse. I use a single CustomSession object which contains all the in scope objects I'm using. So get/setAttribute is something I descourage from my projects. > > Next, I not sure I that getAttribute should use getNetReturnObject, > because it appears to requires that the attribute be in the collection. > In my usage of the HttpSession, I have a couple places where I test for > the existence of the attribute like this > (_session.getAttributte("mykey")==null). This will not work, because it > will fire off an exception due to the attribute not existing in the > myAttributte ReturnObjectBag. session.setupGetAttribute(null); ;-) This way your being explicit about all the inputs in to your component. Not just the ones that exsist but also which ones don't exist. > > I think some of this can be turned off by turning setFailonVerify, but I > could not see how MockHttpSession object could do this. > > Regards, > > Jeff Duska > > > > > ------------------------------------------------------- > 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 <je...@mk...> |
From: Jeff M. <je...@mk...> - 2003-05-02 08:47:11
|
On Thu, 2003-05-01 at 20:59, Jeff Duska wrote: > Jeff, thanks for the changes. > > Now, I have a whole bunch of questions, and comments. I'm breaking them into > several emails. > > Comments on the Build process. > Here is a summary of what I've tried to do. I checked out the current code out > of source control. It took a while to figure while why the said build said it > work, but I had no jar file. The ant build is successful even when the j2ee.jar > file is missing. I think it should fail, because otherwise you end up searching > all over the place to figure out what is wrong. May be we should make the lack of j2ee.jar (and the fact that the mocks j2ee mocks won't be built) more obvious but the build should not fail as the j2ee mocks are optional. > I also would have preferred to > see the j2ee.jar included in CVS, so when I check out the project I have > everything that I need to build the current head. Is there a legal reason you > don't include the various version j2ee.jar in the lib folder in CVS? Not totally sure what the j2ee license is, but as far as I know it's not like other sun jars it's not freely distributable. Also since there are different version of the j2ee api there is no single version of the jar to include. > I see > little point having the Python script to build a Java project. I'd much rather > this function be included into the Ant build.xml. Or I'd even accept the use > something like Maven, if it would make easy to support. The pythong script is just a convinentent wrapped around the ant build script which allows me to test the build against different combinations of JDK and J2EE. If you know of a way to do this in ant/maven/gump/whatever and are willing to replace the python script I'd be happy to include it. Normal build process is just to type "ant" ;) > > Regards, > > Jeff Duska > > > > ------------------------------------------------------- > 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 <je...@mk...> |
From: Jeff D. <Jef...@no...> - 2003-05-01 20:51:18
|
I don't see how MockHttpServlet.getAttribute can work correctly when setAttribute and the getAttribute looking at different collections. This will work fine, if you only plan to set an Attribute or get an Attribute. In my case, I'm chaining two objects implementing a command pattern together. The first command sets some attributes with the standard setAttribute() , but when the next command tries to use getAttribute(). This will call myAttributeValues.getNextReturnObject(), but setAttribute appeared to use myAttributes.addActual(new MapEntry(aKey, aValue)). I don't see how it will find my attribute ever in the second command. It would seem to me that needs to update both of these collections, so the getAttributes would work correctly. Next, I not sure I that getAttribute should use getNetReturnObject, because it appears to requires that the attribute be in the collection. In my usage of the HttpSession, I have a couple places where I test for the existence of the attribute like this (_session.getAttributte("mykey")==null). This will not work, because it will fire off an exception due to the attribute not existing in the myAttributte ReturnObjectBag. I think some of this can be turned off by turning setFailonVerify, but I could not see how MockHttpSession object could do this. Regards, Jeff Duska |
From: Jeff D. <Jef...@no...> - 2003-05-01 19:46:29
|
Jeff, thanks for the changes. Now, I have a whole bunch of questions, and comments. I'm breaking them into several emails. Comments on the Build process. Here is a summary of what I've tried to do. I checked out the current code out of source control. It took a while to figure while why the said build said it work, but I had no jar file. The ant build is successful even when the j2ee.jar file is missing. I think it should fail, because otherwise you end up searching all over the place to figure out what is wrong. I also would have preferred to see the j2ee.jar included in CVS, so when I check out the project I have everything that I need to build the current head. Is there a legal reason you don't include the various version j2ee.jar in the lib folder in CVS? I see little point having the Python script to build a Java project. I'd much rather this function be included into the Ant build.xml. Or I'd even accept the use something like Maven, if it would make easy to support. Regards, Jeff Duska |
From: Jeff M. <je...@mk...> - 2003-05-01 09:28:16
|
You've caught me on a good day. I've just added a setExpectedCreateSession method to the request for ya. On Thu, 2003-05-01 at 01:08, Jeff Duska wrote: > How do I write a unit test for code where I create the Session in the code > I'm testing with _request.getSession(true) ? > > I'm getting a notImplemented Exception. I figure that this is a pretty > basic thing that there is some type of workaround. > > Thanks, > > Jeff > > Jeff Duska wrote: > > > I'm using MockHttpSession in a unit test I bit confused on the proper > > usage. > > > > In here is my setUp method > > > > public void setUp() throws Exception { > > super.setUp(); > > _request = new MockHttpServletRequest(); > > _response = new MockHttpServletResponse(); > > _session = new MockHttpSession(); > > _request.setSession(_session); > > _context = new VelocityContext(); > > } > > > > Here is my unitTest > > > > public void testFreeUserStandByPage() throws ExecuteCommandException { > > > > IUser user = new MockFreeUser(); > > assertNotNull("We must have a user for our test to work", user); > > > > _request.setupAddParameter("VARVALUE", "1880-10"); > > > > // Add User to the session > > _session.setAttribute("user", user); > > > > // our expected session attributes to be used by validate > > _session.setExpectedAttribute("VARVALUE", "1880-10"); > > _session.setExpectedAttribute("noStandby", Boolean.TRUE); > > _session.setExpectedAttribute("user", user); > > > > // run the command > > Command command = new CreateWssrdPdfDocumentCommand(_request, > > _response); > > String templateName = command.exec(_context); > > > > // check the results > > IUser testUser = (IUser) _context.get(IUser.USER_KEY); > > assertEquals(user, testUser); > > _session.verify(); > > assertEquals("Make sure we are getting the standby page > > template", > > templateName, "standby.vm"); > > } > > > > What is weird is that the order of setAttibute and setExpectAttribute > > effect the success of my test. In the previous code the test fails, > > because user object is not found in the session during the verify() > > process. My test succeeds when I move the > > _session.setAttribute("user,user) statement after the > > setExecptedAttribute methods. > > > > This would be fine, but my next test fails both ways. The problem is > > that I have to send the session attribute noStandby to Boolean.TRUE. > > When command is completed I had expect that the attribute would not be > > in the session, but this failed in the test. jUnit was always seeing the > > attribute. Thus, I refactored my code to change it to the attribute > > noStandby to be Boolean.TRUE. The problem is that I get an exception in > > my test code on my _session.setAttribute("noStandby", Boolean.FALSE) > > saying that is unexpected. I confused. > > > > Any help or suggestions would be appreciated. > > > > ------------------------------------------------------- > > 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 > > > > ------------------------------------------------------- > 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 <je...@mk...> |
From: Jeff D. <Jef...@no...> - 2003-04-30 23:55:13
|
How do I write a unit test for code where I create the Session in the code I'm testing with _request.getSession(true) ? I'm getting a notImplemented Exception. I figure that this is a pretty basic thing that there is some type of workaround. Thanks, Jeff Jeff Duska wrote: > I'm using MockHttpSession in a unit test I bit confused on the proper > usage. > > In here is my setUp method > > public void setUp() throws Exception { > super.setUp(); > _request = new MockHttpServletRequest(); > _response = new MockHttpServletResponse(); > _session = new MockHttpSession(); > _request.setSession(_session); > _context = new VelocityContext(); > } > > Here is my unitTest > > public void testFreeUserStandByPage() throws ExecuteCommandException { > > IUser user = new MockFreeUser(); > assertNotNull("We must have a user for our test to work", user); > > _request.setupAddParameter("VARVALUE", "1880-10"); > > // Add User to the session > _session.setAttribute("user", user); > > // our expected session attributes to be used by validate > _session.setExpectedAttribute("VARVALUE", "1880-10"); > _session.setExpectedAttribute("noStandby", Boolean.TRUE); > _session.setExpectedAttribute("user", user); > > // run the command > Command command = new CreateWssrdPdfDocumentCommand(_request, > _response); > String templateName = command.exec(_context); > > // check the results > IUser testUser = (IUser) _context.get(IUser.USER_KEY); > assertEquals(user, testUser); > _session.verify(); > assertEquals("Make sure we are getting the standby page > template", > templateName, "standby.vm"); > } > > What is weird is that the order of setAttibute and setExpectAttribute > effect the success of my test. In the previous code the test fails, > because user object is not found in the session during the verify() > process. My test succeeds when I move the > _session.setAttribute("user,user) statement after the > setExecptedAttribute methods. > > This would be fine, but my next test fails both ways. The problem is > that I have to send the session attribute noStandby to Boolean.TRUE. > When command is completed I had expect that the attribute would not be > in the session, but this failed in the test. jUnit was always seeing the > attribute. Thus, I refactored my code to change it to the attribute > noStandby to be Boolean.TRUE. The problem is that I get an exception in > my test code on my _session.setAttribute("noStandby", Boolean.FALSE) > saying that is unexpected. I confused. > > Any help or suggestions would be appreciated. > > ------------------------------------------------------- > 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 |
From: Jeff D. <Jef...@no...> - 2003-04-30 22:47:10
|
I'm using MockHttpSession in a unit test I bit confused on the proper usage. In here is my setUp method public void setUp() throws Exception { super.setUp(); _request = new MockHttpServletRequest(); _response = new MockHttpServletResponse(); _session = new MockHttpSession(); _request.setSession(_session); _context = new VelocityContext(); } Here is my unitTest public void testFreeUserStandByPage() throws ExecuteCommandException { IUser user = new MockFreeUser(); assertNotNull("We must have a user for our test to work", user); _request.setupAddParameter("VARVALUE", "1880-10"); // Add User to the session _session.setAttribute("user", user); // our expected session attributes to be used by validate _session.setExpectedAttribute("VARVALUE", "1880-10"); _session.setExpectedAttribute("noStandby", Boolean.TRUE); _session.setExpectedAttribute("user", user); // run the command Command command = new CreateWssrdPdfDocumentCommand(_request, _response); String templateName = command.exec(_context); // check the results IUser testUser = (IUser) _context.get(IUser.USER_KEY); assertEquals(user, testUser); _session.verify(); assertEquals("Make sure we are getting the standby page template", templateName, "standby.vm"); } What is weird is that the order of setAttibute and setExpectAttribute effect the success of my test. In the previous code the test fails, because user object is not found in the session during the verify() process. My test succeeds when I move the _session.setAttribute("user,user) statement after the setExecptedAttribute methods. This would be fine, but my next test fails both ways. The problem is that I have to send the session attribute noStandby to Boolean.TRUE. When command is completed I had expect that the attribute would not be in the session, but this failed in the test. jUnit was always seeing the attribute. Thus, I refactored my code to change it to the attribute noStandby to be Boolean.TRUE. The problem is that I get an exception in my test code on my _session.setAttribute("noStandby", Boolean.FALSE) saying that is unexpected. I confused. Any help or suggestions would be appreciated. |
From: Jeff M. <je...@mk...> - 2003-04-30 15:16:05
|
Probably need to write a class a little like this. class MyMailer{ MimeMessageFactory messageFactory; Session session; MyMailer(MimeMessageFactory messageFactory, Session session, Transport transport){ this.messageFactory = messageFactory; this.session = session; this.transport = transport; } send(MyStuff stuff){ MimeMessage message = messageFactory.createMimeMessage(session); // set things on message from stuff. transport.send(message); } } You can then test it by passing mock version of session, transport and messagefactory in. On Wed, 2003-04-30 at 15:23, James Howe wrote: > Ok, I found those definitions but I guess I'm a little fuzzy on how to best > make use of them in writing my code and tests. Are there any examples of > how to make use of these classes? I'm assuming this approach also falls > into a pattern for mocking up code which needs to use functionality > normally provided by static methods. I'd be interested in seeing some > examples of this pattern in action as well. > > Thanks. > > On 30 Apr 2003 12:54:31 +0100, Jeff Martin <je...@mk...> wrote: > > > The mocks for Transport/Message etc are mocks of the alt.javax > > interfaces. Which have both mock and real implementations. The real > > implementations being wrappers around the javax.mail.* classes. > > > > http://www.mockobjects.com/javadoc/1.3/alt/javax/mail/package- > > summary.html > > > > On Tue, 2003-04-29 at 19:40, James Howe wrote: > >> I'm writing a small utility class which will be used to send e-mail. I > >> would like to write the code test-first as much as possible. However, I > >> notice that that Java Mail API makes heavy use of static methods to > >> accomplish many of its tasks. I see that there are Mock implementations > >> of things like Transport and Message in the Mock Objects library, but > >> I'm not sure how to make use of them. Are there any simple examples of > >> using the MockObjects library to test things that use things like > >> javax.mail.Transport (and related classes?) > >> > >> Thanks. -- Jeff Martin <je...@mk...> |