I want to Test the following rest webservice API:
@Stateless
@Path("quotes")
public class QuoteService {
@Inject
QuotesLoaderBean quoteLoader;
@GET
@Path("getquote")
@Produces(MediaType.APPLICATION_JSON)
public String getQuote() {
Gson gson = new GsonBuilder().create();
return gson.toJson(quoteLoader.getQuote());
}
Therefore I wrote the following test method:
@Test
public void test() {
Client client = ClientBuilder.newClient();
client.property("MyProperty", "MyValue")
.register(QuoteService.class);
Response res = client.target("http://localhost:8080/example.rs.jax/rest/quotes/getquote").request().get();
System.out.println(res);
}
The problem is, that this only works when the program is running. But I want to test the methods without starting the whole program. How can I achieve this?
Aucun commentaire:
Enregistrer un commentaire