Package org.springframework.mock.web.portlet

Examples of org.springframework.mock.web.portlet.MockPortletSession


      }
    }.runTest();
  }

  public void testUpdateAccessedAttributes() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute(KEY, VALUE);
    MockPortletRequest request = new MockPortletRequest();
    request.setSession(session);
    PortletRequestAttributes attrs = new PortletRequestAttributes(request);
    Object value = attrs.getAttribute(KEY, RequestAttributes.SCOPE_SESSION);
    assertSame(VALUE, value);
View Full Code Here


      // expected
    }
  }

  public void testSetSessionScopedAttribute() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute(KEY, VALUE);
    MockPortletRequest request = new MockPortletRequest();
    request.setSession(session);
    PortletRequestAttributes attrs = new PortletRequestAttributes(request);
    attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_SESSION);
    Object value = session.getAttribute(KEY);
    assertSame(VALUE, value);
  }
View Full Code Here

    Object value = session.getAttribute(KEY);
    assertSame(VALUE, value);
  }

  public void testSetSessionScopedAttributeAfterCompletion() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute(KEY, VALUE);
    MockPortletRequest request = new MockPortletRequest();
    request.setSession(session);
    PortletRequestAttributes attrs = new PortletRequestAttributes(request);
    attrs.requestCompleted();
    request.close();
    attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_SESSION);
    Object value = session.getAttribute(KEY);
    assertSame(VALUE, value);
  }
View Full Code Here

    Object value = session.getAttribute(KEY);
    assertSame(VALUE, value);
  }

  public void testSetGlobalSessionScopedAttribute() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute(KEY, VALUE);
    MockPortletRequest request = new MockPortletRequest();
    request.setSession(session);
    PortletRequestAttributes attrs = new PortletRequestAttributes(request);
    attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_GLOBAL_SESSION);
    Object value = session.getAttribute(KEY);
    assertSame(VALUE, value);
  }
View Full Code Here

    Object value = session.getAttribute(KEY);
    assertSame(VALUE, value);
  }

  public void testSetGlobalSessionScopedAttributeAfterCompletion() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute(KEY, VALUE);
    MockPortletRequest request = new MockPortletRequest();
    request.setSession(session);
    PortletRequestAttributes attrs = new PortletRequestAttributes(request);
    attrs.requestCompleted();
    request.close();
    attrs.setAttribute(KEY, VALUE, RequestAttributes.SCOPE_GLOBAL_SESSION);
    Object value = session.getAttribute(KEY);
    assertSame(VALUE, value);
  }
View Full Code Here

    mockRequest.verify();
  }

  public void testRemoveSessionScopedAttribute() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute(KEY, VALUE);
    MockPortletRequest request = new MockPortletRequest();
    request.setSession(session);
    PortletRequestAttributes attrs = new PortletRequestAttributes(request);
    attrs.removeAttribute(KEY, RequestAttributes.SCOPE_SESSION);
    Object value = session.getAttribute(KEY);
    assertNull(value);
  }
View Full Code Here

      }
    }.runTest();
  }

  public void testGetOrCreateSessionAttributeJustReturnsAttributeIfItAlreadyExists() throws Exception {
    MockPortletSession session = new MockPortletSession();
    final TestBean expectedAttribute = new TestBean("Donna Tartt");
    session.setAttribute("donna", expectedAttribute);
    Object actualAttribute = PortletUtils.getOrCreateSessionAttribute(session, "donna", TestBean.class);
    assertSame(expectedAttribute, actualAttribute);
  }
View Full Code Here

    Object actualAttribute = PortletUtils.getOrCreateSessionAttribute(session, "donna", TestBean.class);
    assertSame(expectedAttribute, actualAttribute);
  }

  public void testGetOrCreateSessionAttributeCreatesAttributeIfItDoesNotAlreadyExist() throws Exception {
    MockPortletSession session = new MockPortletSession();
    Object actualAttribute = PortletUtils.getOrCreateSessionAttribute(session, "bean", TestBean.class);
    assertNotNull(actualAttribute);
    assertEquals("Wrong type of object being instantiated", TestBean.class, actualAttribute.getClass());
  }
View Full Code Here

  }

  public void testGetOrCreateSessionAttributeWithNoExistingAttributeAndNullClass() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        PortletUtils.getOrCreateSessionAttribute(new MockPortletSession(), "bean", null);
      }
    }.runTest();
  }
View Full Code Here

  }

  public void testGetOrCreateSessionAttributeWithNoExistingAttributeAndClassThatIsAnInterfaceType() throws Exception {
    new AssertThrows(IllegalArgumentException.class) {
      public void test() throws Exception {
        PortletUtils.getOrCreateSessionAttribute(new MockPortletSession(), "bean", ITestBean.class);
      }
    }.runTest();
  }
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.portlet.MockPortletSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.