Search in sources :

Example 26 with MockPortletWindowId

use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.

the class PortletCacheControlServiceImplTest method testGetCacheControlDefault.

@Test
public void testGetCacheControlDefault() {
    MockHttpServletRequest httpRequest = new MockHttpServletRequest();
    MockPortletWindowId portletWindowId = new MockPortletWindowId("123");
    MockPortletDefinitionId portletDefinitionId = new MockPortletDefinitionId(789);
    when(portletDescriptor.getCacheScope()).thenReturn(null);
    final IPortletWindowRegistry portletWindowRegistry = mock(IPortletWindowRegistry.class);
    final IPortletWindow portletWindow = mock(IPortletWindow.class);
    final IPortletEntity portletEntity = mock(IPortletEntity.class);
    when(portletWindowRegistry.getPortletWindow(httpRequest, portletWindowId)).thenReturn(portletWindow);
    when(portletWindow.getPortletEntity()).thenReturn(portletEntity);
    when(portletWindow.getWindowState()).thenReturn(WindowState.NORMAL);
    when(portletWindow.getPortletMode()).thenReturn(PortletMode.VIEW);
    when(portletEntity.getPortletDefinitionId()).thenReturn(portletDefinitionId);
    when(portletDefinitionRegistry.getParentPortletDescriptor(portletDefinitionId)).thenReturn(portletDescriptor);
    final CacheState<CachedPortletData<PortletRenderResult>, PortletRenderResult> cacheState = cacheControlService.getPortletRenderState(httpRequest, portletWindowId);
    final CacheControl cacheControl = cacheState.getCacheControl();
    assertFalse(cacheControl.isPublicScope());
    assertNull(cacheControl.getETag());
}
Also used : MockPortletDefinitionId(org.apereo.portal.mock.portlet.om.MockPortletDefinitionId) IPortletWindowRegistry(org.apereo.portal.portlet.registry.IPortletWindowRegistry) IPortletEntity(org.apereo.portal.portlet.om.IPortletEntity) PortletRenderResult(org.apereo.portal.portlet.rendering.PortletRenderResult) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) CacheControl(javax.portlet.CacheControl) IPortletWindow(org.apereo.portal.portlet.om.IPortletWindow) Test(org.junit.Test)

Example 27 with MockPortletWindowId

use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.

the class JpaPortalEventStoreTest method generateEvents.

protected List<PortalEvent> generateEvents() throws Exception {
    final String sessionId = "1234567890123_system_AAAAAAAAAAA";
    final PortalEvent.PortalEventBuilder eventBuilder = new PortalEvent.PortalEventBuilder(this, "example.com", sessionId, SystemPerson.INSTANCE, null);
    final Set<String> groups = ImmutableSet.of("Student", "Employee");
    final Map<String, List<String>> attributes = ImmutableMap.of("username", (List<String>) ImmutableList.of("system"), "roles", (List<String>) ImmutableList.of("student", "employee"));
    final List<PortalEvent> events = new LinkedList<PortalEvent>();
    events.add(new LoginEvent(eventBuilder, groups, attributes));
    Thread.sleep(EVENT_DELAY);
    events.add(new FolderAddedToLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n32"));
    Thread.sleep(EVENT_DELAY);
    events.add(new FolderMovedInLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n12", "n32"));
    Thread.sleep(EVENT_DELAY);
    events.add(new FolderDeletedFromLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n24", "n32", "My Tab"));
    Thread.sleep(EVENT_DELAY);
    events.add(new PortletAddedToLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n32", "portletA"));
    Thread.sleep(EVENT_DELAY);
    events.add(new PortletMovedInLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n32", "n24", "portletA"));
    Thread.sleep(EVENT_DELAY);
    events.add(new PortletDeletedFromLayoutPortalEvent(eventBuilder, SystemPerson.INSTANCE, 1, "n24", "portletA"));
    final PortletExecutionEvent.PortletExecutionEventBuilder portletExecutionEventBuilder = new PortletExecutionEvent.PortletExecutionEventBuilder(eventBuilder, new MockPortletWindowId("pw1"), "fname", 12345, Collections.EMPTY_MAP, WindowState.NORMAL, PortletMode.VIEW);
    Thread.sleep(EVENT_DELAY);
    events.add(new PortletActionExecutionEvent(portletExecutionEventBuilder));
    Thread.sleep(EVENT_DELAY);
    events.add(new PortletEventExecutionEvent(portletExecutionEventBuilder, new QName("http://www.jasig.org/foo", "event", "e")));
    Thread.sleep(EVENT_DELAY);
    events.add(new PortletRenderExecutionEvent(portletExecutionEventBuilder, true, false));
    Thread.sleep(EVENT_DELAY);
    events.add(new PortletResourceExecutionEvent(portletExecutionEventBuilder, "someImage.jpg", false, false));
    Thread.sleep(EVENT_DELAY);
    events.add(new LogoutEvent(eventBuilder));
    return events;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) LinkedList(java.util.LinkedList) List(java.util.List) QName(javax.xml.namespace.QName) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) LinkedList(java.util.LinkedList)

Example 28 with MockPortletWindowId

use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.

the class UrlSyntaxProviderImplTest method testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlGeneration.

@Test
public void testSingleFolderPortletDelegationFnameSubscribeIdMinimizedRenderUrlGeneration() throws Exception {
    final String layoutNodeId = "n2";
    final String subscribeId1 = "s3";
    final String subscribeId2 = "dlg-71-44";
    final String fname = "fname";
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setContextPath("/uPortal");
    final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("pw1");
    final MockPortletWindowId portletWindowId2 = new MockPortletWindowId("pw2");
    when(portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
    when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
    when(urlNodeSyntaxHelper.getFolderNamesForLayoutNode(request, subscribeId1)).thenReturn(Arrays.asList(layoutNodeId));
    when(urlNodeSyntaxHelper.getFolderNameForPortlet(request, portletWindowId1)).thenReturn(fname + "." + subscribeId1);
    when(portletWindowRegistry.getPortletWindow(request, portletWindowId1)).thenReturn(portletWindow1);
    when(portletWindow1.getPortletEntity()).thenReturn(portletEntity1);
    when(portletEntity1.getLayoutNodeId()).thenReturn(subscribeId1);
    when(portletWindowRegistry.getPortletWindow(request, portletWindowId2)).thenReturn(portletWindow2);
    when(portletWindow2.getPortletEntity()).thenReturn(portletEntity2);
    when(portletWindow2.getDelegationParentId()).thenReturn(portletWindowId1);
    when(portletEntity2.getLayoutNodeId()).thenReturn(subscribeId2);
    final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, layoutNodeId, portletWindowId1, UrlType.RENDER);
    final IPortletUrlBuilder portletUrlBuilder1 = portalUrlBuilder.getPortletUrlBuilder(portletWindowId1);
    portletUrlBuilder1.setWindowState(WindowState.MINIMIZED);
    portletUrlBuilder1.setParameter("action", "dashboard");
    final IPortletUrlBuilder portletUrlBuilder2 = portalUrlBuilder.getPortletUrlBuilder(portletWindowId2);
    portletUrlBuilder2.setParameter("a", "b");
    portletUrlBuilder2.setParameter("b", "c");
    portletUrlBuilder2.setPortletMode(PortletMode.HELP);
    final String url = portalUrlBuilder.getUrlString();
    assertEquals("/uPortal/f/n2/normal/render.uP?pCt=fname.s3&pCs=minimized&pP_action=dashboard&pCd_pw2=pw1&pCm_pw2=help&pP_pw2_a=b&pP_pw2_b=c&pCa=pw2", url);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) Test(org.junit.Test)

Example 29 with MockPortletWindowId

use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.

the class UrlSyntaxProviderImplTest method testLegacyPortletUrlParsingNoParams.

@Test
public void testLegacyPortletUrlParsingNoParams() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setContextPath("/portal");
    request.setRequestURI("/render.userLayoutRootNode.uP");
    request.setQueryString("?uP_fname=contact-information");
    request.addParameter("uP_fname", "contact-information");
    final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("u110l1n41");
    when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
    when(this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, "contact-information")).thenReturn(this.portletWindow1);
    when(this.portletWindow1.getPortletWindowId()).thenReturn(portletWindowId1);
    final IPortalRequestInfo portalRequestInfo = this.urlSyntaxProvider.getPortalRequestInfo(request);
    assertNotNull(portalRequestInfo);
    assertNull(portalRequestInfo.getTargetedLayoutNodeId());
    assertEquals(portletWindowId1, portalRequestInfo.getTargetedPortletWindowId());
    assertEquals(UrlState.MAX, portalRequestInfo.getUrlState());
    assertEquals(UrlType.RENDER, portalRequestInfo.getUrlType());
    final Map<IPortletWindowId, ? extends IPortletRequestInfo> portletRequestInfoMap = portalRequestInfo.getPortletRequestInfoMap();
    assertNotNull(portletRequestInfoMap);
    assertEquals(1, portletRequestInfoMap.size());
    final IPortletRequestInfo portletRequestInfo = portletRequestInfoMap.get(portletWindowId1);
    assertNotNull(portletRequestInfo);
    assertEquals(portletWindowId1, portletRequestInfo.getPortletWindowId());
    assertEquals(Collections.emptyMap(), portletRequestInfo.getPortletParameters());
    assertEquals(WindowState.MAXIMIZED, portletRequestInfo.getWindowState());
    assertNull(portletRequestInfo.getDelegateParentWindowId());
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) IPortletWindowId(org.apereo.portal.portlet.om.IPortletWindowId) Test(org.junit.Test)

Example 30 with MockPortletWindowId

use of org.apereo.portal.mock.portlet.om.MockPortletWindowId in project uPortal by Jasig.

the class UrlSyntaxProviderImplTest method testSingleFolderPortletFnameSubscribeIdMinimizedRenderUrlGeneration.

@Test
public void testSingleFolderPortletFnameSubscribeIdMinimizedRenderUrlGeneration() throws Exception {
    final String layoutNodeId = "n2";
    final String subscribeId = "s3";
    final String fname = "fname";
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setContextPath("/uPortal");
    final MockPortletWindowId portletWindowId = new MockPortletWindowId("pw1");
    when(portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
    when(urlNodeSyntaxHelperRegistry.getCurrentUrlNodeSyntaxHelper(request)).thenReturn(urlNodeSyntaxHelper);
    when(urlNodeSyntaxHelper.getFolderNamesForLayoutNode(request, subscribeId)).thenReturn(Arrays.asList(layoutNodeId));
    when(urlNodeSyntaxHelper.getFolderNameForPortlet(request, portletWindowId)).thenReturn(fname + "." + subscribeId);
    when(portletWindowRegistry.getPortletWindow(request, portletWindowId)).thenReturn(portletWindow1);
    when(portletWindow1.getPortletEntity()).thenReturn(portletEntity1);
    when(portletEntity1.getLayoutNodeId()).thenReturn(subscribeId);
    final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, layoutNodeId, portletWindowId, UrlType.RENDER);
    final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
    portletUrlBuilder.setWindowState(WindowState.MINIMIZED);
    portletUrlBuilder.setParameter("action", "dashboard");
    final String url = portalUrlBuilder.getUrlString();
    assertEquals("/uPortal/f/n2/normal/render.uP?pCt=fname.s3&pCs=minimized&pP_action=dashboard", url);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) Test(org.junit.Test)

Aggregations

MockPortletWindowId (org.apereo.portal.mock.portlet.om.MockPortletWindowId)35 Test (org.junit.Test)33 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)30 IPortletWindowId (org.apereo.portal.portlet.om.IPortletWindowId)16 CacheControl (javax.portlet.CacheControl)6 MockPortletDefinitionId (org.apereo.portal.mock.portlet.om.MockPortletDefinitionId)6 PortletRenderResult (org.apereo.portal.portlet.rendering.PortletRenderResult)5 IPortletWindow (org.apereo.portal.portlet.om.IPortletWindow)3 StringWriter (java.io.StringWriter)2 WindowState (javax.portlet.WindowState)2 QName (javax.xml.namespace.QName)2 Transformer (javax.xml.transform.Transformer)2 StreamResult (javax.xml.transform.stream.StreamResult)2 IPortletUrlBuilder (org.apereo.portal.url.IPortletUrlBuilder)2 Diff (org.custommonkey.xmlunit.Diff)2 ImmutableList (com.google.common.collect.ImmutableList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1