mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
15596: Merged V3.1 to V3.2 14017: Fix ETHREEOH-1880 - remove (double-)reverse of WCM staging snapshot order 14112: Fix ETHREEOH-1758 - apply contributed patch 14447: Merged V2.2 to V3.1 14276: ETWOTWO-1224 / WCM-948 - browsing staging area during (commit of) large submit can cause AVMNotFoundException: Path /www/avm_webapps not found. 14452: Add WCM services-based unit test for ETWOTWO-1224 / WCM-948 14589: ETHREEOH-1646 - User Sandboxes aren't visible for Content Publisher 15604: Merged V3.1 to V3.2 14734: Merged V2.2 to V3.1 14718: ETWOTWO-1244 - unable to revert some snapshots ("Does not exist: xxx") 14852: Merged V2.2 to V3.1 14720: ETWOTWO-1183 - "Show All Sandboxes" checkbox should only be visible for "Content Publisher" or "Content Manager" 15032: Fix ETHREEOH-2240 - delete WCM web project (does not clean-up workflow sandboxes and also appears in archive store) 15037: Fix ETHREEOH-2240 - follow-on for Alfresco Explorer's Manage (Review) Task Dialog 15056: Fix ETHREEOH-2297 - WCM layered folder - problem deleting file 15072: Minor - fix remote AVM test 15605: Merged V3.1 to V3.2 15082: Merged V2.2 to V3.1 15081: AVM - add tests only 15083: Fix ETHREEOH-2296 - user conflict when updating an AVM layered file 15118: Merged V2.2 to V3.1 15115: Fix ETWOTWO-1265 - WCM locking not working as expected (+ add WCM services test) 15137: Fix ETHREEOH-2309 and ETHREEOH-227 - including refactor (& clean-up) of WCM-related actions 15156: Fix ETHREEOH-2078 & ETHREEOH-2040 - WCM - deploy to localhost causes "Must have at least one store" errors 15175: Fix ETHREEOH-2309 and ETHREEOH-227 - further clean-up of WCM submit/undo actions (for consistency) 15190: Minor: message updates for WCM submit/undo actions git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16858 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
248 lines
9.5 KiB
Java
248 lines
9.5 KiB
Java
/*
|
|
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
* As a special exception to the terms and conditions of version 2.0 of
|
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
|
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
|
* FLOSS exception. You should have recieved a copy of the text describing
|
|
* the FLOSS exception, and it is also available here:
|
|
* http://www.alfresco.com/legal/licensing" */
|
|
|
|
package org.alfresco.wcm;
|
|
|
|
import java.io.File;
|
|
import java.io.PrintWriter;
|
|
import java.io.StringWriter;
|
|
|
|
import javax.transaction.UserTransaction;
|
|
|
|
import org.alfresco.config.JNDIConstants;
|
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
|
import org.alfresco.wcm.asset.AssetService;
|
|
import org.alfresco.wcm.sandbox.SandboxService;
|
|
|
|
/**
|
|
*/
|
|
public class WCMConcurrentTest extends AbstractWCMServiceImplTest
|
|
{
|
|
private SandboxService sbService;
|
|
private AssetService assetService;
|
|
|
|
private final static String ADMIN = "admin";
|
|
|
|
private final static String WP = TEST_WEBPROJ_DNS;
|
|
|
|
private final static String SB_STG = WP;
|
|
private final static String SB_ADMIN = WP+"--"+ADMIN;
|
|
|
|
private final static String AVM_WEBAPPS_PATH = JNDIConstants.DIR_DEFAULT_WWW+"/"+JNDIConstants.DIR_DEFAULT_APPBASE;
|
|
private final static String ROOT_PATH = AVM_WEBAPPS_PATH+"/"+"ROOT";
|
|
|
|
//protected static final boolean CLEAN = false; // cleanup during teardown
|
|
|
|
@Override
|
|
protected void setUp() throws Exception
|
|
{
|
|
super.setUp();
|
|
|
|
// Get the required services
|
|
sbService = (SandboxService)ctx.getBean("SandboxService");
|
|
assetService = (AssetService)ctx.getBean("AssetService");
|
|
}
|
|
|
|
|
|
/**
|
|
*/
|
|
public void test_ETWOTWO_1224() throws Exception
|
|
{
|
|
try
|
|
{
|
|
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN);
|
|
|
|
wpService.createWebProject(WP, WP, "title", "description");
|
|
|
|
assertEquals(1, wpService.listWebApps(WP).size());
|
|
|
|
assertEquals(0, assetService.listAssets(SB_STG, ROOT_PATH, false).size());
|
|
assertEquals(0, assetService.listAssets(SB_ADMIN, ROOT_PATH, false).size());
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
System.out.println("Bulk import started ...");
|
|
|
|
// bulk import
|
|
|
|
// ETWOTWO-1224 / WCM-948 - also fails with AVMNotFoundException !!!
|
|
int listingRepeat = 100; // listing web apps
|
|
String testFile = System.getProperty("user.dir") + "/source/test-resources/wcm/small-61-items.zip";
|
|
|
|
File zipFile = new File(testFile);
|
|
assetService.bulkImport(SB_ADMIN, ROOT_PATH, zipFile, false);
|
|
|
|
int itemCount = assetService.listAssets(SB_ADMIN, ROOT_PATH, false).size();
|
|
|
|
System.out.println("Items below ROOT: "+itemCount);
|
|
|
|
assert(itemCount > 0);
|
|
|
|
System.out.println("... bulk import finished in "+(System.currentTimeMillis()-start)+" msecs");
|
|
|
|
assertEquals(0, assetService.listAssets(SB_STG, ROOT_PATH, false).size());
|
|
assertEquals(itemCount, assetService.listAssets(SB_ADMIN, ROOT_PATH, false).size());
|
|
|
|
UserTransaction tx = transactionService.getUserTransaction();
|
|
|
|
tx.begin();
|
|
|
|
start = System.currentTimeMillis();
|
|
|
|
System.out.println("Submit initiation started ...");
|
|
|
|
// submit (from workflow sandbox to staging sandbox and also update user sandbox)
|
|
sbService.submitAll(SB_ADMIN , "s1", "s1");
|
|
|
|
tx.commit();
|
|
|
|
System.out.println("... submit initiation finished in "+(System.currentTimeMillis()-start)+" msecs");
|
|
|
|
|
|
int threadCount = 1;
|
|
|
|
Thread[] threads = new Thread[threadCount];
|
|
|
|
WCMConcurrentTestListing[] listings = new WCMConcurrentTestListing[threadCount];
|
|
|
|
for (int i = 0; i < threadCount; i++)
|
|
{
|
|
WCMConcurrentTestListing listing = new WCMConcurrentTestListing(i, listingRepeat);
|
|
listings[i] = listing;
|
|
threads[i] = new Thread(listing);
|
|
threads[i].start();
|
|
}
|
|
|
|
// join each thread so that we wait for them all to finish
|
|
for (int i = 0; i < threads.length; i++)
|
|
{
|
|
try
|
|
{
|
|
threads[i].join();
|
|
|
|
if (listings[i].getErrorStackTrace() != null)
|
|
{
|
|
throw new RuntimeException(listings[i].getErrorStackTrace());
|
|
}
|
|
}
|
|
catch (InterruptedException e)
|
|
{
|
|
// not too serious - the worker threads are non-daemon
|
|
}
|
|
}
|
|
|
|
assertEquals(1, wpService.listWebApps(WP).size());
|
|
|
|
assertEquals(itemCount, assetService.listAssets(SB_STG, ROOT_PATH, false).size());
|
|
assertEquals(itemCount, assetService.listAssets(SB_ADMIN, ROOT_PATH, false).size());
|
|
}
|
|
finally
|
|
{
|
|
AuthenticationUtil.clearCurrentSecurityContext();
|
|
}
|
|
}
|
|
|
|
private class WCMConcurrentTestListing implements Runnable
|
|
{
|
|
private int id;
|
|
private int repeat;
|
|
private String errorStackTrace = null;
|
|
|
|
public WCMConcurrentTestListing(int id, int repeat)
|
|
{
|
|
this.id = id;
|
|
this.repeat = repeat;
|
|
}
|
|
|
|
public String getErrorStackTrace()
|
|
{
|
|
return errorStackTrace;
|
|
}
|
|
|
|
public void run()
|
|
{
|
|
UserTransaction tx = null;
|
|
try
|
|
{
|
|
AuthenticationUtil.setFullyAuthenticatedUser(ADMIN);
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
for (int i = 1; i <= repeat; i++)
|
|
{
|
|
tx = transactionService.getUserTransaction();
|
|
|
|
try
|
|
{
|
|
tx.begin();
|
|
|
|
System.out.println("Start: id: "+id+" - loop="+i+" ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
|
|
|
assertEquals(1, wpService.listWebApps(WP).size());
|
|
|
|
Thread.sleep(500);
|
|
|
|
System.out.println("Finish: id: "+id+" - loop="+i+" ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
|
|
|
tx.commit();
|
|
|
|
//System.out.println("Post-commit: id: "+id+" - loop="+i+" ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
|
}
|
|
catch (Throwable t)
|
|
{
|
|
if (errorStackTrace == null)
|
|
{
|
|
StringWriter sw = new StringWriter();
|
|
t.printStackTrace(new PrintWriter(sw));
|
|
|
|
errorStackTrace = sw.toString();
|
|
}
|
|
|
|
System.err.println("Failed: id: "+id+" - loop="+i+" ["+AlfrescoTransactionSupport.getTransactionId()+"] "+t.getMessage());
|
|
|
|
if (tx != null) { try { tx.rollback(); } catch(Exception e) { }}
|
|
}
|
|
}
|
|
|
|
System.out.println("id: "+id+" finished (repeated "+repeat+" times) in "+(System.currentTimeMillis()-start)+" msecs");
|
|
}
|
|
catch (Throwable t)
|
|
{
|
|
System.out.println(t.getMessage());
|
|
|
|
if (tx != null) { try { tx.rollback(); } catch(Exception e) { }}
|
|
|
|
StringWriter sw = new StringWriter();
|
|
t.printStackTrace(new PrintWriter(sw));
|
|
|
|
errorStackTrace = sw.toString();
|
|
}
|
|
finally
|
|
{
|
|
AuthenticationUtil.clearCurrentSecurityContext();
|
|
}
|
|
}
|
|
}
|
|
}
|