atom feed2 messages in org.codehaus.jmock.userMocking with beans part 2
FromSent OnAttachments
Mikael PettersonNov 21, 2007 12:27 am 
Jörg SchaibleNov 21, 2007 10:54 am 
Subject:Mocking with beans part 2
From:Mikael Petterson (mika@netwise.se)
Date:Nov 21, 2007 12:27:47 am
List:org.codehaus.jmock.user

Hi,

I really appreciate you taking the time to help me out :-)

This is what is bothering me:

I call this method in spCallHandler:

private AnnoData getAnno(,

String serviceProvider, Integer id, String lang) {

logger.debug("getAnno()");

AnnoData data = null;

try {

data = getAnnouncementServiceHome().create()

.getAnnouncementWithOffset(announcement.getName(),

serviceProvider, id, lang);

} catch (RemoteException e1) {

}

return data;

}

I don't really want to mock further (thanks for showing me how to handle Context. Interesting!) since then it does not become a unit test. It will span over entity beans too.

Problem (code above):

This method returns AnnoData that contains a collection of UiObjectReadOnly that are entity beans.

And when I use the AnnoData objbect later in my code it must contain UiObjectReadOnly (beans).

So the problem is to make getAnno return faked AnnoData with faked UiObjectReadOnly objects. Can I create them in my test code? If I

do:

public static class UiObjectReadOnly implements UiObjectReadOnlyHome{

//impl. Of getters and setters.

}

Is it possible? Or am I into deep water?