jerseytest | Writing lightweight REST integration tests with the Jersey | Code Editor library

 by   mlex Java Version: Current License: No License

kandi X-RAY | jerseytest Summary

kandi X-RAY | jerseytest Summary

jerseytest is a Java library typically used in Editor, Code Editor, Spring Boot, Spring, Maven, Hibernate, Eclipse applications. jerseytest has no bugs, it has no vulnerabilities and it has low support. However jerseytest build file is not available. You can download it from GitHub.

Writing lightweight REST integration tests with the Jersey Test Framework. To compile the project, simply run "mvn package" inside the mjl-jersey-build directory. To view the project in eclipse, best use the maven eclipse plugin ("mvn eclipse:eclipse") and import as existing project. There is a blog post corresponding to this mini-tutorial:
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              jerseytest has a low active ecosystem.
              It has 29 star(s) with 16 fork(s). There are 4 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              jerseytest has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of jerseytest is current.

            kandi-Quality Quality

              jerseytest has 0 bugs and 0 code smells.

            kandi-Security Security

              jerseytest has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              jerseytest code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              jerseytest does not have a standard license declared.
              Check the repository for any license declaration and review the terms closely.
              OutlinedDot
              Without a license, all rights are reserved, and you cannot use the library in your applications.

            kandi-Reuse Reuse

              jerseytest releases are not available. You will need to build from source code and install.
              jerseytest has no build file. You will be need to create the build yourself to build the component from source.
              jerseytest saves you 331 person hours of effort in developing the same functionality from scratch.
              It has 794 lines of code, 56 functions and 17 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of jerseytest
            Get all kandi verified functions for this library.

            jerseytest Key Features

            No Key Features are available at this moment for jerseytest.

            jerseytest Examples and Code Snippets

            No Code Snippets are available at this moment for jerseytest.

            Community Discussions

            QUESTION

            JerseyExtension based test with JUnit5 not keeping session between requests
            Asked 2019-Dec-30 at 20:24

            I have a self contained Jersey test using JerseyExtension (JerseyExtension) with JUnit5 (since JerseyTest does not work with JUnit5 unless you use the vintage engine) and subsequent calls to the container are getting different session. Is there a way to keep the session store same between the calls?

            ...

            ANSWER

            Answered 2019-Dec-30 at 20:24

            The client used by Jersey test framework, does not behave like a browser when it comes to Set-Cookie/Cookie headers. The two requests are not connected and JSESSIONID set by first response is not propagated to next request. While the framework is aware of the JSESSIONID if present, it does not span requests and needs to be manually copied forward.

            Changing the test method to following works:

            Source https://stackoverflow.com/questions/59533190

            QUESTION

            HK2InjectionManager with jersey, upgrading with OpenJDK11
            Asked 2019-May-15 at 19:42

            Ran into a few errors as I am upgrading jdk11 and jersey but this one particularly stumped. So jersey 2.28 is supposedly compatible with OpenJDK11 and fixed some issues that was previously in 2.25.1, so I upgraded it

            I also saw this already, not a working solution - Jersey Spring Maven java.lang.NoClassDefFoundError: org/glassfish/jersey/hk2/HK2InjectionManager

            In my gradle build, failed on this task:

            > Task :ods-impl:test FAILED

            Under my task for this, here is the list of dependencies

            ...

            ANSWER

            Answered 2019-May-15 at 19:42

            Turns out jersey-spring3 is outdated. If you want to use 2.27+ Jersey with Spring, but change dependency to use jersey-spring4

            compile group: 'org.glassfish.jersey.ext', name: 'jersey-spring4', version: '2.28'

            Source https://stackoverflow.com/questions/56139535

            QUESTION

            How to mock Injected value relying on a qualifier using JerseyTest
            Asked 2019-May-10 at 14:30

            I'm trying to mock a controller/resource including the jax-rs layer. The class has dependencies that need to be injected. It however also has some String values that are injected using a qualifier interface.

            Basically, I'm using JerseyTest to run a single controller and use HK2 for dependency injection. I created a ResourceConfig and registered a AbstractBinder to bind the injected classes.

            This works fine for regular injected dependencies, but when the the additional @SomeQualifierInterface annotation is added, it crashes with the following error:

            ...

            ANSWER

            Answered 2019-May-10 at 14:30

            Solved!

            First, use the AbstractBinder from org.glassfish.hk2.utilities.binding.AbstractBinder instead of org.glassfish.jersey.internal.inject.AbstractBinder.

            Second, create a class that extends AnnotationLiteral and implements the interface.

            Last, bind the value to a TypeLiteral and set the qualifiedBy to the AnnotationLiteral.

            Full code:

            Source https://stackoverflow.com/questions/56018793

            QUESTION

            JerseyTest: how to bind to Set
            Asked 2019-Apr-11 at 20:15

            When testing with JerseyTest, I am having trouble to bind to a:

            ...

            ANSWER

            Answered 2019-Apr-11 at 20:15

            answered by @PaulSamsotha in his comment.

            Source https://stackoverflow.com/questions/55569235

            QUESTION

            Compilation error trying to bind factory class in Jersey 2.27
            Asked 2018-Jul-06 at 18:04

            I'm building a Java REST API with Jersey 2.27 and in my test class (as shown below) I get the following compile error: Cannot resolve method 'bindFactory(java.lang.Class)'.

            I don't get why this is not compiling. The bindFactorymethod has one parameter of type Class>, and my factory class is implementing Supplier as shown below. Can someone explain to me why this won't compile?

            PS: Tthese are only snippets of the full code to make things clearer.

            ...

            ANSWER

            Answered 2018-Jul-06 at 18:04

            Remove the generic type from your factory class. What you're supposed to be going is adding the concrete type to the Supplier

            Source https://stackoverflow.com/questions/51208160

            QUESTION

            Mockito with Jersey Test and JAX-RS - UnsatisfiedDependencyException
            Asked 2018-Jun-30 at 14:40

            Trying to test a fairly simple JAX-RS endpoint

            ...

            ANSWER

            Answered 2018-Jun-30 at 14:40

            The MockitoJUnitRunner is for unit tests and JerseyTest is for integration tests.

            When using Mockito, your tests will call directly the declared myRestService and Mockito dependency injection will take place.

            When using JerseyTest, a new web container is created and your tests talk to MyRestService via an HTTP call. Inside this container, the real dependency injection is happening, the classes are not even seeing you declared mocks.

            You can use JerseyTest and Mockito together, exactly as you did. It just requires some extra configurations (as you already found) and the @RunWith annotation is not necessary.

            Source https://stackoverflow.com/questions/51115671

            QUESTION

            Jackson LocalDate/Time deserialization
            Asked 2018-Apr-22 at 07:03

            I configured jackson so that it gives me a smiple string representation if java.time.LocalDate and java.time.LocalDateTime. This works find in the serialization process, e.g when I get data on the REST api.

            It doesn't work the other way round though. When I try to send data to the server and the JSON should be parsed to java objects this exception is thrown:

            javax.ws.rs.client.ResponseProcessingException: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of java.time.LocalDateTime: no String-argument constructor/factory method to deserialize from String value ('2018-04-19T14:10:30.903')

            After a few hours of research I managed to get it to work, but only with the attributes I annotated with @JsonDeserialize(using = LocalDateDeserializer.class) or @JsonDeserialize(using = LocalDateTimeDeserializer.class) respectively.

            In my opinion it would be ideal, if I could define these mappings in one central place.

            ObjectMapper configuration:

            ...

            ANSWER

            Answered 2018-Apr-22 at 07:03

            You registered the ContextResolver with the server via the configure() method of the JerseyTest, but if you look at the exception, you'll see that is a client side exception (notice the client in the package name). So the problem is on the client side. What you are missing is that the deserialization also needs to happen on the client side from JSON to Poc, so you also need the ContextResolver registered on the client. To do that, you can override configureClient() on the JerseyTest and register the ContextResolver there.

            Source https://stackoverflow.com/questions/49921346

            QUESTION

            MessageBodyProvider not found in Test for Custom provider - Manually works
            Asked 2018-Apr-14 at 09:13

            I know that the error "MessageBodyProvider" not found for application type question has been asked a lot of time, but my case is a bit different.

            The REST works fine when I manually invoke the REST API through Fiddler or in the browser. So there seems to something odd with the test. I can't get my head around this.

            ...

            ANSWER

            Answered 2018-Apr-14 at 01:54

            You're only registering the provider on the server side in the configure() method. You still need to register it on the client side. You can see in the stacktrace that the problem is occurring on the client side (see client in the package names).

            You can either just register the provider on the WebTarget or you can override configureClient() to register it with the Client.

            Source https://stackoverflow.com/questions/49820233

            QUESTION

            Jersey test gives NullPointerException when using UriInfo
            Asked 2017-Sep-22 at 10:04

            I am creating a application that should be able to create an account using a REST api. When I wrote the AccountController.java class everything worked fine. I used postman to verify that I got the right response.

            So my AccountController.java works correctly but the unit test I wrote with it don't work. When the unit test is executed it returns a NullPointerException which results in a InternalServerError within the REST API. While debugging i found out that if I remove the use of UriInfo in AccountController.java and return Response.ok() instead of created the test is successfull.

            So my question is. How do i properly test/mock a method that returns and URI?

            Bellow are all relevant classes and dependencies. The Account.java class is in another package. But both the main application as the project that contains Account.java are part of the same parent pom. I am not sure if this is relevant to my question.

            AccountController.java ...

            ANSWER

            Answered 2017-Sep-22 at 10:04

            So I finally figured it out. Somewhere on this line in AccountController.java a NullPointerException was thrown:

            final URI uri = uriInfo.getAbsolutePathBuilder().path(newAccount.getId() + "").build();

            This only happened when using my JerseyUnitTest so i guess Jersey must change some behavior of UriInfo.

            Eventually I solved the problem by overriding equals in Account.java.

            Source https://stackoverflow.com/questions/46219029

            QUESTION

            Jersey/Spring/Grizzly Integration Tests Always Returns 500 - No Details
            Asked 2017-Aug-04 at 02:23

            I am trying to write some integration tests for an application that uses Jersey with some Spring DI. Tests always come back as a 500 with no real explaination. Grizzly appears to start ok and boots up my hibernate connections just fine. Here is the error trace along with all of relevant files sans the class under test. I think it may be an issue with Grizzly and the configuration but I cant find anything that seems to work including switching to a webappcontext.

            ...

            ANSWER

            Answered 2017-Aug-04 at 02:23

            After several days of trial and error with almost no documentation and piecing together from other examples there were out of date, this is what finally worked for me. Hopefully it will help somebody else.

            Test Class

            Source https://stackoverflow.com/questions/45446093

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install jerseytest

            You can download it from GitHub.
            You can use jerseytest like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the jerseytest component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/mlex/jerseytest.git

          • CLI

            gh repo clone mlex/jerseytest

          • sshUrl

            git@github.com:mlex/jerseytest.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link