Search in sources :

Example 16 with MockPortletWindowId

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

the class UrlSyntaxProviderImplTest method testSingleFolderPortletFnameSubscribeIdRenderUrlGeneration.

@Test
public void testSingleFolderPortletFnameSubscribeIdRenderUrlGeneration() 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 String url = portalUrlBuilder.getUrlString();
    assertEquals("/uPortal/f/n2/normal/render.uP?pCt=fname.s3", url);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) Test(org.junit.Test)

Example 17 with MockPortletWindowId

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

the class UrlSyntaxProviderImplTest method testLegacyPortletUrlParsing.

@Test
public void testLegacyPortletUrlParsing() throws Exception {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setContextPath("/uPortal");
    request.setRequestURI("/render.userLayoutRootNode.uP");
    request.setQueryString("?uP_fname=CourseGuide-Browse-Courses&pltc_type=ACTION&pltc_state=detached&pltc_mode=view&pltp_action=advancedSearch&pltp_subjectChoice=512");
    request.addParameter("uP_fname", "CourseGuide-Browse-Courses");
    request.addParameter("pltc_type", "ACTION");
    request.addParameter("pltc_state", "detached");
    request.addParameter("pltc_mode", "view");
    request.addParameter("pltp_action", "advancedSearch");
    request.addParameter("pltp_subjectChoice", "512");
    final MockPortletWindowId portletWindowId1 = new MockPortletWindowId("16_ctf3_5");
    when(this.portalRequestUtils.getOriginalPortalRequest(request)).thenReturn(request);
    when(this.portletWindowRegistry.getOrCreateDefaultPortletWindowByFname(request, "CourseGuide-Browse-Courses")).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.DETACHED, portalRequestInfo.getUrlState());
    assertEquals(UrlType.ACTION, 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(ImmutableMap.of("action", Arrays.asList("advancedSearch"), "subjectChoice", Arrays.asList("512")), portletRequestInfo.getPortletParameters());
    assertEquals(IPortletRenderer.DETACHED, portletRequestInfo.getWindowState());
    assertEquals(PortletMode.VIEW, portletRequestInfo.getPortletMode());
    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 18 with MockPortletWindowId

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

the class UrlSyntaxProviderImplTest method testSingleFolderPortletFnameSubscribeIdDetachedRenderUrlGeneration.

@Test
public void testSingleFolderPortletFnameSubscribeIdDetachedRenderUrlGeneration() 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(portletWindow1.getWindowState()).thenReturn(IPortletRenderer.DETACHED);
    when(portletWindow1.getPortletMode()).thenReturn(PortletMode.VIEW);
    when(portletEntity1.getLayoutNodeId()).thenReturn(subscribeId);
    final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, layoutNodeId, portletWindowId, UrlType.RENDER);
    final IPortletUrlBuilder portletUrlBuilder = portalUrlBuilder.getPortletUrlBuilder(portletWindowId);
    portletUrlBuilder.setPortletMode(PortletMode.EDIT);
    final String url = portalUrlBuilder.getUrlString();
    assertEquals("/uPortal/f/n2/p/fname.s3/detached/render.uP?pCm=edit", url);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) Test(org.junit.Test)

Example 19 with MockPortletWindowId

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

the class UrlSyntaxProviderImplTest method testDetachedResourceUrlGeneration.

@Test
public void testDetachedResourceUrlGeneration() throws Exception {
    final String layoutNodeId = "u12l1s5";
    final String subscribeId = "u12l1n7";
    final String fname = "news";
    final String resourceId = "calendar.2012-06-01.7";
    final MockHttpServletRequest request = new MockHttpServletRequest();
    request.setContextPath("/uPortal");
    final MockPortletWindowId portletWindowId1 = 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, portletWindowId1)).thenReturn(fname + "." + subscribeId);
    when(portletWindowRegistry.getPortletWindow(request, portletWindowId1)).thenReturn(portletWindow1);
    when(portletWindow1.getPortletEntity()).thenReturn(portletEntity1);
    when(portletWindow1.getWindowState()).thenReturn(IPortletRenderer.DETACHED);
    when(portletEntity1.getLayoutNodeId()).thenReturn(subscribeId);
    final PortalUrlBuilder portalUrlBuilder = new PortalUrlBuilder(urlSyntaxProvider, request, layoutNodeId, portletWindowId1, UrlType.RESOURCE);
    final IPortletUrlBuilder portletUrlBuilder1 = portalUrlBuilder.getPortletUrlBuilder(portletWindowId1);
    portletUrlBuilder1.setResourceId(resourceId);
    portletUrlBuilder1.setCacheability(ResourceURL.PAGE);
    final String url = portalUrlBuilder.getUrlString();
    assertEquals("/uPortal/f/u12l1s5/p/news.u12l1n7/detached/calendar.2012-06-01.7.resource.uP?pCc=cacheLevelPage", url);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockPortletWindowId(org.apereo.portal.mock.portlet.om.MockPortletWindowId) Test(org.junit.Test)

Example 20 with MockPortletWindowId

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

the class UrlSyntaxProviderImplTest method testParsePortletWindowIdSuffix.

@Test
public void testParsePortletWindowIdSuffix() {
    final MockHttpServletRequest request = new MockHttpServletRequest();
    final Set<String> ids = ImmutableSet.of("pw2");
    final MockPortletWindowId expectedPortletWindowId = new MockPortletWindowId("pw2");
    when(this.portletWindowRegistry.getPortletWindowId(request, "pw2")).thenReturn(expectedPortletWindowId);
    IPortletWindowId portletWindowId = this.urlSyntaxProvider.parsePortletWindowIdSuffix(request, UrlSyntaxProviderImpl.PARAM_WINDOW_STATE, ids, UrlSyntaxProviderImpl.PARAM_WINDOW_STATE + UrlSyntaxProviderImpl.SEPARATOR + "pw2");
    assertEquals(expectedPortletWindowId, portletWindowId);
    portletWindowId = this.urlSyntaxProvider.parsePortletWindowIdSuffix(request, UrlSyntaxProviderImpl.PARAM_WINDOW_STATE, ids, UrlSyntaxProviderImpl.PARAM_WINDOW_STATE + UrlSyntaxProviderImpl.SEPARATOR + UrlSyntaxProviderImpl.SEPARATOR + "pw2");
    assertNull(portletWindowId);
    portletWindowId = this.urlSyntaxProvider.parsePortletWindowIdSuffix(request, UrlSyntaxProviderImpl.PARAM_WINDOW_STATE, ids, UrlSyntaxProviderImpl.PARAM_WINDOW_STATE);
    assertNull(portletWindowId);
}
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)

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