The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

tgutgu (2) [Avatar] Offline
#1
Hi,

I have difficulties setting up the PlaceOrderServiceTests Testcase.

Following your approach using jMock to use Mock-Objects for the TestCase, I have a problem that using the PendingOrder class to build a Mock-Object does not compile, because jMock expects an interface and not a class.

PendingOrder is of course a entity class of your domain model, and I could not find that you mentioned an interface of that class.

In your solution that would mean that all domain classes, for which mocks are needed, have to represented by an interface. Is this really usefull?

In the downloaded source code, I discovered that pending order implements an interface "PendingOrderDetail", but this is not used in the TestCase.

So is the code wrong, or do I miss something here?

Kind regards

Thomas
tgutgu (2) [Avatar] Offline
#2
Re: PlaceOrderServiceTests and Mock-Objects
OK, I got it.

Obviously, additionally you need to have the cglib-Versions of jMock in your classpath, the cglib2 library and the asm1.5.3 library in your classpath.

Since I first assumed that I made a mistake when trying to follow the examples in the book, it took me quite a bit to realise that I need additional libraries. It would be very nice, if Manning could be more careful, about informaing the reader, what libraries and other prerequisites the reader needs for folloing the examples. An appendix of a list of the need libraries would be very useful.

Hopefully that was the last code sample, that did not work.

Kind regards

Thomas
ceracm (113) [Avatar] Offline
#3
Re: PlaceOrderServiceTests and Mock-Objects
Thomas,

Sorry for any confusion.

The best way to ensure that code compiles is to use the Maven2 -based build system used by the downloadable source code. It will make sure that you have the correct class path.
It will also generate projects for IDEs such as Eclipse and IDEA.

Chris