This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Testing and the fly likes Newbie question on JMock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Newbie question on JMock" Watch "Newbie question on JMock" New topic

Newbie question on JMock

Neha Gap

Joined: May 30, 2007
Posts: 29

I have just come across JMock and haven't quite got the hang of it yet.
I have a class called JabberAccountManager. It has a few methods that perform account management operations. Every method internally creates an object of type XMPPConnection (which is a part of an XMPP library)

Now, I want to mock the Jabber server so I need to create a mock XMPPConnection object, but my problem is that the class I need to test and the class I need to mock are tightly coupled. I cannot de-couple these since there are a lot of issues involved.

Could someone please explain to me how to go about using JMock in a case like this?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32819

Can you introduce an interface to de-couple them?

if not, can you provide an example of how they are tightly coupled?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Newbie question on JMock
It's not a secret anymore!