Search in sources :

Example 1 with DefaultDocumentFormatRegistry

use of org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry in project xwiki-platform by xwiki.

the class DefaultOfficeResourceViewerTest method configure.

/**
 * Test fixture.
 *
 * @throws Exception in case of an exception raised during the fixture preparation
 */
@Before
public void configure() throws Exception {
    final CacheManager cacheManager = mocker.getInstance(CacheManager.class);
    attachmentCache = mock(Cache.class, "attachment");
    externalCache = mock(Cache.class, "external");
    when(cacheManager.<OfficeDocumentView>createNewCache(notNull(CacheConfiguration.class))).thenReturn(attachmentCache, externalCache);
    EntityReferenceSerializer<String> entityReferenceSerializer = mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
    when(entityReferenceSerializer.serialize(ATTACHMENT_REFERENCE)).thenReturn(STRING_ATTACHMENT_REFERENCE);
    when(entityReferenceSerializer.serialize(ATTACHMENT_REFERENCE.getDocumentReference())).thenReturn(STRING_DOCUMENT_REFERENCE);
    AttachmentReferenceResolver<String> attachmentReferenceResolver = mocker.getInstance(AttachmentReferenceResolver.TYPE_STRING, "current");
    when(attachmentReferenceResolver.resolve(STRING_ATTACHMENT_REFERENCE)).thenReturn(ATTACHMENT_REFERENCE);
    this.resourceReferenceSerializer = mocker.getInstance(ResourceReferenceTypeSerializer.class);
    when(this.resourceReferenceSerializer.serialize(ATTACHMENT_RESOURCE_REFERENCE)).thenReturn(STRING_ATTACHMENT_RESOURCE_REFERENCE);
    ConverterManager converterManager = mocker.getInstance(ConverterManager.class);
    when(converterManager.convert(boolean.class, null)).thenReturn(false);
    when(converterManager.convert(DocumentReference.class, ATTACHMENT_REFERENCE.getDocumentReference())).thenReturn(ATTACHMENT_REFERENCE.getDocumentReference());
    documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
    officeDocumentBuilder = mocker.getInstance(XDOMOfficeDocumentBuilder.class);
    OfficeServer officeServer = mocker.getInstance(OfficeServer.class);
    OfficeConverter officeConverter = mock(OfficeConverter.class);
    when(officeServer.getConverter()).thenReturn(officeConverter);
    when(officeConverter.getFormatRegistry()).thenReturn(new DefaultDocumentFormatRegistry());
}
Also used : DefaultDocumentFormatRegistry(org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) OfficeServer(org.xwiki.officeimporter.server.OfficeServer) OfficeConverter(org.xwiki.officeimporter.converter.OfficeConverter) ConverterManager(org.xwiki.properties.ConverterManager) ResourceReferenceTypeSerializer(org.xwiki.rendering.renderer.reference.ResourceReferenceTypeSerializer) CacheManager(org.xwiki.cache.CacheManager) XDOMOfficeDocumentBuilder(org.xwiki.officeimporter.builder.XDOMOfficeDocumentBuilder) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) Cache(org.xwiki.cache.Cache) Before(org.junit.Before)

Example 2 with DefaultDocumentFormatRegistry

use of org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry in project xwiki-platform by xwiki.

the class DefaultOfficeViewerScriptServiceTest method isMimeTypeSupported.

@Test
public void isMimeTypeSupported() throws Exception {
    OfficeServer officeServer = mocker.getInstance(OfficeServer.class);
    OfficeConverter officeConverter = mock(OfficeConverter.class);
    when(officeServer.getConverter()).thenReturn(officeConverter);
    when(officeConverter.getFormatRegistry()).thenReturn(new DefaultDocumentFormatRegistry());
    for (String mediaType : Arrays.asList("application/vnd.oasis.opendocument.text", "application/msword", "application/vnd.oasis.opendocument.presentation", "application/vnd.ms-powerpoint", "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.ms-excel")) {
        Assert.assertTrue(mocker.getComponentUnderTest().isMimeTypeSupported(mediaType));
    }
    for (String mediaType : Arrays.asList("foo/bar", "application/pdf")) {
        Assert.assertFalse(mocker.getComponentUnderTest().isMimeTypeSupported(mediaType));
    }
}
Also used : DefaultDocumentFormatRegistry(org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry) OfficeServer(org.xwiki.officeimporter.server.OfficeServer) OfficeConverter(org.xwiki.officeimporter.converter.OfficeConverter) Test(org.junit.Test)

Aggregations

DefaultDocumentFormatRegistry (org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry)2 OfficeConverter (org.xwiki.officeimporter.converter.OfficeConverter)2 OfficeServer (org.xwiki.officeimporter.server.OfficeServer)2 Before (org.junit.Before)1 Test (org.junit.Test)1 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)1 Cache (org.xwiki.cache.Cache)1 CacheManager (org.xwiki.cache.CacheManager)1 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)1 XDOMOfficeDocumentBuilder (org.xwiki.officeimporter.builder.XDOMOfficeDocumentBuilder)1 ConverterManager (org.xwiki.properties.ConverterManager)1 ResourceReferenceTypeSerializer (org.xwiki.rendering.renderer.reference.ResourceReferenceTypeSerializer)1