Created
December 3, 2017 18:02
-
-
Save Romeh/c281e657fb30489b4fc62b567b2042bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* main spring boot integration test with integration test profile | |
*/ | |
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | |
@ActiveProfiles("INTEGRATION_TEST") | |
@ContextConfiguration | |
public class CucumberRoot { | |
@Autowired | |
protected TestRestTemplate template; | |
@Before | |
public void before() { | |
// demo to show how to add custom header Globally for the http request in spring test template , like user header | |
template.getRestTemplate().setInterceptors(Collections.singletonList((request, body, execution) -> { | |
request.getHeaders() | |
.add("userHeader", "user"); | |
return execution.execute(request, body); | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment