public void testGetFormItemEncodingProblem() throws Exception {
RESTFormService restService = new RESTFormService();
FormRepresentationEncoder encoder = EasyMock.createMock(FormRepresentationEncoder.class);
FormEncodingException exception = new FormEncodingException("Something going wrong");
EasyMock.expect(encoder.encode(EasyMock.notNull(FormItemRepresentation.class))).andThrow(exception).anyTimes();
FormDefinitionService formService = EasyMock.createMock(FormDefinitionService.class);
FormItemRepresentation item = createMockForm("myForm", "param1").getFormItems().iterator().next();
EasyMock.expect(formService.getFormItem(EasyMock.eq("somePackage"), EasyMock.eq("MY_ITEM_ID"))).andReturn(item).once();
ServletContext context = EasyMock.createMock(ServletContext.class);
restService.setFormService(formService);
FormEncodingFactory.register(encoder, FormEncodingServerFactory.getDecoder());
EasyMock.replay(formService, context, encoder);