|
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...> |