lundi 24 septembre 2018

Exposing endpoint URL in tests

Let's go straight to the problem:

I want to test a method that wants URL of Rest endpoint as a parameter. That method is using RestTemplate internally to send a request to that URL, so it needs to be full URL, for example http://localhost:8080/rest. Because of that I also have no way to mock RestTemplate.

I wanted to create simple @RestController but it seems that Spring is not creating endpoint when running tests.

I've tried creating MockMvc but it's not what I want. I have no way of getting the IP and port of MockMvc's created endpoint because no actual endpoint is created.

So, what I want is to make my @RestController accessible in tests by sending requests to URL, for example: http://localhost:8080/rest.

It's my first time creating a test like that, I will be grateful for your help. I was searching for an answer but I couldn't find a solution for my problem.

Aucun commentaire:

Enregistrer un commentaire