congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
MockHttpServletRequestBuilder.flashAttr
Code IndexAdd Tabnine to your IDE (free)

How to use
flashAttr
method
in
org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder

Best Java code snippets using org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder.flashAttr (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

@Test
public void flashAttribute() {
  this.builder.flashAttr("foo", "bar");
  MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
  FlashMap flashMap = new SessionFlashMapManager().retrieveAndUpdate(request, null);
  assertNotNull(flashMap);
  assertEquals("bar", flashMap.get("foo"));
}
origin: spring-projects/spring-framework

@Test
public void getPerson() throws Exception {
  this.mockMvc.perform(get("/persons/Joe").flashAttr("message", "success!"))
    .andExpect(status().isOk())
    .andExpect(forwardedUrl("persons/index"))
    .andExpect(model().size(2))
    .andExpect(model().attribute("person", new Person("Joe")))
    .andExpect(model().attribute("message", "success!"))
    .andExpect(flash().attributeCount(0));
}
origin: apache/servicemix-bundles

/**
 * Set flash attributes.
 * @param flashAttributes the flash attributes
 */
public MockHttpServletRequestBuilder flashAttrs(Map<String, Object> flashAttributes) {
  Assert.notEmpty(flashAttributes, "'flashAttributes' must not be empty");
  for (String name : flashAttributes.keySet()) {
    flashAttr(name, flashAttributes.get(name));
  }
  return this;
}
origin: castlemock/castlemock

  @Test
  public void testUpdateEndpoint() throws Exception {
    final String projectId = "projectId";

    final UpdateRestApplicationsEndpointCommand command = new UpdateRestApplicationsEndpointCommand();
    command.setForwardedEndpoint("http://localhost:8080/web");
    command.setRestApplications(ImmutableList.of());

    final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
        SLASH + projectId + SLASH + APPLICATION + SLASH + "update/confirm")
        .flashAttr("command", command);
    mockMvc.perform(message)
        .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
        .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId));

    Mockito.verify(serviceProcessor, Mockito.times(1))
        .process(Mockito.any(UpdateRestApplicationsForwardedEndpointInput.class));
  }
}
origin: castlemock/castlemock

@Test
public void testUpdateEndpoint() throws Exception {
  final String projectId = "projectId";
  final String applicationId = "applicationId";
  final UpdateRestResourcesEndpointCommand command = new UpdateRestResourcesEndpointCommand();
  command.setForwardedEndpoint("http://localhost:8080/web");
  command.setRestResources(ImmutableList.of());
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL +
      PROJECT + SLASH + projectId + SLASH + APPLICATION + SLASH + applicationId + SLASH +
      RESOURCE + SLASH + "update/confirm")
      .flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId + "/application/" + applicationId));
  Mockito.verify(serviceProcessor, Mockito.times(1)).process(Mockito.any(UpdateRestResourcesForwardedEndpointInput.class));
}
origin: castlemock/castlemock

@Test
public void testUpdateEndpoint() throws Exception {
  final String projectId = "projectId";
  final String portId = "portId";
  final UpdateSoapOperationsEndpointCommand command =
      new UpdateSoapOperationsEndpointCommand();
  command.setSoapOperations(ImmutableList.of());
  command.setForwardedEndpoint("http://localhost:8080/web");
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
      SLASH + projectId + SLASH + PORT + SLASH + portId + SLASH + OPERATION + SLASH  + "update/confirm")
      .flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/soap/project/" + projectId + "/port/" + portId));
  Mockito.verify(serviceProcessor, Mockito.times(1))
      .process(Mockito.any(UpdateSoapOperationsForwardedEndpointInput.class));
}
origin: castlemock/castlemock

@Test
public void testUpdateEndpoint() throws Exception {
  final String projectId = "projectId";
  final String applicationId = "applicationId";
  final String resourceId = "resourceId";
  final UpdateRestMethodsEndpointCommand command = new UpdateRestMethodsEndpointCommand();
  command.setForwardedEndpoint("http://localhost:8080/web");
  command.setRestMethods(ImmutableList.of());
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
      SLASH + projectId + SLASH + APPLICATION + SLASH + applicationId + SLASH + RESOURCE + SLASH +
      resourceId + SLASH + METHOD + SLASH + "update/confirm")
      .flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId + "/application/" + applicationId + "/resource/" + resourceId));
  Mockito.verify(serviceProcessor, Mockito.times(1)).process(Mockito.any(UpdateRestMethodsForwardedEndpointInput.class));
}
origin: castlemock/castlemock

@Test
public void testUpdatePortEndpoint() throws Exception {
  final UpdateSoapPortsEndpointCommand command = new UpdateSoapPortsEndpointCommand();
  final SoapProject soapProject = SoapProjectGenerator.generateSoapProject();
  final SoapPort soapPort = SoapPortGenerator.generateSoapPort();
  final List<SoapPort> soapPorts = new ArrayList<SoapPort>();
  soapPorts.add(soapPort);
  command.setSoapPorts(soapPorts);
  command.setForwardedEndpoint("/new/endpoint");
  when(serviceProcessor.process(any(Input.class))).thenReturn(UpdateSoapPortOutput.builder()
      .port(soapPort)
      .build());
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
      SLASH + soapProject.getId() + SLASH + PORT +  SLASH + UPDATE + SLASH + CONFIRM)
      .flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().isFound())
      .andExpect(MockMvcResultMatchers.model().size(1));
}
origin: castlemock/castlemock

  @Test
  public void testConfirmDeletationOfMultipleMethods() throws Exception {
    final RestProject restProject = RestProjectGenerator.generateRestProject();
    final RestApplication restApplication = RestApplicationGenerator.generateRestApplication();
    final RestResource restResource = RestResourceGenerator.generateRestResource();
    final DeleteRestResourcesCommand command = new DeleteRestResourcesCommand();
    command.setRestResources(new ArrayList<RestResource>());
    command.getRestResources().add(restResource);

    when(serviceProcessor.process(any(DeleteRestMethodInput.class))).thenReturn(DeleteRestMethodOutput.builder().build());
    final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL +
        PROJECT + SLASH + restProject.getId() + SLASH + APPLICATION + SLASH + restApplication.getId() +
        SLASH + RESOURCE + SLASH + DELETE + SLASH + CONFIRM)
        .flashAttr("command", command);
    mockMvc.perform(message)
        .andExpect(MockMvcResultMatchers.status().isFound())
        .andExpect(MockMvcResultMatchers.model().size(1));
  }
}
origin: castlemock/castlemock

@Test
public void projectFunctionalityUpdate() throws Exception {
  final String projectId = "projectId";
  final String[] soapPortIds = {"soapPort1", "soapPort2"};
  final SoapPortModifierCommand command = new SoapPortModifierCommand();
  command.setSoapPortIds(soapPortIds);
  command.setSoapPortStatus("MOCKED");
  final MockHttpServletRequestBuilder message =
      MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH)
          .param("action", "update").flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.model().size(1))
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/soap/project/" + projectId));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.any(UpdateSoapPortsStatusInput.class));
}
origin: castlemock/castlemock

@Test
public void projectFunctionalityUpdate() throws Exception {
  final String projectId = "projectId";
  final String[] restApplicationIds = {"restApplication1", "restApplication2"};
  final RestApplicationModifierCommand command = new RestApplicationModifierCommand();
  command.setRestApplicationIds(restApplicationIds);
  command.setRestMethodStatus("MOCKED");
  final MockHttpServletRequestBuilder message =
      MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH)
          .param("action", "update").flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.model().size(1))
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.any(UpdateRestApplicationsStatusInput.class));
}
origin: castlemock/castlemock

@Test
public void testConfirmDeletationOfMultpleProjects() throws Exception {
  final DeleteRestApplicationsCommand command = new DeleteRestApplicationsCommand();
  final RestProject restProject = RestProjectGenerator.generateRestProject();
  final RestApplication restApplication = RestApplicationGenerator.generateRestApplication();
  final List<RestApplication> restApplications = new ArrayList<RestApplication>();
  restApplications.add(restApplication);
  command.setRestApplications(restApplications);
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
      SLASH + restProject.getId() + SLASH + APPLICATION + SLASH + DELETE + SLASH + CONFIRM)
      .flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().isFound())
      .andExpect(MockMvcResultMatchers.model().size(1));
}
origin: castlemock/castlemock

@Test
public void projectFunctionalityUpdate() throws Exception {
  final String projectId = "projectId";
  final String applicationId = "applicationId";
  final String[] restResources = {"restApplication1", "restApplication2"};
  final RestResourceModifierCommand command = new RestResourceModifierCommand();
  command.setRestResourceIds(restResources);
  command.setRestMethodStatus("MOCKED");
  final MockHttpServletRequestBuilder message =
      MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH + APPLICATION + SLASH + applicationId)
          .param("action", "update").flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.model().size(1))
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/rest/project/" + projectId + "/application/" + applicationId));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.any(ReadRestResourceInput.class));
}
origin: castlemock/castlemock

@Test
public void testConfirmDeletationOfMultpleProjects() throws Exception {
  final DeleteSoapPortsCommand command = new DeleteSoapPortsCommand();
  final SoapProject soapProject = SoapProjectGenerator.generateSoapProject();
  final SoapPort soapPort = SoapPortGenerator.generateSoapPort();
  final List<SoapPort> soapPorts = new ArrayList<SoapPort>();
  soapPorts.add(soapPort);
  command.setSoapPorts(soapPorts);
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
      SLASH + soapProject.getId() + SLASH + PORT + SLASH + DELETE + SLASH + CONFIRM)
      .flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().isFound())
      .andExpect(MockMvcResultMatchers.model().size(1));
}
origin: castlemock/castlemock

  @Test
  public void testConfirmDeletationOfMultipleMethods() throws Exception {
    final RestProject restProject = RestProjectGenerator.generateRestProject();
    final RestApplication restApplication = RestApplicationGenerator.generateRestApplication();
    final RestResource restResource = RestResourceGenerator.generateRestResource();
    final RestMethod restMethod = RestMethodGenerator.generateRestMethod();
    final DeleteRestMethodsCommand command = new DeleteRestMethodsCommand();
    command.setRestMethods(new ArrayList<RestMethod>());
    command.getRestMethods().add(restMethod);

    when(serviceProcessor.process(any(DeleteRestMethodInput.class))).thenReturn(DeleteRestMethodOutput.builder().build());
    final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
        SLASH + restProject.getId() + SLASH + APPLICATION + SLASH + restApplication.getId() + SLASH +
        RESOURCE + SLASH + restResource.getId() + SLASH + METHOD + SLASH + DELETE + SLASH + CONFIRM)
        .flashAttr("command", command);
    mockMvc.perform(message)
        .andExpect(MockMvcResultMatchers.status().isFound())
        .andExpect(MockMvcResultMatchers.model().size(1));
  }
}
origin: castlemock/castlemock

  @Test
  public void testConfirmDeletationOfMultipleMockResponses() throws Exception {
    final SoapProject project = SoapProjectGenerator.generateSoapProject();
    final SoapPort application = SoapPortGenerator.generateSoapPort();
    final SoapOperation soapOperation = SoapOperationGenerator.generateSoapOperation();
    final SoapMockResponse soapMockResponse = SoapMockResponseGenerator.generateSoapMockResponse();
    final DeleteSoapMockResponsesCommand deleteSoapMockResponsesCommand = new DeleteSoapMockResponsesCommand();
    deleteSoapMockResponsesCommand.setSoapMockResponses(new ArrayList<SoapMockResponse>());
    deleteSoapMockResponsesCommand.getSoapMockResponses().add(soapMockResponse);

    when(serviceProcessor.process(any(DeleteSoapMockResponseInput.class))).thenReturn(DeleteSoapMockResponseOutput.builder().build());
    final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
        SLASH + project.getId() + SLASH + PORT + SLASH + application.getId() + SLASH + OPERATION + SLASH +
        soapOperation.getId() + SLASH + RESPONSE + SLASH + DELETE + SLASH + CONFIRM)
        .flashAttr("command", deleteSoapMockResponsesCommand);
    mockMvc.perform(message)
        .andExpect(MockMvcResultMatchers.status().isFound())
        .andExpect(MockMvcResultMatchers.model().size(1));
  }
}
origin: castlemock/castlemock

  @Test
  public void testConfirmDeletationOfMultipleMockResponses() throws Exception {
    final RestProject restProject = RestProjectGenerator.generateRestProject();
    final RestApplication restApplication = RestApplicationGenerator.generateRestApplication();
    final RestResource restResource = RestResourceGenerator.generateRestResource();
    final RestMethod restMethod = RestMethodGenerator.generateRestMethod();
    final RestMockResponse restMockResponse = RestMockResponseGenerator.generateRestMockResponse();
    final DeleteRestMockResponsesCommand command = new DeleteRestMockResponsesCommand();
    command.setRestMockResponses(new ArrayList<RestMockResponse>());
    command.getRestMockResponses().add(restMockResponse);

    when(serviceProcessor.process(any(DeleteRestMockResponsesInput.class))).thenReturn(DeleteRestMockResponsesOutput.builder().build());
    final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
        SLASH + restProject.getId() + SLASH + APPLICATION + SLASH + restApplication.getId() + SLASH +
        RESOURCE + SLASH + restResource.getId() + SLASH + METHOD + SLASH + restMethod.getId() + SLASH +
        RESPONSE + SLASH + DELETE + SLASH + CONFIRM)
        .flashAttr("command", command);
    mockMvc.perform(message)
        .andExpect(MockMvcResultMatchers.status().isFound())
        .andExpect(MockMvcResultMatchers.model().size(1));
  }
}
origin: castlemock/castlemock

@Test
public void testUpdateMockResponse() throws Exception {
  final SoapProject project = SoapProjectGenerator.generateSoapProject();
  final SoapPort application = SoapPortGenerator.generateSoapPort();
  final SoapOperation soapOperation = SoapOperationGenerator.generateSoapOperation();
  final SoapMockResponse soapMockResponse = SoapMockResponseGenerator.generateSoapMockResponse();
  when(serviceProcessor.process(any(UpdateSoapMockResponseInput.class))).thenReturn(UpdateSoapMockResponseOutput.builder()
      .mockResponse(soapMockResponse)
      .build());
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL + PROJECT +
      SLASH + project.getId() + SLASH + PORT + SLASH + application.getId() + SLASH + OPERATION +
      SLASH + soapOperation.getId() + SLASH + RESPONSE + SLASH + soapMockResponse.getId() + SLASH + UPDATE)
      .flashAttr("soapMockResponse", soapMockResponse);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().isFound())
      .andExpect(MockMvcResultMatchers.model().size(1));
}
origin: castlemock/castlemock

@Test
public void testServiceFunctionalityUpdate() throws Exception {
  final String projectId = "projectId";
  final String portId = "portId";
  final String[] soapOperationIds = {"Operation1", "Operation2"};
  final SoapOperationModifierCommand command = new SoapOperationModifierCommand();
  command.setSoapOperationIds(soapOperationIds);
  command.setSoapOperationStatus("MOCKED");
  final MockHttpServletRequestBuilder message =
      MockMvcRequestBuilders.post(SERVICE_URL + PROJECT + SLASH + projectId + SLASH + PORT + SLASH + portId)
          .param("action", "update").flashAttr("command", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().is3xxRedirection())
      .andExpect(MockMvcResultMatchers.model().size(1))
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web/soap/project/" + projectId + "/port/" + portId));
  Mockito.verify(serviceProcessor, Mockito.times(2)).process(Mockito.isA(UpdateSoapOperationsStatusInput.class));
}
origin: castlemock/castlemock

@Test
public void testConfirmDeletationOfMultpleProjects() throws Exception {
  final String[] projects = {"Project"};
  final String[] types = {"SOAP"};
  final DeleteProjectsCommand command = new DeleteProjectsCommand();
  command.setProjectIds(projects);
  command.setTypeUrls(types);
  final MockHttpServletRequestBuilder message = MockMvcRequestBuilders.post(SERVICE_URL_DELETE_MULTIPLE).flashAttr("deleteProjectsCommand", command);
  mockMvc.perform(message)
      .andExpect(MockMvcResultMatchers.status().isFound())
      .andExpect(MockMvcResultMatchers.model().size(1))
      .andExpect(MockMvcResultMatchers.redirectedUrl("/web"));
}
org.springframework.test.web.servlet.requestMockHttpServletRequestBuilderflashAttr

Javadoc

Set an "input" flash attribute.

Popular methods of MockHttpServletRequestBuilder

  • contentType
    Set the 'Content-Type' header of the request.
  • content
    Set the request body.
  • param
    Add a request parameter to the MockHttpServletRequest.If called more than once, new values get added
  • accept
    Set the 'Accept' header to the given media type(s).
  • header
    Add a header to the request. Values are always added.
  • with
    An extension point for further initialization of MockHttpServletRequestin ways not built directly in
  • requestAttr
    Set a request attribute.
  • buildRequest
    Build a MockHttpServletRequest.
  • contextPath
    Specify the portion of the requestURI that represents the context path. The context path, if specifi
  • principal
    Set the principal of the request.
  • headers
    Add all headers to the request. Values are always added.
  • session
    Set the HTTP session to use, possibly re-used across requests.Individual attributes provided via #se
  • headers,
  • session,
  • sessionAttr,
  • cookie,
  • params,
  • servletPath,
  • <init>,
  • characterEncoding,
  • locale

Popular in Java

  • Reactive rest calls using spring rest template
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • JPanel (javax.swing)
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now