Search in sources :

Example 1 with OfficeServer

use of org.xwiki.officeimporter.server.OfficeServer 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 OfficeServer

use of org.xwiki.officeimporter.server.OfficeServer in project xwiki-platform by xwiki.

the class DefaultXHTMLOfficeDocumentBuilderTest method configure.

@Before
public void configure() throws Exception {
    this.officeConverter = mock(OfficeConverter.class);
    OfficeServer officeServer = this.mocker.getInstance(OfficeServer.class);
    when(officeServer.getConverter()).thenReturn(this.officeConverter);
    this.officeHTMLCleaner = this.mocker.getInstance(HTMLCleaner.class, "openoffice");
    this.entityReferenceSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
}
Also used : OfficeServer(org.xwiki.officeimporter.server.OfficeServer) OfficeConverter(org.xwiki.officeimporter.converter.OfficeConverter) HTMLCleaner(org.xwiki.xml.html.HTMLCleaner) Before(org.junit.Before)

Example 3 with OfficeServer

use of org.xwiki.officeimporter.server.OfficeServer in project xwiki-platform by xwiki.

the class DefaultPresentationBuilderTest method configure.

@Before
public void configure() throws Exception {
    this.xhtmlParser = this.mocker.getInstance(Parser.class, "xhtml/1.0");
    this.officeHTMLCleaner = this.mocker.getInstance(HTMLCleaner.class, "openoffice");
    this.entityReferenceSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
    this.officeConverter = mock(OfficeConverter.class);
    OfficeServer officeServer = this.mocker.getInstance(OfficeServer.class);
    when(officeServer.getConverter()).thenReturn(this.officeConverter);
}
Also used : OfficeServer(org.xwiki.officeimporter.server.OfficeServer) OfficeConverter(org.xwiki.officeimporter.converter.OfficeConverter) Parser(org.xwiki.rendering.parser.Parser) HTMLCleaner(org.xwiki.xml.html.HTMLCleaner) Before(org.junit.Before)

Example 4 with OfficeServer

use of org.xwiki.officeimporter.server.OfficeServer 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

OfficeConverter (org.xwiki.officeimporter.converter.OfficeConverter)4 OfficeServer (org.xwiki.officeimporter.server.OfficeServer)4 Before (org.junit.Before)3 DefaultDocumentFormatRegistry (org.artofsolving.jodconverter.document.DefaultDocumentFormatRegistry)2 HTMLCleaner (org.xwiki.xml.html.HTMLCleaner)2 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 Parser (org.xwiki.rendering.parser.Parser)1 ResourceReferenceTypeSerializer (org.xwiki.rendering.renderer.reference.ResourceReferenceTypeSerializer)1