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());
}
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);
}
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);
}
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));
}
}
Aggregations