CejshBuilder { File writeProperties(File packageFolder, int articleCount) throws IOException, FileNotFoundException { File propertiesFile = new File(packageFolder, IMPORT_PROPERTIES_FILENAME); Properties properties = new Properties(); gcalendar.setTimeInMillis(System.currentTimeMillis()); String importDate = DatatypeConverter.printDateTime(gcalendar); properties.setProperty(PROP_IMPORT_INFODATE, importDate); properties.setProperty(PROP_IMPORT_OBJECTS, String.valueOf(articleCount)); properties.setProperty(PROP_IMPORT_CONTENT_FILES, "0"); properties.setProperty(PROP_IMPORT_BWMETA_FILES, "1"); Writer propsWriter = new NoCommentsWriter(new OutputStreamWriter(new FileOutputStream(propertiesFile), Charsets.UTF_8)); try { properties.store(propsWriter, null); return propertiesFile; } finally { propsWriter.close(); } } CejshBuilder(CejshConfig config, ExportOptions options); XPathExpression getDateIssuedPath(); XPathExpression getIssnPath(); XPathExpression getPartNumberPath(); XPathExpression getReviewedArticlePath(); Article addArticle(DigitalObjectElement article, CejshContext p); File writePackage(DigitalObjectElement packageElm, List<Article> articles, CejshContext p); Title getTitle(); void setTitle(Title title); Volume getVolume(); void setVolume(Volume volume); Issue getIssue(); void setIssue(Issue issue); static final String NS_BWMETA105; }
@Test public void testWriteProperties() throws Exception { CejshBuilder cb = new CejshBuilder(new CejshConfig(), appConfig.getExportOptions()); File folder = temp.getRoot(); int articleCount = 3; cb.writeProperties(folder, articleCount); File file = new File(folder, CejshBuilder.IMPORT_PROPERTIES_FILENAME); assertTrue(file.exists()); Properties props = new Properties(); props.load(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8)); assertEquals(String.valueOf(articleCount), props.getProperty(CejshBuilder.PROP_IMPORT_OBJECTS)); assertEquals("1", props.getProperty(CejshBuilder.PROP_IMPORT_BWMETA_FILES)); assertEquals("0", props.getProperty(CejshBuilder.PROP_IMPORT_CONTENT_FILES)); String resultDate = props.getProperty(CejshBuilder.PROP_IMPORT_INFODATE); assertNotNull(resultDate); String expDated = DatatypeConverter.printDateTime( new GregorianCalendar(CejshBuilder.UTC)).substring(0, 14); assertEquals(resultDate, expDated, resultDate.substring(0, 14)); }