use of org.springframework.mock.web.MockHttpServletResponse in project gocd by gocd.
the class RestfulPropertiesControllerTest method setProperty.
private void setProperty(Pipeline pipeline, String property, String value) throws Exception {
response = new MockHttpServletResponse();
propertiesController.setProperty("pipeline", pipeline.getLabel(), "stage", null, "build", property, value, response, request);
assertThat(response.getContentAsString(), response.getStatus(), is(SC_CREATED));
}
use of org.springframework.mock.web.MockHttpServletResponse in project gocd by gocd.
the class RestfulPropertiesControllerTest method setProperty.
private void setProperty(String property, String value) throws Exception {
response = new MockHttpServletResponse();
propertiesController.setProperty("pipeline", "latest", "stage", null, "build", property, value, response, request);
}
use of org.springframework.mock.web.MockHttpServletResponse in project gocd by gocd.
the class RestfulPropertiesControllerTest method shouldReturn404WhenUnknownBuildOnList.
@Test
public void shouldReturn404WhenUnknownBuildOnList() throws Exception {
setProperty(oldPipeline, "a/2", "200");
setProperty(oldPipeline, "a/1", "100");
response = new MockHttpServletResponse();
propertiesController.jobSearch("unknown", oldPipeline.getLabel(), "stage", String.valueOf(oldStage.getCounter()), "build", "json", null, response);
assertThat(response.getStatus(), Is.is(SC_NOT_FOUND));
}
use of org.springframework.mock.web.MockHttpServletResponse in project cas by apereo.
the class FrontChannelLogoutActionTests method onSetUp.
@Before
public void onSetUp() throws Exception {
final UrlValidator validator = new SimpleUrlValidatorFactoryBean(false).getObject();
final DefaultSingleLogoutServiceMessageHandler handler = new DefaultSingleLogoutServiceMessageHandler(new SimpleHttpClientFactoryBean().getObject(), new SamlCompliantLogoutMessageCreator(), servicesManager, new DefaultSingleLogoutServiceLogoutUrlBuilder(validator), false, new DefaultAuthenticationServiceSelectionPlan(new DefaultAuthenticationServiceSelectionStrategy()));
final DefaultLogoutManager logoutManager = new DefaultLogoutManager(new SamlCompliantLogoutMessageCreator(), handler, false, mock(LogoutExecutionPlan.class));
this.frontChannelLogoutAction = new FrontChannelLogoutAction(logoutManager);
final MockHttpServletRequest request = new MockHttpServletRequest();
final MockHttpServletResponse response = new MockHttpServletResponse();
this.requestContext = mock(RequestContext.class);
final ServletExternalContext servletExternalContext = mock(ServletExternalContext.class);
when(this.requestContext.getExternalContext()).thenReturn(servletExternalContext);
when(servletExternalContext.getNativeRequest()).thenReturn(request);
when(servletExternalContext.getNativeResponse()).thenReturn(response);
final LocalAttributeMap flowScope = new LocalAttributeMap();
when(this.requestContext.getFlowScope()).thenReturn(flowScope);
final MockFlowExecutionKey mockFlowExecutionKey = new MockFlowExecutionKey(FLOW_EXECUTION_KEY);
final MockFlowExecutionContext mockFlowExecutionContext = new MockFlowExecutionContext();
mockFlowExecutionContext.setKey(mockFlowExecutionKey);
when(this.requestContext.getFlowExecutionContext()).thenReturn(mockFlowExecutionContext);
}
use of org.springframework.mock.web.MockHttpServletResponse in project cas by apereo.
the class InitialFlowSetupActionCookieTests method verifySettingContextPath.
@Test
public void verifySettingContextPath() {
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setContextPath(CONST_CONTEXT_PATH);
final MockRequestContext context = new MockRequestContext();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
this.action.doExecute(context);
assertEquals(CONST_CONTEXT_PATH + '/', this.warnCookieGenerator.getCookiePath());
assertEquals(CONST_CONTEXT_PATH + '/', this.tgtCookieGenerator.getCookiePath());
}
Aggregations