Merged V2.1 to HEAD

6636: Temporary hack to fix build.  
   6637: Better handling of binary string bufs, disable link validation when poll interval is <= 0
   6638: Forgotten files for TXT to PDF transformer.
   6639: Fix for AWC-1541
   6641: Fix for WCM-792.
   6642: A little extra PropertyValue support for createNode, too.
   6643: Fix for WCM-791
   6644: Closure of AR-1528: Check concurrency handling of DuplicateChildNodeNameException
   6647: Fix WCM-794
   6648: WCM-656
   6650: Applied user supplied patch to fix AWC-1546 - Cannot mount AVM using CIFS on new alfresco installation.
   6651: Index tidy ups
   6654: Various minor updates for passthru authentication debugging and error handling.
   6657: Fix for WCM-799 (Some items selected for submission were not present)
   6659: Updated installers.
   6660: Partial fix to AWC-1524
   6661: Fix WCM-803
   6664: Including  hibernate-3.2.1.jar in $VIRTUAL_TOMCAT_HOME/server/lib/ 
   6665: adding an automated unit test for output path patterns.
   6668: Fixed to add shale-test-1.0.4.jar to Eclipse classpath (PHH oked)
   6681: Fixes WCM-811 - Lookup.getIndirectionPath() had a bit of a howler in it.
   6684: UncategorizedSQLException with the word 'deadlock' in the message is now cause for retrying a transaction.
   6691: Fix for WCM-813 (lock not removed when expiration date set and no workflow on web project)
   6696: Imporved SSO filters for SiteMinder etc + test filter
   6697: Support for scheduled import
   6699: Fix for the compliation target:  compile-benchmarkframework 
   6701: Fix for 1.6 JVMs (1.5 gets by with lucky ordering)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6749 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-11 04:18:53 +00:00
parent f279d99d80
commit ac03bb5f8c
14 changed files with 486 additions and 728 deletions

View File

@@ -37,6 +37,7 @@ import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -201,8 +202,9 @@ public class FormImpl
te);
}
result = AVMUtil.buildPath(parentAVMPath,
result,
AVMUtil.PathRelation.SANDBOX_RELATIVE);
result,
AVMUtil.PathRelation.SANDBOX_RELATIVE);
result = AVMNodeConverter.NormalizePath(result);
LOGGER.debug("processed pattern " + outputPathPattern + " as " + result);
return result;
}

View File

@@ -0,0 +1,274 @@
/*
* Copyright (C) 2005-2007 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.web.forms;
import java.io.*;
import java.util.*;
import org.alfresco.service.namespace.QName;
import org.alfresco.model.WCMAppModel;
import junit.framework.AssertionFailedError;
import org.alfresco.service.cmr.repository.*;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.util.BaseSpringTest;
import org.alfresco.web.forms.XMLUtil;
import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.jxpath.Pointer;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chiba.xml.ns.NamespaceConstants;
import org.chiba.xml.events.XFormsEventNames;
import org.chiba.xml.events.XMLEvent;
import org.chiba.xml.xforms.ChibaBean;
import org.chiba.xml.xforms.exception.XFormsException;
import org.chiba.xml.xforms.XFormsElement;
import org.chiba.xml.events.DOMEventNames;
import org.w3c.dom.*;
import org.w3c.dom.events.*;
import org.xml.sax.*;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.model.*;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.util.TestWithUserUtils;
import org.apache.shale.test.mock.*;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.StaticWebApplicationContext;
/**
* JUnit tests to exercise parts of the forms codebase
*
* @author ariel backenroth
*/
public class FormsTest
extends BaseSpringTest
{
/////////////////////////////////////////////////////////////////////////////
private static class MockForm
extends FormImpl
{
MockForm(final NodeRef folderNodeRef,
final FormsService formsService)
{
super(folderNodeRef, formsService);
}
public void setOutputPathPattern(final String opp)
{
final NodeService nodeService = this.getServiceRegistry().getNodeService();
nodeService.setProperty(this.getNodeRef(), WCMAppModel.PROP_OUTPUT_PATH_PATTERN, opp);
}
}
/////////////////////////////////////////////////////////////////////////////
private final static Log LOGGER = LogFactory.getLog(FormsTest.class);
private final static String WEB_CLIENT_APPLICATION_CONTEXT =
"classpath:alfresco/web-client-application-context.xml";
private NodeService nodeService;
private FormsService formsService;
private MockForm mockForm;
protected void onSetUpInTransaction()
throws Exception
{
System.err.println("onSetUpInTransaction");
super.onSetUpInTransaction();
this.nodeService = (NodeService)super.applicationContext.getBean("dbNodeService");
assertNotNull(this.nodeService);
final FileFolderService fileFolderService = (FileFolderService)
super.applicationContext.getBean("fileFolderService");
assertNotNull(fileFolderService);
this.formsService = (FormsService)super.applicationContext.getBean("FormsService");
assertNotNull(this.formsService);
final AuthenticationService authenticationService = (AuthenticationService)
applicationContext.getBean("authenticationService");
authenticationService.clearCurrentSecurityContext();
final MutableAuthenticationDao authenticationDAO = (MutableAuthenticationDao)
applicationContext.getBean("authenticationDao");
// Create a workspace that contains the 'live' nodes
final StoreRef testStoreRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE,
"Test_" + System.currentTimeMillis());
// Get a reference to the root node
final NodeRef rootNodeRef = this.nodeService.getRootNode(testStoreRef);
// Create an authenticate the user
if(!authenticationDAO.userExists("admin"))
{
authenticationService.createAuthentication("admin", "admin".toCharArray());
}
TestWithUserUtils.authenticateUser("admin",
"admin",
rootNodeRef,
authenticationService);
// set up a faces context
final MockExternalContext ec = new MockExternalContext(new MockServletContext(),
new MockHttpServletRequest(),
new MockHttpServletResponse());
final StaticWebApplicationContext ac = new StaticWebApplicationContext();
ac.setParent(this.applicationContext);
this.applicationContext = ac;
ec.getApplicationMap().put(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
this.applicationContext);
new MockFacesContext(ec);
final FileInfo folderInfo =
fileFolderService.create(rootNodeRef,
"test_form",
WCMAppModel.TYPE_FORMFOLDER);
final HashMap<QName, Serializable> props = new HashMap<QName, Serializable>();
this.nodeService.addAspect(folderInfo.getNodeRef(),
WCMAppModel.ASPECT_FORM,
props);
this.mockForm = new MockForm(folderInfo.getNodeRef(), this.formsService);
}
@Override
protected String[] getConfigLocations()
{
return (String[])ArrayUtils.add(super.getConfigLocations(),
WEB_CLIENT_APPLICATION_CONTEXT);
}
@Override
protected ConfigurableApplicationContext loadContext(Object key)
throws Exception
{
return new ClassPathXmlApplicationContext((String[])key);
}
public void testOutputPathPatternForFormInstanceData()
throws Exception
{
class OutputPathPatternTest
{
public final String expected;
public final String pattern;
public final Document xml;
public final String name;
public final String parentAVMPath;
public final String webapp;
public OutputPathPatternTest(final String expected,
final String pattern,
final Document xml,
final String name,
final String parentAVMPath,
final String webapp)
{
this.expected = expected;
this.pattern = pattern;
this.xml = xml;
this.name = name;
this.parentAVMPath = parentAVMPath;
this.webapp = webapp;
}
}
final OutputPathPatternTest[] opps = new OutputPathPatternTest[] {
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
"${name}.xml",
XMLUtil.parse("<foo/>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/foo.xml",
"/${name}.xml",
XMLUtil.parse("<foo/>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml",
"/${webapp}/${name}.xml",
XMLUtil.parse("<foo/>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/foo.xml",
"/${webapp}/${name}.xml",
XMLUtil.parse("<foo/>"),
"foo",
"avmstore:/www/avm_webapps/another_webapp/dir",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir1/dir2/foo.xml",
"/${webapp}/${cwd}/${name}.xml",
XMLUtil.parse("<foo/>"),
"foo",
"avmstore:/www/avm_webapps/another_webapp/dir1/dir2",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/" + Calendar.getInstance().get(Calendar.YEAR) + "_foo.xml",
"${date?string('yyyy')}_${name}.xml",
XMLUtil.parse("<foo/>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
"${xml.root_tag.name}.xml",
XMLUtil.parse("<root_tag><name>foo</name></root_tag>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/07.xml",
"${xml.root_tag.date?date('yyyy-MM-dd')?string('MM')}.xml",
XMLUtil.parse("<root_tag><date>1776-07-04</date></root_tag>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp"),
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
"${xml['foons:root_tag/foons:name']}.xml",
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp")/*,
new OutputPathPatternTest("avmstore:/www/avm_webapps/webapp/dir/foo.xml",
"${xml.root_tag.name}",
XMLUtil.parse("<foons:root_tag xmlns:foons='bar'><foons:name>foo</foons:name></foons:root_tag>"),
"foo",
"avmstore:/www/avm_webapps/webapp/dir",
"webapp")*/
};
for (final OutputPathPatternTest oppt : opps)
{
this.mockForm.setOutputPathPattern(oppt.pattern);
assertEquals(oppt.pattern + " failed",
oppt.expected,
this.mockForm.getOutputPathForFormInstanceData(oppt.xml,
oppt.name,
oppt.parentAVMPath,
oppt.webapp));
}
}
}