}
//test response to a FormEncodingException for RESTFormService.getForms(...)
public void testGetFormsEncodingProblem() throws Exception {
RESTFormService restService = new RESTFormService();
FormDefinitionService formService = EasyMock.createMock(FormDefinitionService.class);
ServletContext context = EasyMock.createMock(ServletContext.class);
FormEncodingException exception = new FormEncodingException("Something going wrong");
FormRepresentationEncoder encoder = EasyMock.createMock(FormRepresentationEncoder.class);
EasyMock.expect(encoder.encode(EasyMock.anyObject(FormRepresentation.class))).andThrow(exception).once();
FormEncodingFactory.register(encoder, FormEncodingServerFactory.getDecoder());
List<FormRepresentation> forms = new ArrayList<FormRepresentation>();
forms.add(createMockForm("form1", "param1", "param2", "param3"));
forms.add(createMockForm("form2", "paramA", "paramB", "paramC"));
EasyMock.expect(formService.getForms(EasyMock.same("somePackage"))).andReturn(forms).once();
restService.setFormService(formService);
EasyMock.replay(formService, context, encoder);
Response resp = restService.getForms("somePackage", context);
EasyMock.verify(formService, context, encoder);