List of usage examples for com.liferay.portal.kernel.util PortalUtil setPortal
public void setPortal(Portal portal)
From source file:com.liferay.exportimport.internal.content.processor.test.DefaultExportImportContentProcessorTest.java
License:Open Source License
@Test public void testInvalidLayoutReferencesCauseNoSuchLayoutException() throws Exception { PortalImpl portalImpl = new PortalImpl() { @Override/* w w w. j a v a 2 s.c o m*/ public String getPathContext() { return "/de"; } }; PortalUtil portalUtil = new PortalUtil(); portalUtil.setPortal(portalImpl); String content = replaceParameters(getContent("invalid_layout_references.txt"), _fileEntry); String[] layoutReferences = StringUtil.split(content, StringPool.NEW_LINE); for (String layoutReference : layoutReferences) { if (!layoutReference.contains(PortalUtil.getPathContext())) { continue; } boolean noSuchLayoutExceptionThrown = false; try { _exportImportContentProcessor.validateContentReferences(_stagingGroup.getGroupId(), layoutReference); } catch (NoSuchLayoutException nsle) { noSuchLayoutExceptionThrown = true; } Assert.assertTrue(layoutReference + " was not flagged as invalid", noSuchLayoutExceptionThrown); } portalUtil.setPortal(new PortalImpl()); }
From source file:com.liferay.item.selector.web.internal.ItemSelectorImplTest.java
License:Open Source License
@Before public void setUp() { _flickrItemSelectorCriterion = new FlickrItemSelectorCriterion(); List<ItemSelectorReturnType> desiredItemSelectorReturnTypes = new ArrayList<>(); desiredItemSelectorReturnTypes.add(_testURLItemSelectorReturnType); _flickrItemSelectorCriterion.setDesiredItemSelectorReturnTypes(desiredItemSelectorReturnTypes); _itemSelectorImpl = new ItemSelectorImpl(); _stubItemSelectorCriterionSerializer.addItemSelectorReturnType(_testFileEntryItemSelectorReturnType); _stubItemSelectorCriterionSerializer.addItemSelectorReturnType(_testStringItemSelectorReturnType); _stubItemSelectorCriterionSerializer.addItemSelectorReturnType(_testURLItemSelectorReturnType); _itemSelectorImpl.setItemSelectorCriterionSerializer(_stubItemSelectorCriterionSerializer); ReflectionTestUtil.setFieldValue(_itemSelectorImpl, "_http", new HttpImpl()); ReflectionTestUtil.setFieldValue(_itemSelectorImpl, "_portal", new PortalImpl()); _mediaItemSelectorCriterion = new MediaItemSelectorCriterion(); _mediaItemSelectorCriterion.setFileExtension("jpg"); _mediaItemSelectorCriterion.setMaxSize(2048); desiredItemSelectorReturnTypes = new ArrayList<>(); desiredItemSelectorReturnTypes.add(new TestFileEntryItemSelectorReturnType()); desiredItemSelectorReturnTypes.add(_testURLItemSelectorReturnType); _mediaItemSelectorCriterion.setDesiredItemSelectorReturnTypes(desiredItemSelectorReturnTypes); HttpUtil httpUtil = new HttpUtil(); httpUtil.setHttp(new HttpImpl()); JSONFactoryUtil jsonFactoryUtil = new JSONFactoryUtil(); jsonFactoryUtil.setJSONFactory(new JSONFactoryImpl()); PortalUtil portalUtil = new PortalUtil(); portalUtil.setPortal(new PortalImpl()); }
From source file:com.liferay.message.boards.comment.internal.MBCommentManagerImplTest.java
License:Open Source License
protected void setUpPortalUtil() { PortalUtil portalUtil = new PortalUtil(); portalUtil.setPortal(_portal); }
From source file:it.infn.ct.indigo.futuregateway.portlet.action.FGAddAppMVCActionCommandTest.java
License:Apache License
/** * Prepare the environment./*from ww w. java2s . c o m*/ * @throws Exception In case of a problem to replicate Liferay context */ @Before public final void setUp() throws Exception { JSONFactoryUtil jsonFactoryUtil = new JSONFactoryUtil(); jsonFactoryUtil.setJSONFactory(new JSONFactoryImpl()); PortalUtil pu = new PortalUtil(); pu.setPortal(portalImpl); Mockito.when(themeDisplay.getCompanyId()).thenReturn(0L); Mockito.when(themeDisplay.getUserId()).thenReturn(0L); Mockito.when(themeDisplay.getLayout()).thenReturn(layout); Mockito.when(layout.isTypeControlPanel()).thenReturn(true); Mockito.when(actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG)).thenReturn(portletConfig); Mockito.when(portletConfig.getInitParameter("add-process-action-success-action")).thenReturn("true"); Mockito.when(actionRequest.getAttribute(WebKeys.THEME_DISPLAY)).thenReturn(themeDisplay); Mockito.when(actionRequest.getParameter("redirect")).thenReturn(null); Mockito.when(portalImpl.getUploadPortletRequest(Mockito.any(PortletRequest.class))) .thenReturn(uploadRequest); Mockito.when(portalImpl.getHttpServletRequest(Mockito.any(PortletRequest.class))).thenReturn(httpRequest); Mockito.when(portalImpl.getOriginalServletRequest(Mockito.any(HttpServletRequest.class))) .thenReturn(httpRequest); Mockito.when(liferayRequest.getPortletName()).thenReturn(""); Mockito.when(portalImpl.getLiferayPortletRequest(Mockito.any(PortletRequest.class))) .thenReturn(liferayRequest); }
From source file:it.infn.ct.indigo.futuregateway.portlet.action.FGAddInfraMVCActionCommandTest.java
License:Apache License
/** * Prepare the environment./* ww w . j a v a 2 s .c o m*/ * @throws Exception In case of a problem to replicate Liferay context */ @Before public final void setUp() throws Exception { JSONFactoryUtil jsonFactoryUtil = new JSONFactoryUtil(); jsonFactoryUtil.setJSONFactory(new JSONFactoryImpl()); PortalUtil pu = new PortalUtil(); pu.setPortal(portalImpl); Mockito.when(themeDisplay.getCompanyId()).thenReturn(0L); Mockito.when(themeDisplay.getUserId()).thenReturn(0L); Mockito.when(themeDisplay.getLayout()).thenReturn(layout); Mockito.when(layout.isTypeControlPanel()).thenReturn(true); Mockito.when(actionRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG)).thenReturn(portletConfig); Mockito.when(portletConfig.getInitParameter("add-process-action-success-action")).thenReturn("true"); Mockito.when(actionRequest.getAttribute(WebKeys.THEME_DISPLAY)).thenReturn(themeDisplay); Mockito.when(actionRequest.getParameter("redirect")).thenReturn(null); Mockito.when(portalImpl.getHttpServletRequest(Mockito.any(PortletRequest.class))).thenReturn(httpRequest); Mockito.when(portalImpl.getOriginalServletRequest(Mockito.any(HttpServletRequest.class))) .thenReturn(httpRequest); Mockito.when(liferayRequest.getPortletName()).thenReturn(""); Mockito.when(portalImpl.getLiferayPortletRequest(Mockito.any(PortletRequest.class))) .thenReturn(liferayRequest); }