Hi,
I am building an app that combines Spring and JAX-RS. I am looking for the simplest way to test my resources(including the path bindings). What I would ideally like to do is to not use spring in my unit tests but just boot-strap an individual resource into the simplest HTTPContainerFactory and test it. The problem is that I can get the resource loaded but since some of the attributes of the resource are loaded by Spring I then get NullPointerExceptions when I try to test it.
Ideally I would like to create an instance of a resource, initialize it with all of its required members(which is usually done by Spring), and then hand it over to a some jersey context so that I can make resource calls on it. One thing that seems crucial for me to test with a restful app is that the resource calls actually land in the expected method calls. I use a fair bit of regular expressions and therefore would like to do the following type of test:
public void testGetDate() {
assertEquals( myResource.getDate(1), resource().path("/event/1/date").get(Date.class) );
}
Is there any way to do this? I have been able to get tests boot-strapped as shown in the sample code but these assume you want to initialize a whole spring application. This in turn doing more than just a unit test and maintaining a lot of per-test spring configuration.
Cheers,
Florian
________________________________
The information in this e-mail is intended only for the person or entity to which it is addressed.
It may contain confidential and /or privileged material. If someone other than the intended recipient should receive this e-mail, he / she shall not be entitled to read, disseminate, disclose or duplicate it.
If you receive this e-mail unintentionally, please inform us immediately by "reply" and then delete it from your system. Although this information has been compiled with great care, neither IMC Financial Markets & Asset Management nor any of its related entities shall accept any responsibility for any errors, omissions or other inaccuracies in this information or for the consequences thereof, nor shall it be bound in any way by the contents of this e-mail or its attachments. In the event of incomplete or incorrect transmission, please return the e-mail to the sender and permanently delete this message and any attachments.
Messages and attachments are scanned for all known viruses. Always scan attachments before opening them.