• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Does Bear's FrontMan have a mock object for CommandContext?

 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to do some JUnit testing with my FrontMan beans. So I need a minimal CommandContext to subclass for testing.
It does not have to be a full blown HTTP servlet request and respnse object, but it would be nice to have an
AbstractCommandContextForTesting
to start with.

Anybody got one?

Thanks
pat
 
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CommandContext was designed as an interface exactly so that mock instances could be used for testing. EFH was the person who suggested this, so maybe he has one?

You reading this Ernest?
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading it now!

I did use that interface for mocking while developing two FrontMan-driven projects. Both times I used EasyMock, which creates the mocks for you -- you just hand it an interface, and tell it what usage pattern you expect to see. EasyMock is pretty darn... easy.
 
Pat Farrell
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hacked up some, it was easy. The CommandContext is trivial, but all of my code calls it get HttpRequest, HttpResponse, HttpSession, etc.
Its not hard, but there are a lot of parts.

Probably not realistic for Bear to provide them, as they have to be tweaked for the calls your class really uses.

After hacking with it, the beauty of Bear's design shows
 
Bear Bibeault
Marshal
Posts: 67275
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the praise, Pat. I can't grab it all for myself, though -- I got some great feedback from devos like EFH!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!