From 2b2ede1e38d86e089cb0b1c8262b6c887e68f95f Mon Sep 17 00:00:00 2001 From: Donald Woods Date: Wed, 20 Jan 2010 20:53:57 +0000 Subject: [PATCH] OPENJPA-1374 Enable junits to be executed against an in-memory Derby 10.5.3.0 db. Moved common Derby profiles to the parent POM. Added new Derby props in o-p-j which knocked 2 mins off build time. Added a test-derbymem profile to use Derby 10.5.3.0 as in-memory DB, which reduced build time by 5 mins. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@901374 13f79535-47bb-0310-9956-ffa450edef68 --- openjpa-persistence-jdbc/pom.xml | 79 ++----------- openjpa-persistence-locking/pom.xml | 71 ------------ .../persistence/PersistenceProviderImpl.java | 40 ++++--- openjpa-slice/pom.xml | 25 +---- pom.xml | 106 ++++++++++++++++++ 5 files changed, 141 insertions(+), 180 deletions(-) diff --git a/openjpa-persistence-jdbc/pom.xml b/openjpa-persistence-jdbc/pom.xml index d938ce4b5..f942bcee7 100644 --- a/openjpa-persistence-jdbc/pom.xml +++ b/openjpa-persistence-jdbc/pom.xml @@ -99,77 +99,6 @@ - - - - test-derby - - true - - test-derby - - - - - org.apache.derby - derby - ${derby.version} - test - - - - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:target/database/openjpa-derby-database;create=true - - - - - - - - - test-derbynet - - - test-derbynet - - - - - org.apache.derby - derbyclient - ${derby.version} - test - - - - jdbc:derby://localhost:1527/openjpa20;create=true;traceDirectory=target;traceFile=derby.log - org.apache.derby.jdbc.ClientDriver - - uid - pwd - ${openjpa.derbynet.driver} - ${openjpa.derbynet.url} - ${openjpa.derbynet.username} - ${openjpa.derbynet.password} - - - test-hsqldb @@ -1062,6 +991,14 @@ derby.locks.waitTimeout ${derby.locks.waitTimeout} + + derby.storage.pageCacheSize + 10000 + + + derby.storage.initialPages + 10 + openjpa.ConnectionProperties DriverClassName=${connection.driver.name},Url=${connection.url},Username=${connection.username},Password=${connection.password},${dbcp.args} diff --git a/openjpa-persistence-locking/pom.xml b/openjpa-persistence-locking/pom.xml index 3793c8e94..7f82cc5c8 100644 --- a/openjpa-persistence-locking/pom.xml +++ b/openjpa-persistence-locking/pom.xml @@ -101,77 +101,6 @@ - - - - test-derby - - true - - test-derby - - - - - org.apache.derby - derby - ${derby.version} - test - - - - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:target/database/openjpa-derby-database;create=true - - - - - - - - - test-derbynet - - - test-derbynet - - - - - org.apache.derby - derbyclient - ${derby.version} - test - - - - jdbc:derby://localhost:1527/openjpa20;create=true;traceDirectory=target;traceFile=derby.log - org.apache.derby.jdbc.ClientDriver - - uid - pwd - ${openjpa.derbynet.driver} - ${openjpa.derbynet.url} - ${openjpa.derbynet.username} - ${openjpa.derbynet.password} - - - test-hsqldb diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java index 907a720b7..287c0d3ac 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java @@ -93,12 +93,17 @@ public class PersistenceProviderImpl _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME); pd.checkPuNameCollisions(_log,name); - loadAgent(_log, conf); + // add enhancer + loadAgent(factory); - // TODO - Can this be moved back to BrokerImpl.initialize()? // Create appropriate LifecycleEventManager - loadValidator(_log, conf); + loadValidator(factory); + // We need to wait to preload until after we get back a fully configured/instantiated + // BrokerFactory. This is because it is possible that someone has extended OpenJPA + // functions and they need to be allowed time to configure themselves before we go off and + // start instanting configurable objects (ie:openjpa.MetaDataRepository). Don't catch + // any exceptions here because we want to fail-fast. preloadMetaDataRepository(factory); return JPAFacadeHelper.toEntityManagerFactory(factory); @@ -181,18 +186,17 @@ public class PersistenceProviderImpl log.warn(_loc.get("transformer-registration-error", pui)); } } + // Create appropriate LifecycleEventManager - OpenJPAConfiguration conf = factory.getConfiguration(); - conf.setPersistenceUnitRootUrl(pui.getPersistenceUnitRootUrl()); - _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME); - loadValidator(_log, conf); + loadValidator(factory); // We need to wait to preload until after we get back a fully configured/instantiated // BrokerFactory. This is because it is possible that someone has extended OpenJPA // functions and they need to be allowed time to configure themselves before we go off and // start instanting configurable objects (ie:openjpa.MetaDataRepository). Don't catch // any exceptions here because we want to fail-fast. - preloadMetaDataRepository(factory); + preloadMetaDataRepository(factory); + return JPAFacadeHelper.toEntityManagerFactory(factory); } catch (Exception e) { throw PersistenceExceptions.toPersistenceException(e); @@ -234,7 +238,7 @@ public class PersistenceProviderImpl // We need to wait to preload until after we get back a fully configured/instantiated // BrokerFactory. This is because it is possible that someone has extended OpenJPA // functions and they need to be allowed time to configure themselves before we go off and - // start instanting configurable objects (ie:openjpa.MetaDataRepository). Don't catch + // start instantiating configurable objects (ie:openjpa.MetaDataRepository). Don't catch // any exceptions here because we want to fail-fast. OpenJPAConfiguration conf = factory.getConfiguration(); Options o = Configurations.parseProperties(Configurations.getProperties(conf.getMetaDataRepository())); @@ -285,11 +289,14 @@ public class PersistenceProviderImpl /** * This private worker method will attempt load the PCEnhancerAgent. */ - private void loadAgent(Log log, OpenJPAConfiguration conf) { + private void loadAgent(BrokerFactory factory) { + OpenJPAConfiguration conf = factory.getConfiguration(); + Log log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME); + if (conf.getDynamicEnhancementAgent() == true) { boolean res = PCEnhancerAgent.loadDynamicAgent(log); - if(_log.isInfoEnabled() && res == true ){ - _log.info(_loc.get("dynamic-agent")); + if (log.isInfoEnabled() && res == true ){ + log.info(_loc.get("dynamic-agent")); } } } @@ -302,10 +309,13 @@ public class PersistenceProviderImpl * @param conf * @throws if validation setup failed and was required by the config */ - private void loadValidator(Log log, OpenJPAConfiguration conf) { + private void loadValidator(BrokerFactory factory) { + OpenJPAConfiguration conf = factory.getConfiguration(); + Log log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME); + if ((ValidationUtils.setupValidation(conf) == true) && - _log.isInfoEnabled()) { - _log.info(_loc.get("vlem-creation-info")); + log.isInfoEnabled()) { + log.info(_loc.get("vlem-creation-info")); } } diff --git a/openjpa-slice/pom.xml b/openjpa-slice/pom.xml index c00d9e874..7dfd2f62a 100644 --- a/openjpa-slice/pom.xml +++ b/openjpa-slice/pom.xml @@ -63,29 +63,8 @@ - - - test-derby - - true - - test-derby - - - - - org.apache.derby - derby - test - - - - org.apache.derby.jdbc.EmbeddedDriver - jdbc:derby:target/database/slice-derby-One;create=true - - - - + diff --git a/pom.xml b/pom.xml index 57b36b145..a259e7064 100644 --- a/pom.xml +++ b/pom.xml @@ -111,7 +111,113 @@ openjpa-integration openjpa-all + + + + + + + + test-derby + + true + + test-derby + + + + + org.apache.derby + derby + ${derby.version} + test + + + + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:target/database/openjpa-derby-database;create=true + + + + + + + + test-derbymem + + + test-derbymem + + + + + org.apache.derby + derby + ${derby.version} + test + + + + 10.5.3.0_1 + org.apache.derby.jdbc.EmbeddedDriver + jdbc:derby:memory:openjpa-derby-inmem-database;create=true + + + + + + + + test-derbynet + + + test-derbynet + + + + + org.apache.derby + derbyclient + ${derby.version} + test + + + + jdbc:derby://localhost:1527/openjpa20;create=true;traceDirectory=target;traceFile=derby.log + org.apache.derby.jdbc.ClientDriver + + uid + pwd + ${openjpa.derbynet.driver} + ${openjpa.derbynet.url} + ${openjpa.derbynet.username} + ${openjpa.derbynet.password} + + + + + + + release