mardi 29 décembre 2015

Spring boot integrationTest web configuration

Trying implement integration test for httpClient. HttpClient can use stub rest controller service to send data for "other web".

Configuration is:

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = {
     SpringMvcApplicationConfiguration.class
    , StorageConfiguration.class
    , …
})
@WebIntegrationTest({"server.port=8080", "management.port=0"})
@Transactional
public class HttpSendHelperTest {
  private final static Logger LOGGER =     LoggerFactory.getLogger(HttpSendHelperTest.class);

  @Inject
  private HttpSendHelper httpSendHelper;
  @Inject
  private RequestMappingHandlerMapping mapping;
…
}

Test starts correctly loading all my configured contests. Checking mapping.getHandlerMethods() - all uris present in map.

Sending test request to default url - response status is 200, but sending to others (trying some from mapped uris) - response status is 404.

RestTemplate restTemplate = new TestRestTemplate();


restTemplate.postForEntity("http://localhost:8080/",
    StubBuilder.getInspection(), String.class)

responseEntity = restTemplate.postForEntity("http://localhost:8080/stub/send",
    StubBuilder.getInspection(), String.class);

Please suggest how to solve the problem.

Aucun commentaire:

Enregistrer un commentaire