r545 - in trunk/wikitty-jdbc-impl: . src/test/java/org/nuiton/wikitty/jdbc/test src/test/resources
Author: sletellier Date: 2010-11-30 18:05:35 +0100 (Tue, 30 Nov 2010) New Revision: 545 Url: http://nuiton.org/repositories/revision/wikitty/545 Log: Test if wikitty with postgres database is working, allow to add other config Added: trunk/wikitty-jdbc-impl/src/test/resources/postrges-wikitty-config.properties Removed: trunk/wikitty-jdbc-impl/src/test/resources/wikitty-jdbc-config.properties Modified: trunk/wikitty-jdbc-impl/pom.xml trunk/wikitty-jdbc-impl/src/test/java/org/nuiton/wikitty/jdbc/test/StorageJDBCTest.java Modified: trunk/wikitty-jdbc-impl/pom.xml =================================================================== --- trunk/wikitty-jdbc-impl/pom.xml 2010-11-30 14:42:42 UTC (rev 544) +++ trunk/wikitty-jdbc-impl/pom.xml 2010-11-30 17:05:35 UTC (rev 545) @@ -71,6 +71,7 @@ <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </dependency> + <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> @@ -103,6 +104,13 @@ <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> + + <dependency> + <groupId>postgresql</groupId> + <artifactId>postgresql</artifactId> + <scope>runtime</scope> + </dependency> + </dependencies> <!-- ************************************************************* --> Modified: trunk/wikitty-jdbc-impl/src/test/java/org/nuiton/wikitty/jdbc/test/StorageJDBCTest.java =================================================================== --- trunk/wikitty-jdbc-impl/src/test/java/org/nuiton/wikitty/jdbc/test/StorageJDBCTest.java 2010-11-30 14:42:42 UTC (rev 544) +++ trunk/wikitty-jdbc-impl/src/test/java/org/nuiton/wikitty/jdbc/test/StorageJDBCTest.java 2010-11-30 17:05:35 UTC (rev 545) @@ -25,10 +25,16 @@ package org.nuiton.wikitty.jdbc.test; +import org.junit.Assume; import org.junit.Before; +import org.nuiton.wikitty.WikittyConfig; +import org.nuiton.wikitty.jdbc.WikittyExtensionStorageJDBC; import org.nuiton.wikitty.jdbc.WikittyServiceJDBC; import org.nuiton.wikitty.conform.StorageTest; +import java.io.InputStream; +import java.util.Properties; + /** * * @author ruchaud, martel @@ -37,11 +43,75 @@ * Last update: $Date$ * by : $Author$ */ -public class StorageJDBCTest extends StorageTest { - +public abstract class StorageJDBCTest extends StorageTest { + @Before public void deleteAll() throws Exception { + String configFileName = getConfigFileName(); + + // If not null use secific config file + // else using H2 by default + if (configFileName != null) { + + // Be sure to not read other config files + InputStream input = WikittyConfig.class.getResourceAsStream(configFileName); + Properties options = new Properties(); + options.load(input); + WikittyConfig config = new WikittyConfig(options); + + try { + canConnectWithConfig(config); + } catch (Exception eee) { + if (log.isWarnEnabled()) { + log.warn("Failled to run test with config '" + configFileName + '"'); + } + if (log.isDebugEnabled()) { + log.debug("An error is occured : ", eee); + } + Assume.assumeNoException(eee); + } + + log.info("Using config file : " + configFileName); + ws = new WikittyServiceJDBC(config); + } + WikittyServiceJDBC service = ((WikittyServiceJDBC) ws); service.clear(null); } + + public void canConnectWithConfig(WikittyConfig config) throws Exception { + new WikittyExtensionStorageJDBC(config); + } + + public abstract String getConfigFileName(); + + /** + *@author sletellier + */ + public class H2StorageJDBCTest extends StorageJDBCTest { + + @Override + public String getConfigFileName() { + + // Use H2 by default + return null; + } + + } + + /** + * You must configure an postgres database and configure + * postgres-wikitty-config.properties to run this test + * <p> + * (see http://jdbc.postgresql.org/development/intro.html#Test+Suite) + * + * @author sletellier + */ + public class PostgresqlStorageJDBCTest extends StorageJDBCTest { + + @Override + public String getConfigFileName() { + return "/postrges-wikitty-config.properties"; + } + } } Added: trunk/wikitty-jdbc-impl/src/test/resources/postrges-wikitty-config.properties =================================================================== --- trunk/wikitty-jdbc-impl/src/test/resources/postrges-wikitty-config.properties (rev 0) +++ trunk/wikitty-jdbc-impl/src/test/resources/postrges-wikitty-config.properties 2010-11-30 17:05:35 UTC (rev 545) @@ -0,0 +1,9 @@ +wikitty.storage.jdbc.driver=org.postgresql.Driver +wikitty.storage.jdbc.host=jdbc:postgresql://localhost/test +wikitty.storage.jdbc.password=password +wikitty.storage.jdbc.login=test +wikitty.storage.jdbc.xadatasource=org.postgresql.xa.PGXADataSource +wikitty.storage.jdbc.xadatasource.org.postgresql.xa.PGXADataSource.serverName=localhost +wikitty.storage.jdbc.xadatasource.org.postgresql.xa.PGXADataSource.databaseName=test +wikitty.storage.jdbc.xadatasource.org.postgresql.xa.PGXADataSource.password=password +wikitty.storage.jdbc.xadatasource.org.postgresql.xa.PGXADataSource.user=test \ No newline at end of file Deleted: trunk/wikitty-jdbc-impl/src/test/resources/wikitty-jdbc-config.properties =================================================================== --- trunk/wikitty-jdbc-impl/src/test/resources/wikitty-jdbc-config.properties 2010-11-30 14:42:42 UTC (rev 544) +++ trunk/wikitty-jdbc-impl/src/test/resources/wikitty-jdbc-config.properties 2010-11-30 17:05:35 UTC (rev 545) @@ -1,35 +0,0 @@ -### -# #%L -# Wikitty :: wikitty-jdbc-impl -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2010 CodeLutin, 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% -### -#Connection parameters for standard datasource -jdbc.con.driver=org.h2.Driver -jdbc.con.host=jdbc:h2:file:./target/data/data -jdbc.con.userName=sa -jdbc.con.password= - -#Connection parameters for xadatasource -jdbc.xadatasource=org.h2.jdbcx.JdbcDataSource -jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.URL=jdbc:h2:file:./target/data/data -jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.user=sa -jdbc.xadatasource.org.h2.jdbcx.JdbcDataSource.password=
participants (1)
-
sletellier@users.nuiton.org