ODE-666 Migrated to H2 for bpel-runtime tests and bpel-test. Also cleaned up the axis2-war h2 tests.
Project: http://git-wip-us.apache.org/repos/asf/ode/repo Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/dec47e4b Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/dec47e4b Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/dec47e4b Branch: refs/heads/master Commit: dec47e4ba34045de1194be09aa311c10b101bbb7 Parents: 34b4e76 Author: Tammo van Lessen <[email protected]> Authored: Fri Jul 25 12:07:08 2014 +0200 Committer: Tammo van Lessen <[email protected]> Committed: Fri Jul 25 12:07:08 2014 +0200 ---------------------------------------------------------------------- Rakefile | 48 ++++---- .../webapp/WEB-INF/conf/ode-axis2.properties | 16 +-- .../org/apache/ode/axis2/Axis2TestBase.java | 2 +- .../org/apache/ode/axis2/BpelActivityTest.java | 2 +- .../ode/axis2/ClusteredOutgoingTrafficTest.java | 2 +- .../org/apache/ode/axis2/ODEConfigDirAware.java | 4 +- .../org/apache/ode/axis2/SelectorsTest.java | 2 +- .../correlation/CorrelationJoinHibTest.java | 2 +- .../correlation/CorrelationJoinLazyHibTest.java | 2 +- .../correlation/CorrelationJoinLazyTest.java | 2 +- .../axis2/correlation/CorrelationJoinTest.java | 2 +- .../correlation/CorrelationMultiHibTest.java | 2 +- .../axis2/correlation/CorrelationMultiTest.java | 2 +- .../correlation/CorrelationUnicityTest.java | 2 +- .../instancecleanup/CleanFailureHibTest.java | 2 +- .../axis2/instancecleanup/CleanFailureTest.java | 2 +- .../instancecleanup/CleanFaultHibTest.java | 2 +- .../axis2/instancecleanup/CleanFaultTest.java | 2 +- .../instancecleanup/CleanSuccessHibTest.java | 2 +- .../axis2/instancecleanup/CleanSuccessTest.java | 2 +- .../instancecleanup/ProcessCronCleanupTest.java | 2 +- .../instancecleanup/SystemCronCleanupTest.java | 2 +- .../management/InstanceManagementTest.java | 2 +- axis2-war/src/test/maven2/ode-axis2.properties | 2 +- .../WEB-INF/conf.hib-derby/ode-axis2.properties | 7 +- .../WEB-INF/conf.hib-h2/ode-axis2.properties | 30 +++++ .../WEB-INF/conf.jpa-derby/ode-axis2.properties | 5 +- .../WEB-INF/conf.jpa-h2/ode-axis2.properties | 21 ++++ .../webapp/WEB-INF/conf/ode-axis2.properties | 6 +- .../ode/il/config/OdeConfigProperties.java | 27 +++++ .../java/org/apache/ode/il/dbutil/Database.java | 10 +- .../il/dbutil/DatabaseConnectionManager.java | 117 +++++++++++++++++++ .../apache/ode/il/dbutil/DerbyEmbeddedDB.java | 101 ++++++++++++++++ .../org/apache/ode/il/dbutil/EmbeddedDB.java | 44 ------- .../org/apache/ode/il/dbutil/H2EmbeddedDB.java | 81 +++++++++++++ .../org/apache/ode/il/dbutil/InternalDB.java | 115 +++--------------- .../ode/bpel/engine/cron/CronSchedulerTest.java | 14 +-- .../apache/ode/bpel/runtime/MockBpelServer.java | 96 +++++---------- .../store/hib/DbConfStoreConnectionFactory.java | 2 - .../java/org/apache/ode/store/hib/DaoTest.java | 36 +++--- .../org/apache/ode/test/BPELTestAbstract.java | 85 +++----------- .../apache/ode/test/ExternalVariableTest.java | 11 +- .../bpel/BpelDAOConnectionFactoryImpl.java | 2 - .../org/apache/ode/daohib/bpel/BaseTestDAO.java | 3 - .../src/main/descriptors/persistence.h2.xml | 55 +++++++++ .../src/main/scripts/simplesched-h2.sql | 31 +++++ jbi/src/test/resources/smx-base.xml | 2 +- tasks/derby.rake | 2 +- tasks/h2.rake | 6 +- 49 files changed, 631 insertions(+), 388 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/Rakefile ---------------------------------------------------------------------- diff --git a/Rakefile b/Rakefile index ebc3e20..8f55fe5 100644 --- a/Rakefile +++ b/Rakefile @@ -28,12 +28,14 @@ require File.join(File.dirname(__FILE__), 'dependencies.rb') Buildr.settings.build['jmock'] = "1.2.0" +Buildr::Hibernate::REQUIRES[:hibernate] = HIBERNATE, Buildr::Hibernate::REQUIRES[:xdoclet] = Buildr.group("xdoclet", "xdoclet-xdoclet-module", "xdoclet-hibernate-module", :under=>"xdoclet", :version=>"1.2.3") + ["xdoclet:xjavadoc:jar:1.1-j5"] # XMLBeans addon must use the same version as we do. Buildr::XMLBeans::REQUIRES.xmlbeans.version = artifact(XMLBEANS).version +Buildr::OpenJPA::REQUIRES[0] = "org.apache.openjpa:openjpa:jar:1.2.0" # dirty workaround for BUILDR-541/BUILDR-508 Java.classpath << Buildr::OpenJPA::REQUIRES @@ -111,7 +113,7 @@ define "ode" do end package(:war).path("WEB-INF/modules").include(artifacts(AXIS2_MODULES.mods)) package(:war).tap do |root| - root.merge(artifact(AXIS2_WAR)).exclude("WEB-INF/*").exclude("META-INF/*") + root.merge(artifact(AXIS2_WAR)).include("WEB-INF/classes/org/*") end task("start"=>[package(:war), jetty.use]) do |task| @@ -128,7 +130,7 @@ define "ode" do end test.using :testng, :forkmode=>'perTest', :properties=>{ "org.apache.commons.logging.LogFactory" => "org.apache.commons.logging.impl.LogFactoryImpl", "log4j.configuration"=>"test-log4j.properties", "test.ports" => ENV['TEST_PORTS'], "org.apache.ode.scheduler.deleteJobsOnStart" => "true", "org.apache.ode.autoRetireProcess"=>"true" } , :java_args=>['-Xmx2048m', '-XX:MaxPermSize=256m'] #'-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=6001', - test.with projects("tools"), libs, AXIS2_MODULES.mods, AXIOM, JAVAX.servlet, Buildr::Jetty::REQUIRES, HIBERNATE, DOM4J, H2::REQUIRES, SPRING_TEST + test.with [projects("tools"), libs, AXIS2_MODULES.mods, AXIOM, JAVAX.servlet, Buildr::Jetty::REQUIRES, HIBERNATE, DOM4J, H2::REQUIRES, SPRING_TEST].uniq webapp_dir = "#{test.compile.target}/webapp" test.setup task(:prepare_webapp) do |task| cp_r _("src/main/webapp"), test.compile.target.to_s @@ -198,7 +200,7 @@ define "ode" do define "bpel-epr" do compile.with projects("utils", "bpel-dao", "bpel-api"), AXIOM, COMMONS.lang, COMMONS.beanutils, DERBY, JAVAX.connector, JAVAX.stream, JAVAX.transaction, - GERONIMO.transaction, GERONIMO.connector, TRANQL, XMLBEANS, SLF4J, LOG4J + GERONIMO.transaction, GERONIMO.connector, TRANQL, XMLBEANS, SLF4J, LOG4J, H2::REQUIRES test.with XERCES package :jar end @@ -229,7 +231,7 @@ define "ode" do test.with projects("scheduler-simple", "dao-jpa", "dao-hibernate", "bpel-epr"), BACKPORT, COMMONS.pool, COMMONS.lang, COMMONS.io, DERBY, JAVAX.connector, JAVAX.transaction, GERONIMO.transaction, GERONIMO.kernel, GERONIMO.connector, TRANQL, HSQLDB, JAVAX.ejb, - OPENJPA, XERCES, XALAN, DOM4J, HIBERNATE, SPRING_TEST, + OPENJPA, XERCES, XALAN, DOM4J, HIBERNATE, SPRING_TEST, H2::REQUIRES, "tranql:tranql-connector-derby-common:jar:1.1" package :jar @@ -268,7 +270,7 @@ define "ode" do test.with COMMONS.collections, COMMONS.lang, JAVAX.connector, JAVAX.transaction, DOM4J, XERCES, XALAN, JAXEN, SAXON, OPENJPA, GERONIMO.transaction, SLF4J, SPRING_TEST, DERBY, - GERONIMO.transaction, GERONIMO.kernel, GERONIMO.connector, JAVAX.connector, JAVAX.ejb + GERONIMO.transaction, GERONIMO.kernel, GERONIMO.connector, JAVAX.connector, JAVAX.ejb, H2::REQUIRES package :jar end @@ -283,7 +285,7 @@ define "ode" do test.using :properties=>{ "org.apache.ode.autoRetireProcess"=>"true" } test.with projects("bpel-obj", "bpel-schemas", "bpel-scripts"), COMMONS.collections, COMMONS.lang, DERBY, JACOB, JAVAX.connector, - JAVAX.stream, JAVAX.transaction, JAVAX.connector, JAXEN, HSQLDB, SAXON, XERCES, XMLBEANS, XALAN, GERONIMO.transaction, SPRING, HIBERNATE, DOM4J + JAVAX.stream, JAVAX.transaction, JAVAX.connector, JAXEN, HSQLDB, SAXON, XERCES, XMLBEANS, XALAN, GERONIMO.transaction, SPRING, HIBERNATE, DOM4J, H2::REQUIRES package :jar end @@ -337,22 +339,22 @@ define "ode" do end end - runtime_sql = export[ properties_for[:derby], dao_hibernate, _("target/runtime.sql") ] - store_sql = export[ properties_for[:derby], bpel_store, _("target/store.sql") ] common_sql = _("src/main/sql/common.sql") - derby_sql = concat(_("target/derby.sql")=>[ predefined_for[:derby], common_sql, runtime_sql, store_sql ]) - derby_db = Derby.create(_("target/derby/hibdb")=>derby_sql) - build derby_db - h2_sql = _("src/schema/ode-hib-h2.sql") - h2_db = H2.create("ode-hib-h2", _("target/h2/hibdb")=>h2_sql) - build h2_db - - %w{ mysql firebird hsql postgres sqlserver oracle }.each do |db| - partial = export[ properties_for[db], dao_hibernate, _("target/partial.#{db}.sql") ] - build concat(_("target/#{db}.sql")=>[ common_sql, predefined_for[db], partial ]) + %w{ derby mysql firebird hsql postgres sqlserver oracle h2}.each do |db| + partial_runtime = export[ properties_for[db], dao_hibernate, _("target/partial.runtime.#{db}.sql") ] + partial_store = export[ properties_for[db], bpel_store, _("target/partial.store.#{db}.sql") ] + build concat(_("target/#{db}.sql")=>[ common_sql, predefined_for[db], partial_store, partial_runtime]) end + derby_sql = _("target/derby.sql") + derby_db = Derby.create(_("target/derby-hibdb")=>derby_sql) + build derby_db + + h2_sql = _("target/h2.sql") + h2_db = H2.create("ode-hib-h2", _("target/h2-hibdb")=>h2_sql) + build h2_db + NativeDB.create_dbs self, _("."), :hib package(:zip).include(derby_db, h2_db) @@ -368,7 +370,7 @@ define "ode" do desc "ODE OpenJPA Derby Database" define "dao-jpa-ojpa-derby" do - %w{ derby mysql oracle postgres }.each do |db| + %w{ derby mysql oracle postgres h2 }.each do |db| db_xml = _("src/main/descriptors/persistence.#{db}.xml") scheduler_sql = _("src/main/scripts/simplesched-#{db}.sql") common_sql = _("src/main/scripts/common.sql") @@ -380,7 +382,8 @@ define "ode" do sql = concat(_("target/#{db}.sql")=>[_("src/main/scripts/license-header.sql"), common_sql, partial_sql, scheduler_sql]) build sql end - derby_db = Derby.create(_("target/derby/jpadb")=>_("target/derby.sql")) + derby_db = Derby.create(_("target/derby-jpadb")=>_("target/derby.sql")) + h2_db = H2.create("ode-jpa-h2", _("target/h2-jpadb")=>_("target/h2.sql")) test.with projects("bpel-api", "bpel-dao", "bpel-obj", "bpel-epr", "dao-jpa", "utils"), BACKPORT, COMMONS.collections, COMMONS.lang, COMMONS.logging, GERONIMO.transaction, @@ -388,10 +391,11 @@ define "ode" do JAVAX.transaction, LOG4J, OPENJPA, XERCES, WSDL4J build derby_db - + build h2_db + NativeDB.create_dbs self, _("."), :jpa - package(:zip).include(derby_db) + package(:zip).include(derby_db, h2_db) end desc "ODE JBI Integration Layer" http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/main/webapp/WEB-INF/conf/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/main/webapp/WEB-INF/conf/ode-axis2.properties b/axis2-war/src/main/webapp/WEB-INF/conf/ode-axis2.properties index 20bdc04..253037c 100644 --- a/axis2-war/src/main/webapp/WEB-INF/conf/ode-axis2.properties +++ b/axis2-war/src/main/webapp/WEB-INF/conf/ode-axis2.properties @@ -24,7 +24,7 @@ ## * "EMBEDDED" - ODE will create its own embbeded database (Derby) ## and connection pool (Minerva). ## * "EXTERNAL" - ODE will use an app-server provided database and pool. -## The "ode-jbi.db.ext.dataSource" property will need to +## The "ode-axis2.db.ext.dataSource" property will need to ## be set. ## * "INTERNAL" - ODE will create its own connection pool for a user- ## specified JDBC URL and driver. @@ -43,18 +43,20 @@ ode-axis2.db.emb.type=derby ## External Database [JNDI Name] ## JNDI Name of the DataSource for the ODE database. This is only -## used if the "ode-jbi.db.mode" property is set to "EXTERNAL" +## used if the "ode-axis2.db.mode" property is set to "EXTERNAL" #ode-axis2.db.ext.dataSource=java:comp/env/jdbc/ode ## Embedded Database Name [String] ## Name of the embedded Derby database. This is only used if the -## "ode-jbi.db.mode" property is set to "EMBEDDED". -#ode-jbi.db.emb.name=hibdb -#ode-jbi.db.emb.name=jpadb +## "ode-axis2.db.mode" property is set to "EMBEDDED". +#ode-axis2.db.emb.name=h2-hibdb +#ode-axis2.db.emb.name=h2-jpadb +#ode-axis2.db.emb.name=derby-hibdb +ode-axis2.db.emb.name=derby-jpadb ## Internal Database Configuration -#ode-jbi.db.int.jdbcurl=jdbc:mysql://localhost/ode?user=sa -#ode-jbi.db.int.driver=com.mysql.jdbc.Driver +#ode-axis2.db.int.jdbcurl=jdbc:mysql://localhost/ode?user=sa +#ode-axis2.db.int.driver=com.mysql.jdbc.Driver #ode-axis2.db.int.password = #ode-axis2.db.int.username = http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java b/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java index 1c94b47..bac073b 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/Axis2TestBase.java @@ -184,7 +184,7 @@ public abstract class Axis2TestBase { @BeforeMethod protected void setUp() throws Exception { System.out.println("##### Running "+getClass().getName()); - log.debug("##### Running "+getClass().getName()); + log.info("##### Running "+getClass().getName()); /** * 1. If no settings are given from buildr, the test runs with the default config directory. * 2. If no settings are given from buildr and if the test implements ODEConfigDirAware, the test runs with http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java index 130dce6..c7e412e 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/BpelActivityTest.java @@ -73,6 +73,6 @@ public class BpelActivityTest extends Axis2TestBase implements ODEConfigDirAware } public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } } http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/ClusteredOutgoingTrafficTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/ClusteredOutgoingTrafficTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/ClusteredOutgoingTrafficTest.java index 6d0c6a4..75af7d3 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/ClusteredOutgoingTrafficTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/ClusteredOutgoingTrafficTest.java @@ -48,6 +48,6 @@ public class ClusteredOutgoingTrafficTest extends Axis2TestBase implements ODECo } public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } } http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java b/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java index 0dfdf00..dd3bc0c 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/ODEConfigDirAware.java @@ -20,8 +20,8 @@ package org.apache.ode.axis2; public interface ODEConfigDirAware { - final String HIB_DERBY_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; - final String JPA_DERBY_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + final String HIB_H2_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; + final String JPA_H2_CONF_DIR = ODEConfigDirAware.class.getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; String getODEConfigDir(); } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/SelectorsTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/SelectorsTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/SelectorsTest.java index de22141..e679fb0 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/SelectorsTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/SelectorsTest.java @@ -45,6 +45,6 @@ public class SelectorsTest extends Axis2TestBase implements ODEConfigDirAware { } public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java index 3774810..910324a 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinHibTest.java @@ -22,6 +22,6 @@ package org.apache.ode.axis2.correlation; public class CorrelationJoinHibTest extends CorrelationJoinTest { @Override public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java index f7cedf9..20c2256 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyHibTest.java @@ -22,6 +22,6 @@ package org.apache.ode.axis2.correlation; public class CorrelationJoinLazyHibTest extends CorrelationJoinLazyTest { @Override public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java index b515b1c..32166a5 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinLazyTest.java @@ -79,6 +79,6 @@ public class CorrelationJoinLazyTest extends Axis2TestBase implements ODEConfigD } public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java index b135d29..d934d86 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationJoinTest.java @@ -78,6 +78,6 @@ public class CorrelationJoinTest extends Axis2TestBase implements ODEConfigDirAw } public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java index 2bab73b..3aa7808 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiHibTest.java @@ -22,6 +22,6 @@ package org.apache.ode.axis2.correlation; public class CorrelationMultiHibTest extends CorrelationMultiTest { @Override public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.hib-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java index 8fe9d04..15d2cb7 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationMultiTest.java @@ -60,6 +60,6 @@ public class CorrelationMultiTest extends Axis2TestBase implements ODEConfigDirA } public String getODEConfigDir() { - return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-derby"; + return getClass().getClassLoader().getResource("webapp").getFile() + "/WEB-INF/conf.jpa-h2"; } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationUnicityTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationUnicityTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationUnicityTest.java index 178ac87..d4a80fe 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationUnicityTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/correlation/CorrelationUnicityTest.java @@ -59,6 +59,6 @@ public class CorrelationUnicityTest extends Axis2TestBase implements ODEConfigDi } public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } } http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureHibTest.java index 0a2c63b..153c4af 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureHibTest.java @@ -25,7 +25,7 @@ import org.apache.ode.bpel.dao.ProcessInstanceDAO; public class CleanFailureHibTest extends CleanFailureTest { @Override public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } @Override http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureTest.java index 2b8924e..001dc1d 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFailureTest.java @@ -43,7 +43,7 @@ public class CleanFailureTest extends CleanTestBase { } public String getODEConfigDir() { - return JPA_DERBY_CONF_DIR; + return JPA_H2_CONF_DIR; } protected ProcessInstanceDAO getInstance() { http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultHibTest.java index 61d8abe..b23a20d 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultHibTest.java @@ -24,7 +24,7 @@ import org.apache.ode.bpel.dao.ProcessInstanceDAO; public class CleanFaultHibTest extends CleanFaultTest { @Override public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } @Override http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultTest.java index bfaac89..f1453c3 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanFaultTest.java @@ -92,7 +92,7 @@ public class CleanFaultTest extends CleanTestBase { } public String getODEConfigDir() { - return JPA_DERBY_CONF_DIR; + return JPA_H2_CONF_DIR; } @Override http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessHibTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessHibTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessHibTest.java index 84d2c06..42e061d 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessHibTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessHibTest.java @@ -24,7 +24,7 @@ import org.apache.ode.bpel.dao.ProcessInstanceDAO; public class CleanSuccessHibTest extends CleanSuccessTest { @Override public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } @Override http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessTest.java index 697d41f..ef6fa64 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/CleanSuccessTest.java @@ -90,7 +90,7 @@ public class CleanSuccessTest extends CleanTestBase { } public String getODEConfigDir() { - return JPA_DERBY_CONF_DIR; + return JPA_H2_CONF_DIR; } protected ProcessInstanceDAO getInstance() { http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/ProcessCronCleanupTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/ProcessCronCleanupTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/ProcessCronCleanupTest.java index 46890d0..e934e94 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/ProcessCronCleanupTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/ProcessCronCleanupTest.java @@ -46,7 +46,7 @@ public class ProcessCronCleanupTest extends CleanTestBase { } public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } protected ProcessInstanceDAO getInstance() { http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/SystemCronCleanupTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/SystemCronCleanupTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/SystemCronCleanupTest.java index 8b036d3..b567b9f 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/SystemCronCleanupTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/instancecleanup/SystemCronCleanupTest.java @@ -73,7 +73,7 @@ public class SystemCronCleanupTest extends CleanTestBase { } public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } protected ProcessInstanceDAO getInstance() { http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java index cebed4f..a0ad6de 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/management/InstanceManagementTest.java @@ -283,6 +283,6 @@ public class InstanceManagementTest extends Axis2TestBase implements ODEConfigDi } public String getODEConfigDir() { - return HIB_DERBY_CONF_DIR; + return HIB_H2_CONF_DIR; } } http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/maven2/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/maven2/ode-axis2.properties b/axis2-war/src/test/maven2/ode-axis2.properties index a293a19..24ac9dc 100644 --- a/axis2-war/src/test/maven2/ode-axis2.properties +++ b/axis2-war/src/test/maven2/ode-axis2.properties @@ -17,7 +17,7 @@ ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.HibDaoConnectionFactoryImpl ode-axis2.db.mode=INTERNAL -ode-axis2.db.int.jdbcurl=jdbc:h2:file:${basedir}/target/webapp/WEB-INF/hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 +ode-axis2.db.int.jdbcurl=jdbc:h2:file:${basedir}/target/webapp/WEB-INF/h2-hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 ode-axis2.db.int.driver=org.h2.Driver ode-axis2.cluster.localRoute.targets=http://doesntexist:8080/ode/processes/ ode-axis2.cluster.localRoute.base=http://localhost:8888/ode/processes/ http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/webapp/WEB-INF/conf.hib-derby/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf.hib-derby/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf.hib-derby/ode-axis2.properties index 131993d..0badc6b 100644 --- a/axis2-war/src/test/webapp/WEB-INF/conf.hib-derby/ode-axis2.properties +++ b/axis2-war/src/test/webapp/WEB-INF/conf.hib-derby/ode-axis2.properties @@ -16,12 +16,11 @@ # ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.HibDaoConnectionFactoryImpl -ode-axis2.db.mode=INTERNAL -ode-axis2.db.int.jdbcurl=jdbc:h2:file:axis2-war/target/test/classes/webapp/WEB-INF/hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 -ode-axis2.db.int.driver=org.h2.Driver +ode-axis2.db.mode=EMBEDDED +ode-axis2.db.emb.type=DERBY +ode-axis2.db.emb.name=derby-hibdb ode-axis2.cluster.localRoute.targets=http://doesntexist:8080/ode/processes/ ode-axis2.cluster.localRoute.base=http://localhost:8888/ode/processes/ ode-axis2.event.listeners=org.apache.ode.bpel.common.evt.DebugBpelEventListener -#hibernate.dialect=org.hibernate.dialect.H2Dialect ode-axis2.acquireTransactionLocks=true http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties new file mode 100644 index 0000000..e91a008 --- /dev/null +++ b/axis2-war/src/test/webapp/WEB-INF/conf.hib-h2/ode-axis2.properties @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.HibDaoConnectionFactoryImpl +#ode-axis2.db.mode=INTERNAL +#ode-axis2.db.int.jdbcurl=jdbc:h2:file:axis2-war/target/test/classes/webapp/WEB-INF/h2-hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 +#ode-axis2.db.int.driver=org.h2.Driver +ode-axis2.db.mode=EMBEDDED +ode-axis2.db.emb.type=H2 +ode-axis2.db.emb.name=h2-hibdb/ode-hib-h2 + +ode-axis2.cluster.localRoute.targets=http://doesntexist:8080/ode/processes/ +ode-axis2.cluster.localRoute.base=http://localhost:8888/ode/processes/ +ode-axis2.event.listeners=org.apache.ode.bpel.common.evt.DebugBpelEventListener +ode-axis2.acquireTransactionLocks=true + http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-derby/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf.jpa-derby/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-derby/ode-axis2.properties index f8b7e93..eea8b64 100644 --- a/axis2-war/src/test/webapp/WEB-INF/conf.jpa-derby/ode-axis2.properties +++ b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-derby/ode-axis2.properties @@ -15,4 +15,7 @@ # limitations under the License. # -ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.JpaDaoConnectionFactoryImpl \ No newline at end of file +ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.JpaDaoConnectionFactoryImpl +ode-axis2.db.mode=EMBEDDED +ode-axis2.db.emb.type=DERBY +ode-axis2.db.emb.name=derby-jpadb http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties new file mode 100644 index 0000000..c186678 --- /dev/null +++ b/axis2-war/src/test/webapp/WEB-INF/conf.jpa-h2/ode-axis2.properties @@ -0,0 +1,21 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.JpaDaoConnectionFactoryImpl +ode-axis2.db.mode=EMBEDDED +ode-axis2.db.emb.type=H2 +ode-axis2.db.emb.name=h2-jpadb/ode-jpa-h2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties b/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties index 94dd2f1..e12b199 100644 --- a/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties +++ b/axis2-war/src/test/webapp/WEB-INF/conf/ode-axis2.properties @@ -16,9 +16,9 @@ # ode-axis2.dao.factory=org.apache.ode.axis2.instancecleanup.HibDaoConnectionFactoryImpl -ode-axis2.db.mode=INTERNAL -ode-axis2.db.int.jdbcurl=jdbc:h2:file:axis2-war/target/test/classes/webapp/WEB-INF/hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 -ode-axis2.db.int.driver=org.h2.Driver +#ode-axis2.db.mode=INTERNAL +#ode-axis2.db.int.jdbcurl=jdbc:h2:file:axis2-war/target/test/classes/webapp/WEB-INF/h2-hibdb/ode-hib-h2;DB_CLOSE_ON_EXIT=false;user=sa;TRACE_LEVEL_FILE=3 +#ode-axis2.db.int.driver=org.h2.Driver ode-axis2.cluster.localRoute.targets=http://doesntexist:8080/ode/processes/ ode-axis2.cluster.localRoute.base=http://localhost:8888/ode/processes/ ode-axis2.event.listeners=org.apache.ode.bpel.common.evt.DebugBpelEventListener http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java b/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java index 5db7ceb..39ca2b0 100644 --- a/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java +++ b/bpel-epr/src/main/java/org/apache/ode/il/config/OdeConfigProperties.java @@ -46,6 +46,10 @@ public class OdeConfigProperties { public static final String PROP_DB_EMBEDDED_NAME = "db.emb.name"; + public static final String PROP_DB_EMBEDDED_TYPE = "db.emb.type"; + + public static final String PROP_DB_EMBEDDED_CREATE = "db.emb.create"; + public static final String PROP_DB_INTERNAL_URL = "db.int.jdbcurl"; public static final String PROP_DB_INTERNAL_DRIVER = "db.int.driver"; @@ -112,6 +116,10 @@ public class OdeConfigProperties { private static String __dbEmbName = "jpadb"; private static String __daoCfClass = "org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl"; + public static String DEFAULT_DB_EMB_NAME = "ode-db"; + public static String DEFAULT_DB_EMB_TYPE = "h2"; + public static String DEFAULT_DAOCF_CLASS = "org.apache.ode.dao.jpa.openjpa.BpelDAOConnectionFactoryImpl"; + static { String odep = System.getProperty("ode.persistence"); if (odep != null && @@ -135,6 +143,17 @@ public class OdeConfigProperties { /** Embedded database (Ode provides default embedded database with connection pool) */ EMBEDDED } + + /** + * Possible database implementation. + */ + public enum EmbeddedDbType { + + DERBY, + + H2 + } + public OdeConfigProperties(File cfgFile, String prefix) { _cfgFile = cfgFile; @@ -187,6 +206,14 @@ public class OdeConfigProperties { return getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_NAME, __dbEmbName); } + + public EmbeddedDbType getDbEmbeddedType() { + return EmbeddedDbType.valueOf(getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_TYPE, DEFAULT_DB_EMB_TYPE).trim().toUpperCase()); + } + + public boolean isDbEmbeddedCreate() { + return Boolean.valueOf(getProperty(OdeConfigProperties.PROP_DB_EMBEDDED_CREATE, "true")); + } public DatabaseMode getDbMode() { return DatabaseMode.valueOf(getProperty(OdeConfigProperties.PROP_DB_MODE, DatabaseMode.EMBEDDED.toString()).trim() http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java index 5d895ef..9d8c04d 100644 --- a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java +++ b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/Database.java @@ -40,10 +40,6 @@ public abstract class Database { protected static final Messages __msgs = Messages.getMessages(Messages.class); - protected static final int CONNECTION_MAX_WAIT_MILLIS = 30000; - - protected static final int CONNECTION_MAX_IDLE_MINUTES = 5; - protected OdeConfigProperties _odeConfig; protected boolean _started; @@ -59,7 +55,11 @@ public abstract class Database { throw new NullPointerException("Must provide a configuration."); switch (props.getDbMode()) { - case EMBEDDED: return new EmbeddedDB(props); + case EMBEDDED: + switch (props.getDbEmbeddedType()) { + case DERBY: return new DerbyEmbeddedDB(props); + case H2: return new H2EmbeddedDB(props); + } case EXTERNAL: return new ExternalDB(props); case INTERNAL: return new InternalDB(props); default: throw new IllegalStateException(); http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java new file mode 100644 index 0000000..2ef9732 --- /dev/null +++ b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DatabaseConnectionManager.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.ode.il.dbutil; + + +import javax.sql.DataSource; +import javax.transaction.TransactionManager; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.geronimo.connector.outbound.GenericConnectionManager; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; +import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; +import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker; +import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator; +import org.apache.geronimo.transaction.manager.RecoverableTransactionManager; +import org.apache.ode.il.config.OdeConfigProperties; +import org.tranql.connector.jdbc.JDBCDriverMCF; + +public class DatabaseConnectionManager { + + private static final long serialVersionUID = 1L; + private static final Log __log = LogFactory.getLog(DatabaseConnectionManager.class); + private static final Messages __msgs = Messages.getMessages(Messages.class); + private static final int CONNECTION_MAX_WAIT_MILLIS = 30000; + private static final int CONNECTION_MAX_IDLE_MINUTES = 5; + private GenericConnectionManager _connectionManager; + private TransactionManager _txm = null; + private String _url = null; + private OdeConfigProperties _odeConfig = null; + private DataSource _dataSource = null; + + public DatabaseConnectionManager(TransactionManager txm, OdeConfigProperties odeConfig) { + _txm = txm; + _odeConfig = odeConfig; + } + + public void init(String url, String driverClass, String username, String password) throws DatabaseConfigException { + __log.debug("Creating connection pool for " + url + " with driver " + driverClass); + + if (!(_txm instanceof RecoverableTransactionManager)) { + throw new RuntimeException("TransactionManager is not recoverable."); + } + + _url = url; + TransactionSupport transactionSupport = LocalTransactions.INSTANCE; + ConnectionTracker connectionTracker = new ConnectionTrackingCoordinator(); + + PoolingSupport poolingSupport = new SinglePool( + _odeConfig.getPoolMaxSize(), + _odeConfig.getPoolMinSize(), + CONNECTION_MAX_WAIT_MILLIS, + CONNECTION_MAX_IDLE_MINUTES, + true, // match one + false, // match all + false); // select one assume match + + _connectionManager = new GenericConnectionManager( + transactionSupport, + poolingSupport, + null, + connectionTracker, + (RecoverableTransactionManager) _txm, + getClass().getName(), + getClass().getClassLoader()); + + JDBCDriverMCF mcf = new JDBCDriverMCF(); + try { + mcf.setDriver(driverClass); + mcf.setConnectionURL(url); + if (username != null) { + mcf.setUserName(username); + } + if (password != null) { + mcf.setPassword(password); + } + _connectionManager.doStart(); + _dataSource = (DataSource) mcf.createConnectionFactory(_connectionManager); + } catch (Exception ex) { + String errmsg = __msgs.msgOdeDbPoolStartupFailed(url); + __log.error(errmsg, ex); + throw new DatabaseConfigException(errmsg, ex); + } + } + + public void shutdown() throws DatabaseConfigException { + try { + _connectionManager.doStop(); + } catch (Exception ex) { + String errmsg = __msgs.msgOdeDbPoolStartupFailed(_url); + __log.error(errmsg, ex); + throw new DatabaseConfigException(errmsg, ex); + } + } + + public DataSource getDataSource() { + return _dataSource; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyEmbeddedDB.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyEmbeddedDB.java b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyEmbeddedDB.java new file mode 100644 index 0000000..c98f93b --- /dev/null +++ b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/DerbyEmbeddedDB.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.ode.il.dbutil; + +import java.io.File; +import java.sql.DriverManager; +import java.sql.SQLException; + +import org.apache.derby.impl.io.VFMemoryStorageFactory; +import org.apache.derby.jdbc.EmbeddedDataSource; +import org.apache.ode.il.config.OdeConfigProperties; + +public class DerbyEmbeddedDB extends InternalDB { + + private String _dbUrl = null; + private String _dbName = null; + + public DerbyEmbeddedDB(OdeConfigProperties props) { + super(props); + } + + /** + * Initialize embedded (DERBY) database. + */ + @Override + protected void initDataSource() throws DatabaseConfigException { + _dbName = _odeConfig.getDbEmbeddedName(); + if (_workRoot == null) { + _dbUrl = "jdbc:derby:memory:" + _dbName + ";create=true"; + try { + DriverManager.getConnection(_dbUrl).close(); + } catch (SQLException se) { + __log.error(se); + } + EmbeddedDataSource dds = new EmbeddedDataSource(); + dds.setDatabaseName("memory:" + _dbName); + dds.setUser("sa"); + dds.setCreateDatabase("true"); + _datasource = dds; + } else { + _dbUrl = "jdbc:derby:" + _workRoot + File.separator + _dbName; + if (_odeConfig.isDbEmbeddedCreate()) { + _dbUrl += ";create=true"; + } + String clazz = org.apache.derby.jdbc.EmbeddedDriver.class.getName(); + _connectionManager = new DatabaseConnectionManager(_txm, _odeConfig); + try { + _connectionManager.init(_dbUrl, clazz, "sa", null); + } catch (DatabaseConfigException ex) { + __log.error("Unable to initialize connection pool", ex); + } + _datasource = _connectionManager.getDataSource(); + __log.debug("Using Embedded Database: " + _dbUrl); + } + } + + public void shutdownDB() { + if (_connectionManager != null) { + try { + _connectionManager.shutdown(); + } catch (DatabaseConfigException ex) { + __log.error("unable to shutdown connection pool", ex); + } + } + try { + DriverManager.getConnection(_dbUrl + ";shutdown=true").close(); + } catch (SQLException ex) { + // Shutdown will always return an exeption! + if (ex.getErrorCode() != 45000) { + __log.error("Error shutting down Derby: " + ex.getErrorCode(), ex); + } + } catch (Throwable ex) { + __log.debug("Error shutting down Derby.", ex); + } + if (_workRoot == null) { + try { + //Don't worry about File IO, this is only virtual + VFMemoryStorageFactory.purgeDatabase(new File(_dbName).getCanonicalPath()); + } catch (Exception e) { + __log.debug("Error shutting down Derby.", e); + } + } + } +} http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDB.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDB.java b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDB.java deleted file mode 100644 index d2cca54..0000000 --- a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/EmbeddedDB.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.ode.il.dbutil; - -import org.apache.ode.il.config.OdeConfigProperties; - -public class EmbeddedDB extends InternalDB { - - public EmbeddedDB(OdeConfigProperties props) { - super(props); - } - - /** - * Initialize embedded (DERBY) database. - */ - @Override - protected void initDataSource() throws DatabaseConfigException { - String db = _odeConfig.getDbEmbeddedName(); - - String url = "jdbc:derby:" + _workRoot + "/" + db ; - __log.info("Using Embedded Derby: " + url); - _derbyUrl = url; - initInternalDb(url, org.apache.derby.jdbc.EmbeddedDriver.class.getName(),"sa",null); - _needDerbyShutdown = true; - } - -} http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2EmbeddedDB.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2EmbeddedDB.java b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2EmbeddedDB.java new file mode 100644 index 0000000..fea740d --- /dev/null +++ b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/H2EmbeddedDB.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.ode.il.dbutil; + +import java.io.File; +import java.sql.Connection; + +import org.apache.ode.il.config.OdeConfigProperties; +import org.h2.jdbcx.JdbcDataSource; + +public class H2EmbeddedDB extends InternalDB { + + private String _dbUrl = null; + private String _dbName = null; + + public H2EmbeddedDB(OdeConfigProperties props) { + super(props); + } + + /** + * Initialize embedded (DERBY) database. + */ + @Override + protected void initDataSource() throws DatabaseConfigException { + String db = _odeConfig.getDbEmbeddedName(); + if (_workRoot == null) { + _dbUrl = "jdbc:h2:mem:" + db + ";DB_CLOSE_DELAY=-1"; + JdbcDataSource hds = new JdbcDataSource(); + hds.setURL(_dbUrl); + hds.setUser("sa"); + _datasource = hds; + } else { + _dbUrl = "jdbc:h2:" + _workRoot + File.separator + db; + if (!_odeConfig.isDbEmbeddedCreate()) { + _dbUrl += ";IFEXISTS=TRUE"; + } + String clazz = org.h2.Driver.class.getName(); + _connectionManager = new DatabaseConnectionManager(_txm, _odeConfig); + try { + _connectionManager.init(_dbUrl, clazz, "sa", null); + } catch (DatabaseConfigException ex) { + __log.error("Unable to initialize connection pool", ex); + } + _datasource = _connectionManager.getDataSource(); + } + __log.debug("Using Embedded Database: " + _dbUrl); + } + + public void shutdownDB() { + if (_connectionManager != null) { + try { + _connectionManager.shutdown(); + } catch (DatabaseConfigException ex) { + __log.error("unable to shutdown connection pool", ex); + } + } + try { + Connection conn = getDataSource().getConnection(); + conn.createStatement().execute("SHUTDOWN"); + } catch (Throwable ex) { + __log.debug("Error shutting down H2.", ex); + } + } +} http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/InternalDB.java ---------------------------------------------------------------------- diff --git a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/InternalDB.java b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/InternalDB.java index e21c17f..465d13b 100644 --- a/bpel-epr/src/main/java/org/apache/ode/il/dbutil/InternalDB.java +++ b/bpel-epr/src/main/java/org/apache/ode/il/dbutil/InternalDB.java @@ -19,31 +19,13 @@ package org.apache.ode.il.dbutil; -import java.sql.SQLException; -import java.util.Properties; - -import javax.sql.DataSource; - -import org.apache.commons.beanutils.BeanUtils; -import org.apache.derby.jdbc.EmbeddedDriver; -import org.apache.geronimo.connector.outbound.GenericConnectionManager; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; -import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker; -import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator; -import org.apache.geronimo.transaction.manager.RecoverableTransactionManager; import org.apache.ode.il.config.OdeConfigProperties; -import org.tranql.connector.jdbc.JDBCDriverMCF; public class InternalDB extends Database { + protected static final int CONNECTION_MAX_WAIT_MILLIS = 30000; + protected static final int CONNECTION_MAX_IDLE_MINUTES = 5; - protected GenericConnectionManager _connectionManager; - - protected boolean _needDerbyShutdown; - - protected String _derbyUrl; + protected DatabaseConnectionManager _connectionManager; public InternalDB(OdeConfigProperties props) { super(props); @@ -54,7 +36,6 @@ public class InternalDB extends Database { if (_started) return; - _needDerbyShutdown = false; _datasource = null; _connectionManager = null; @@ -67,36 +48,25 @@ public class InternalDB extends Database { if (!_started) return; - if (_connectionManager != null) + if (_connectionManager != null) { try { __log.debug("Stopping connection manager"); - _connectionManager.doStop(); + _connectionManager.shutdown(); } catch (Throwable t) { __log.warn("Exception while stopping connection manager: " + t.getMessage()); } finally { _connectionManager = null; } - - if (_needDerbyShutdown) { - __log.debug("shutting down derby."); - EmbeddedDriver driver = new EmbeddedDriver(); - try { - driver.connect(_derbyUrl + ";shutdown=true", new Properties()); - } catch (SQLException ex) { - // Shutdown will always return an exeption! - if (ex.getErrorCode() != 45000) - __log.error("Error shutting down Derby: " + ex.getErrorCode(), ex); - - } catch (Throwable ex) { - __log.debug("Error shutting down Derby.", ex); - } } - - _needDerbyShutdown = false; + + shutdownDB(); + _datasource = null; _started = false; } + protected void shutdownDB() {} + protected void initDataSource() throws DatabaseConfigException { __log.info(__msgs.msgOdeUsingInternalDb(_odeConfig.getDbIntenralJdbcUrl(), _odeConfig.getDbInternalJdbcDriverClass())); initInternalDb(_odeConfig.getDbIntenralJdbcUrl(), _odeConfig.getDbInternalJdbcDriverClass(), @@ -104,65 +74,8 @@ public class InternalDB extends Database { } protected void initInternalDb(String url, String driverClass, String username,String password) throws DatabaseConfigException { - - __log.debug("Creating connection pool for " + url + " with driver " + driverClass); - if (!(_txm instanceof RecoverableTransactionManager)) { - throw new RuntimeException("TransactionManager is not recoverable."); - } - - TransactionSupport transactionSupport = LocalTransactions.INSTANCE; - ConnectionTracker connectionTracker = new ConnectionTrackingCoordinator(); - - PoolingSupport poolingSupport = new SinglePool( - _odeConfig.getPoolMaxSize(), - _odeConfig.getPoolMinSize(), - CONNECTION_MAX_WAIT_MILLIS, - CONNECTION_MAX_IDLE_MINUTES, - true, // match one - false, // match all - false); // select one assume match - - _connectionManager = new GenericConnectionManager( - transactionSupport, - poolingSupport, - null, - connectionTracker, - (RecoverableTransactionManager) _txm, - getClass().getName(), - getClass().getClassLoader()); - - - try { - javax.resource.spi.ManagedConnectionFactory mcf = null; - String mcfClass = _odeConfig.getDbInternalMCFClass(); - if (mcfClass != null) { - Properties dbInternalMCFProps = _odeConfig.getDbInternalMCFProperties(); - if (__log.isDebugEnabled()) { - __log.debug("Using internal DB MCF " + mcfClass + " " + dbInternalMCFProps); - } - mcf = (javax.resource.spi.ManagedConnectionFactory) Class.forName(mcfClass).newInstance(); - BeanUtils.copyProperties(mcf, dbInternalMCFProps); - } else { - if (__log.isDebugEnabled()) { - __log.debug("Using internal DB JDBCDriverMCF"); - } - JDBCDriverMCF mcf2 = new JDBCDriverMCF(); - mcf = mcf2; - mcf2.setDriver(driverClass); - mcf2.setConnectionURL(url); - if (username != null) { - mcf2.setUserName(username); - } - if (password != null) { - mcf2.setPassword(password); - } - } - _connectionManager.doStart(); - _datasource = (DataSource) mcf.createConnectionFactory(_connectionManager); - } catch (Exception ex) { - String errmsg = __msgs.msgOdeDbPoolStartupFailed(url); - __log.error(errmsg, ex); - throw new DatabaseConfigException(errmsg, ex); - } - } + _connectionManager = new DatabaseConnectionManager(_txm,_odeConfig); + _connectionManager.init(url, driverClass, username, password); + _datasource = _connectionManager.getDataSource(); + } } http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java ---------------------------------------------------------------------- diff --git a/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java b/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java index df9d8ad..a8e9876 100644 --- a/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java +++ b/bpel-runtime/src/test/java/org/apache/ode/bpel/engine/cron/CronSchedulerTest.java @@ -48,13 +48,13 @@ public class CronSchedulerTest extends MockObjectTestCase { private CronScheduler cronScheduler; private ExecutorService execService; - static { - BasicConfigurator.configure(); - LogManager.getRootLogger().setLevel(Level.DEBUG); - LogManager.getLogger(RuntimeDataCleanupRunnable.class).setLevel(Level.DEBUG); - LogManager.getLogger(BpelDAOConnectionImpl.class).setLevel(Level.DEBUG); - LogManager.getLogger("org.apache.ode").setLevel(Level.DEBUG); - } +// static { +// BasicConfigurator.configure(); +// LogManager.getRootLogger().setLevel(Level.DEBUG); +// LogManager.getLogger(RuntimeDataCleanupRunnable.class).setLevel(Level.DEBUG); +// LogManager.getLogger(BpelDAOConnectionImpl.class).setLevel(Level.DEBUG); +// LogManager.getLogger("org.apache.ode").setLevel(Level.DEBUG); +// } protected void setUp() throws Exception { contexts = new Contexts(); http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java ---------------------------------------------------------------------- diff --git a/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java b/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java index d37907e..edc1fd7 100644 --- a/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java +++ b/bpel-runtime/src/test/java/org/apache/ode/bpel/runtime/MockBpelServer.java @@ -18,17 +18,24 @@ */ package org.apache.ode.bpel.runtime; -import org.apache.derby.jdbc.EmbeddedXADataSource; -import org.apache.geronimo.connector.outbound.GenericConnectionManager; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; -import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker; -import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator; -import org.apache.geronimo.transaction.manager.RecoverableTransactionManager; +import java.io.File; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; + +import javax.sql.DataSource; +import javax.transaction.TransactionManager; +import javax.wsdl.PortType; +import javax.xml.namespace.QName; + import org.apache.ode.bpel.dao.BpelDAOConnectionFactory; -import org.apache.ode.bpel.dao.BpelDAOConnectionFactoryJDBC; import org.apache.ode.bpel.engine.BpelServerImpl; import org.apache.ode.bpel.iapi.BindingContext; import org.apache.ode.bpel.iapi.ContextException; @@ -41,9 +48,7 @@ import org.apache.ode.bpel.iapi.MyRoleMessageExchange; import org.apache.ode.bpel.iapi.PartnerRoleChannel; import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange; import org.apache.ode.bpel.iapi.Scheduler; -import org.apache.ode.bpel.iapi.Scheduler.MapSerializableRunnable; import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl; -import org.apache.ode.dao.jpa.BPELDAOConnectionFactoryImpl; import org.apache.ode.il.EmbeddedGeronimoFactory; import org.apache.ode.il.MockScheduler; import org.apache.ode.il.config.OdeConfigProperties; @@ -51,28 +56,9 @@ import org.apache.ode.il.dbutil.Database; import org.apache.ode.store.ProcessStoreImpl; import org.apache.ode.utils.DOMUtils; import org.apache.ode.utils.GUID; -import org.hsqldb.jdbc.jdbcDataSource; -import org.tranql.connector.derby.EmbeddedLocalMCF; import org.w3c.dom.Document; import org.w3c.dom.Element; -import javax.resource.spi.ConnectionManager; -import javax.sql.DataSource; -import javax.transaction.TransactionManager; -import javax.wsdl.PortType; -import javax.xml.namespace.QName; -import java.io.File; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Collections; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - class MockBpelServer { @@ -173,6 +159,7 @@ class MockBpelServer { _server.stop(); _scheduler.stop(); _scheduler.shutdown(); + _database.shutdown(); } protected TransactionManager createTransactionManager() throws Exception { @@ -183,45 +170,14 @@ class MockBpelServer { } protected DataSource createDataSource() throws Exception { - TransactionSupport transactionSupport = LocalTransactions.INSTANCE; - ConnectionTracker connectionTracker = new ConnectionTrackingCoordinator(); - - PoolingSupport poolingSupport = new SinglePool( - 10, - 0, - 1000, - 1, - true, - false, - false); - - ConnectionManager connectionManager = new GenericConnectionManager( - transactionSupport, - poolingSupport, - null, - connectionTracker, - (RecoverableTransactionManager) _txManager, - getClass().getName(), - getClass().getClassLoader()); - - - EmbeddedLocalMCF mcf = new org.tranql.connector.derby.EmbeddedLocalMCF(); - mcf.setCreateDatabase(true); - mcf.setDatabaseName("target/testdb"); - mcf.setUserName("sa"); - mcf.setPassword(""); - _dataSource = (DataSource) mcf.createConnectionFactory(connectionManager); - return _dataSource; - - -// d = org.tranql.connector.jdbc.JDBCDriverMCF(); -// EmbeddedXADataSource ds = new EmbeddedXADataSource(); -// ds.setCreateDatabase("create"); -// ds.setDatabaseName("target/testdb"); -// ds.setUser("sa"); -// ds.setPassword(""); -// _dataSource = ds; -// return _dataSource; + Properties props = new Properties(); + props.setProperty(OdeConfigProperties.PROP_DAOCF, System.getProperty(OdeConfigProperties.PROP_DAOCF, OdeConfigProperties.DEFAULT_DAOCF_CLASS)); + OdeConfigProperties odeProps = new OdeConfigProperties(props,""); + _database = Database.create(odeProps); + _database.setTransactionManager(_txManager); + _database.start(); + _dataSource = _database.getDataSource(); + return _dataSource; } protected Scheduler createScheduler() throws Exception { http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java ---------------------------------------------------------------------- diff --git a/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java b/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java index edf39d1..db4e9d0 100644 --- a/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java +++ b/bpel-store/src/main/java/org/apache/ode/store/hib/DbConfStoreConnectionFactory.java @@ -51,8 +51,6 @@ public class DbConfStoreConnectionFactory implements ConfStoreConnectionFactory private static final Messages __msgs = MessageBundle.getMessages(Messages.class); - private static final String DEFAULT_HIBERNATE_DIALECT = "org.hibernate.dialect.DerbyDialect"; - private static final String _guid = new GUID().toString(); private static final Map<String, DataSource> _dataSources = new ConcurrentHashMap<String, DataSource>(); http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java ---------------------------------------------------------------------- diff --git a/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java b/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java index 9b1c8fa..f289e5e 100644 --- a/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java +++ b/bpel-store/src/test/java/org/apache/ode/store/hib/DaoTest.java @@ -18,46 +18,46 @@ */ package org.apache.ode.store.hib; +import java.util.Properties; + +import javax.sql.DataSource; +import javax.transaction.TransactionManager; +import javax.xml.namespace.QName; + import junit.framework.TestCase; -import org.apache.derby.jdbc.EmbeddedXADataSource; import org.apache.ode.bpel.dao.BpelDAOConnection; import org.apache.ode.il.EmbeddedGeronimoFactory; import org.apache.ode.il.config.OdeConfigProperties; +import org.apache.ode.il.dbutil.Database; +import org.apache.ode.il.dbutil.DatabaseConfigException; import org.apache.ode.store.ConfStoreConnection; import org.apache.ode.store.ConfStoreConnectionFactory; import org.apache.ode.store.DeploymentUnitDAO; import org.apache.ode.store.ProcessConfDAO; -import org.hsqldb.jdbc.jdbcDataSource; -import java.util.Properties; - -import javax.resource.spi.ConnectionManager; -import javax.sql.DataSource; -import javax.transaction.TransactionManager; -import javax.xml.namespace.QName; public class DaoTest extends TestCase { protected BpelDAOConnection daoConn; protected TransactionManager txm; - protected ConnectionManager connectionManager; private DataSource ds; + private Database db; ConfStoreConnectionFactory cf; - protected DataSource getDataSource() { + protected DataSource getDataSource() throws DatabaseConfigException { if (ds == null) { - EmbeddedXADataSource ds = new EmbeddedXADataSource(); - ds.setCreateDatabase("create"); - ds.setDatabaseName("target/testdb"); - ds.setUser("sa"); - ds.setPassword(""); - this.ds = ds; + Properties props = new Properties(); + props.setProperty(OdeConfigProperties.PROP_DAOCF, System.getProperty(OdeConfigProperties.PROP_DAOCF, OdeConfigProperties.DEFAULT_DAOCF_CLASS)); + OdeConfigProperties odeProps = new OdeConfigProperties(props,""); + db = Database.create(odeProps); + db.setTransactionManager(txm); + db.start(); + this.ds = db.getDataSource(); } return ds; } public void setUp() throws Exception { EmbeddedGeronimoFactory factory = new EmbeddedGeronimoFactory(); - connectionManager = new org.apache.geronimo.connector.outbound.GenericConnectionManager(); txm = factory.getTransactionManager(); ds = getDataSource(); org.springframework.mock.jndi.SimpleNamingContextBuilder.emptyActivatedContextBuilder().bind("java:comp/UserTransaction", txm); @@ -67,7 +67,7 @@ public class DaoTest extends TestCase { } public void tearDown() throws Exception { -// hsqlds.getConnection().createStatement().execute("SHUTDOWN"); + db.shutdown(); } public void testEmpty() { http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java ---------------------------------------------------------------------- diff --git a/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java b/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java index 5d51a4c..d24b59b 100644 --- a/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java +++ b/bpel-test/src/main/java/org/apache/ode/test/BPELTestAbstract.java @@ -30,55 +30,46 @@ import java.util.List; import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.geronimo.connector.outbound.GenericConnectionManager; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool; -import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport; -import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker; -import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator; -import org.apache.geronimo.transaction.manager.RecoverableTransactionManager; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; -import javax.persistence.Persistence; -import javax.resource.spi.ConnectionManager; import javax.sql.DataSource; import javax.transaction.TransactionManager; import javax.xml.namespace.QName; -import org.apache.derby.jdbc.EmbeddedXADataSource; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.ode.bpel.common.evt.DebugBpelEventListener; import org.apache.ode.bpel.dao.BpelDAOConnectionFactory; import org.apache.ode.bpel.engine.BpelServerImpl; import org.apache.ode.bpel.iapi.Message; import org.apache.ode.bpel.iapi.MessageExchange; +import org.apache.ode.bpel.iapi.MessageExchange.Status; import org.apache.ode.bpel.iapi.MyRoleMessageExchange; +import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus; import org.apache.ode.bpel.iapi.ProcessStore; import org.apache.ode.bpel.iapi.ProcessStoreEvent; import org.apache.ode.bpel.iapi.ProcessStoreListener; -import org.apache.ode.bpel.iapi.MessageExchange.Status; -import org.apache.ode.bpel.iapi.MyRoleMessageExchange.CorrelationStatus; import org.apache.ode.bpel.memdao.BpelDAOConnectionFactoryImpl; import org.apache.ode.il.EmbeddedGeronimoFactory; import org.apache.ode.il.config.OdeConfigProperties; +import org.apache.ode.il.dbutil.Database; +import org.apache.ode.scheduler.simple.JdbcDelegate; +import org.apache.ode.scheduler.simple.SimpleScheduler; import org.apache.ode.store.ProcessConfImpl; import org.apache.ode.store.ProcessStoreImpl; import org.apache.ode.utils.DOMUtils; import org.apache.ode.utils.GUID; -import org.apache.ode.scheduler.simple.SimpleScheduler; -import org.apache.ode.scheduler.simple.JdbcDelegate; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.w3c.dom.Element; -import java.util.concurrent.*; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public abstract class BPELTestAbstract { private static final Log log = LogFactory.getLog(BPELTestAbstract.class); @@ -90,6 +81,7 @@ public abstract class BPELTestAbstract { public static TransactionManager _txManager = null; public static DataSource _dataSource = null; + protected Database _database; protected ProcessStore store; @@ -119,7 +111,6 @@ public abstract class BPELTestAbstract { @Before public void setUp() throws Exception { - EmbeddedGeronimoFactory factory = new EmbeddedGeronimoFactory(); if (_txManager == null) { _txManager = createTransactionManager(); org.springframework.mock.jndi.SimpleNamingContextBuilder.emptyActivatedContextBuilder().bind("java:comp/UserTransaction", _txManager); @@ -136,12 +127,7 @@ public abstract class BPELTestAbstract { _txManager.commit(); } } -// try { -// _dataSource.getConnection(); -// } catch (Exception e) { -// -// } -// createDataSource(false); + _failures = new CopyOnWriteArrayList<Failure>(); _server = new BpelServerImpl(); Properties props = getConfigProperties(); @@ -202,8 +188,6 @@ public abstract class BPELTestAbstract { _deployed = null; _deployments = null; _invocations = null; - - } protected TransactionManager createTransactionManager() throws Exception { @@ -214,45 +198,14 @@ public abstract class BPELTestAbstract { } protected DataSource createDataSource(boolean shutdown) throws Exception { - TransactionSupport transactionSupport = LocalTransactions.INSTANCE; - ConnectionTracker connectionTracker = new ConnectionTrackingCoordinator(); - - PoolingSupport poolingSupport = new SinglePool( - 10, - 0, - 1000, - 1, - true, - false, - false); - - ConnectionManager connectionManager = new GenericConnectionManager( - transactionSupport, - poolingSupport, - null, - connectionTracker, - (RecoverableTransactionManager) _txManager, - getClass().getName(), - getClass().getClassLoader()); - - org.tranql.connector.derby.EmbeddedLocalMCF mcf = new org.tranql.connector.derby.EmbeddedLocalMCF(); - mcf.setCreateDatabase(true); - mcf.setDatabaseName("target/testdb"); - mcf.setUserName("sa"); - mcf.setPassword(""); - if (shutdown) { - mcf.setShutdownDatabase("shutdown"); - } - return (DataSource) mcf.createConnectionFactory(connectionManager); - -// d = org.tranql.connector.jdbc.JDBCDriverMCF(); -// EmbeddedXADataSource ds = new EmbeddedXADataSource(); -// ds.setCreateDatabase("create"); -// ds.setDatabaseName("target/testdb"); -// ds.setUser("sa"); -// ds.setPassword(""); -// _dataSource = ds; -// return _dataSource; + Properties props = new Properties(); + props.setProperty(OdeConfigProperties.PROP_DAOCF, System.getProperty(OdeConfigProperties.PROP_DAOCF, OdeConfigProperties.DEFAULT_DAOCF_CLASS)); + OdeConfigProperties odeProps = new OdeConfigProperties(props,""); + _database = Database.create(odeProps); + _database.setTransactionManager(_txManager); + _database.start(); + _dataSource = _database.getDataSource(); + return _dataSource; } protected void negative(String deployDir) throws Throwable { http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java ---------------------------------------------------------------------- diff --git a/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java b/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java index 3bbc6e2..0d49e3d 100644 --- a/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java +++ b/bpel-test/src/test/java/org/apache/ode/test/ExternalVariableTest.java @@ -26,8 +26,8 @@ import java.sql.Statement; import javax.sql.DataSource; import javax.xml.namespace.QName; -import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource; import org.apache.ode.bpel.extvar.jdbc.JdbcExternalVariableModule; +import org.h2.jdbcx.JdbcDataSource; import org.junit.Test; /** @@ -41,11 +41,12 @@ public class ExternalVariableTest extends BPELTestAbstract { public void setUp() throws Exception { super.setUp(); + + JdbcDataSource hds = new JdbcDataSource(); + hds.setURL("jdbc:h2:mem:odeextvar;DB_CLOSE_DELAY=-1"); + hds.setUser("sa"); - EmbeddedConnectionPoolDataSource ds = new EmbeddedConnectionPoolDataSource(); - ds.setCreateDatabase("create"); - ds.setDatabaseName("target/ExternalVariableTest"); - _ds = ds; + _ds = hds; _jdbcext = new JdbcExternalVariableModule(); _jdbcext.registerDataSource("testds", _ds); http://git-wip-us.apache.org/repos/asf/ode/blob/dec47e4b/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java ---------------------------------------------------------------------- diff --git a/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java b/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java index 9d7d309..2b24c4f 100644 --- a/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java +++ b/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java @@ -123,8 +123,6 @@ public class BpelDAOConnectionFactoryImpl implements BpelDAOConnectionFactoryJDB return new SessionManager(properties, ds, tm); } - private static final String DEFAULT_HIBERNATE_DIALECT = "org.hibernate.dialect.DerbyDialect"; - public void shutdown() { _sessionManager.shutdown(); }
