Author: rhauch
Date: 2009-09-16 16:56:22 -0400 (Wed, 16 Sep 2009)
New Revision: 1227
Added:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/TestEnvironment.java
trunk/extensions/dna-connector-store-jpa/src/test/resources/database.properties
Modified:
trunk/dna-integration-tests/pom.xml
trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml
trunk/docs/reference/src/main/docbook/en-US/content/developers/tools.xml
trunk/extensions/dna-connector-store-jpa/pom.xml
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorCreateWorkspacesTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorNoCreateWorkspaceTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorReadingTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java
trunk/pom.xml
Log:
DNA-521 Define infrastructure for testing with multiple DBMSes
The parent POM file was changed to define a new profiles for each database configuration,
and each profile defines the dependencies and properties for the JPA Source objects used
in the unit and integration tests.
For the most part, I followed Hibernate's example. Hibernate's POM is such that
the database profile is specified explicitly on the Maven command (e.g., 'mvn
-Poracle9i ...'), and thus is able to define a 'default' database profile that
is used when no other profile is specified. However, this means that if ANY other profile
is explicitly used on the command line (e.g., 'mvn -Pintegration ...'), the
default database profile is not used, and in effect NO database profile is used. This
causes a locking up of the build process.
jBPM's approach of using a property to refer to the database profile is actually
superior in this respect, since there is a default database profile that is run when the
'database' property is not set. Thus, the database profiles and the other
profiles remain orthogonal and independent. Yet another advantage to this approach is
that it encourages specifying only one database profile. The cost is a bit more verbosity
in the parent POM. So, 'mvn -P integration clean install' still runs the
integration builds as before (using the HSQLDB database), and to use a different database
simply set the 'database' property to the name of the database profile. For
example, 'mvn -P integration -Ddatabase=oracle9i clean install' runs the
integration tests against the 'oracle9i' database.
Note that it still is possible to specify the database via the '-P' flag, but then
be sure to always include a database profile when using another profile. For example,
'mvn -P integration,oracle9i ...' does work.
The JPA unit tests were changed to read a resource file and set the JpaSource bean
properties using the values in that resource file. This resource file is simply a
properties file where the values are substituted by Maven during the build with the
properties in the selected profile. Thus, each database profile can actually set any and
all of the JpaSource bean properties (tho some integration tests explicitly override some
of the property values, since they are related to the tests being run). A number of
database profiles has been added, but these will be updated as we acquire database
instances in the QA lab.
The integration tests that use a JPA connector all work in a similar manner, except that
the integration tests already load the DNA configuration from an XML file. Here also the
XML file (and the 'dna-integration-test/pom.xml' file) was changed so that Maven
would substitute the properties in the database profile.
The short summary is this: simply change or add the appropriate database profile in the
parent POM file, and then specify the DBMS that should be used by including the
'-Ddatabase=dbprofilename' parameter on the command line. That's it.
Modified: trunk/dna-integration-tests/pom.xml
===================================================================
--- trunk/dna-integration-tests/pom.xml 2009-09-16 14:40:56 UTC (rev 1226)
+++ trunk/dna-integration-tests/pom.xml 2009-09-16 20:56:22 UTC (rev 1227)
@@ -225,6 +225,24 @@
phase
-->
<build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>*</include>
+ <include>**/*</include>
+ </includes>
+ </testResource>
+ <!-- Apply the properties set in the POM to the resource files -->
+ <testResource>
+ <filtering>true</filtering>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>tck/jpa/configRepository.xml</include>
+ </includes>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
Modified: trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml
===================================================================
--- trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml 2009-09-16
14:40:56 UTC (rev 1226)
+++ trunk/dna-integration-tests/src/test/resources/tck/jpa/configRepository.xml 2009-09-16
20:56:22 UTC (rev 1227)
@@ -35,19 +35,19 @@
The 'JCR' repository is a JBoss Cache source with a single default
workspace (though others could be created, too).
-->
<dna:source jcr:name="Store"
dna:classname="org.jboss.dna.connector.store.jpa.JpaSource"
- dna:dialect="org.hibernate.dialect.HSQLDialect"
- dna:driverClassName="org.hsqldb.jdbcDriver"
- dna:username="sa"
- dna:password=""
- dna:url="jdbc:hsqldb:."
- dna:maximumConnectionsInPool="1"
- dna:referentialIntegrityEnforced="true"
- dna:largeValueSizeInBytes="150"
- dna:retryLimit="3"
- dna:compressData="true"
+ dna:dialect="${jpaSource.dialect}"
+ dna:driverClassName="${jpaSource.driverClassName}"
+ dna:username="${jpaSource.username}"
+ dna:password="${jpaSource.password}"
+ dna:url="${jpaSource.url}"
+ dna:maximumConnectionsInPool="${jpaSource.maximumConnectionsInPool}"
+
dna:referentialIntegrityEnforced="${jpaSource.referentialIntegrityEnforced}"
+ dna:largeValueSizeInBytes="${jpaSource.largeValueSizeInBytes}"
+ dna:retryLimit="${jpaSource.retryLimit}"
+ dna:compressData="${jpaSource.compressData}"
dna:predefinedWorkspaceNames="default"
- dna:showSql="false"
- dna:autoGenerateSchema="create"
+ dna:showSql="${jpaSource.showSql}"
+ dna:autoGenerateSchema="${jpaSource.autoGenerateSchema}"
dna:defaultWorkspaceName="default"/>
</dna:sources>
<!--
Modified: trunk/docs/reference/src/main/docbook/en-US/content/developers/tools.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/developers/tools.xml 2009-09-16
14:40:56 UTC (rev 1226)
+++ trunk/docs/reference/src/main/docbook/en-US/content/developers/tools.xml 2009-09-16
20:56:22 UTC (rev 1227)
@@ -252,36 +252,81 @@
see the <ulink
url="http://wiki.jboss.org/wiki/Maven">JBoss.org
Wiki</ulink>.
</para>
</note>
- <para>
- There are just a few commands that are useful for building JBoss DNA (and it's
<link linkend="modules">subprojects</link>).
- Usually, these are issued while at the top level of the code (usually just below
<code>trunk/</code>), although issuing
- them inside a subproject just applies to that subproject.
- </para>
- <table frame='all'>
- <title>Useful Maven commands</title>
- <tgroup cols='2' align='left' colsep='1'
rowsep='1'>
- <colspec colname='c1' colwidth="1*"/>
- <colspec colname='c2' colwidth="1*"/>
- <thead>
- <row>
- <entry>Command</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><code>mvn clean</code></entry>
- <entry>Clean up all built artifacts (e.g., the
<code>target/</code> directory in each project)</entry>
- </row>
- <row>
- <entry><code>mvn clean install</code></entry>
- <entry>Clean up all built artifacts, then compile, run the unit tests, and
install the resulting JAR artifact(s)
- into your local Maven repository (e.g, usually
<code>~/.m2/repository</code>).
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <sect2 id="build_commands">
+ <title>Building</title>
+ <para>
+ There are just a few commands that are useful for building JBoss DNA (and it's
<link linkend="modules">subprojects</link>).
+ Usually, these are issued while at the top level of the code (usually just below
<code>trunk/</code>), although issuing
+ them inside a subproject just applies to that subproject.
+ </para>
+ <table frame='all'>
+ <title>Useful Maven commands</title>
+ <tgroup cols='2' align='left' colsep='1'
rowsep='1'>
+ <colspec colname='c1' colwidth="1*"/>
+ <colspec colname='c2' colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Command</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><code>mvn clean</code></entry>
+ <entry>Clean up all built artifacts (e.g., the
<code>target/</code> directory in each project)</entry>
+ </row>
+ <row>
+ <entry><code>mvn clean install</code></entry>
+ <entry>Called the "quick build". Clean up all produced artifacts;
compile the source code and test cases;
+ run all of the unit tests; and install the resulting JAR artifact(s)
+ into your local Maven repository (e.g, usually
<code>~/.m2/repository</code>). This is often what
+ developers run prior to checking in changes, since it generally runs quickly.
+ Note that no integration tests are performed, and HSQLDB is used when a database
is needed.
+ </entry>
+ </row>
+ <row>
+ <entry><code>mvn clean install
-Ddatabase=dbprofile</code></entry>
+ <entry>Same as the "quick build", except that it specifies the
database management system
+ that is to be used by the tests.
+ Options for "<code>dbprofile</code>" values are:
+ "<code>hsqldb</code>",
"<code>h2</code>",
+ "<code>postgresql_local</code>",
"<code>postgresql8</code>",
+ "<code>mysql5</code>",
+ "<code>oracle9i</code>",
"<code>oracle10g</code>",
"<code>oracle11g</code>",
+ "<code>db2v8</code>",
"<code>db2v9</code>",
+ "<code>sybase15</code>", and
+ "<code>mysql2005</code>".
+ The database connection information for these database profiles are in the parent
"pom.xml" file,
+ and most of these are configured to use database instances within the JBoss
Quality Assurance
+ lab and are accessible only to Red Hat employees. However, feel free to add your
own profiles
+ or even change the settings in the POM file to suit your needs.
+ </entry>
+ </row>
+ <row>
+ <entry><code>mvn -P integration clean
install</code></entry>
+ <entry>This "integration build" does everything the
"quick" build does plus it compiles and
+ runs the integration tests, which take several extra minutes to run.
+ Also, HSQLDB is used when a database is needed.
+ </entry>
+ </row>
+ <row>
+ <entry><code>mvn -P integration clean install
-Ddatabase=dbprofile</code></entry>
+ <entry>This does the same as the "integration build", except that
it specifies the database management system
+ that is to be used by the unit and integration tests. Options for the
"<code>dbprofile</code>" values are
+ the same as listed above.
+ </entry>
+ </row>
+ <row>
+ <entry><code>mvn -P assembly clean install</code></entry>
+ <entry>This runs a builds all source code, documentation, JavaDoc, runs all
unit and integration tests,
+ and produces all assemblies (e.g., zip files).
+ HSQLDB is used when a database is needed.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </sect2>
</sect1>
<sect1 id="hudson">
<title>Continuous integration with Hudson</title>
@@ -303,11 +348,11 @@
<tbody>
<row>
<entry><ulink
url="http://hudson.jboss.org/hudson/job/DNA%20continuous%20on%20JDK1...
on JDK 5</ulink></entry>
- <entry>Continuous build that runs after changes are committed to SVN. SVN is
polled every 15 minutes.</entry>
+ <entry>Continuous build that runs an integration build after changes are
committed to SVN. SVN is polled every 15 minutes.</entry>
</row>
<row>
<entry><ulink
url="http://hudson.jboss.org/hudson/job/DNA%20nightly%20integration%...
on JDK 5</ulink></entry>
- <entry>Build that runs every night (usually around 2 a.m. EDT), regardless of
whether changes have been committed to SVN
+ <entry>Integration build that runs every night (usually around 2 a.m. EDT),
regardless of whether changes have been committed to SVN
since the previous night.</entry>
</row>
</tbody>
Modified: trunk/extensions/dna-connector-store-jpa/pom.xml
===================================================================
--- trunk/extensions/dna-connector-store-jpa/pom.xml 2009-09-16 14:40:56 UTC (rev 1226)
+++ trunk/extensions/dna-connector-store-jpa/pom.xml 2009-09-16 20:56:22 UTC (rev 1227)
@@ -102,4 +102,24 @@
</plugin>
</plugins>
</reporting>
+ <build>
+ <testResources>
+ <testResource>
+ <filtering>false</filtering>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>*</include>
+ <include>**/*</include>
+ </includes>
+ </testResource>
+ <!-- Apply the properties set in the POM to the resource files -->
+ <testResource>
+ <filtering>true</filtering>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>database.properties</include>
+ </includes>
+ </testResource>
+ </testResources>
+ </build>
</project>
\ No newline at end of file
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorCreateWorkspacesTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorCreateWorkspacesTest.java 2009-09-16
14:40:56 UTC (rev 1226)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorCreateWorkspacesTest.java 2009-09-16
20:56:22 UTC (rev 1227)
@@ -51,23 +51,12 @@
protected RepositorySource setUpSource() {
predefinedWorkspaces = new String[] {"workspace1",
"workspace1a"};
- // Set the connection properties to be an in-memory HSQL database ...
- JpaSource source = new JpaSource();
- source.setName("Test Repository");
- source.setDialect("org.hibernate.dialect.HSQLDialect");
- source.setDriverClassName("org.hsqldb.jdbcDriver");
- source.setUsername("sa");
- source.setPassword("");
- source.setUrl("jdbc:hsqldb:.");
- source.setMaximumConnectionsInPool(3);
- source.setMinimumConnectionsInPool(0);
- source.setNumberOfConnectionsToAcquireAsNeeded(1);
- source.setMaximumSizeOfStatementCache(100);
- source.setMaximumConnectionIdleTimeInSeconds(0);
- source.setLargeValueSizeInBytes(150);
+ // Set the connection properties using the environment defined in the POM files
...
+ JpaSource source = TestEnvironment.configureJpaSource("Test
Repository", this);
+
+ // Override the inherited properties, since that's the focus of these tests
...
source.setCreatingWorkspacesAllowed(true);
source.setPredefinedWorkspaceNames(predefinedWorkspaces);
- source.setAutoGenerateSchema("create");
return source;
}
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorNoCreateWorkspaceTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorNoCreateWorkspaceTest.java 2009-09-16
14:40:56 UTC (rev 1226)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorNoCreateWorkspaceTest.java 2009-09-16
20:56:22 UTC (rev 1227)
@@ -51,23 +51,12 @@
protected RepositorySource setUpSource() {
predefinedWorkspaces = new String[] {"workspace1",
"workspace2", "workspace3"};
- // Set the connection properties to be an in-memory HSQL database ...
- JpaSource source = new JpaSource();
- source.setName("Test Repository");
- source.setDialect("org.hibernate.dialect.HSQLDialect");
- source.setDriverClassName("org.hsqldb.jdbcDriver");
- source.setUsername("sa");
- source.setPassword("");
- source.setUrl("jdbc:hsqldb:.");
- source.setMaximumConnectionsInPool(3);
- source.setMinimumConnectionsInPool(0);
- source.setNumberOfConnectionsToAcquireAsNeeded(1);
- source.setMaximumSizeOfStatementCache(100);
- source.setMaximumConnectionIdleTimeInSeconds(0);
- source.setLargeValueSizeInBytes(150);
+ // Set the connection properties using the environment defined in the POM files
...
+ JpaSource source = TestEnvironment.configureJpaSource("Test
Repository", this);
+
+ // Override the inherited properties, since that's the focus of these tests
...
source.setCreatingWorkspacesAllowed(false);
source.setPredefinedWorkspaceNames(predefinedWorkspaces);
- source.setAutoGenerateSchema("create");
return source;
}
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorReadingTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorReadingTest.java 2009-09-16
14:40:56 UTC (rev 1226)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorReadingTest.java 2009-09-16
20:56:22 UTC (rev 1227)
@@ -41,21 +41,8 @@
*/
@Override
protected RepositorySource setUpSource() {
- // Set the connection properties to be an in-memory HSQL database ...
- JpaSource source = new JpaSource();
- source.setName("Test Repository");
- source.setDialect("org.hibernate.dialect.HSQLDialect");
- source.setDriverClassName("org.hsqldb.jdbcDriver");
- source.setUsername("sa");
- source.setPassword("");
- source.setUrl("jdbc:hsqldb:.");
- source.setMaximumConnectionsInPool(3);
- source.setMinimumConnectionsInPool(0);
- source.setNumberOfConnectionsToAcquireAsNeeded(1);
- source.setMaximumSizeOfStatementCache(100);
- source.setMaximumConnectionIdleTimeInSeconds(0);
- source.setLargeValueSizeInBytes(150);
- source.setAutoGenerateSchema("create");
+ // Set the connection properties using the environment defined in the POM files
...
+ JpaSource source = TestEnvironment.configureJpaSource("Test
Repository", this);
// Create a graph and look up the root node. We do this to initialize the
connection pool and
// force the database to be setup at this point. By doing it now, we don't
include this overhead
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java 2009-09-16
14:40:56 UTC (rev 1226)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaConnectorWritingTest.java 2009-09-16
20:56:22 UTC (rev 1227)
@@ -42,22 +42,11 @@
*/
@Override
protected RepositorySource setUpSource() {
- // Set the connection properties to be an in-memory HSQL database ...
- JpaSource source = new JpaSource();
- source.setName("Test Repository");
- source.setDialect("org.hibernate.dialect.HSQLDialect");
- source.setDriverClassName("org.hsqldb.jdbcDriver");
- source.setUsername("sa");
- source.setPassword("");
- source.setUrl("jdbc:hsqldb:.");
- source.setMaximumConnectionsInPool(1);
- source.setMinimumConnectionsInPool(0);
- source.setNumberOfConnectionsToAcquireAsNeeded(1);
- source.setMaximumSizeOfStatementCache(100);
- source.setMaximumConnectionIdleTimeInSeconds(0);
+ // Set the connection properties using the environment defined in the POM files
...
+ JpaSource source = TestEnvironment.configureJpaSource("Test
Repository", this);
+
+ // Override the inherited properties ...
source.setReferentialIntegrityEnforced(true);
- source.setLargeValueSizeInBytes(150);
- source.setAutoGenerateSchema("create");
source.setCompressData(true);
return source;
Modified:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java 2009-09-16
14:40:56 UTC (rev 1226)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/JpaSourceTest.java 2009-09-16
20:56:22 UTC (rev 1227)
@@ -45,22 +45,12 @@
@Before
public void beforeEach() throws Exception {
- this.source = new JpaSource();
- // Set the connection properties to be an in-memory HSQL database ...
- this.source.setName("Test Repository");
- this.source.setDialect("org.hibernate.dialect.HSQLDialect");
- this.source.setDriverClassName("org.hsqldb.jdbcDriver");
- this.source.setUsername("sa");
- this.source.setPassword("");
- this.source.setUrl("jdbc:hsqldb:.");
- this.source.setMaximumConnectionsInPool(3);
- this.source.setMinimumConnectionsInPool(0);
- this.source.setNumberOfConnectionsToAcquireAsNeeded(1);
- this.source.setMaximumSizeOfStatementCache(100);
- this.source.setMaximumConnectionIdleTimeInSeconds(0);
+ // Set the connection properties using the environment defined in the POM files
...
+ this.source = TestEnvironment.configureJpaSource("Test Repository",
this);
+
+ // Override the inherited properties ...
this.source.setDefaultWorkspaceName("default");
this.source.setCreatingWorkspacesAllowed(true);
- this.source.setAutoGenerateSchema("create");
}
@After
Added:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/TestEnvironment.java
===================================================================
---
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/TestEnvironment.java
(rev 0)
+++
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/TestEnvironment.java 2009-09-16
20:56:22 UTC (rev 1227)
@@ -0,0 +1,118 @@
+/*
+ * JBoss DNA (
http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.dna.connector.store.jpa;
+
+import java.io.IOException;
+import java.util.Properties;
+
+public class TestEnvironment {
+
+ public static JpaSource configureJpaSource( String sourceName,
+ Object testCase ) {
+ Properties properties = new Properties();
+ ClassLoader loader = testCase instanceof Class ?
((Class<?>)testCase).getClassLoader() : testCase.getClass()
+
.getClassLoader();
+ try {
+
properties.load(loader.getResourceAsStream("database.properties"));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+
+ // Set the connection properties to be an in-memory HSQL database ...
+ JpaSource source = new JpaSource();
+ source.setName(sourceName);
+ source.setDialect(properties.getProperty("jpaSource.dialect"));
+
source.setDriverClassName(properties.getProperty("jpaSource.driverClassName"));
+ source.setUsername(properties.getProperty("jpaSource.username"));
+ source.setPassword(properties.getProperty("jpaSource.password"));
+ source.setUrl(properties.getProperty("jpaSource.url"));
+
+ String value =
properties.getProperty("jpaSource.maximumConnectionsInPool");
+ if (isValue(value)) source.setMaximumConnectionsInPool(Integer.parseInt(value));
+
+ value = properties.getProperty("jpaSource.minimumConnectionsInPool");
+ if (isValue(value)) source.setMinimumConnectionsInPool(Integer.parseInt(value));
+
+ value =
properties.getProperty("jpaSource.maximumSizeOfStatementCache");
+ if (isValue(value))
source.setMaximumSizeOfStatementCache(Integer.parseInt(value));
+
+ value =
properties.getProperty("jpaSource.maximumConnectionIdleTimeInSeconds");
+ if (isValue(value))
source.setMaximumConnectionIdleTimeInSeconds(Integer.parseInt(value));
+
+ value = properties.getProperty("jpaSource.largeValueSizeInBytes");
+ if (isValue(value)) source.setLargeValueSizeInBytes(Long.parseLong(value));
+
+ value = properties.getProperty("jpaSource.autoGenerateSchema");
+ if (isValue(value)) source.setAutoGenerateSchema(value);
+
+ value = properties.getProperty("jpaSource.compressData");
+ if (isValue(value)) source.setCompressData(Boolean.parseBoolean(value));
+
+ value =
properties.getProperty("jpaSource.cacheTimeToLiveInMilliseconds");
+ if (isValue(value))
source.setCacheTimeToLiveInMilliseconds(Integer.parseInt(value));
+
+ value = properties.getProperty("jpaSource.creatingWorkspacesAllowed");
+ if (isValue(value))
source.setCreatingWorkspacesAllowed(Boolean.parseBoolean(value));
+
+ value = properties.getProperty("jpaSource.defaultWorkspaceName");
+ if (isValue(value)) source.setDefaultWorkspaceName(value);
+
+ value = properties.getProperty("jpaSource.predefinedWorkspaceNames");
+ if (isValue(value)) source.setPredefinedWorkspaceNames(splitValues(value));
+
+ value = properties.getProperty("jpaSource.model");
+ if (isValue(value)) source.setModel(value);
+
+ value =
properties.getProperty("jpaSource.numberOfConnectionsToAcquireAsNeeded");
+ if (isValue(value))
source.setNumberOfConnectionsToAcquireAsNeeded(Integer.parseInt(value));
+
+ value =
properties.getProperty("jpaSource.referentialIntegrityEnforced");
+ if (isValue(value))
source.setReferentialIntegrityEnforced(Boolean.parseBoolean(value));
+
+ value = properties.getProperty("jpaSource.retryLimit");
+ if (isValue(value)) source.setRetryLimit(Integer.parseInt(value));
+
+ value = properties.getProperty("jpaSource.rootNodeUuid");
+ if (isValue(value)) source.setRootNodeUuid(value);
+
+ value = properties.getProperty("jpaSource.showSql");
+ if (isValue(value)) source.setShowSql(Boolean.parseBoolean(value));
+
+ return source;
+ }
+
+ protected static boolean isValue( String value ) {
+ return value != null && value.trim().length() != 0;
+ }
+
+ protected static String[] splitValues( String value ) {
+ String[] results = value.split(", ");
+ for (int i = 0; i != results.length; ++i) {
+ results[i] = results[i].trim();
+ // Remove leading and trailing quotes, if there are any ...
+ results[i] = results[i].replaceFirst("^['\"]+",
"").replaceAll("['\"]+$", "").trim();
+ }
+ return results;
+ }
+}
Property changes on:
trunk/extensions/dna-connector-store-jpa/src/test/java/org/jboss/dna/connector/store/jpa/TestEnvironment.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/extensions/dna-connector-store-jpa/src/test/resources/database.properties
===================================================================
--- trunk/extensions/dna-connector-store-jpa/src/test/resources/database.properties
(rev 0)
+++
trunk/extensions/dna-connector-store-jpa/src/test/resources/database.properties 2009-09-16
20:56:22 UTC (rev 1227)
@@ -0,0 +1,52 @@
+#
+# JBoss DNA (
http://www.jboss.org/dna)
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership. Some portions may be licensed
+# to Red Hat, Inc. under one or more contributor license agreements.
+# See the AUTHORS.txt file in the distribution for a full listing of
+# individual contributors.
+#
+# JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+# is licensed to you under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# JBoss DNA 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+#
+
+# All of these properties are or can be set in the parent POM in the different profiles.
+# The property names are designed to match those used in the POM.
+# Any property that does not have a non-empty value set by Maven will not be set on the
JpaSource.
+jpaSource.dialect = ${jpaSource.dialect}
+jpaSource.driverClassName = ${jpaSource.driverClassName}
+jpaSource.url = ${jpaSource.url}
+jpaSource.username = ${jpaSource.username}
+jpaSource.password = ${jpaSource.password}
+jpaSource.maximumConnectionsInPool = ${jpaSource.maximumConnectionsInPool}
+jpaSource.minimumConnectionsInPool = ${jpaSource.minimumConnectionsInPool}
+jpaSource.numberOfConnectionsToAcquireAsNeeded =
${jpaSource.numberOfConnectionsToAcquireAsNeeded}
+jpaSource.maximumSizeOfStatementCache = ${jpaSource.maximumSizeOfStatementCache}
+jpaSource.maximumConnectionIdleTimeInSeconds =
${jpaSource.maximumConnectionIdleTimeInSeconds}
+jpaSource.largeValueSizeInBytes = ${jpaSource.largeValueSizeInBytes}
+jpaSource.autoGenerateSchema = ${jpaSource.autoGenerateSchema}
+jpaSource.compressData = ${jpaSource.compressData}
+jpaSource.cacheTimeToLiveInMilliseconds = ${jpaSource.cacheTimeToLiveInMilliseconds}
+jpaSource.creatingWorkspacesAllowed = ${jpaSource.creatingWorkspacesAllowed}
+jpaSource.defaultWorkspaceName = ${jpaSource.defaultWorkspaceName}
+# comma-separated and optionally quoted
+jpaSource.predefinedWorkspaceNames = ${jpaSource.predefinedWorkspaceNames}
+jpaSource.model = ${jpaSource.model}
+jpaSource.numberOfConnectionsToAcquireAsNeeded =
${jpaSource.numberOfConnectionsToAcquireAsNeeded}
+jpaSource.referentialIntegrityEnforced = ${jpaSource.referentialIntegrityEnforced}
+jpaSource.retryLimit = ${jpaSource.retryLimit}
+jpaSource.rootNodeUuid = ${jpaSource.rootNodeUuid}
+jpaSource.showSql = ${jpaSource.showSql}
+
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-09-16 14:40:56 UTC (rev 1226)
+++ trunk/pom.xml 2009-09-16 20:56:22 UTC (rev 1227)
@@ -137,6 +137,36 @@
<module>web/dna-web-jcr-rest</module>
<module>web/dna-web-jcr-rest-war</module>
</modules>
+ <properties>
+ <!-- These are properties used in the database profiles. Must initialize them to be
empty so that Maven applies
+ them via filtering to the resources. If a project needs files filtered, however,
make sure to include
+ a 'testResources' fragment in the 'build' section of the child
project POM to say which files need to be filtered.
+ See the "dna-integration" or
"extensions/dna-connector-store-jpa" project POMs for examples. -->
+ <jpaSource.dialect/>
+ <jpaSource.driverClassName/>
+ <jpaSource.url/>
+ <jpaSource.username/>
+ <jpaSource.password/>
+ <jpaSource.maximumConnectionsInPool>1</jpaSource.maximumConnectionsInPool>
+ <jpaSource.minimumConnectionsInPool>0</jpaSource.minimumConnectionsInPool>
+ <jpaSource.numberOfConnectionsToAcquireAsNeeded>1</jpaSource.numberOfConnectionsToAcquireAsNeeded>
+ <jpaSource.maximumSizeOfStatementCache>100</jpaSource.maximumSizeOfStatementCache>
+ <jpaSource.maximumConnectionIdleTimeInSeconds>0</jpaSource.maximumConnectionIdleTimeInSeconds>
+ <jpaSource.referentialIntegrityEnforced>true</jpaSource.referentialIntegrityEnforced>
+ <jpaSource.largeValueSizeInBytes>150</jpaSource.largeValueSizeInBytes>
+ <jpaSource.autoGenerateSchema>create</jpaSource.autoGenerateSchema>
+ <jpaSource.compressData/>
+ <jpaSource.cacheTimeToLiveInMilliseconds/>
+ <jpaSource.creatingWorkspacesAllowed/>
+ <jpaSource.defaultWorkspaceName/>
+ <jpaSource.predefinedWorkspaceNames/>
+ <jpaSource.model/>
+ <jpaSource.numberOfConnectionsToAcquireAsNeeded/>
+ <jpaSource.referentialIntegrityEnforced>true</jpaSource.referentialIntegrityEnforced>
+ <jpaSource.retryLimit>3</jpaSource.retryLimit>
+ <jpaSource.rootNodeUuid/>
+ <jpaSource.showSql>false</jpaSource.showSql>
+ </properties>
<profiles>
<profile>
@@ -310,6 +340,368 @@
</plugins>
</reporting>
</profile>
+
+ <!--
+ ###################################################################
+ Database profiles to specify which DBMS is used for tests.
+ ###################################################################
+
+ To use, specify "-Ddatbase=<dbProfileName>" on the Maven
command line.
+ -->
+
+ <!-- The default test environment is HSQLDB (may eventually move to H2) -->
+ <profile>
+ <id>default_dbms</id>
+ <activation>
+ <property>
+ <name>!database</name>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <database>hsqldb</database>
+
<jpaSource.dialect>org.hibernate.dialect.HSQLDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>org.hsqldb.jdbcDriver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:hsqldb:target/test/db/hsqldb/hibernate</jpaSource.url>
+ <jpaSource.username>sa</jpaSource.username>
+ <jpaSource.password />
+ </properties>
+ </profile>
+
+ <!-- The HSQLDB test environment -->
+ <profile>
+ <id>hsqldb</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>h2</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ </dependency>
+ </dependencies>
+ <properties>
+ <database>hsqldb</database>
+
<jpaSource.dialect>org.hibernate.dialect.HSQLDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>org.hsqldb.jdbcDriver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:hsqldb:target/test/db/hsqldb/hibernate</jpaSource.url>
+ <jpaSource.username>sa</jpaSource.username>
+ <jpaSource.password />
+ </properties>
+ </profile>
+
+ <!-- The H2 test environment -->
+
+ <profile>
+ <id>h2</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>h2</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.h2database</groupId>
+ <artifactId>h2database</artifactId>
+ <version>1.0.20061217</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.H2Dialect</jpaSource.dialect>
+
<jpaSource.driverClassName>org.h2.Driver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:h2:mem:target/test/db/h2/hibernate</jpaSource.url>
+ <jpaSource.username>sa</jpaSource.username>
+ <jpaSource.password />
+ </properties>
+ </profile>
+
+ <!-- The PostgreSQL test environment, local to the developer -->
+ <profile>
+ <id>postgresql_local</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>postgresql_local</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.4-701.jdbc3</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.PostgreSQLDialect</jpaSource.dialect>
+ <jpaSource.driver>org.postgresql.Driver</jpaSource.driver>
+
<jpaSource.url>jdbc:postgresql://localhost/unit_test</jpaSource.url>
+ <jpaSource.username>postgres</jpaSource.username>
+ <jpaSource.password>data</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!--
+ ###################################################################
+ Profiles naming db instances in the Red Hat QA/QE lab
+ First, those with OSS drivers
+ ###################################################################
+ -->
+
+ <!-- The MySQL5 test environment -->
+ <profile>
+ <id>mysql5</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>mysql5</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.0.5</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>com.mysql.jdbc.driverClassName</jpaSource.driverClassName>
+
<
jpaSource.url>jdbc:mysql://vmg08.mw.lab.eng.bos.redhat.com/hibbrtru<...
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!-- The PostgreSQL test environment -->
+ <profile>
+ <id>postgresql8</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>postgresql8</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.2-504</version>
+ <classifier>jdbc3</classifier>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.PostgreSQLDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>org.postgresql.Driver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:postgresql://dev01.qa.atl.jboss.com:5432:hibbrtru</jpaSource.url>
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!--
+ ###################################################################
+ Then, those with commercial drivers
+ ###################################################################
+ -->
+
+ <!-- The DB2 8.x test environment (using 9x drivers)-->
+ <profile>
+ <id>db2v8</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>db2v8</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc_license_cu</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.DB2Dialect</jpaSource.dialect>
+
<jpaSource.driverClassName>com.ibm.db2.jcc.DB2Driver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:db2://dev32.qa.atl.jboss.com:50000/jbossqa</jpaSource.url>
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!-- The DB2 9.x test environment (using 9x drivers)-->
+ <profile>
+ <id>db2v9</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>db2v9</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm</groupId>
+ <artifactId>db2jcc_license_cu</artifactId>
+ <version>3.1.57</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.DB2Dialect</jpaSource.dialect>
+
<jpaSource.driverClassName>com.ibm.db2.jcc.DB2Driver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:db2://dev67.qa.atl.jboss.com:50000/jbossqa</jpaSource.url>
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!-- The Oracle9i test environment -->
+ <profile>
+ <id>oracle9i</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>oracle9i</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc14</artifactId>
+ <!-- use the 10g drivers which are surprisingly largely bug free -->
+ <version>10.0.2.0</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.Oracle9iDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>oracle.jdbc.driverClassName.OracleDriver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:oracle:thin:@dev20.qa.atl.jboss.com:1521:qa</jpaSource.url>
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!-- The Oracle10g test environment -->
+ <profile>
+ <id>oracle10g</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>oracle10g</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc14</artifactId>
+ <!-- use the 10g drivers which are surprisingly largely bug free -->
+ <version>10.0.2.0</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.Oracle10gDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>oracle.jdbc.driverClassName.OracleDriver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:oracle:thin:@dev01.qa.atl.jboss.com:1521:qadb01</jpaSource.url>
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!-- The Oracle11g test environment -->
+ <profile>
+ <id>oracle11g</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>oracle11g</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.oracle</groupId>
+ <artifactId>ojdbc6</artifactId>
+ <version>11.1.0.7.0</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.Oracle10gDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>oracle.jdbc.driverClassName.OracleDriver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:oracle:thin:@ENGLXDBS11.mm.atl2.redhat.com:1521:orcl</jpaSource.url>
+ <jpaSource.username>integtest</jpaSource.username>
+ <jpaSource.password>teiid</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!-- The Sybase 15 test environment -->
+ <profile>
+ <id>sybase15</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>sybase15</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.sybase</groupId>
+ <artifactId>jconnect</artifactId>
+ <version>6.0.5</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.SybaseASE15Dialect</jpaSource.dialect>
+
<jpaSource.driverClassName>com.sybase.jdbc3.jdbc.SybDriver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:sybase:Tds:dev77.qa.atl2.redhat.com:5000/hibbrtru</jpaSource.url>
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
+ <!-- The SQLServer2005 (MS JDBC) test environment -->
+ <profile>
+ <id>mssql2005</id>
+ <activation>
+ <property>
+ <name>database</name>
+ <value>mssql2005</value>
+ </property>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>com.microsoft.sqlserver</groupId>
+ <artifactId>msjdbc</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
+ <properties>
+
<jpaSource.dialect>org.hibernate.dialect.SQLServerDialect</jpaSource.dialect>
+
<jpaSource.driverClassName>com.microsoft.sqlserver.jdbc.SQLServerDriver</jpaSource.driverClassName>
+
<jpaSource.url>jdbc:sqlserver://dev30.qa.atl.jboss.com:3918</jpaSource.url>
+ <jpaSource.username>username</jpaSource.username>
+ <jpaSource.password>password</jpaSource.password>
+ </properties>
+ </profile>
+
</profiles>
<build>
<!-- This section defines the default plugin settings inherited by child projects.
-->