/** Utility method for importing test files. */ private List<String> importTestFile(String filename) throws Throwable { File file = TestFileUtil.retrieveFile(TEST_FILES_DIR, filename); Locale locale = new Locale("en", "US"); String virtualWiki = VIRTUAL_WIKI_EN; String authorDisplay = "127.0.0.1"; WikiUser user = null; return MigrationUtil.importFromFile(file, virtualWiki, user, authorDisplay, locale); }
@Test public void testTwoTopics() throws Throwable { String virtualWiki = VIRTUAL_WIKI_EN; List<String> topicNames = new ArrayList<String>(); topicNames.add("Example1"); topicNames.add("Example2"); boolean excludeHistory = false; File file = TEMP_FOLDER.newFile("export.xml"); try { MigrationUtil.exportToFile(file, virtualWiki, topicNames, excludeHistory); } catch (MigrationException e) { fail("Failure during export" + e); } }
@Test public void testExportNonExistentTopic() throws Throwable { String virtualWiki = VIRTUAL_WIKI_EN; List<String> topicNames = new ArrayList<String>(); topicNames.add("Bogus Topic Name"); boolean excludeHistory = false; File file = TEMP_FOLDER.newFile("export.xml"); try { MigrationUtil.exportToFile(file, virtualWiki, topicNames, excludeHistory); } catch (MigrationException e) { if (file.exists()) { // should have been deleted fail("Partial export file not deleted"); } return; } fail("Expected MigrationException to be thrown"); }