Today I needed to test some rest services implemented with Jaxrs and Jersey, My intention was to have a fast running unit test that can be run on CI build and will test that the jaxrs+spring wiring, json serialization etc. don't break. All my resources are just calling other internal services, so I decided to deploy my rest resources and wire mock objects to them on an embedded jetty server.
I used spring annotations to wire everything up and all my resources look like that:
@Component("myResource")
@Path("/somepath")
public class SomeResource {
@Autowired
private mocktest.SomeService someService;
...
so the easy way to mock SomeService would be to just create an Easymock factory-method bean: