Author: tchemit Date: 2010-03-06 16:34:23 +0100 (Sat, 06 Mar 2010) New Revision: 1823 Log: fix Tests (resources used in a test must be unique in time) + add license header Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2010-03-06 14:08:13 UTC (rev 1822) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2010-03-06 15:34:23 UTC (rev 1823) @@ -1,4 +1,23 @@ - +/* + * *##% + * ToPIA :: Persistence + * Copyright (C) 2004 - 2010 CodeLutin + * + * 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>. + * ##% + */ package org.nuiton.topia.persistence; import org.apache.commons.logging.Log; @@ -150,7 +169,8 @@ TopiaContext root = TestUtils.start("naturalIdTest/existNaturalId"); TopiaContext transaction = root.beginTransaction(); - NaturalizedEntityDAO dao = TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction); + NaturalizedEntityDAO dao = + TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction); dao.create(NaturalizedEntity.NATURAL_ID_NOT_NULL, 5, NaturalizedEntity.NATURAL_ID_NULL, "str"); Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java 2010-03-06 14:08:13 UTC (rev 1822) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java 2010-03-06 15:34:23 UTC (rev 1823) @@ -1,41 +1,77 @@ - +/* + * *##% + * ToPIA :: Persistence + * Copyright (C) 2004 - 2010 CodeLutin + * + * 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>. + * ##% + */ package org.nuiton.topiatest; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; -import org.hibernate.cfg.Environment; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.junit.Ignore; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; -import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; import org.nuiton.topia.TopiaTestDAOHelper; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + /** * TestUtils - * + * <p/> * Created: 18 févr. 2010 * * @author fdesbois * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ + * <p/> + * Mise a jour: $Date$ + * par : $Author$ */ @Ignore public class TestUtils { - public static TopiaContext start(String dbname) throws IOException, TopiaNotFoundException { - InputStream stream = TestUtils.class.getResourceAsStream("/TopiaContextImpl.properties"); + /** Logger */ + private static final Log log = LogFactory.getLog(TestUtils.class); + public static TopiaContext start(String dbname) + throws IOException, TopiaNotFoundException { + + InputStream stream = TestUtils.class.getResourceAsStream( + "/TopiaContextImpl.properties"); + Properties configuration = new Properties(); configuration.load(stream); - configuration.setProperty("topia.persistence.classes", - TopiaTestDAOHelper.getImplementationClassesAsString()); + configuration.setProperty( + "topia.persistence.classes", + TopiaTestDAOHelper.getImplementationClassesAsString()); - configuration.setProperty("hibernate.connection.url", "jdbc:h2:file:target/surefire-data/" + dbname); + // make sure we always use a different directory + + String dbPath = "target/surefire-data/" + dbname + '_' + + System.nanoTime(); + if (log.isInfoEnabled()) { + log.info("dbPath = " + dbPath); + } + configuration.setProperty( + "hibernate.connection.url", + "jdbc:h2:file:" + dbPath); return TopiaContextFactory.getContext(configuration); } }