mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Updated header to LGPL
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18926 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 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 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.imap;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -46,97 +64,97 @@ public class LoadTester extends TestCase
|
||||
|
||||
private ImapService imapService;
|
||||
private ImporterService importerService;
|
||||
private MutableAuthenticationService authenticationService;
|
||||
private MutableAuthenticationService authenticationService;
|
||||
|
||||
private AlfrescoImapUser user;
|
||||
// DH: Do not assume the presence of any specific user or password. Create a new user for the test.
|
||||
private static final String USER_NAME = "admin";
|
||||
private static final String USER_PASSWORD = "admin";
|
||||
private static final String TEST_IMAP_ROOT_FOLDER_NAME = "aaa";
|
||||
private static final String TEST_IMAP_ROOT_FOLDER_NAME = "aaa";
|
||||
private static final String TEST_DATA_FOLDER_NAME = "test_data";
|
||||
private static final String TEST_FOLDER_NAME = "test_imap1000";
|
||||
private static final long MESSAGE_QUANTITY = 1000;
|
||||
|
||||
private String anotherUserName;
|
||||
|
||||
private String anotherUserName;
|
||||
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
|
||||
authenticationService = serviceRegistry.getAuthenticationService();
|
||||
authenticationService = serviceRegistry.getAuthenticationService();
|
||||
imapService = serviceRegistry.getImapService();
|
||||
importerService = serviceRegistry.getImporterService();
|
||||
NodeService nodeService = serviceRegistry.getNodeService();
|
||||
SearchService searchService = serviceRegistry.getSearchService();
|
||||
NamespaceService namespaceService = serviceRegistry.getNamespaceService();
|
||||
PersonService personService = serviceRegistry.getPersonService();
|
||||
FileFolderService fileFolderService = serviceRegistry.getFileFolderService();
|
||||
TransactionService transactionService = serviceRegistry.getTransactionService();
|
||||
PermissionService permissionService = serviceRegistry.getPermissionService();
|
||||
PersonService personService = serviceRegistry.getPersonService();
|
||||
FileFolderService fileFolderService = serviceRegistry.getFileFolderService();
|
||||
TransactionService transactionService = serviceRegistry.getTransactionService();
|
||||
PermissionService permissionService = serviceRegistry.getPermissionService();
|
||||
|
||||
|
||||
// start the transaction
|
||||
UserTransaction txn = transactionService.getUserTransaction();
|
||||
txn.begin();
|
||||
|
||||
// start the transaction
|
||||
UserTransaction txn = transactionService.getUserTransaction();
|
||||
txn.begin();
|
||||
|
||||
authenticationService.authenticate(USER_NAME, USER_PASSWORD.toCharArray());
|
||||
|
||||
anotherUserName = "test_imap_user";
|
||||
|
||||
NodeRef person = personService.getPerson(anotherUserName);
|
||||
anotherUserName = "test_imap_user";
|
||||
|
||||
NodeRef person = personService.getPerson(anotherUserName);
|
||||
|
||||
if (person != null)
|
||||
if (person != null)
|
||||
{
|
||||
personService.deletePerson(anotherUserName);
|
||||
PropertyMap testUser = new PropertyMap();
|
||||
testUser.put(ContentModel.PROP_USERNAME, anotherUserName);
|
||||
testUser.put(ContentModel.PROP_FIRSTNAME, anotherUserName);
|
||||
testUser.put(ContentModel.PROP_LASTNAME, anotherUserName);
|
||||
testUser.put(ContentModel.PROP_EMAIL, anotherUserName + "@alfresco.com");
|
||||
testUser.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
||||
personService.createPerson(testUser);
|
||||
|
||||
personService.deletePerson(anotherUserName);
|
||||
PropertyMap testUser = new PropertyMap();
|
||||
testUser.put(ContentModel.PROP_USERNAME, anotherUserName);
|
||||
testUser.put(ContentModel.PROP_FIRSTNAME, anotherUserName);
|
||||
testUser.put(ContentModel.PROP_LASTNAME, anotherUserName);
|
||||
testUser.put(ContentModel.PROP_EMAIL, anotherUserName + "@alfresco.com");
|
||||
testUser.put(ContentModel.PROP_JOBTITLE, "jobTitle");
|
||||
personService.createPerson(testUser);
|
||||
|
||||
}
|
||||
if (authenticationService.authenticationExists(anotherUserName))
|
||||
{
|
||||
authenticationService.deleteAuthentication(anotherUserName);
|
||||
}
|
||||
authenticationService.createAuthentication(anotherUserName, anotherUserName.toCharArray());
|
||||
|
||||
|
||||
user = new AlfrescoImapUser(anotherUserName + "@alfresco.com", anotherUserName, anotherUserName);
|
||||
|
||||
String storePath = "workspace://SpacesStore";
|
||||
String companyHomePathInStore = "/app:company_home";
|
||||
|
||||
StoreRef storeRef = new StoreRef(storePath);
|
||||
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
|
||||
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, companyHomePathInStore, null, namespaceService, false);
|
||||
NodeRef companyHomeNodeRef = nodeRefs.get(0);
|
||||
|
||||
ChildApplicationContextFactory imap = (ChildApplicationContextFactory) ctx.getBean("imap");
|
||||
ApplicationContext imapCtx = imap.getApplicationContext();
|
||||
ImapServiceImpl imapServiceImpl = (ImapServiceImpl)imapCtx.getBean("imapService");
|
||||
|
||||
|
||||
// Delete test folder
|
||||
nodeRefs = searchService.selectNodes(storeRootNodeRef,
|
||||
companyHomePathInStore + "/" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_ROOT_FOLDER_NAME,
|
||||
null, namespaceService, false);
|
||||
if (authenticationService.authenticationExists(anotherUserName))
|
||||
{
|
||||
authenticationService.deleteAuthentication(anotherUserName);
|
||||
}
|
||||
authenticationService.createAuthentication(anotherUserName, anotherUserName.toCharArray());
|
||||
|
||||
|
||||
user = new AlfrescoImapUser(anotherUserName + "@alfresco.com", anotherUserName, anotherUserName);
|
||||
|
||||
String storePath = "workspace://SpacesStore";
|
||||
String companyHomePathInStore = "/app:company_home";
|
||||
|
||||
StoreRef storeRef = new StoreRef(storePath);
|
||||
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
|
||||
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, companyHomePathInStore, null, namespaceService, false);
|
||||
NodeRef companyHomeNodeRef = nodeRefs.get(0);
|
||||
|
||||
ChildApplicationContextFactory imap = (ChildApplicationContextFactory) ctx.getBean("imap");
|
||||
ApplicationContext imapCtx = imap.getApplicationContext();
|
||||
ImapServiceImpl imapServiceImpl = (ImapServiceImpl)imapCtx.getBean("imapService");
|
||||
|
||||
|
||||
// Delete test folder
|
||||
nodeRefs = searchService.selectNodes(storeRootNodeRef,
|
||||
companyHomePathInStore + "/" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_ROOT_FOLDER_NAME,
|
||||
null, namespaceService, false);
|
||||
if (nodeRefs.size() == 1)
|
||||
{
|
||||
NodeRef ch = nodeRefs.get(0);
|
||||
nodeService.deleteNode(ch);
|
||||
}
|
||||
|
||||
|
||||
// Creating IMAP test folder for IMAP root
|
||||
LinkedList<String> folders = new LinkedList<String>();
|
||||
folders.add(TEST_IMAP_ROOT_FOLDER_NAME);
|
||||
FileFolderServiceImpl.makeFolders(fileFolderService, companyHomeNodeRef, folders, ContentModel.TYPE_FOLDER);
|
||||
|
||||
|
||||
// Creating IMAP test folder for IMAP root
|
||||
LinkedList<String> folders = new LinkedList<String>();
|
||||
folders.add(TEST_IMAP_ROOT_FOLDER_NAME);
|
||||
FileFolderServiceImpl.makeFolders(fileFolderService, companyHomeNodeRef, folders, ContentModel.TYPE_FOLDER);
|
||||
|
||||
// Setting IMAP root
|
||||
RepositoryFolderConfigBean imapHome = new RepositoryFolderConfigBean();
|
||||
imapHome.setStore(storePath);
|
||||
@@ -146,21 +164,21 @@ public class LoadTester extends TestCase
|
||||
|
||||
// Starting IMAP
|
||||
imapServiceImpl.startup();
|
||||
|
||||
nodeRefs = searchService.selectNodes(storeRootNodeRef,
|
||||
companyHomePathInStore + "/" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_ROOT_FOLDER_NAME,
|
||||
null,
|
||||
namespaceService,
|
||||
false);
|
||||
|
||||
nodeRefs = searchService.selectNodes(storeRootNodeRef,
|
||||
companyHomePathInStore + "/" + NamespaceService.CONTENT_MODEL_PREFIX + ":" + TEST_IMAP_ROOT_FOLDER_NAME,
|
||||
null,
|
||||
namespaceService,
|
||||
false);
|
||||
|
||||
// Used to create User's folder
|
||||
NodeRef userFolderRef = imapService.getMailboxRootRef(TEST_DATA_FOLDER_NAME, anotherUserName);
|
||||
permissionService.setPermission(userFolderRef, anotherUserName, PermissionService.ALL_PERMISSIONS, true);
|
||||
// Used to create User's folder
|
||||
NodeRef userFolderRef = imapService.getMailboxRootRef(TEST_DATA_FOLDER_NAME, anotherUserName);
|
||||
permissionService.setPermission(userFolderRef, anotherUserName, PermissionService.ALL_PERMISSIONS, true);
|
||||
|
||||
importTestData("imap/load_test_data.acp", userFolderRef);
|
||||
|
||||
reauthenticate(anotherUserName, anotherUserName);
|
||||
|
||||
importTestData("imap/load_test_data.acp", userFolderRef);
|
||||
|
||||
reauthenticate(anotherUserName, anotherUserName);
|
||||
|
||||
AlfrescoImapFolder testDataFolder = imapService.getFolder(user, TEST_DATA_FOLDER_NAME);
|
||||
|
||||
SimpleStoredMessage m = testDataFolder.getMessages().get(0);
|
||||
@@ -186,18 +204,18 @@ public class LoadTester extends TestCase
|
||||
|
||||
t = System.currentTimeMillis() - t;
|
||||
logger.info("Create time: " + t + " ms (" + t/1000 + " s (" + t/60000 + " min))");
|
||||
|
||||
txn.commit();
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
|
||||
private void reauthenticate(String name, String password)
|
||||
{
|
||||
authenticationService.invalidateTicket(authenticationService.getCurrentTicket(), null);
|
||||
authenticationService.clearCurrentSecurityContext();
|
||||
authenticationService.authenticate(name, password.toCharArray());
|
||||
}
|
||||
|
||||
private void reauthenticate(String name, String password)
|
||||
{
|
||||
authenticationService.invalidateTicket(authenticationService.getCurrentTicket(), null);
|
||||
authenticationService.clearCurrentSecurityContext();
|
||||
authenticationService.authenticate(name, password.toCharArray());
|
||||
}
|
||||
|
||||
|
||||
public void tearDown() throws Exception
|
||||
{
|
||||
|
Reference in New Issue
Block a user