mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
125781 rmunteanu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1) 125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127808 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
87 lines
2.8 KiB
Java
87 lines
2.8 KiB
Java
package org.alfresco.repo.content.metadata;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.Calendar;
|
|
import java.util.Map;
|
|
|
|
import org.alfresco.model.ContentModel;
|
|
import org.alfresco.repo.content.MimetypeMap;
|
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.apache.pdfbox.util.DateConverter;
|
|
|
|
/**
|
|
* @see org.alfresco.repo.content.metadata.PdfBoxMetadataExtracter
|
|
*
|
|
* @author Jesper Steen Møller
|
|
*/
|
|
public class PdfBoxMetadataExtracterTest extends AbstractMetadataExtracterTest
|
|
{
|
|
private PdfBoxMetadataExtracter extracter;
|
|
|
|
@Override
|
|
public void setUp() throws Exception
|
|
{
|
|
super.setUp();
|
|
extracter = new PdfBoxMetadataExtracter();
|
|
extracter.setDictionaryService(dictionaryService);
|
|
extracter.register();
|
|
}
|
|
|
|
/**
|
|
* @return Returns the same transformer regardless - it is allowed
|
|
*/
|
|
protected MetadataExtracter getExtracter()
|
|
{
|
|
return extracter;
|
|
}
|
|
|
|
public void testSupports() throws Exception
|
|
{
|
|
for (String mimetype : PdfBoxMetadataExtracter.SUPPORTED_MIMETYPES)
|
|
{
|
|
boolean supports = extracter.isSupported(mimetype);
|
|
assertTrue("Mimetype should be supported: " + mimetype, supports);
|
|
}
|
|
}
|
|
|
|
public void testPdfExtraction() throws Exception
|
|
{
|
|
testExtractFromMimetype(MimetypeMap.MIMETYPE_PDF);
|
|
}
|
|
|
|
/**
|
|
* This test method extracts metadata from an Adobe Illustrator file (which in recent versions is a pdf file).
|
|
* @since 3.5.0
|
|
*/
|
|
public void testAiExtraction() throws Exception
|
|
{
|
|
testExtractFromMimetype(MimetypeMap.MIMETYPE_APPLICATION_ILLUSTRATOR);
|
|
}
|
|
|
|
/**
|
|
* We can also return a created date
|
|
*/
|
|
protected void testFileSpecificMetadata(String mimetype,
|
|
Map<QName, Serializable> properties) {
|
|
assertEquals(
|
|
"Property " + ContentModel.PROP_CREATED + " not found for mimetype " + mimetype,
|
|
"2005-05-26T19:52:58.000Z",
|
|
DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_CREATED)));
|
|
}
|
|
|
|
/**
|
|
* Test that will show when the workaround is in place.
|
|
*/
|
|
public void testDateConversion() throws Exception {
|
|
Calendar c = DateConverter.toCalendar("D:20050526205258+01'00'");
|
|
assertEquals(2005, c.get(Calendar.YEAR));
|
|
assertEquals(05-1, c.get(Calendar.MONTH));
|
|
assertEquals(26, c.get(Calendar.DAY_OF_MONTH));
|
|
assertEquals(20, c.get(Calendar.HOUR_OF_DAY));
|
|
assertEquals(52, c.get(Calendar.MINUTE));
|
|
assertEquals(58, c.get(Calendar.SECOND));
|
|
//assertEquals(0, c.get(Calendar.MILLISECOND));
|
|
}
|
|
}
|