Examples of MockPortletSession


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

    assertSame(expectedAttribute, actualAttribute);
  }

  @Test
  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

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

    assertEquals("Wrong type of object being instantiated", TestBean.class, actualAttribute.getClass());
  }

  @Test(expected=IllegalArgumentException.class)
  public void testGetOrCreateSessionAttributeWithNoExistingAttributeAndNullClass() throws Exception {
    PortletUtils.getOrCreateSessionAttribute(new MockPortletSession(), "bean", null);
  }
View Full Code Here

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

    PortletUtils.getOrCreateSessionAttribute(new MockPortletSession(), "bean", null);
  }

  @Test(expected=IllegalArgumentException.class)
  public void testGetOrCreateSessionAttributeWithNoExistingAttributeAndClassThatIsAnInterfaceType() throws Exception {
    PortletUtils.getOrCreateSessionAttribute(new MockPortletSession(), "bean", ITestBean.class);
  }
View Full Code Here

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

    PortletUtils.getOrCreateSessionAttribute(new MockPortletSession(), "bean", ITestBean.class);
  }

  @Test(expected=IllegalArgumentException.class)
  public void testGetOrCreateSessionAttributeWithNoExistingAttributeAndClassWithNoPublicCtor() throws Exception {
    PortletUtils.getOrCreateSessionAttribute(new MockPortletSession(), "bean", NoPublicCtor.class);
  }
View Full Code Here

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

    PortletUtils.getSessionMutex(null);
  }

  @Test
  public void testGetSessionMutexWithNoExistingSessionMutexDefinedJustReturnsTheSessionArgument() throws Exception {
    MockPortletSession session = new MockPortletSession();
    Object sessionMutex = PortletUtils.getSessionMutex(session);
    assertNotNull("PortletUtils.getSessionMutex(..) must never return a null mutex", sessionMutex);
    assertSame("PortletUtils.getSessionMutex(..) must return the exact same PortletSession supplied as an argument if no mutex has been bound as a Session attribute beforehand",
        session, sessionMutex);
  }
View Full Code Here

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

        session, sessionMutex);
  }

  @Test
  public void testGetSessionMutexWithExistingSessionMutexReturnsTheExistingSessionMutex() throws Exception {
    MockPortletSession session = new MockPortletSession();
    Object expectSessionMutex = new Object();
    session.setAttribute(WebUtils.SESSION_MUTEX_ATTRIBUTE, expectSessionMutex, PortletSession.APPLICATION_SCOPE);
    Object actualSessionMutex = PortletUtils.getSessionMutex(session);
    assertNotNull("PortletUtils.getSessionMutex(..) must never return a null mutex", actualSessionMutex);
    assertSame("PortletUtils.getSessionMutex(..) must return the bound mutex attribute if a mutex has been bound as a Session attribute beforehand",
        expectSessionMutex, actualSessionMutex);
  }
View Full Code Here

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

    verify(request).getPortletSession(false);
  }

  @Test
  public void testGetSessionAttributeWithExistingSession() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute("foo", "foo");

    PortletRequest request = mock(PortletRequest.class);
    given(request.getPortletSession(false)).willReturn(session);

    Object sessionAttribute = PortletUtils.getSessionAttribute(request, "foo");
View Full Code Here

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

    assertEquals("foo", sessionAttribute);
  }

  @Test
  public void testGetRequiredSessionAttributeWithExistingSession() throws Exception {
    MockPortletSession session = new MockPortletSession();
    session.setAttribute("foo", "foo");

    PortletRequest request = mock(PortletRequest.class);
    given(request.getPortletSession(false)).willReturn(session);

    Object sessionAttribute = PortletUtils.getRequiredSessionAttribute(request, "foo");
View Full Code Here

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

    assertEquals("foo", sessionAttribute);
  }

  @Test
  public void testGetRequiredSessionAttributeWithExistingSessionAndNoAttribute() throws Exception {
    MockPortletSession session = new MockPortletSession();

    final PortletRequest request = mock(PortletRequest.class);
    given(request.getPortletSession(false)).willReturn(session);
    try {
      PortletUtils.getRequiredSessionAttribute(request, "foo");
View Full Code Here

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

    new PortletRequestAttributes(null);
  }

  @Test
  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
TOP
Copyright © 2018 www.massapi.com. 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.