Example usage for com.liferay.portal.kernel.util PortalUtil PortalUtil

List of usage examples for com.liferay.portal.kernel.util PortalUtil PortalUtil

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util PortalUtil PortalUtil.

Prototype

PortalUtil

Source Link

Usage

From source file:com.liferay.adaptive.media.web.internal.processor.DefaultAdaptiveMediaURIResolverTest.java

License:Open Source License

@Before
public void setUp() {
    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(_portal);//from w  ww  . j  ava  2 s  .com

    ReflectionTestUtil.setFieldValue(_uriResolver, "_portal", _portal);
}

From source file:com.liferay.adaptive.media.web.internal.processor.DefaultAMURIResolverTest.java

License:Open Source License

@Before
public void setUp() {
    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(_portal);/*from  w  w w . jav  a  2 s  .  co m*/

    ReflectionTestUtil.setFieldValue(_amURIResolver, "_portal", _portal);
}

From source file:com.liferay.blogs.internal.util.PingbackMethodImplTest.java

License:Open Source License

protected void setUpPortalUtil() throws Exception {
    when(_portal.getLayoutFullURL(Matchers.anyLong(), Matchers.eq(BlogsPortletKeys.BLOGS)))
            .thenReturn(_LAYOUT_FULL_URL);

    when(_portal.getPlidFromFriendlyURL(Matchers.eq(_COMPANY_ID), Matchers.anyString()))
            .thenReturn(RandomTestUtil.randomLong());

    when(_portal.getScopeGroupId(Matchers.anyLong())).thenReturn(RandomTestUtil.randomLong());

    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(_portal);/*from   w  w w . jav  a  2s .c  om*/
}

From source file:com.liferay.blogs.web.internal.portlet.action.TrackbackMVCActionCommandTest.java

License:Open Source License

protected void setUpPortalUtil() throws Exception {
    PortalUtil portalUtil = new PortalUtil();

    Portal portal = mock(Portal.class);

    when(portal.getOriginalServletRequest((HttpServletRequest) Matchers.any()))
            .thenReturn(_mockOriginalServletRequest);

    when(portal.getHttpServletRequest((PortletRequest) Matchers.any())).thenReturn(_mockHttpServletRequest);

    when(portal.getHttpServletResponse((PortletResponse) Matchers.any())).thenReturn(_mockHttpServletResponse);

    portalUtil.setPortal(portal);//from ww  w  .  ja va  2s  . co  m
}

From source file:com.liferay.dynamic.data.lists.form.web.internal.display.context.DDLFormAdminDisplayContextTest.java

License:Open Source License

protected void setUpPortalUtil() {
    PortalUtil portalUtil = new PortalUtil();

    Portal portal = mock(Portal.class);

    HttpServletRequest request = mockHttpServletRequest();

    when(portal.getHttpServletRequest(Matchers.any(PortletRequest.class))).thenReturn(request);

    portalUtil.setPortal(portal);/*from  ww  w.  j a  va2s.c  o  m*/
}

From source file:com.liferay.dynamic.data.lists.form.web.internal.display.context.DDLFormDisplayContextTest.java

License:Open Source License

protected void setUpPortalUtil() {
    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(mock(Portal.class));
}

From source file:com.liferay.dynamic.data.mapping.form.evaluator.impl.internal.DDMFormEvaluatorHelperTest.java

License:Open Source License

protected void setPortalUtil() throws Exception {
    PortalUtil portalUtil = new PortalUtil();

    Portal portal = mock(Portal.class);

    when(portal.getUser(_request)).thenReturn(_user);
    when(portal.getCompany(_request)).thenReturn(_company);

    portalUtil.setPortal(portal);/* w  ww  .j a v  a2 s. co  m*/
}

From source file:com.liferay.dynamic.data.mapping.form.evaluator.internal.DDMFormEvaluatorHelperTest.java

License:Open Source License

protected void setUpPortalUtil() throws Exception {
    PortalUtil portalUtil = new PortalUtil();

    Portal portal = Mockito.mock(Portal.class);

    Mockito.when(portal.getUser(_request)).thenReturn(_user);

    Mockito.when(portal.getCompany(_request)).thenReturn(_company);

    portalUtil.setPortal(portal);//from  w w  w . ja  va  2  s .c om
}

From source file:com.liferay.dynamic.data.mapping.form.evaluator.internal.functions.BelongsToRoleFunctionTest.java

License:Open Source License

protected void setPortalUtil() throws Exception {
    PortalUtil portalUtil = new PortalUtil();

    Portal portal = Mockito.mock(Portal.class);

    Mockito.when(portal.getUser(_request)).thenReturn(_user);

    Mockito.when(portal.getCompany(_request)).thenReturn(_company);

    portalUtil.setPortal(portal);//from  w  w  w. j a  v  a  2 s .  c  om
}

From source file:com.liferay.exportimport.internal.content.processor.test.DefaultExportImportContentProcessorTest.java

License:Open Source License

@Test
public void testExportLayoutReferencesWithContext() throws Exception {
    PortalImpl portalImpl = new PortalImpl() {

        @Override//from w w  w.j  a  v  a 2  s  .  c o m
        public String getPathContext() {
            return "/de";
        }

    };

    PortalUtil portalUtil = new PortalUtil();

    portalUtil.setPortal(portalImpl);

    Portal originalPortal = ReflectionTestUtil
            .getAndSetFieldValue(_layoutReferencesExportImportContentProcessor, "_portal", portalImpl);

    _oldLayoutFriendlyURLPrivateUserServletMapping = PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING;

    setFinalStaticField(PropsValues.class.getField("LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING"), "/en");

    Class<?> clazz = _layoutReferencesExportImportContentProcessor.getClass();

    setFinalStaticField(clazz.getDeclaredField("_PRIVATE_USER_SERVLET_MAPPING"), "/en/");

    String content = replaceParameters(getContent("layout_references.txt"), _fileEntry);

    _exportImportContentProcessor.validateContentReferences(_stagingGroup.getGroupId(), content);

    content = _exportImportContentProcessor.replaceExportContentReferences(_portletDataContextExport,
            _referrerStagedModel, content, true, true);

    Assert.assertFalse(content, content.contains(VirtualLayoutConstants.CANONICAL_URL_SEPARATOR));
    Assert.assertFalse(content, content.contains(GroupConstants.CONTROL_PANEL_FRIENDLY_URL));
    Assert.assertFalse(content, content.contains(PropsValues.CONTROL_PANEL_LAYOUT_FRIENDLY_URL));
    Assert.assertFalse(content,
            content.contains(PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING));
    Assert.assertFalse(content, content.contains(PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING));
    Assert.assertTrue(content,
            content.contains("@data_handler_group_friendly_url@@" + _stagingGroup.getFriendlyURL() + "@"));
    Assert.assertTrue(content, content.contains("@data_handler_path_context@/en@"));
    Assert.assertFalse(content, content.contains("@data_handler_path_context@/de@"));

    setFinalStaticField(PropsValues.class.getDeclaredField("LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING"),
            _oldLayoutFriendlyURLPrivateUserServletMapping);

    setFinalStaticField(clazz.getDeclaredField("_PRIVATE_USER_SERVLET_MAPPING"),
            PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING + StringPool.SLASH);

    portalUtil.setPortal(new PortalImpl());

    ReflectionTestUtil.setFieldValue(_layoutReferencesExportImportContentProcessor, "_portal", originalPortal);
}