jersey-test-framework

Jersey Test Framework & HK2-Guice bridge

99封情书 提交于 2019-12-08 05:22:44
问题 There are REST web service based on Jersey 2.23.2 & Guice 3.0. To use Guice it is necessary to adjust the hk2-guice bridge (I'm using 2.5.0-b07). Everything works fine until I have tried to test the service using Jersey Test Framework. Can't configure hk2-guice bridge for tests. My test: public class SomeTest extends JerseyTestNg.ContainerPerClassTest { @Override protected TestContainerFactory getTestContainerFactory() throws TestContainerException { return new GrizzlyWebTestContainerFactory(

How to start a Jersey Test Container (Grizzly) once for all tests in a test class?

∥☆過路亽.° 提交于 2019-12-07 06:40:28
问题 I am working on fixing the integration tests in one of the projects. Currently, all the integration test classes extend the JerseyTest class. Going through the JerseyTest class I realized that it starts and stops the container for every test method using Junit's Before and After annotations. Why is this necessary? Isn't it enough if we bring up the container once, run the tests and shut it down at the end of it? We also use Spring and it takes time for the context to get initialized. Prior to

Jersey client API vs Jersey test framework

≡放荡痞女 提交于 2019-12-04 13:16:29
问题 I am new to web services and would like to know what is the difference between Jersey client API and jersey test framework? I would like to test my jersey REST web-services end points. Which is the the right one to use? 回答1: There are many HTTP client APIs out there (for example Apache HttpClient). You will need one to do client side testing. We will need to somehow access our services through HTTP, so one of these APIs will be needed for unit testing. Since you're already using Jersey, the

Unit Testing with Jersey Rest Test Framework and Mockito

时光毁灭记忆、已成空白 提交于 2019-12-04 01:54:26
问题 Could someone help me on this. I am writing Unit test for Rest resource using Jersey rest test framework version 2.21.(On Grizzly container). When I debug the test class, am seeing mock object for myManager . But when the debug enters my "MyResouce class, myManager object is becoming null and getting NullPointer Exception. Have tried with solutions given by different people, but no luck.Could someone help me please. Am with this problem from almost three days. :( My Resource class is like

Resource model validation failure in JerseyTest for Spring-Jersey application

ぐ巨炮叔叔 提交于 2019-12-02 02:52:23
问题 I have an annotated Spring-Jersey application. I am trying to set up unit test for my controllers using JerseyTest . I am getting the following errors on running the test that I am not able to figure out. What have I missed? SEVERE: Following issues have been detected: WARNING: No injection source found for a parameter of type public com.example.services.dto.UnitDto com.example.apis.UnitResource.getUnits(com.example.services.dto.PointDto) throws com.example.exceptions.PointOutsideBounds at

Resource model validation failure in JerseyTest for Spring-Jersey application

丶灬走出姿态 提交于 2019-12-02 01:39:51
I have an annotated Spring-Jersey application. I am trying to set up unit test for my controllers using JerseyTest . I am getting the following errors on running the test that I am not able to figure out. What have I missed? SEVERE: Following issues have been detected: WARNING: No injection source found for a parameter of type public com.example.services.dto.UnitDto com.example.apis.UnitResource.getUnits(com.example.services.dto.PointDto) throws com.example.exceptions.PointOutsideBounds at index 2. Validation of the application resource model has failed during application initialization. [

How do I get Jersey Test/Client to not fill in a default Accept header?

大兔子大兔子 提交于 2019-12-01 17:40:43
I'm trying to handle a request with no Accept header in a particular way, but Jersey seems hell-bent on filling one in, no matter what I do, so it always looks like the request has an Accept header, even if it doesn't. import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.Application; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders; import static org.junit.Assert.assertEquals; public class JerseyTestTest extends JerseyTest { @Path("hello

How do I get Jersey Test/Client to not fill in a default Accept header?

南楼画角 提交于 2019-12-01 16:52:32
问题 I'm trying to handle a request with no Accept header in a particular way, but Jersey seems hell-bent on filling one in, no matter what I do, so it always looks like the request has an Accept header, even if it doesn't. import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; import org.junit.Test; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.core.Application; import javax.ws.rs.core.Context; import javax.ws.rs.core.HttpHeaders;

Unit Testing with Jersey Rest Test Framework and Mockito

蓝咒 提交于 2019-12-01 11:11:59
Could someone help me on this. I am writing Unit test for Rest resource using Jersey rest test framework version 2.21.(On Grizzly container). When I debug the test class, am seeing mock object for myManager . But when the debug enters my "MyResouce class, myManager object is becoming null and getting NullPointer Exception. Have tried with solutions given by different people, but no luck.Could someone help me please. Am with this problem from almost three days. :( My Resource class is like this. @Component @Path("/somepath") public class MyResource { @Autowired private MyManager myManager;