Java Code Examples for org.springframework.web.bind.support.SimpleSessionStatus

Following code examples demonstrate how to use org.springframework.web.bind.support.SimpleSessionStatusfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.web.bind.support.SimpleSessionStatusand various code implementation of this class.

	public void testPost() throws Exception {
		Account account = new Account("1", "Ben");
		account.setEntityId(new Long(0));
		BindingResult result = new BeanPropertyBindingResult(account, "account");
		SessionStatus sessionStatus = new SimpleSessionStatus();
		String view = null;
		assertEquals("redirect:/accounts/accountDetails.htm?entityId=0", view);
		assertTrue(sessionStatus.isComplete());
		account = accountManager.getAccount(Long.valueOf(0));
		assertEquals("1", account.getNumber());
		assertEquals("Ben", account.getName());
	} 


	public void testAddBook() {
		Book book = new Book("test book", "test author", 1234567890L);
		MockActionResponse response = new MockActionResponse();
		addBookController.addBook(book, new BindException(book, "book"),
				response, new SimpleSessionStatus());
		assertNotNull(bookService.getBook(1234567890L));
		assertEquals("books", response.getRenderParameter("myaction"));
	} 

    private void callAuthEndpoint(PageParameters pageParameters) {
        Map<String,String> params = new HashMap<>();
        for(String key : pageParameters.getNamedKeys()) {
            System.out.println(key+": "+pageParameters.get(key).toString());
            params.put(key, pageParameters.get(key).toString());
        }

        Principal principal = SecurityContextHolder.getContext().getAuthentication();
        Map<String, Object> model = new HashMap<>();
        authorizationEndpoint.authorize(model, params, new SimpleSessionStatus(), principal);

    } 

  public void submit_redirects_to_people() throws Exception {
    SimpleSessionStatus sessionStatus = new SimpleSessionStatus();
    String actual = controller.submit(form, bindingResult, sessionStatus);
    assertThat(actual, equalTo("redirect:/people"));
  } 

  public void submit_returns_to_person() throws Exception {
    bindingResult.addError(new ObjectError("form", "fail"));
    SimpleSessionStatus sessionStatus = new SimpleSessionStatus();
    String actual = controller.submit(form, bindingResult, sessionStatus);
    assertThat(actual, equalTo("person"));
  } 

Advertisement
Javadoc
Simple implementation of the SessionStatus interface, keeping the complete flag as an instance varia

ble. @author Juergen Hoeller @since 2.5

Read More
Advertisement