Author: julien_viet
Date: 2010-02-27 16:44:43 -0500 (Sat, 27 Feb 2010)
New Revision: 1899
Modified:
portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java
portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml
portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml
portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java
portal/trunk/component/test/jcr/src/main/resources/conf/exo.portal.component.test.jcr-repository-configuration.xml
portal/trunk/component/test/organization/src/main/resources/conf/exo.portal.component.test.organization-configuration.xml
portal/trunk/pom.xml
Log:
externalize unit test jdbc configuration with a profile for mysql (that will not work for
the whole build as no cleanup is done in the database)
Modified:
portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java
===================================================================
---
portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java 2010-02-27
18:56:53 UTC (rev 1898)
+++
portal/trunk/component/test/core/src/main/java/org/exoplatform/component/test/AbstractGateInTest.java 2010-02-27
21:44:43 UTC (rev 1899)
@@ -22,14 +22,12 @@
import junit.framework.TestCase;
import org.exoplatform.container.PortalContainer;
import org.exoplatform.container.component.RequestLifeCycle;
+import org.gatein.common.logging.Logger;
+import org.gatein.common.logging.LoggerFactory;
import java.io.File;
import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
/**
* An abstract test that takes care of running the unit tests with the semantic described
by the
@@ -42,9 +40,12 @@
{
/** The system property for gatein tmp dir. */
- private static final String TMP_DIR = "gatein.tmp.dir";
+ private static final String TMP_DIR = "gatein.test.tmp.dir";
/** . */
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ /** . */
private PortalContainer container;
protected AbstractGateInTest()
@@ -77,7 +78,28 @@
{
ClassLoader realClassLoader = Thread.currentThread().getContextClassLoader();
+ // Patch a bug with maven that does not pass properly the system property
+ // with an empty value
+ if
("org.hsqldb.jdbcDriver".equals(System.getProperty("gatein.test.datasource.driver")))
+ {
+ System.setProperty("gatein.test.datasource.password", "");
+ }
+
//
+ log.info("Listing gatein system properties:");
+ for (Map.Entry<?, ?> entry : System.getProperties().entrySet())
+ {
+ if (entry.getKey() instanceof String)
+ {
+ String key = (String)entry.getKey();
+ if (key.startsWith("gatein."))
+ {
+ log.info(key + "=" + entry.getValue());
+ }
+ }
+ }
+
+ //
Set<String> rootConfigPaths = new HashSet<String>();
rootConfigPaths.add("conf/root-configuration.xml");
Modified:
portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml
===================================================================
---
portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml 2010-02-27
18:56:53 UTC (rev 1898)
+++
portal/trunk/component/test/core/src/main/resources/conf/portal-configuration.xml 2010-02-27
21:44:43 UTC (rev 1899)
@@ -24,6 +24,7 @@
xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd
http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
+<!--
<component>
<key>org.jboss.cache.transaction.TransactionManagerLookup</key>
<type>org.jboss.cache.transaction.JBossStandaloneJTAManagerLookup</type>
@@ -39,6 +40,7 @@
</value-param>
</init-params>
</component>
+-->
<component>
<key>org.exoplatform.services.naming.InitialContextInitializer</key>
@@ -74,10 +76,10 @@
<properties-param>
<name>ref-addresses</name>
<description>ref-addresses</description>
- <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
- <property name="url"
value="jdbc:hsqldb:file:${gatein.tmp.dir}/hsqldb"/>
- <property name="username" value="sa"/>
- <property name="password" value=""/>
+ <property name="driverClassName"
value="${gatein.test.datasource.driver}"/>
+ <property name="url"
value="${gatein.test.datasource.url}"/>
+ <property name="username"
value="${gatein.test.datasource.username}"/>
+ <property name="password"
value="${gatein.test.datasource.password}"/>
</properties-param>
</init-params>
</component-plugin>
Modified: portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml
===================================================================
---
portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml 2010-02-27
18:56:53 UTC (rev 1898)
+++
portal/trunk/component/test/core/src/main/resources/conf/root-configuration.xml 2010-02-27
21:44:43 UTC (rev 1899)
@@ -28,4 +28,17 @@
<type>org.exoplatform.container.definition.PortalContainerConfig</type>
</component>
+<!--
+ <component>
+ <key>org.exoplatform.container.PropertyConfigurator</key>
+ <type>org.exoplatform.container.PropertyConfigurator</type>
+ <init-params>
+ <value-param>
+ <name>properties.url</name>
+ <value>jar:/conf/test-configuration.properties</value>
+ </value-param>
+ </init-params>
+ </component>
+-->
+
</configuration>
Modified:
portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java
===================================================================
---
portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java 2010-02-27
18:56:53 UTC (rev 1898)
+++
portal/trunk/component/test/core/src/test/java/org/exoplatform/component/test/BootstrapTestCase.java 2010-02-27
21:44:43 UTC (rev 1899)
@@ -25,6 +25,8 @@
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.io.File;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
@@ -58,6 +60,14 @@
container.getComponentInstanceOfType(InitialContextInitializer.class);
DataSource ds = (DataSource)new InitialContext().lookup("jdbcexo");
assertNotNull(ds);
+ Connection conn = ds.getConnection();
+ DatabaseMetaData databaseMD = conn.getMetaData();
+ String db = databaseMD.getDatabaseProductName() + " " +
databaseMD.getDatabaseProductVersion() + "." +
+ databaseMD.getDatabaseMajorVersion() + "." +
databaseMD.getDatabaseMinorVersion();
+ String driver = databaseMD.getDriverName() + " " +
databaseMD.getDriverVersion() + "." +
+ databaseMD.getDriverMajorVersion() + "." +
databaseMD.getDriverMinorVersion();
+ log.info("Using database " + db + " with driver " + driver);
+ conn.close();
}
public void testTmpDir1() throws Exception
@@ -72,7 +82,7 @@
private void ensureTmpDir() throws Exception
{
- String tmpDirPath = System.getProperty("gatein.tmp.dir");
+ String tmpDirPath = System.getProperty("gatein.test.tmp.dir");
assertNotNull(tmpDirPath);
//
Modified:
portal/trunk/component/test/jcr/src/main/resources/conf/exo.portal.component.test.jcr-repository-configuration.xml
===================================================================
---
portal/trunk/component/test/jcr/src/main/resources/conf/exo.portal.component.test.jcr-repository-configuration.xml 2010-02-27
18:56:53 UTC (rev 1898)
+++
portal/trunk/component/test/jcr/src/main/resources/conf/exo.portal.component.test.jcr-repository-configuration.xml 2010-02-27
21:44:43 UTC (rev 1899)
@@ -34,12 +34,12 @@
<property name="multi-db" value="false"/>
<property name="update-storage" value="true"/>
<property name="max-buffer-size"
value="204800"/>
- <property name="swap-directory"
value="${gatein.tmp.dir}/jcr/swap/system"/>
+ <property name="swap-directory"
value="${gatein.test.tmp.dir}/jcr/swap/system"/>
</properties>
<value-storages>
<value-storage id="system"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
<properties>
- <property name="path"
value="${gatein.tmp.dir}/jcr/values/system"/>
+ <property name="path"
value="${gatein.test.tmp.dir}/jcr/values/system"/>
</properties>
<filters>
<filter property-type="Binary"/>
@@ -60,7 +60,7 @@
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
- <property name="index-dir"
value="${gatein.tmp.dir}/jcr/jcrlucenedb/system"/>
+ <property name="index-dir"
value="${gatein.test.tmp.dir}/jcr/jcrlucenedb/system"/>
</properties>
</query-handler>
<lock-manager
class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
@@ -80,12 +80,12 @@
<property name="multi-db" value="false"/>
<property name="update-storage" value="true"/>
<property name="max-buffer-size"
value="204800"/>
- <property name="swap-directory"
value="${gatein.tmp.dir}/jcr/swap/portal-test"/>
+ <property name="swap-directory"
value="${gatein.test.tmp.dir}/jcr/swap/portal-test"/>
</properties>
<value-storages>
<value-storage id="portal-test"
class="org.exoplatform.services.jcr.impl.storage.value.fs.TreeFileValueStorage">
<properties>
- <property name="path"
value="${gatein.tmp.dir}/jcr/values/portal-test"/>
+ <property name="path"
value="${gatein.test.tmp.dir}/jcr/values/portal-test"/>
</properties>
<filters>
<filter property-type="Binary"/>
@@ -106,7 +106,7 @@
</cache>
<query-handler
class="org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex">
<properties>
- <property name="index-dir"
value="${gatein.tmp.dir}/jcr/jcrlucenedb/portal-test"/>
+ <property name="index-dir"
value="${gatein.test.tmp.dir}/jcr/jcrlucenedb/portal-test"/>
</properties>
</query-handler>
<lock-manager
class="org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl">
Modified:
portal/trunk/component/test/organization/src/main/resources/conf/exo.portal.component.test.organization-configuration.xml
===================================================================
---
portal/trunk/component/test/organization/src/main/resources/conf/exo.portal.component.test.organization-configuration.xml 2010-02-27
18:56:53 UTC (rev 1898)
+++
portal/trunk/component/test/organization/src/main/resources/conf/exo.portal.component.test.organization-configuration.xml 2010-02-27
21:44:43 UTC (rev 1899)
@@ -77,14 +77,7 @@
<!--CHANGEME HashtableCacheProvider shold not be used in production
env-->
<property name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider"/>
<property name="hibernate.cglib.use_reflection_optimizer"
value="true"/>
-<!--
- <property name="hibernate.connection.url"
value="jdbc:hsqldb:file:${basedir}/target/temp/organization"/>
- <property name="hibernate.connection.driver_class"
value="org.hsqldb.jdbcDriver"/>
- <property name="hibernate.connection.autocommit"
value="true"/>
- <property name="hibernate.connection.username"
value="sa"/>
- <property name="hibernate.connection.password"
value=""/>
--->
- <property name="hibernate.connection.datasource"
value="jdbcexo"/>
+ <property name="hibernate.connection.datasource"
value="jdbcidm"/>
<property name="hibernate.dialect"
value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.c3p0.min_size"
value="5"/>
<property name="hibernate.c3p0.max_size"
value="20"/>
@@ -119,4 +112,34 @@
</component-plugin>
</external-component-plugins>
+ <external-component-plugins>
+
<target-component>org.exoplatform.services.naming.InitialContextInitializer</target-component>
+ <component-plugin>
+ <name>bind.datasource</name>
+ <set-method>addPlugin</set-method>
+ <type>org.exoplatform.services.naming.BindReferencePlugin</type>
+ <init-params>
+ <value-param>
+ <name>bind-name</name>
+ <value>jdbcidm</value>
+ </value-param>
+ <value-param>
+ <name>class-name</name>
+ <value>javax.sql.DataSource</value>
+ </value-param>
+ <value-param>
+ <name>factory</name>
+ <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
+ </value-param>
+ <properties-param>
+ <name>ref-addresses</name>
+ <description>ref-addresses</description>
+ <property name="driverClassName"
value="org.hsqldb.jdbcDriver"/>
+ <property name="url"
value="jdbc:hsqldb:file:${gatein.test.tmp.dir}/idm"/>
+ <property name="username" value="sa"/>
+ <property name="password" value=""/>
+ </properties-param>
+ </init-params>
+ </component-plugin>
+ </external-component-plugins>
</configuration>
\ No newline at end of file
Modified: portal/trunk/pom.xml
===================================================================
--- portal/trunk/pom.xml 2010-02-27 18:56:53 UTC (rev 1898)
+++ portal/trunk/pom.xml 2010-02-27 21:44:43 UTC (rev 1899)
@@ -595,6 +595,97 @@
</plugins>
</build>
+ <profiles>
+ <profile>
+ <id>hsqldb</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+
<name>com.arjuna.ats.arjuna.objectstore.objectStoreDir</name>
+ <value>${project.build.directory}</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.driver</name>
+ <value>org.hsqldb.jdbcDriver</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.url</name>
+
<value>jdbc:hsqldb:file:${gatein.test.tmp.dir}/idm</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.username</name>
+ <value>sa</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.password</name>
+ <value></value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>mysql5</id>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.6</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <property>
+
<name>com.arjuna.ats.arjuna.objectstore.objectStoreDir</name>
+ <value>${project.build.directory}</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.driver</name>
+ <value>com.mysql.jdbc.Driver</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.url</name>
+
<value>jdbc:mysql://10.37.129.4/bilto?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.username</name>
+ <value>root</value>
+ </property>
+ <property>
+ <name>gatein.test.datasource.password</name>
+ <value>a</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
<!-- To be removed and replaced by settings in user config -->
<repositories>
<repository>