First JMock test...how can I improve it?
I started using JMock today, and it seems very promising. However, the seems a *little* tdocumentationhin, and I was hoping that someone might be able to help me improve my first unit test. It works correctly and gives me the results I am expecting, but I have to admit, it's very smelly. If anyone can offer improvements on the following test case, I would greatly appreciate it!
Thanks!
public class OMSInboundMsgAdaptorImplITC extends MockObjectTestCase {
Mockery context;
Gateway gateway;
OMSInboundMsgAdaptorImpl adaptor;
<at> Override
protected void setUp() throws Exception {
context = new Mockery();
gateway = context.mock(Gateway.class);
adaptor = new OMSInboundMsgAdaptorImpl(gateway, null);
}
public void testOnNewOrderSingle() throws Exception {
SingleOrderMessage singleOrderMessage = new SingleOrderMessage();
MessageWrapperFactory factory = MessageWrapperFactory.instance(singleOrderMessage);
final MessageWrapper wrapper = factory.wrap(singleOrderMessage);
wrapper.setSide(Constants.SIDE_Sell.charAt(0));
context.checking(new Expectations() {
{ one(gateway).getNextExecutionIDString((String)with(a(String.class)));};
{ one(gateway).sendToOMS((MessageWrapper)
with(AllOf.allOf(
a(MessageWrapper.class),
HasPropertyWithValue.hasProperty("execTypeRejected", IsEqual.equalTo(true) ))));};
});
adaptor.onNewOrderSingle(wrapper);
context.assertIsSatisfied();
}
RSS Feed