On Wed, 24 Sep 2008 17:51:24 +1200, "Miskell, Craig" <[EMAIL PROTECTED]> said: > Hi, > I'm writing a test where I need to test that a method *isn't* > called (testing scheduled outages). Is there an EasyMock way of > doing that? I've looked, but no methods jump out at me. > > Any suggestions?
Easy... create your mock object, don't expect() anything, set it to replay(), and then when your test is done, call verify() as you normally would (or if you are using EasyMockUtils, replayAll(), verifyAll(), etc..). If you set no expectations, EasyMock will expect nothing, and by default it will fail fast if something unexpected is called. > <Aside>: > I've tried creating my own custom implementation of the interface in > question (rather than having EasyMock create a proxy for me), with a > "fail" in the method I don't want called, but simply adding that causes > an odd EasyMock error at a seemingly unrelated line of code: > (1 matchers expected, 2 recorded) > which I can't figure out. I'm replacing m_collector in CollectdTest, and > it gives the above error on the call to > m_ipIfdao.findByserviceType("SNMP") in setupInterface, if that helps > anyone figure it out. I'd prefer to find another way though, as it looks > like I'm messing with things I don't understand. Ah, "1 matchers expected, 2 recorded". So, when you set up an easymock expectation, you either need to use *all* specific arguments or *all* matchers and you can't mix-n-match the two (it knows which matcher is for which argument to the method call based on the order in which they are called, and if you don't use matchers for every single argument, it doesn't know what the ordering is). In the "Flexible Expectations with Argument Matchers" section below it says "If you would like to use matchers in a call, you have to specify matchers for all arguments of the method call." http://www.easymock.org/EasyMock2_2_Documentation.html Good luck! - djg ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Please read the OpenNMS Mailing List FAQ: http://www.opennms.org/index.php/Mailing_List_FAQ opennms-devel mailing list To *unsubscribe* or change your subscription options, see the bottom of this page: https://lists.sourceforge.net/lists/listinfo/opennms-devel