alfresco-community-repo/source/java/org/alfresco/repo/site/SiteServiceImplMoreTest.java
Dave Ward 507c4d8bf8 Merged V4.0-BUG-FIX to HEAD
37207: BDE-69: Filter more tests for minimal build plan
   37253: Fix for ALF-13634 Re-created category won't show up again on a node in Document Library.
   - also fixes deletion of secondary associations
   37265: Merged V4.0 to V4.0-BUG-FIX
      37224: ALF-14174: Part 14 for ALF-14237 Upgrades from 4.0.0.x/4..0.1.0 will not fix the timestamps on acl changesets - SOLR will skip ACLs set prior to upgrade
      - Fix syntax error on Oracle
      37250: Fix for ALF-14174 The patch adding timestamps to acl_change_set breaks SOLR tracking
      - better cross DB fix
   37298:  ALF-14365 - added hazelcastConfig.xml.sample
   37323: ALF-13247: Two nodes with the same primary path. 
      -Fixed by initializing zone before parallel batch processing begins.
   37326: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
   ALF-13452 Open office startup from Java not working on OSX
      - Added code to start LibreOffice 3.5 on Mac (requires different options to the command and
        ure-link is a directory rather than a file on mac)
      - Removes $DYLD_LIBRARY_PATH from the environment when starting either openoffice or libreoffice on mac
        so does not need to rely on the installer moving the soffice.bin process to .soffice.bin and then
        creating a soffice.bin shell script that removed $DYLD_LIBRARY_PATH
      - Indent TransformerDebug a bit more now we have fail over transformers at the top and lower levels
        (saves N.N.N.N.N.N getting mixed up with text)
   37340: Merged V3.4-BUG-FIX (3.4.10) to V4.0-BUG-FIX (4.0.3) RECORD ONLY
      37339: ALF-13452: Merged V4.0-BUG-FIX (4.0.3) to V3.4-BUG-FIX (3.4.10)
         37326: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
         ALF-13452 Open office startup from Java not working on OSX
            - Added code to start LibreOffice 3.5 on Mac (requires different options to the command and
              ure-link is a directory rather than a file on mac)
            - Removes $DYLD_LIBRARY_PATH from the environment when starting either openoffice or libreoffice on mac
              so does not need to rely on the installer moving the soffice.bin process to .soffice.bin and then
              creating a soffice.bin shell script that removed $DYLD_LIBRARY_PATH
            - Indent TransformerDebug a bit more now we have fail over transformers at the top and lower levels
              (saves N.N.N.N.N.N getting mixed up with text)
         36273: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
            - Return a dummy OpenOffice command even when there is no OpenOffice/LibreOffice installed or on the path. 
         36264: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
            - remove old jodconverter-core-3.0-beta-3.diff
         36259: ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
            << Developed on Windows 7. Might need more work on Linux to get LibreOffice to shut down, but should be
               okay with OpenOffice 3.2 which was used in the previous release. >> 
            - Updated jodconverter to latest version jodconverter-core-3.0-SNAPSHOT-patched.jar 28/4/2012 which is newer
              than 3.0 beta-4
            - Applied patch for http://code.google.com/p/jodconverter/issues/detail?id=103 to handle setting the env
              for LibreOffice 3.5
            - Modified code to use partial GNU style options (not used for -env!) when using LibreOffice
            - Added OpenOfficeCommandLine to dynamically supply OpenOffice or LibreOffice command line args for OOoDirect
            - Tested to work with OpenOffice 3.4 and 3.2 on Windows 7
   37353: Merged V3.4-BUG-FIX (3.4.10) to V4.0-BUG-FIX (4.0.3)
      37352: ALF-13452, ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
         - Build test failure
   37359: New JUnit Rule to support automatic creation and cleanup of Share sites in test code.
   This is required for an imminent fix to ALF-14345, but I'm checking it in separately in order to merge this general utility.
   37360: Fix for ALF-14345. Site Service list method does not recognise sub-types of st:site.
   37364: Merged V3.4-BUG-FIX (3.4.10) to V4.0-BUG-FIX (4.0.3) RECORD ONLY (not needed in 4.0.x)
      37363: ALF-13452, ALF-13933 Alfresco needs to be able to support LibreOffice for transformations
         - Build test failure x2 (reference to jodconverter*jar not needed in 4.0.x)
   37370: Merged V3.4-BUG-FIX:
      ALF-11714: Updated WCMQS to ensure all FreeMarker variables output to HTML are protected with ?html to prevent XSS
   37382: Translation (DE, IT, JA, NL) updates from Gloria, based on EN rev37081
   37384: Fix for ALF-14219 SolrQueryHTTPClient unable to handle long queries (4096 bytes)
   37386: Merged V4.0 to V4.0-BUG-FIX
      37385: ALF-14238: Fix by Dmitry to correct iteration in ImapUnsubscribedAspectPatch


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@37387 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2012-06-02 07:56:08 +00:00

122 lines
5.6 KiB
Java

/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.site;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.site.SiteInfo;
import org.alfresco.service.cmr.site.SiteService;
import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.test.junitrules.ApplicationContextInit;
import org.alfresco.util.test.junitrules.RunAsFullyAuthenticatedRule;
import org.alfresco.util.test.junitrules.TemporarySites;
import org.alfresco.util.test.junitrules.TemporarySitesTest;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
import org.springframework.extensions.webscripts.GUID;
/**
* This class contains some tests for the {@link SiteServiceImpl} - in addition to those already
* included in {@link SiteServiceImplTest}. This uses JUnit 4 annotations and JUnit Rules.
*
* TODO Refactor the two classes together into one common approach.
*
* @author Neil Mc Erlean
* @since 4.0.3
*/
public class SiteServiceImplMoreTest
{
// Rule to initialise the default Alfresco spring configuration
public static ApplicationContextInit APP_CONTEXT_INIT = ApplicationContextInit.createStandardContextWithOverrides("classpath:sites/test-"
+ TemporarySitesTest.class.getSimpleName() + "-context.xml");
// A rule to manage test nodes reused across all the test methods
public static TemporarySites STATIC_TEST_SITES = new TemporarySites(APP_CONTEXT_INIT);
// Tie them together in a static Rule Chain
@ClassRule public static RuleChain ruleChain = RuleChain.outerRule(APP_CONTEXT_INIT)
.around(STATIC_TEST_SITES);
@Rule public RunAsFullyAuthenticatedRule runAllTestsAsAdmin = new RunAsFullyAuthenticatedRule(AuthenticationUtil.getAdminUserName());
// Various services
private static NamespaceService NAMESPACE_SERVICE;
private static SiteService SITE_SERVICE;
private static RetryingTransactionHelper TRANSACTION_HELPER;
private static String TEST_SITE_NAME, TEST_SUB_SITE_NAME;
@BeforeClass public static void initStaticData() throws Exception
{
NAMESPACE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("namespaceService", NamespaceService.class);
SITE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("siteService", SiteService.class);
TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class);
// We'll create this test content as admin.
final String admin = AuthenticationUtil.getAdminUserName();
TEST_SITE_NAME = GUID.generate();
TEST_SUB_SITE_NAME = GUID.generate();
final QName subSiteType = QName.createQName("testsite", "testSubsite", NAMESPACE_SERVICE);
STATIC_TEST_SITES.createSite("sitePreset", TEST_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, admin);
STATIC_TEST_SITES.createSite("sitePreset", TEST_SUB_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, subSiteType, admin);
}
/**
* This method ensures that {@link SiteService#listSites(String)} includes content subtypes of {@link SiteModel#TYPE_SITE st:site}.
*/
@Test public void listSitesIncludingSubTypesOfSite() throws Exception
{
TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
{
PagingResults<SiteInfo> sites = SITE_SERVICE.listSites(null, null, new PagingRequest(0, 1024));
Map<String, SiteInfo> sitesByName = new HashMap<String, SiteInfo>();
for (SiteInfo site : sites.getPage())
{
sitesByName.put(site.getShortName(), site);
}
assertNotNull("st:site missing.", sitesByName.get(TEST_SITE_NAME));
assertNotNull("subtype of st:site missing.", sitesByName.get(TEST_SUB_SITE_NAME));
return null;
}
});
}
}