mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged BRANCHES/DEV/V4.1-BUG-FIX to HEAD:
46383: ALF-17893: CLONE - Mappings for Metadata Extractors Should be Defined in Config - Added support for new alfresco/metadata location will preserving backwards compatibility with the old location - Added tests for support of properties in the new location, the old location, and that on missing properties the error thrown indicates the new location - Updated JavaDoc for new alfresco/metadata location git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@46392 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,6 +28,7 @@ import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.repo.content.metadata.MetadataExtracter.OverwritePolicy;
|
||||
@@ -68,6 +69,42 @@ public class MappingMetadataExtracterTest extends TestCase
|
||||
assertTrue("Extracter not initialized.", extracter.initCheck);
|
||||
}
|
||||
|
||||
/** Test the new alfresco/metadata properties location */
|
||||
public void testSetUpPropertiesLocationMetadata()
|
||||
{
|
||||
DummyPropertiesInMetadataLocationMappingMetadataExtracter metadataLocationExtracter =
|
||||
new DummyPropertiesInMetadataLocationMappingMetadataExtracter();
|
||||
metadataLocationExtracter.register();
|
||||
assertNotNull("Extracter not initialized.", metadataLocationExtracter.getMapping());
|
||||
assertNotNull("Mapping not found",
|
||||
metadataLocationExtracter.getMapping().get(DummyMappingMetadataExtracter.PROP_A));
|
||||
}
|
||||
|
||||
/** Test that the old package-based properties location still works */
|
||||
public void testSetUpPropertiesLocationPackage()
|
||||
{
|
||||
DummyPropertiesInPackageLocationMappingMetadataExtracter packageLocationExtracter =
|
||||
new DummyPropertiesInPackageLocationMappingMetadataExtracter();
|
||||
packageLocationExtracter.register();
|
||||
assertNotNull("Extracter not initialized.", packageLocationExtracter.getMapping());
|
||||
assertNotNull("Mapping not found",
|
||||
packageLocationExtracter.getMapping().get(DummyMappingMetadataExtracter.PROP_A));
|
||||
}
|
||||
|
||||
/** Test that an extract with missing location throws the correct error */
|
||||
public void testSetUpPropertiesMissing()
|
||||
{
|
||||
DummyPropertiesMissingMappingMetadataExtracter propertiesMissingExtracter =
|
||||
new DummyPropertiesMissingMappingMetadataExtracter();
|
||||
try
|
||||
{
|
||||
propertiesMissingExtracter.register();
|
||||
} catch (AlfrescoRuntimeException e)
|
||||
{
|
||||
assertTrue(e.getMessage().contains("alfresco/metadata/"));
|
||||
}
|
||||
}
|
||||
|
||||
public void testDefaultExtract() throws Exception
|
||||
{
|
||||
destination.clear();
|
||||
@@ -277,6 +314,33 @@ public class MappingMetadataExtracterTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyPropertiesInPackageLocationMappingMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
{
|
||||
@Override
|
||||
protected Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyPropertiesInMetadataLocationMappingMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
{
|
||||
@Override
|
||||
protected Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DummyPropertiesMissingMappingMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
{
|
||||
@Override
|
||||
protected Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class JunkValue implements Serializable
|
||||
{
|
||||
private static final JunkValue INSTANCE = new JunkValue();
|
||||
|
Reference in New Issue
Block a user