Merged V2.9 to HEAD

8960: Stop tests running if image transformer not available
   8991: Fix AR-2099
   8993: Fix AR-2099 - fix test fallout


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9031 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2008-05-08 10:46:36 +00:00
parent 5fe540e1cb
commit 76cea3002b
6 changed files with 205 additions and 204 deletions

View File

@@ -45,7 +45,7 @@
<value>/app:company_home/app:dictionary/app:models</value> <value>/app:company_home/app:dictionary/app:models</value>
</property> </property>
<property name="queryLanguage"> <property name="queryLanguage">
<value>lucene</value> <value>xpath</value>
</property> </property>
</bean> </bean>
@@ -55,7 +55,7 @@
<value>/app:company_home/app:dictionary/app:messages</value> <value>/app:company_home/app:dictionary/app:messages</value>
</property> </property>
<property name="queryLanguage"> <property name="queryLanguage">
<value>lucene</value> <value>xpath</value>
</property> </property>
</bean> </bean>

View File

@@ -35,7 +35,6 @@ import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.ClassDefinition; import org.alfresco.service.cmr.dictionary.ClassDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
import org.alfresco.service.cmr.dictionary.ModelDefinition; import org.alfresco.service.cmr.dictionary.ModelDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition;
@@ -199,12 +198,12 @@ public class DictionaryComponent implements DictionaryService, TenantDeployer
ClassDefinition classDef = getClass(className); ClassDefinition classDef = getClass(className);
if (classDef == null) if (classDef == null)
{ {
throw new InvalidTypeException(className); return false;
} }
ClassDefinition ofClassDef = getClass(ofClassName); ClassDefinition ofClassDef = getClass(ofClassName);
if (ofClassDef == null) if (ofClassDef == null)
{ {
throw new InvalidTypeException(ofClassName); return false;
} }
// Only check if both ends are either a type or an aspect // Only check if both ends are either a type or an aspect

View File

@@ -44,7 +44,6 @@ import org.alfresco.service.cmr.dictionary.Constraint;
import org.alfresco.service.cmr.dictionary.ConstraintDefinition; import org.alfresco.service.cmr.dictionary.ConstraintDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.InvalidTypeException;
import org.alfresco.service.cmr.dictionary.ModelDefinition; import org.alfresco.service.cmr.dictionary.ModelDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition; import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition; import org.alfresco.service.cmr.dictionary.TypeDefinition;
@@ -311,19 +310,15 @@ public class DictionaryDAOTest extends TestCase
QName referenceable = QName.createQName(TEST_URL, "referenceable"); QName referenceable = QName.createQName(TEST_URL, "referenceable");
// Test invalid args // Test invalid args
try boolean testI1 = service.isSubClass(invalid, referenceable);
{
service.isSubClass(invalid, referenceable);
fail("Failed to catch invalid class parameter");
}
catch(InvalidTypeException e) {}
try assertFalse(testI1);
{
service.isSubClass(referenceable, invalid); boolean testI2 = service.isSubClass(referenceable, invalid);
fail("Failed to catch invalid class parameter"); assertFalse(testI2);
}
catch(InvalidTypeException e) {} boolean testI3 = service.isSubClass(invalid, invalid);
assertFalse(testI3);
// Test various flavours of subclassof // Test various flavours of subclassof
boolean test1 = service.isSubClass(file, referenceable); // type vs aspect boolean test1 = service.isSubClass(file, referenceable); // type vs aspect

View File

@@ -43,7 +43,6 @@ import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef; import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService; import org.alfresco.service.transaction.TransactionService;
@@ -236,19 +235,23 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
continue; // skip this location continue; // skip this location
} }
if (repositoryLocation.getQueryLanguage().equals(SearchService.LANGUAGE_LUCENE)) if (repositoryLocation.getQueryLanguage().equals(SearchService.LANGUAGE_XPATH))
{ {
ResultSet rs = searchService.query(storeRef, NodeRef rootNode = nodeService.getRootNode(storeRef);
SearchService.LANGUAGE_LUCENE,
repositoryLocation.getLuceneQueryStatement(ContentModel.TYPE_DICTIONARY_MODEL.getPrefixedQName(namespaceService))); List<NodeRef> nodeRefs = searchService.selectNodes(rootNode,
if (rs.length() > 0) repositoryLocation.getXPathQueryStatement(ContentModel.TYPE_DICTIONARY_MODEL.getPrefixedQName(namespaceService)),
{ null,
for (NodeRef dictionaryModel : rs.getNodeRefs()) namespaceService,
false);
for (NodeRef dictionaryModel : nodeRefs)
{ {
// Ignore if the node is a working copy or if its inactive // Ignore if the node is a working copy or if its inactive
if (nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_WORKING_COPY) == false) if (nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_WORKING_COPY) == false)
{ {
Boolean isActive = (Boolean)nodeService.getProperty(dictionaryModel, ContentModel.PROP_MODEL_ACTIVE); Boolean isActive = (Boolean)nodeService.getProperty(dictionaryModel, ContentModel.PROP_MODEL_ACTIVE);
if ((isActive != null) && (isActive.booleanValue() == true)) if ((isActive != null) && (isActive.booleanValue() == true))
{ {
M2Model model = createM2Model(dictionaryModel); M2Model model = createM2Model(dictionaryModel);
@@ -263,7 +266,6 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
} }
} }
} }
}
else else
{ {
logger.error("Unsupported query language for models location: " + repositoryLocation.getQueryLanguage()); logger.error("Unsupported query language for models location: " + repositoryLocation.getQueryLanguage());
@@ -287,7 +289,6 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
for (RepositoryLocation repositoryLocation : this.repositoryMessagesLocations) for (RepositoryLocation repositoryLocation : this.repositoryMessagesLocations)
{ {
StoreRef storeRef = repositoryLocation.getStoreRef(); StoreRef storeRef = repositoryLocation.getStoreRef();
String path = repositoryLocation.getPath();
if (! nodeService.exists(storeRef)) if (! nodeService.exists(storeRef))
{ {
@@ -295,15 +296,19 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
continue; // skip this location continue; // skip this location
} }
if (repositoryLocation.getQueryLanguage().equals(SearchService.LANGUAGE_LUCENE)) if (repositoryLocation.getQueryLanguage().equals(SearchService.LANGUAGE_XPATH))
{
ResultSet rs = searchService.query(storeRef,
SearchService.LANGUAGE_LUCENE,
repositoryLocation.getLuceneQueryStatement(ContentModel.TYPE_CONTENT.getPrefixedQName(namespaceService)));
if (rs.length() > 0)
{ {
NodeRef rootNode = nodeService.getRootNode(storeRef);
List<NodeRef> nodeRefs = searchService.selectNodes(rootNode,
repositoryLocation.getXPathQueryStatement(ContentModel.TYPE_CONTENT.getPrefixedQName(namespaceService)),
null,
namespaceService,
false);
List<String> resourceBundleBaseNames = new ArrayList<String>(); List<String> resourceBundleBaseNames = new ArrayList<String>();
for (NodeRef messageResource : rs.getNodeRefs())
for (NodeRef messageResource : nodeRefs)
{ {
String resourceName = (String) nodeService.getProperty( String resourceName = (String) nodeService.getProperty(
messageResource, ContentModel.PROP_NAME); messageResource, ContentModel.PROP_NAME);
@@ -315,16 +320,6 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
resourceBundleBaseNames.add(bundleBaseName); resourceBundleBaseNames.add(bundleBaseName);
} }
} }
// Only need to register resource bundle names
for (String resourceBundleBaseName : resourceBundleBaseNames)
{
logger.info("Register bundle: " + resourceBundleBaseName);
messageService.registerResourceBundle(storeRef.toString() + path + "/cm:" + resourceBundleBaseName);
}
}
} }
else else
{ {

View File

@@ -110,7 +110,7 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest
RepositoryLocation location = new RepositoryLocation(); RepositoryLocation location = new RepositoryLocation();
location.setStoreProtocol(this.storeRef.getProtocol()); location.setStoreProtocol(this.storeRef.getProtocol());
location.setStoreId(this.storeRef.getIdentifier()); location.setStoreId(this.storeRef.getIdentifier());
location.setQueryLanguage(SearchService.LANGUAGE_LUCENE); location.setQueryLanguage(SearchService.LANGUAGE_XPATH);
// NOTE: we are not setting the path for now .. in doing so we are searching the whole dictionary // NOTE: we are not setting the path for now .. in doing so we are searching the whole dictionary
List<RepositoryLocation> locations = new ArrayList<RepositoryLocation>(); List<RepositoryLocation> locations = new ArrayList<RepositoryLocation>();

View File

@@ -82,6 +82,9 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
} }
public void testCreateThumbnailFromImage() throws Exception public void testCreateThumbnailFromImage() throws Exception
{
// Check that the image transformations are available
if (this.contentService.getImageTransformer() != null)
{ {
NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG); NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG);
NodeRef gifOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_GIF); NodeRef gifOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_GIF);
@@ -98,6 +101,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
MimetypeMap.MIMETYPE_IMAGE_JPEG, MimetypeMap.MIMETYPE_IMAGE_JPEG,
imageTransformationOptions, imageTransformationOptions,
"small"); "small");
NodeRef thumbnail1 = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, createOptions); NodeRef thumbnail1 = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, createOptions);
assertNotNull(thumbnail1); assertNotNull(thumbnail1);
checkThumbnailed(jpgOrig, "small"); checkThumbnailed(jpgOrig, "small");
@@ -155,11 +159,13 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
checkThumbnailed(gifOrig, "half2"); checkThumbnailed(gifOrig, "half2");
checkThumbnail(thumbnail4, imageTransformationOptions4); checkThumbnail(thumbnail4, imageTransformationOptions4);
outputThumbnailTempContentLocation(thumbnail4, "jpg", "half2 - 50%x50%, from gif"); outputThumbnailTempContentLocation(thumbnail4, "jpg", "half2 - 50%x50%, from gif");
}
} }
public void testDuplicationNames() public void testDuplicationNames()
throws Exception throws Exception
{
if (contentService.getImageTransformer() != null)
{ {
NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG); NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG);
ImageResizeOptions imageResizeOptions = new ImageResizeOptions(); ImageResizeOptions imageResizeOptions = new ImageResizeOptions();
@@ -187,9 +193,12 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
// OK since this should have been thrown // OK since this should have been thrown
} }
} }
}
public void testThumbnailUpdate() public void testThumbnailUpdate()
throws Exception throws Exception
{
if (contentService.getImageTransformer() != null)
{ {
// First create a thumbnail // First create a thumbnail
NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG); NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG);
@@ -207,12 +216,14 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
// Update the thumbnail // Update the thumbnail
this.thumbnailService.updateThumbnail(thumbnail1); this.thumbnailService.updateThumbnail(thumbnail1);
}
} }
public void testGetThumbnailByName() public void testGetThumbnailByName()
throws Exception throws Exception
{
if (contentService.getImageTransformer() != null)
{ {
NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG); NodeRef jpgOrig = createOrigionalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG);
@@ -242,6 +253,7 @@ public class ThumbnailServiceImplTest extends BaseAlfrescoSpringTest
NodeRef result3 = this.thumbnailService.getThumbnailByName(jpgOrig, ContentModel.PROP_CONTENT, "anotherone"); NodeRef result3 = this.thumbnailService.getThumbnailByName(jpgOrig, ContentModel.PROP_CONTENT, "anotherone");
assertNull("The thumbnail 'anotherone' should have been missing", result3); assertNull("The thumbnail 'anotherone' should have been missing", result3);
} }
}
// TODO test getThumbnails // TODO test getThumbnails