Questions tagged [jersey-test-framework]
119 questions
11
votes
1 answer
MessageBodyWriter not found for media type=multipart/form-data in JerseyTest
I'm trying to create a test for a POST method in a resource class in a Jersey program.
Here's the POST method of the resource:
@POST @Path("/new")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response HTTPPostMethod(@FormDataParam("file")…

luispcosta
- 542
- 1
- 6
- 20
9
votes
3 answers
Static initializer doesn't run during JUnit tests
I have an interesting JUnit problem here (JUnit 4.12). I have a base class that only has static methods. They have to be static, because of the way they're used. I inherit other classes from the base class. So, if the base class is Base, we have…

Frecklefoot
- 1,660
- 2
- 21
- 52
9
votes
1 answer
JerseyTest using GrizzlyWebTestContainerFactory in Jersey 2.13
I am trying to get a JerseyTest running using a org.glassfish.jersey.test.grizzly.GrizzlyWebContainerFactory. I already searched the internet and tried several things for the better part of a day. It seems to be impossible and I would really…

ali
- 1,475
- 4
- 22
- 40
8
votes
2 answers
How to start a Jersey Test Container (Grizzly) once for all tests in a test class?
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…

Karthick R
- 599
- 9
- 25
7
votes
3 answers
How do I get Jersey Test/Client to not fill in a default Accept header?
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…

postfuturist
- 22,211
- 11
- 65
- 85
7
votes
1 answer
Mock Service inside resource using jersey test framwork
I have a resource for rest API which uses a service.
This service has a constructor with parameters.
I want to test this resource and to mock this service.
This Question: How to pass parameters to REST resource using Jersey 2.5
wasn't helpful…

Shiran Maor
- 309
- 2
- 5
- 18
5
votes
1 answer
Jackson LocalDate/Time deserialization
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…

Mrvonwyl
- 347
- 2
- 15
4
votes
2 answers
Mockito with Jersey Test and JAX-RS - UnsatisfiedDependencyException
Trying to test a fairly simple JAX-RS endpoint
@ApplicationScoped
@Path("mypath")
public class MyRestService {
@Inject
private Logger logger;
@Inject
private EjbService ejbService;
@GET
public String myMethod() {
…

LppEdd
- 20,274
- 11
- 84
- 139
4
votes
4 answers
JerseyTest Default port change to test REST WEB SERVICE
I made a test case to test my Rest Web Service. but in test case I am seeing that the request is going to default port of jersey test framework which is http://localhost:9998 whereas my service is register on http://localhost:8080. I am unable to…

Despicable
- 3,797
- 3
- 24
- 42
4
votes
1 answer
Jersey test - ExceptionMapper is not invoked
I have REST web service which I test with Jersey Test, Mockito, Junit. When web service method is executed successfully, I get correct response. In case of invalid data, custom exception is thrown which must be handled by ExceptionMapper. It should…

Justinas Jakavonis
- 8,220
- 10
- 69
- 114
4
votes
1 answer
Jersey client API vs Jersey test framework
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?

user1247412
- 647
- 7
- 16
- 29
3
votes
0 answers
Unable to see logs in Jersey Test Framework Enabled via TestProperties class
I'm trying to run tests using maven for Jersey Test Framework, In this code basically I'm trying to test a resource, I also wanted to dump the entity to the console and also look at the log traffic for the kind of request I'm getting ... Here is the…
user4739287
3
votes
1 answer
CDI in JUnit tests with Jersey Test Framework
We are using the Jersey Test Frameworks for API testing. In test-mode, we use an h2 database, mysql in production. Everything is fine to this point.
Now i want to write tests for our repositories to check if the data is written properly to the…

Mr Mueseli
- 55
- 7
3
votes
1 answer
ExceptionMapper not working in JerseyTest framework
I had made an RESTFUL-API for an specific object and using javax.validation.Constraints for validation, when I execute the app it works as expected and ExceptionMapper class is been executed correctly but when I try to automatize tests with…

Carlos Zerga
- 190
- 3
- 10
3
votes
1 answer
Jersey Unit Test: in memory container vs grizzly
I'm trying to get my head around unit testing in Jersey.
The classes that do not depend on Jersey directly can be unit tested using standard JUnit. This one is OK.
But there are also Jersey (or, should I say JAX-RS?) dependent classes. In order to…

Vasiliy
- 16,221
- 11
- 71
- 127