Java Code Examples for org.springframework.mock.web.test.MockHttpServletRequest#close()
The following examples show how to use
org.springframework.mock.web.test.MockHttpServletRequest#close() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServletRequestAttributesTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void setRequestScopedAttributeAfterCompletion() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); ServletRequestAttributes attrs = new ServletRequestAttributes(request); request.close(); try { attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_REQUEST); fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { // expected } }
Example 2
Source File: ServletRequestAttributesTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void setSessionScopedAttributeAfterCompletion() throws Exception { MockHttpSession session = new MockHttpSession(); session.setAttribute(KEY, VALUE); MockHttpServletRequest request = new MockHttpServletRequest(); request.setSession(session); ServletRequestAttributes attrs = new ServletRequestAttributes(request); assertSame(VALUE, attrs.getAttribute(KEY, RequestAttributes.SCOPE_SESSION)); attrs.requestCompleted(); request.close(); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_SESSION); assertSame(VALUE, session.getAttribute(KEY)); }
Example 3
Source File: ServletRequestAttributesTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void setRequestScopedAttributeAfterCompletion() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); ServletRequestAttributes attrs = new ServletRequestAttributes(request); request.close(); try { attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_REQUEST); fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { // expected } }
Example 4
Source File: ServletRequestAttributesTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void setSessionScopedAttributeAfterCompletion() throws Exception { MockHttpSession session = new MockHttpSession(); session.setAttribute(KEY, VALUE); MockHttpServletRequest request = new MockHttpServletRequest(); request.setSession(session); ServletRequestAttributes attrs = new ServletRequestAttributes(request); assertSame(VALUE, attrs.getAttribute(KEY, RequestAttributes.SCOPE_SESSION)); attrs.requestCompleted(); request.close(); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_SESSION); assertSame(VALUE, session.getAttribute(KEY)); }
Example 5
Source File: ServletRequestAttributesTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void setRequestScopedAttributeAfterCompletion() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); ServletRequestAttributes attrs = new ServletRequestAttributes(request); request.close(); try { attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_REQUEST); fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { // expected } }
Example 6
Source File: ServletRequestAttributesTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void setSessionScopedAttributeAfterCompletion() throws Exception { MockHttpSession session = new MockHttpSession(); session.setAttribute(KEY, VALUE); MockHttpServletRequest request = new MockHttpServletRequest(); request.setSession(session); ServletRequestAttributes attrs = new ServletRequestAttributes(request); attrs.requestCompleted(); request.close(); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_SESSION); Object value = session.getAttribute(KEY); assertSame(VALUE, value); }
Example 7
Source File: ServletRequestAttributesTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void setGlobalSessionScopedAttributeAfterCompletion() throws Exception { MockHttpSession session = new MockHttpSession(); session.setAttribute(KEY, VALUE); MockHttpServletRequest request = new MockHttpServletRequest(); request.setSession(session); ServletRequestAttributes attrs = new ServletRequestAttributes(request); attrs.requestCompleted(); request.close(); attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_GLOBAL_SESSION); Object value = session.getAttribute(KEY); assertSame(VALUE, value); }