branch feature1378-MAJ_libs updated (319b133 -> 80f8889)
This is an automated email from the git hooks/post-receive script. New change to branch feature1378-MAJ_libs in repository lima. See https://gitlab.nuiton.org/chorem/lima.git from 319b133 refs #1373 gestion de log new f93f743 refs #1373 intégration mise à jour topia new 80f8889 refs #1373 intégration mise à jour topia The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 80f8889ace61f8dae862e25fa72330ab75d69e18 Author: David Cossé <cosse@codelutin.com> Date: Wed Jan 18 10:39:52 2017 +0100 refs #1373 intégration mise à jour topia commit f93f7436c0966ea64e468e32d592d0536d467c4e Author: David Cossé <cosse@codelutin.com> Date: Wed Jan 18 10:39:40 2017 +0100 refs #1373 intégration mise à jour topia Summary of changes: .../org/chorem/lima/business/LimaInterceptor.java | 32 ++++++------ .../org/chorem/lima/business/AbstractLimaTest.java | 59 +++++++++++++++++----- .../org/chorem/lima/business/LimaTestsConfig.java | 2 +- .../src/test/resources/lima-test.properties | 4 +- 4 files changed, 65 insertions(+), 32 deletions(-) -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature1378-MAJ_libs in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit f93f7436c0966ea64e468e32d592d0536d467c4e Author: David Cossé <cosse@codelutin.com> Date: Wed Jan 18 10:39:40 2017 +0100 refs #1373 intégration mise à jour topia --- .../org/chorem/lima/business/AbstractLimaTest.java | 59 +++++++++++++++++----- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java b/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java index 118646d..268f89a 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java +++ b/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java @@ -24,6 +24,7 @@ package org.chorem.lima.business; import com.google.common.base.Function; import com.google.common.collect.Lists; +import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.api.AccountService; @@ -51,10 +52,14 @@ import org.chorem.lima.entity.FiscalPeriodImpl; import org.chorem.lima.entity.LimaCallaoEntityEnum; import org.chorem.lima.entity.LimaCallaoTopiaApplicationContext; import org.hibernate.cfg.Environment; +import org.junit.After; import org.junit.Before; import org.nuiton.i18n.I18n; import org.nuiton.i18n.init.ClassPathI18nInitializer; +import org.nuiton.topia.persistence.HibernateAvailableSettings; import org.nuiton.topia.persistence.TopiaApplicationContextCache; +import org.nuiton.topia.persistence.TopiaConfigurationConstants; +import org.nuiton.topia.persistence.TopiaPersistenceContext; import java.io.File; import java.math.BigDecimal; @@ -62,6 +67,7 @@ import java.text.DateFormat; import java.util.Date; import java.util.Locale; import java.util.Properties; +import java.util.Set; import java.util.UUID; /** @@ -76,12 +82,9 @@ import java.util.UUID; public abstract class AbstractLimaTest { protected static final Log log = LogFactory.getLog(AbstractLimaTest.class); - protected static final Function<Properties, LimaCallaoTopiaApplicationContext> CREATE_CONTEXT_FUNCTION = new Function<Properties, LimaCallaoTopiaApplicationContext>() { - @Override - public LimaCallaoTopiaApplicationContext apply(Properties input) { - return new LimaCallaoTopiaApplicationContext(input); - } - }; + protected static final Long TEST_RUN_ID = System.currentTimeMillis(); + + protected static final Function<Properties, LimaCallaoTopiaApplicationContext> CREATE_CONTEXT_FUNCTION = LimaCallaoTopiaApplicationContext::new; protected static DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.ENGLISH); protected static final String LIMA_TEST_DEFAULT_CONF_FILENAME = "lima-test.properties"; @@ -116,6 +119,21 @@ public abstract class AbstractLimaTest { context = createNewTestApplicationContext(); } + @After + public void afterEachTest() { + if (!context.isClosed()) { + Set<TopiaPersistenceContext> persitenceContexts = context.getPersistenceContexts(); + if (CollectionUtils.isNotEmpty(persitenceContexts)) { + for (TopiaPersistenceContext persitenceContext : persitenceContexts) { + persitenceContext.rollback(); + persitenceContext.close(); + } + } + context.close(); + } + } + + protected void setUpLocale() { I18n.init(new ClassPathI18nInitializer(), Locale.UK); } @@ -154,11 +172,26 @@ public abstract class AbstractLimaTest { // load file manually (lima-business.config) Properties testProperties = new Properties(); // override somes - String testDir = System.getProperty("java.io.tmpdir") + File.separator + "lima-business-" + UUID.randomUUID().toString(); -// testProperties.setProperty(LimaBusinessConfig.ServiceConfigOption.DATA_DIR.getKey(), testDir); - testProperties.setProperty(Environment.URL, "jdbc:h2:file:" + testDir + File.separator + "data"); + String jdbcUrl = "jdbc:h2:mem:" + File.separator + "lima-business-" + UUID.randomUUID().toString() + TEST_RUN_ID + ";DB_CLOSE_DELAY=-1"; + + testProperties.setProperty(Environment.URL, jdbcUrl); testProperties.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "thread"); + + testProperties.setProperty(Environment.USER, "sa"); + testProperties.setProperty(Environment.PASS, ""); + testProperties.setProperty(Environment.SHOW_SQL, "false"); + // add c3p0 pool + testProperties.setProperty(Environment.C3P0_MIN_SIZE, "10"); + testProperties.setProperty(Environment.C3P0_MAX_SIZE, "100"); + testProperties.setProperty(Environment.C3P0_TIMEOUT, "0"); + testProperties.setProperty(Environment.C3P0_MAX_STATEMENTS, "0"); + + // Topia specifics + testProperties.setProperty(HibernateAvailableSettings.SHOW_SQL, "false"); + testProperties.setProperty(TopiaConfigurationConstants.CONFIG_PERSISTENCE_INIT_SCHEMA, "true"); testProperties.setProperty("topia.persistence.classes", LimaCallaoEntityEnum.getImplementationClassesAsString()); + testProperties.setProperty("topia.persistence.validateSchema", "false"); // can work in mem + return testProperties; } @@ -170,10 +203,12 @@ public abstract class AbstractLimaTest { * @return a topia context */ protected LimaCallaoTopiaApplicationContext getTestApplicationContext(Properties options) { - log.info("Opening context to database : " + options.getProperty("hibernate.connection.url")); + if (log.isInfoEnabled()) { + log.info("Opening context to database : " + options.getProperty("hibernate.connection.url")); + } - LimaCallaoTopiaApplicationContext result = TopiaApplicationContextCache.getContext(options, CREATE_CONTEXT_FUNCTION); - return result; + LimaCallaoTopiaApplicationContext rootContext = TopiaApplicationContextCache.getContext(options, CREATE_CONTEXT_FUNCTION); + return rootContext; } protected LimaCallaoTopiaApplicationContext createNewTestApplicationContext() { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature1378-MAJ_libs in repository lima. See https://gitlab.nuiton.org/chorem/lima.git commit 80f8889ace61f8dae862e25fa72330ab75d69e18 Author: David Cossé <cosse@codelutin.com> Date: Wed Jan 18 10:39:52 2017 +0100 refs #1373 intégration mise à jour topia --- .../org/chorem/lima/business/LimaInterceptor.java | 32 +++++++++++----------- .../org/chorem/lima/business/LimaTestsConfig.java | 2 +- .../src/test/resources/lima-test.properties | 4 +-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java b/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java index 236ca36..8a7264c 100644 --- a/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java +++ b/lima-business/src/main/java/org/chorem/lima/business/LimaInterceptor.java @@ -22,14 +22,13 @@ package org.chorem.lima.business; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaXAResource; import org.chorem.lima.entity.LimaCallaoTopiaApplicationContext; import org.chorem.lima.entity.LimaCallaoTopiaDaoSupplier; +import org.chorem.lima.entity.LimaCallaoTopiaPersistenceContext; import org.nuiton.topia.persistence.TopiaApplicationContextCache; -import org.nuiton.topia.persistence.TopiaPersistenceContext; import javax.annotation.Resource; import javax.ejb.Stateless; @@ -38,7 +37,6 @@ import javax.interceptor.AroundInvoke; import javax.interceptor.InvocationContext; import javax.transaction.Transaction; import javax.transaction.TransactionManager; -import java.util.Set; /** * Interceptor for topia context transaction. @@ -85,28 +83,30 @@ public class LimaInterceptor { LimaBusinessConfig.getRootContextProperties(), LimaConfigurationHelper.getCreateTopiaContextFunction()); - TopiaPersistenceContext tx; - Set<TopiaPersistenceContext> contexts = rootContext.getPersistenceContexts(); - if (CollectionUtils.isEmpty(contexts)) { - rootContext.newPersistenceContext(); - contexts = rootContext.getPersistenceContexts(); + LimaCallaoTopiaPersistenceContext transaction; + if (rootContext.getPersistenceContexts().isEmpty()) { + transaction = rootContext.newPersistenceContext(); + } else { + transaction = (LimaCallaoTopiaPersistenceContext) rootContext.getPersistenceContexts().iterator().next(); } - tx = contexts.iterator().next(); - DAO_HELPER.set((LimaCallaoTopiaDaoSupplier) tx); + DAO_HELPER.set(transaction); Transaction tr = transactionManager.getTransaction(); // enlist topia xaresource, will commited or rollback // by container - tr.enlistResource(new LimaXAResource(tx)); - } - } + tr.enlistResource(new LimaXAResource(transaction)); + + result = context.proceed(); - try { + DAO_HELPER.remove(); + + } else { + result = context.proceed(); + } + } else { result = context.proceed(); - } finally { - DAO_HELPER.remove(); } return result; diff --git a/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java b/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java index abbed22..eea9c60 100644 --- a/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java +++ b/lima-business/src/test/java/org/chorem/lima/business/LimaTestsConfig.java @@ -54,7 +54,7 @@ public class LimaTestsConfig { Map<String, String> toAddIfNotPresent = Maps.newLinkedHashMap(); toAddIfNotPresent.put("topia.service.migration", TopiaFlywayServiceImpl.class.getName()); - toAddIfNotPresent.put("topia.service.migration." + TopiaFlywayService.USE_MODEL_VERSION, "true"); + toAddIfNotPresent.put("topia.service.migration." + TopiaFlywayService.USE_MODEL_VERSION, "false"); toAddIfNotPresent.put(TopiaConfigurationConstants.CONFIG_PERSISTENCE_INIT_SCHEMA, "true"); for (Map.Entry<String, String> entry : toAddIfNotPresent.entrySet()) { diff --git a/lima-business/src/test/resources/lima-test.properties b/lima-business/src/test/resources/lima-test.properties index 03593f7..629253b 100644 --- a/lima-business/src/test/resources/lima-test.properties +++ b/lima-business/src/test/resources/lima-test.properties @@ -27,6 +27,4 @@ hibernate.dialect=org.hibernate.dialect.H2Dialect hibernate.connection.username=sa hibernate.connection.password= hibernate.connection.driver_class=org.h2.Driver -hibernate.hbm2ddl.auto=update -# Topia should not create the schema -topia.persistence.initSchema=false +topia.service.migration.flyway.baselineVersion=99999 \ No newline at end of file -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm