The Artima Developer Community
Sponsored Link

Java Buzz Forum
Support for Mocking Classes as well as Interfaces

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Support for Mocking Classes as well as Interfaces Posted: Jan 7, 2004 7:59 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Support for Mocking Classes as well as Interfaces
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

MockObjects have a great dyanamic proxy based mock object implementation available, but it is limited to mocking interfaces up. A coworker needed (well, wanted) to dynamically mock up a class instead of an interface so I tossed together support in intercepts for mocking arbitrary objects. If you want to mock a class it requires an instance of that class, as Java doesn't allow you to instantiate subclasses without being able to instantiate the super class, but it guarantees that no methods will be invoked on the object it is given.

Also fixed a pretty major bug where interceptors could be invoked out of order if objects were wrapped, and interceptors added, in a specific way. I fixed it via changing a map to a list of tuples. Sometimes Java's static typing instead of dynamic typing really bugs me.

Posted new snapshots as this involved a fix to the first bug found!

Read: Support for Mocking Classes as well as Interfaces

Topic: Raible Blogs Struts 2.0 Previous Topic   Next Topic Topic: Links: Open Source Research, Dell Systems Management, Google Stickyness

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use