Jersey Testing Framework on separate jar?
Suppose I have many Maven web projects which consists on a series of REST
web services each. Every service is different from the others, but they
all have some common behaviour. For example: if the request is missing a
mandatory input parameter, every service will respond the following JSON:
{
"status":"MISSING_PARAMETER"
}
I'm implementing functional tests for these services. The difficulty is
that we want these tests to be 100% generic, meaning they can be ran on
every service and every project we have in the company.
So, imagine we have Project A, which has only one service: login. This
project will have a class LoginTest in its Test folder, which looks like
this:
public class LoginTest {
@Test
public static void missingParameterTest() {
String[] mandatoryInput = ["username","password"];
boolean result =
TestModule.missingParameter("login","post",mandatoryInput);
assertTrue(result);
}
}
As you can see, the actual test is not implemented in the LoginTest class,
but its implemented somewhere else.
We want the TestModule class to be implemented in Project B, a separate
Jar (So the tests can be used by different projects). Project A (and any
other project that wanted to use the test module) would have to add
Project B as a dependency in its POM.
The main question is wether it is possible to use the Jersey Testing
Framework in Project B to deploy Project A's services in one of the
supported containers (Grizzly, Glasshfish, etc), send some requests and
validate the responses. We're assuming the Testing Framework only needs
the resource name and method to call (post, get, etc). Is this true? Or do
we need something else to use the framework?
Also, if all of this is possible, which container would be better?
Thank you very much in advance!
No comments:
Post a Comment