@Test public void testExportLinksToLayouts() throws Exception { Element rootElement = _portletDataContextExport.getExportDataRootElement(); String content = replaceParameters(getContent("layout_links.txt"), _fileEntry); content = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, rootElement.element("entry"), content, true); StringBundler sb = new StringBundler(5); sb.append("[1@private-group@"); sb.append(_stagingPrivateLayout.getUuid()); sb.append(StringPool.AT); sb.append(_stagingPrivateLayout.getFriendlyURL()); sb.append(StringPool.CLOSE_BRACKET); Assert.assertTrue(content.contains(sb.toString())); sb.setIndex(0); sb.append("[1@public@"); sb.append(_stagingPublicLayout.getUuid()); sb.append(StringPool.AT); sb.append(_stagingPublicLayout.getFriendlyURL()); sb.append(StringPool.CLOSE_BRACKET); Assert.assertTrue(content.contains(sb.toString())); }
@Test public void testExportDLReferences() throws Exception { Element rootElement = _portletDataContextExport.getExportDataRootElement(); String content = replaceParameters(getContent("dl_references.txt"), _fileEntry); List<String> urls = getURLs(content); content = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, rootElement.element("entry"), content, true); for (String url : urls) { Assert.assertFalse(content.contains(url)); } TestReaderWriter testReaderWriter = (TestReaderWriter) _portletDataContextExport.getZipWriter(); List<String> entries = testReaderWriter.getEntries(); Assert.assertEquals(entries.size(), 1); List<String> binaryEntries = testReaderWriter.getBinaryEntries(); Assert.assertEquals(binaryEntries.size(), entries.size()); for (String entry : testReaderWriter.getEntries()) { Assert.assertTrue(content.contains("[$dl-reference=" + entry + "$]")); } ; }
@Test public void testImportLinksToLayouts() throws Exception { Element rootElement = _portletDataContextExport.getExportDataRootElement(); Element entryElement = rootElement.element("entry"); String content = replaceParameters(getContent("layout_links.txt"), _fileEntry); content = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, entryElement, content, true); String importedContent = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, entryElement, content, true); Assert.assertEquals(importedContent, content); }
@Test public void testExportLayoutReferencesWithContext() throws Exception { PortalImpl portalImpl = spy(new PortalImpl()); when(portalImpl.getPathContext()).thenReturn("/de"); PortalUtil portalUtil = new PortalUtil(); portalUtil.setPortal(portalImpl); _OLD_LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING = PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING; setFinalStaticField( PropsValues.class.getField("LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING"), "/en"); setFinalStaticField( ExportImportHelperImpl.class.getDeclaredField("_PRIVATE_USER_SERVLET_MAPPING"), "/en/"); Element rootElement = _portletDataContextExport.getExportDataRootElement(); String content = replaceParameters(getContent("layout_references.txt"), _fileEntry); content = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, rootElement.element("entry"), content, true); Assert.assertFalse( content.contains(PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING)); Assert.assertFalse(content.contains(PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING)); Assert.assertFalse(content.contains(_stagingGroup.getFriendlyURL())); Assert.assertFalse(content.contains(PortalUtil.getPathContext())); Assert.assertFalse(content.contains("/en/en")); setFinalStaticField( PropsValues.class.getDeclaredField("LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING"), _OLD_LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING); setFinalStaticField( ExportImportHelperImpl.class.getDeclaredField("_PRIVATE_USER_SERVLET_MAPPING"), PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING + StringPool.SLASH); portalUtil.setPortal(new PortalImpl()); }
@Test public void testImportDLReferences() throws Exception { Element rootElement = _portletDataContextExport.getExportDataRootElement(); Element entryElement = rootElement.element("entry"); String content = replaceParameters(getContent("dl_references.txt"), _fileEntry); content = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, entryElement, content, true); content = ExportImportHelperUtil.replaceImportContentReferences( _portletDataContextImport, entryElement, content, true); Assert.assertFalse(content.contains("[$dl-reference=")); }
@Test public void testImportLayoutReferences() throws Exception { Element rootElement = _portletDataContextExport.getExportDataRootElement(); Element entryElement = rootElement.element("entry"); String content = replaceParameters(getContent("layout_references.txt"), _fileEntry); content = ExportImportHelperUtil.replaceExportContentReferences( _portletDataContextExport, _referrerStagedModel, entryElement, content, true); content = ExportImportHelperUtil.replaceImportContentReferences( _portletDataContextExport, entryElement, content, true); Assert.assertFalse(content.contains("@data_handler_group_friendly_url@")); Assert.assertFalse(content.contains("@data_handler_path_context@")); Assert.assertFalse(content.contains("@data_handler_private_group_servlet_mapping@")); Assert.assertFalse(content.contains("@data_handler_private_user_servlet_mapping@")); Assert.assertFalse(content.contains("@data_handler_public_servlet_mapping@")); }