Skip to content

Instantly share code, notes, and snippets.

@Romeh
Created December 3, 2017 18:02
Show Gist options
  • Save Romeh/c281e657fb30489b4fc62b567b2042bf to your computer and use it in GitHub Desktop.
Save Romeh/c281e657fb30489b4fc62b567b2042bf to your computer and use it in GitHub Desktop.
/**
* 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