@Test @SuppressWarnings("deprecation") public void exportPartialXAR() throws Exception { XWikiContext context = this.oldcore.getXWikiContext(); when(this.oldcore.getMockRightService().hasWikiAdminRights(context)).thenReturn(true); when(this.request.get("format")).thenReturn("xar"); when(this.request.get("name")).thenReturn("my export"); when(this.request.get("description")).thenReturn("my description"); when(this.request.get("version")).thenReturn("my version"); when(this.request.get("author")).thenReturn("my author"); when(this.request.get("licence")).thenReturn("my license"); when(this.request.get("backup")).thenReturn("false"); when(this.request.get("history")).thenReturn("true"); when(this.documentSelectionResolver.isSelectionSpecified()).thenReturn(true); DocumentReference page1Ref = new DocumentReference("xwiki", "Space", "Page1"); DocumentReference page2Ref = new DocumentReference("xwiki", "Space", "Page2"); when(this.documentSelectionResolver.getSelectedDocuments()).thenReturn(Arrays.asList(page1Ref, page2Ref)); assertNull(this.action.render(context)); ArgumentCaptor<DocumentInstanceInputProperties> inputProperties = ArgumentCaptor.forClass(DocumentInstanceInputProperties.class); verify(this.inputFilterStreamFactory).createInputFilterStream(inputProperties.capture()); assertFalse(inputProperties.getValue().isVerbose()); assertTrue(inputProperties.getValue().isWithJRCSRevisions()); assertFalse(inputProperties.getValue().isWithRevisions()); assertTrue(inputProperties.getValue().getEntities().matches(page1Ref)); assertTrue(inputProperties.getValue().getEntities().matches(page2Ref)); ArgumentCaptor<XAROutputProperties> xarProperties = ArgumentCaptor.forClass(XAROutputProperties.class); verify(this.xarFilterStreamFactory).createOutputFilterStream(xarProperties.capture()); assertEquals("my export", xarProperties.getValue().getPackageName()); assertEquals("my description", xarProperties.getValue().getPackageDescription()); assertEquals("my version", xarProperties.getValue().getPackageVersion()); assertEquals("my author", xarProperties.getValue().getPackageAuthor()); assertEquals("my license", xarProperties.getValue().getPackageLicense()); assertFalse(xarProperties.getValue().isPackageBackupPack()); assertTrue(xarProperties.getValue().isPreserveVersion()); }
@Override public String render(XWikiContext context) throws XWikiException { String defaultPage; try { XWikiRequest request = context.getRequest(); String format = request.get("format"); if ((format == null) || (format.equals("xar"))) { defaultPage = exportXAR(context); } else if (format.equals("html")) { defaultPage = exportHTML(context); } else { defaultPage = export(format, context); } } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_EXPORT, "Exception while exporting", e); } return defaultPage; }
ExportAction extends XWikiAction { @Override public String render(XWikiContext context) throws XWikiException { String defaultPage; try { XWikiRequest request = context.getRequest(); String format = request.get("format"); if ((format == null) || (format.equals("xar"))) { defaultPage = exportXAR(context); } else if (format.equals("html")) { defaultPage = exportHTML(context); } else { defaultPage = export(format, context); } } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_EXPORT, "Exception while exporting", e); } return defaultPage; } }
ExportAction extends XWikiAction { @Override public String render(XWikiContext context) throws XWikiException { String defaultPage; try { XWikiRequest request = context.getRequest(); String format = request.get("format"); if ((format == null) || (format.equals("xar"))) { defaultPage = exportXAR(context); } else if (format.equals("html")) { defaultPage = exportHTML(context); } else { defaultPage = export(format, context); } } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_EXPORT, "Exception while exporting", e); } return defaultPage; }  }
ExportAction extends XWikiAction { @Override public String render(XWikiContext context) throws XWikiException { String defaultPage; try { XWikiRequest request = context.getRequest(); String format = request.get("format"); if ((format == null) || (format.equals("xar"))) { defaultPage = exportXAR(context); } else if (format.equals("html")) { defaultPage = exportHTML(context); } else { defaultPage = export(format, context); } } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_EXPORT, "Exception while exporting", e); } return defaultPage; }  @Override String render(XWikiContext context); }
ExportAction extends XWikiAction { @Override public String render(XWikiContext context) throws XWikiException { String defaultPage; try { XWikiRequest request = context.getRequest(); String format = request.get("format"); if ((format == null) || (format.equals("xar"))) { defaultPage = exportXAR(context); } else if (format.equals("html")) { defaultPage = exportHTML(context); } else { defaultPage = export(format, context); } } catch (Exception e) { throw new XWikiException(XWikiException.MODULE_XWIKI_APP, XWikiException.ERROR_XWIKI_APP_EXPORT, "Exception while exporting", e); } return defaultPage; }  @Override String render(XWikiContext context);  }