r1822 - in tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton: topia/persistence topiatest
Author: tchemit Date: 2010-03-06 15:08:13 +0100 (Sat, 06 Mar 2010) New Revision: 1822 Log: fix Tests (resources used in a test must be unique in time) + add license header Modified: tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java Modified: tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java =================================================================== --- tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2010-03-06 13:38:38 UTC (rev 1821) +++ tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2010-03-06 14:08:13 UTC (rev 1822) @@ -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; Modified: tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java =================================================================== --- tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java 2010-03-06 13:38:38 UTC (rev 1821) +++ tags/topia-2.3.0-beta-9/topia-persistence/src/test/java/org/nuiton/topiatest/TestUtils.java 2010-03-06 14:08:13 UTC (rev 1822) @@ -1,14 +1,34 @@ - +/* + * *##% + * 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; @@ -25,17 +45,34 @@ */ @Ignore public class TestUtils { + + /** 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"); + 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); } + }
participants (1)
-
tchemit@users.nuiton.org