use of org.springframework.test.web.servlet.MockMvc in project spring-framework by spring-projects.
the class HtmlUnitRequestBuilderTests method mergeParameter.
@Test
public void mergeParameter() throws Exception {
String paramName = "PARENT";
String paramValue = "VALUE";
String paramValue2 = "VALUE2";
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new HelloController()).defaultRequest(get("/").param(paramName, paramValue, paramValue2)).build();
MockHttpServletRequest performedRequest = mockMvc.perform(requestBuilder).andReturn().getRequest();
assertThat(asList(performedRequest.getParameterValues(paramName)), contains(paramValue, paramValue2));
}
use of org.springframework.test.web.servlet.MockMvc in project pact-jvm by DiUS.
the class MockMvcTarget method testInteraction.
/**
* {@inheritDoc}
*/
@Override
public void testInteraction(final String consumerName, final Interaction interaction) {
ProviderInfo provider = getProviderInfo();
ConsumerInfo consumer = new ConsumerInfo(consumerName);
provider.setVerificationType(PactVerification.ANNOTATED_METHOD);
MockMvc mockMvc = standaloneSetup(controllers.toArray()).setControllerAdvice(controllerAdvice.toArray()).build();
MvcProviderVerifier verifier = (MvcProviderVerifier) setupVerifier(interaction, provider, consumer);
Map<String, Object> failures = new HashMap<>();
for (int i = 0; i < runTimes; i++) {
verifier.verifyResponseFromProvider(provider, interaction, interaction.getDescription(), failures, mockMvc);
}
try {
if (!failures.isEmpty()) {
verifier.displayFailures(failures);
throw getAssertionError(failures);
}
} finally {
verifier.finialiseReports();
}
}
Aggregations