Author: tchemit Date: 2012-02-19 12:19:30 +0100 (Sun, 19 Feb 2012) New Revision: 185 Url: http://nuiton.org/repositories/revision/nuiton-web/185 Log: Anomalie #1974: nuiton-rss tests are not isolated (and are not self-contained by project) Added: trunk/nuiton-rss/src/test/resources/ trunk/nuiton-rss/src/test/resources/log4j.properties Removed: trunk/nuiton-rss/src/test/java/resources/ Modified: trunk/nuiton-rss/pom.xml trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java Modified: trunk/nuiton-rss/pom.xml =================================================================== --- trunk/nuiton-rss/pom.xml 2012-02-18 16:03:59 UTC (rev 184) +++ trunk/nuiton-rss/pom.xml 2012-02-19 11:19:30 UTC (rev 185) @@ -56,6 +56,11 @@ </dependency> <dependency> + <groupId>org.nuiton</groupId> + <artifactId>nuiton-utils</artifactId> + </dependency> + + <dependency> <groupId>org.jdom</groupId> <artifactId>jdom</artifactId> </dependency> Modified: trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java =================================================================== --- trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java 2012-02-18 16:03:59 UTC (rev 184) +++ trunk/nuiton-rss/src/main/java/org/nuiton/rss/RSSGenerator.java 2012-02-19 11:19:30 UTC (rev 185) @@ -62,16 +62,27 @@ public static final DateFormat DATE_PARSER = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); /** + * @param generatorDirectory generator directory * @return une nouvelle instance de RssHelper en utilisant les implantations * definies dans RSSGeneratorConfig. * @throws Exception pour tout pb lors de l'instanciation des objects */ - public static RSSGenerator newDefaultInstance() throws Exception { + public static RSSGenerator newDefaultInstance(File generatorDirectory) throws Exception { RSSGenerator helper = new RSSGenerator(); return helper; } + /** + * @return une nouvelle instance de RssHelper en utilisant les implantations + * definies dans RSSGeneratorConfig. + * @throws Exception pour tout pb lors de l'instanciation des objects + */ + public static RSSGenerator newDefaultInstance() throws Exception { + RSSGenerator helper = newDefaultInstance(null); + return helper; + } + /** * dictonnary of field <-> property for feed */ Modified: trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java =================================================================== --- trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java 2012-02-18 16:03:59 UTC (rev 184) +++ trunk/nuiton-rss/src/test/java/org/nuiton/rss/RSSGeneratorHelperTest.java 2012-02-19 11:19:30 UTC (rev 185) @@ -31,7 +31,10 @@ import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TestName; +import org.nuiton.util.FileUtil; import java.io.File; import java.net.MalformedURLException; @@ -42,24 +45,38 @@ import java.util.List; import java.util.Map; -/** - * @author tony - */ +/** @author tony */ public class RSSGeneratorHelperTest { private static Log log = LogFactory.getLog(RSSGeneratorHelperTest.class); - static RSSGenerator helper; - static File f; + private static final long TIMESTAMP = System.nanoTime(); + RSSGenerator helper; + + File f; + + @Rule + public TestName testMethodName = new TestName(); + @Before public void setUp() throws Exception { - if (helper == null) { - helper = RSSGenerator.newDefaultInstance(); + String base = System.getProperty("java.io.tmpdir"); + if (base == null || base.isEmpty()) { + base = new File("").getAbsolutePath(); } - if (f == null) { - f = getFeedFile(); + File testBasedir = new File(base); + if (log.isInfoEnabled()) { + log.info("basedir for test " + testBasedir); } + File testdir = FileUtil.getFileFromFQN(testBasedir, + getClass().getName() + "." + TIMESTAMP); + + helper = RSSGenerator.newDefaultInstance(testdir); + + + f = getFeedFile(); + } @Test @@ -106,6 +123,8 @@ @Test public void testCreateFeedAlreadyExisting() throws Exception { + testCreateFeed(); + Map<Field, Object> values = new HashMap<Field, Object>(); values.put(Field.NAME, "feedName : " + f.getName()); values.put(Field.DESCRIPTION, "feedDescription : " + f.getName()); @@ -128,6 +147,9 @@ @Test public void testAddFeedEntry() throws Exception { + + testCreateFeed(); + Assert.assertTrue(f.exists()); Map<Field, Object> values = createEntry(0); @@ -150,6 +172,8 @@ @Test public void testAddFeedEntryToMax() throws Exception { + testAddFeedEntry(); + Assert.assertTrue(f.exists()); SyndFeed feed = RSSIOUtil.readFeed(f.toURI().toURL()); @@ -197,6 +221,7 @@ @Test public void testCleanFile() throws Exception { + testCreateFeed(); try { Assert.assertNotNull(f); Assert.assertTrue(f.exists()); Copied: trunk/nuiton-rss/src/test/resources/log4j.properties (from rev 183, trunk/nuiton-rss/src/test/java/resources/log4j.properties) =================================================================== --- trunk/nuiton-rss/src/test/resources/log4j.properties (rev 0) +++ trunk/nuiton-rss/src/test/resources/log4j.properties 2012-02-19 11:19:30 UTC (rev 185) @@ -0,0 +1,31 @@ +### +# #%L +# Nuiton Utils :: Nuiton RSS +# +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2008 - 2010 CodeLutin, Tony Chemit, Benjamin Poussin +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Lesser Public License for more details. +# +# You should have received a copy of the GNU General Lesser Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/lgpl-3.0.html>. +# #L% +### +# Global logging configuration +log4j.rootLogger=INFO, stdout + +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy/MM/dd hh:mm:ss} %5p (%F:%L) %m%n Property changes on: trunk/nuiton-rss/src/test/resources/log4j.properties ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native