Author: tchemit Date: 2011-06-21 09:35:52 +0200 (Tue, 21 Jun 2011) New Revision: 2301 Url: http://nuiton.org/repositories/revision/topia/2301 Log: Evolution #1598: Updates to eugene 2.4 Evolution #476: Updates to hibernate 3.6.4.Final Anomalie #1548: topia-persistence does not build (some test are failing) when using hibernate 3.5.6 Anomalie #1547: Make topia-replication-service works with hibernate > 3.5 Modified: trunk/ trunk/pom.xml trunk/topia-persistence/pom.xml trunk/topia-persistence/src/license/THIRD-PARTY.properties trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java trunk/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties trunk/topia-persistence/src/test/java/org/nuiton/topia/TestHelper.java trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml trunk/topia-service-migration/pom.xml trunk/topia-service-migration/src/license/THIRD-PARTY.properties trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java trunk/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml trunk/topia-service-replication/pom.xml trunk/topia-service-replication/src/license/THIRD-PARTY.properties trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationOperation.java trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/Duplicate.java trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractTopiaReplicationServiceTest.java trunk/topia-service-security/pom.xml trunk/topia-service-security/src/license/THIRD-PARTY.properties trunk/topia-tutorial/pom.xml Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/from2.2.2-eugene2-beta:1662-1714 + /branches/from2.2.2-eugene2-beta:1662-1714 /branches/topia-2.6.x:2293-2300 Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/pom.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -37,7 +37,7 @@ </parent> <artifactId>topia</artifactId> - <version>2.5.5-SNAPSHOT</version> + <version>2.6-SNAPSHOT</version> <modules> <module>topia-persistence</module> @@ -54,6 +54,33 @@ <!--module>topia-service-history</module--> </modules> + <name>ToPIA</name> + <description> + Tools for Portable and Independent Architecture : + Framework de persistance et de distribution d'application. + </description> + <inceptionYear>2004</inceptionYear> + <url>http://maven-site.nuiton.org/topia</url> + + <properties> + <!-- pour un muli module on doit fixer le projectId --> + <projectId>topia</projectId> + + <!-- libs version --> + <eugeneVersion>2.4-SNAPSHOT</eugeneVersion> + <nuitonUtilsVersion>2.2</nuitonUtilsVersion> + <processorPluginVersion>1.2.1</processorPluginVersion> + <nuitonI18nVersion>2.4</nuitonI18nVersion> + <xmlrpcVersion>3.1.2</xmlrpcVersion> + <!--<hibernateVersion>3.3.2.GA</hibernateVersion>--> + <hibernateVersion>3.6.5.Final</hibernateVersion> + <sl4jVersion>1.6.1</sl4jVersion> + + <!-- i18n configuration --> + <i18n.bundles>fr_FR,en_GB,es_ES</i18n.bundles> + + </properties> + <dependencyManagement> <dependencies> @@ -82,6 +109,12 @@ <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>${hibernateVersion}</version> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> <scope>compile</scope> </dependency> @@ -89,13 +122,19 @@ <groupId>org.hibernate</groupId> <artifactId>hibernate-ehcache</artifactId> <version>${hibernateVersion}</version> + <exclusions> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </exclusion> + </exclusions> <scope>runtime</scope> </dependency> <dependency> <groupId>javassist</groupId> <artifactId>javassist</artifactId> - <version>3.8.0.GA</version> + <version>3.12.1.GA</version> <scope>runtime</scope> </dependency> @@ -110,8 +149,14 @@ --> <dependency> <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>${sl4jVersion}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> - <version>1.6.1</version> + <version>${sl4jVersion}</version> <scope>test</scope> </dependency> @@ -119,7 +164,7 @@ <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> - <version>1.2.128</version> + <version>1.3.154</version> <scope>test</scope> </dependency> @@ -129,13 +174,7 @@ <!-- ************************************************************* --> <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>ToPIA</name> - <description> - Tools for Portable and Independent Architecture : - Framework de persistance et de distribution d'application. - </description> - <inceptionYear>2004</inceptionYear> - <url>http://maven-site.nuiton.org/topia</url> + <developers> @@ -251,23 +290,7 @@ <packaging>pom</packaging> - <properties> - <!-- pour un muli module on doit fixer le projectId --> - <projectId>topia</projectId> - <!-- libs version --> - <eugeneVersion>2.4-SNAPSHOT</eugeneVersion> - <nuitonUtilsVersion>2.2</nuitonUtilsVersion> - <processorPluginVersion>1.2.1</processorPluginVersion> - <nuitonI18nVersion>2.4</nuitonI18nVersion> - <xmlrpcVersion>3.1.2</xmlrpcVersion> - <hibernateVersion>3.3.2.GA</hibernateVersion> - - <!-- i18n configuration --> - <i18n.bundles>fr_FR,en_GB,es_ES</i18n.bundles> - - </properties> - <build> <pluginManagement> Modified: trunk/topia-persistence/pom.xml =================================================================== --- trunk/topia-persistence/pom.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/pom.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>topia</artifactId> - <version>2.5.5-SNAPSHOT</version> + <version>2.6-SNAPSHOT</version> </parent> <groupId>org.nuiton.topia</groupId> @@ -132,6 +132,8 @@ <!-- *** Build Settings ****************************************** --> <!-- ************************************************************* --> + <packaging>jar</packaging> + <build> <testResources> Modified: trunk/topia-persistence/src/license/THIRD-PARTY.properties =================================================================== --- trunk/topia-persistence/src/license/THIRD-PARTY.properties 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/license/THIRD-PARTY.properties 2011-06-21 07:35:52 UTC (rev 2301) @@ -1,29 +1,27 @@ -# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # - Common Public License Version 1.0 -# - GNU Lesser General Public License -# - LGPL -# - Lesser General Public License (LGPL) v 2.1 # - Lesser General Public License (LGPL) v 3.0 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 # - MIT License +# - MPL 1.1 # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 # - http://jaxen.codehaus.org/license.html +# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Fri Nov 19 08:42:33 CET 2010 +#Fri Jun 03 13:49:37 CEST 2011 antlr--antlr--2.7.6--jar=BSD License commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1--jar=BSD License -javassist--javassist--3.8.0.GA--jar=Lesser General Public License (LGPL) v 2.1 javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 jaxen--jaxen--1.1.1--jar=http\://jaxen.codehaus.org/license.html jdom--jdom--1.0--jar=The Apache Software License, Version 2.0 -org.slf4j--slf4j-api--1.5.8--jar=MIT License -org.slf4j--slf4j-log4j12--1.5.8--jar=MIT License xalan--xalan--2.6.0--jar=The Apache Software License, Version 2.0 Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -607,7 +607,7 @@ // ajout des repertoires contenant les mappings hibernate String[] dirs = getConfig().getProperty( - TOPIA_PERSISTENCE_DIRECTORIES, "").split(","); + TopiaContextFactory.CONFIG_PERSISTENCE_DIRECTORIES, "").split(","); for (String dir : dirs) { dir = dir.trim(); if (StringUtils.isNotEmpty(dir)) { @@ -634,7 +634,7 @@ } String listPersistenceClasses = getConfig().getProperty( - TOPIA_PERSISTENCE_CLASSES, ""); + TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, ""); String[] classes = listPersistenceClasses.split(","); for (String classname : classes) { @@ -677,7 +677,7 @@ // TOPIA_PERSISTENCE_PROPERTIES_FILE in config. Properties propertiesFromClasspath = TopiaUtil.getProperties(getConfig(). - getProperty(TOPIA_PERSISTENCE_PROPERTIES_FILE)); + getProperty(TopiaContextFactory.CONFIG_PERSISTENCE_PROPERTIES_FILE)); if (!propertiesFromClasspath.isEmpty()) { if (log.isDebugEnabled()) { @@ -688,6 +688,9 @@ } hibernateConfiguration.setProperties(prop); + + // tchemit 2011-05-26 When using hibernate > 3.3, need to make sure all mappings are loaded (the one from directory files are not still done). + hibernateConfiguration.buildMappings(); } } return hibernateConfiguration; @@ -1212,8 +1215,7 @@ } } } catch (HibernateException eee) { - throw new TopiaException(_( - "topia.persistence.error.on.replicate", + throw new TopiaException(_("topia.persistence.error.on.replicate", eee.getMessage()), eee); } } @@ -1572,8 +1574,7 @@ } } catch (HibernateException eee) { - throw new TopiaException(_( - "topia.persistence.error.on.replicate", + throw new TopiaException(_("topia.persistence.error.on.replicate", eee.getMessage()), eee); } } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -42,16 +42,16 @@ package org.nuiton.topia.generator; +import org.apache.commons.lang.BooleanUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.java.JavaGeneratorUtil; -import org.nuiton.eugene.models.object.ObjectModelGenerator; -import org.nuiton.eugene.GeneratorUtil; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; import org.nuiton.eugene.models.object.ObjectModelAttribute; import org.nuiton.eugene.models.object.ObjectModelClass; -import static org.nuiton.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType; +import org.nuiton.eugene.models.object.ObjectModelGenerator; import java.io.File; import java.io.IOException; @@ -62,7 +62,7 @@ import java.util.Map; import java.util.TreeMap; -import org.apache.commons.lang.BooleanUtils; +import static org.nuiton.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType; /** * FIXME-poussin-20060102 mettre les attributs node="..." sur tous les attributs @@ -118,7 +118,7 @@ return; } /*{<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-access="field" auto-import="true" package="<%=input.getPackageName()%>"> }*/ boolean haveSuper = input.getSuperclasses().size() > 0; Modified: trunk/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties =================================================================== --- trunk/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/main/resources/i18n/topia-persistence_en_GB.properties 2011-06-21 07:35:52 UTC (rev 2301) @@ -9,6 +9,7 @@ topia.persistence.error.on.export=An error occurs while export operation \: %1$s topia.persistence.error.on.loding.xml.doc=Could not read xml document for following reason \: %1$s topia.persistence.error.on.query=An error occurs while query operation \: %1$s +topia.persistence.error.on.replicate=An error occurs while a replication operation \: %s topia.persistence.error.on.rollback=An error occurs while rollback operation \: %1$s topia.persistence.error.open.transaction.failed=An error occurs while asking a new transaction \: %1$s topia.persistence.error.replicate.entity=Could not replicate entity '%1$s' pour following reason \: %2$s Modified: trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties =================================================================== --- trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties 2011-06-21 07:35:52 UTC (rev 2301) @@ -9,6 +9,7 @@ topia.persistence.error.on.export=Se produjo un error durante la exportación \: %1$s topia.persistence.error.on.loding.xml.doc=No se puede leer el documento debido a \: %1$s topia.persistence.error.on.query=Se produjo un error duratne la busqueda (consulta %1$s) \: %2$s +topia.persistence.error.on.replicate=Se produjo un error durante la vuelta a atrás (replication) \: %1$s topia.persistence.error.on.rollback=Se produjo un error durante la vuelta a atrás (rollback) \: %1$s topia.persistence.error.open.transaction.failed= topia.persistence.error.replicate.entity=Error de repliación de la entidad %1$s\ndebido a la siguiente razón \: %2$s Modified: trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties =================================================================== --- trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties 2011-06-21 07:35:52 UTC (rev 2301) @@ -9,6 +9,7 @@ topia.persistence.error.on.export=Une erreur est apparue pendant l'export \: %1$s topia.persistence.error.on.loding.xml.doc=Lecture du document impossible pour la raison suivante \: %1$s topia.persistence.error.on.query=Une erreur est apparue pendant le recherche (requête %1$s) \: %2$s +topia.persistence.error.on.replicate=Une erreur lors de la réplication est survenue \: %s topia.persistence.error.on.rollback=Une erreur est apparue pendant le rollback \: %1$s topia.persistence.error.open.transaction.failed=Une erreur est apparue pendant la demande de transaction \: %1$s topia.persistence.error.replicate.entity=Echec de replication de l'entite %1$s\npour la raison suivante \: %2$s Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/TestHelper.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/TestHelper.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/TestHelper.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -136,7 +136,7 @@ configuration.load(stream); configuration.setProperty( - "topia.persistence.classes", + TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, TopiaTestDAOHelper.getImplementationClassesAsString()); return configuration; } @@ -150,6 +150,10 @@ String dbname) throws IOException { - return initTopiaContextConfiguration(testDirectory, DEFAULT_CONFIGURATION_LOCATION, dbname); + return initTopiaContextConfiguration( + testDirectory, + DEFAULT_CONFIGURATION_LOCATION, + dbname + ); } } Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -35,8 +35,16 @@ import org.junit.BeforeClass; import org.junit.Test; import org.nuiton.i18n.I18n; +import org.nuiton.topia.TestHelper; +import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; +import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; +import org.nuiton.topia.TopiaTestDAOHelper; +import org.nuiton.topia.test.entities.Person; +import org.nuiton.topia.test.entities.PersonDAO; +import org.nuiton.topia.test.entities.Pet; +import org.nuiton.topia.test.entities.PetDAO; import org.nuiton.topiatest.persistence.Entity1; import org.nuiton.topiatest.persistence.Entity1Impl; import org.nuiton.topiatest.service.FakeService; @@ -61,8 +69,12 @@ protected Properties properties = new Properties(); + static File testBasedir; + @BeforeClass public static void setUpClass() throws Exception { + + testBasedir = TestHelper.getTestBasedir(TopiaContextImplTest.class); I18n.init(null, Locale.FRENCH); } @@ -77,33 +89,41 @@ @Test public void testLoadServices() throws Exception { - log.info("## testLoadServices"); + if (log.isDebugEnabled()) { + log.debug("## testLoadServices"); + } /** PREPARE DATA **/ properties.setProperty("topia.service.test", - TestService.class.getName()); + TestService.class.getName()); TopiaContextImpl context = new TopiaContextImpl(); /** EXEC METHOD **/ - log.info("test 1 : load a simple TestService from properties"); + if (log.isInfoEnabled()) { + log.info("test 1 : load a simple TestService from properties"); + } Map<String, TopiaService> results = context.loadServices(properties); Assert.assertEquals(1, results.size()); Assert.assertTrue(results.containsKey("test")); TopiaService service = results.get("test"); Assert.assertEquals(TestService.class, service.getClass()); - log.info("test 2 : load with wrong key : will display a WARN"); + if (log.isInfoEnabled()) { + log.info("test 2 : load with wrong key : will display a WARN"); + } properties.clear(); properties.setProperty("topia.service.fake", - TestService.class.getName()); + TestService.class.getName()); results = context.loadServices(properties); Assert.assertEquals(0, results.size()); Assert.assertFalse(results.containsKey("fake")); - log.info("test 3 : load with fake service name : will display an ERROR"); + if (log.isInfoEnabled()) { + log.info("test 3 : load with fake service name : will display an ERROR"); + } properties.clear(); properties.setProperty("topia.service.test", "FAKE"); @@ -111,17 +131,17 @@ results = context.loadServices(properties); Assert.assertEquals(0, results.size()); Assert.assertFalse(results.containsKey("test")); - - // TODO-fdesbois-20100510 : need integration tests for all existing topia services } @Test public void testGetServices() throws Exception { - log.info("## testGetServices"); + if (log.isDebugEnabled()) { + log.debug("## testGetServices"); + } /** PREPARE DATA **/ properties.setProperty("topia.service.test", - TestService.class.getName()); + TestService.class.getName()); // Calling the constructor with properties will load the services TopiaContextImpl context = new TopiaContextImpl(properties); @@ -130,69 +150,94 @@ TopiaContextImpl child = new TopiaContextImpl(context); /** EXEC METHOD **/ - log.info("test 1 : with child context"); + if (log.isInfoEnabled()) { + log.info("test 1 : with child context"); + } Map<String, TopiaService> test1 = child.getServices(); Assert.assertEquals(1, test1.size()); Assert.assertTrue(test1.containsKey("test")); - log.info("test 2 : test serviceEnabled method"); + if (log.isInfoEnabled()) { + log.info("test 2 : test serviceEnabled method"); + } boolean test2 = child.serviceEnabled("test"); Assert.assertTrue(test2); - log.info("test 3 : test getService method"); + if (log.isInfoEnabled()) { + log.info("test 3 : test getService method"); + } TopiaService test3 = child.getService("test"); Assert.assertEquals(TestService.class, test3.getClass()); - log.info("test 4 : test serviceEnabled from class TestService"); + if (log.isInfoEnabled()) { + log.info("test 4 : test serviceEnabled from class TestService"); + } boolean test4 = child.serviceEnabled(TestService.class); Assert.assertTrue(test4); - log.info("test 5 : test getService from class TestService"); + if (log.isInfoEnabled()) { + log.info("test 5 : test getService from class TestService"); + } TestService test5 = child.getService(TestService.class); Assert.assertNotNull(test5); - log.info("test 6 : test serviceEnabled error with class FakeService"); + if (log.isInfoEnabled()) { + log.info("test 6 : test serviceEnabled error with class FakeService"); + } // FakeService doesn't contains property SERVICE_NAME used by // serviceEnabled method // Even it's properly loaded the serviceEnabled method will return false properties.clear(); properties.setProperty("topia.service.fake", - FakeService.class.getName()); + FakeService.class.getName()); TopiaContextImpl otherContext = new TopiaContextImpl(properties); boolean test6 = otherContext.serviceEnabled(FakeService.class); Assert.assertFalse(test6); - log.info("test 7 : test getService with error TopiaNotFoundException" + - " : service not loaded"); + if (log.isInfoEnabled()) { + log.info("test 7 : test getService with error TopiaNotFoundException" + + " : service not loaded"); + } // TestService is not loaded in otherContext try { TestService test7 = otherContext.getService(TestService.class); - } catch (Exception eee) { - log.error(eee.getClass().getSimpleName() + " : " + eee.getMessage()); - Assert.assertEquals(TopiaNotFoundException.class, eee.getClass()); + Assert.fail(); + } catch (TopiaNotFoundException eee) { + //log.error(eee.getClass().getSimpleName() + " : " + eee.getMessage()); + //Assert.assertEquals(TopiaNotFoundException.class, eee.getClass()); + } catch (Exception e) { + Assert.fail(); } } @Test public void testContextHierarchy() throws Exception { - log.info("## testContextHierarchy"); + if (log.isDebugEnabled()) { + log.debug("## testContextHierarchy"); + } /** PREPARE DATA **/ TopiaContextImpl context = new TopiaContextImpl(properties); /** EXEC METHODS **/ - log.info("test 1 : constructor with parent context"); + if (log.isInfoEnabled()) { + log.info("test 1 : constructor with parent context"); + } TopiaContextImpl test1 = new TopiaContextImpl(context); Assert.assertEquals(context, test1.parentContext); - log.info("test 2 : addChildContext"); + if (log.isInfoEnabled()) { + log.info("test 2 : addChildContext"); + } TopiaContextImpl test2 = new TopiaContextImpl(properties); TopiaContextImpl child2 = new TopiaContextImpl(); test2.addChildContext(child2); Assert.assertEquals(1, test2.childContext.size()); - log.info("test 3 : removeChildContext"); + if (log.isInfoEnabled()) { + log.info("test 3 : removeChildContext"); + } TopiaContextImpl test3 = new TopiaContextImpl(properties); TopiaContextImpl child3 = new TopiaContextImpl(test3); test3.childContext.add(child3); @@ -205,7 +250,9 @@ test3.removeChildContext(child3); Assert.assertEquals(1, test3.childContext.size()); - log.info("test 4 : getRootContext"); + if (log.isInfoEnabled()) { + log.info("test 4 : getRootContext"); + } TopiaContextImplementor test4 = child3.getRootContext(); Assert.assertEquals(test3, test4); @@ -232,7 +279,9 @@ @Test public void testGetHibernateFactory() throws Exception { - log.info("## testGetHibernateFactory"); + if (log.isDebugEnabled()) { + log.debug("## testGetHibernateFactory"); + } /** PREPARE DATA **/ TopiaContextImpl context = new TopiaContextImpl(); @@ -245,24 +294,30 @@ basedir = new File("").getAbsolutePath(); } - log.debug("baseDir : " + basedir); + if (log.isDebugEnabled()) { + log.debug("baseDir : " + basedir); + } File persistenceDir = new File(basedir, - "target" + File.separator + - "test-classes" +File.separator + - "org" + File.separator + - "nuiton" + File.separator + - "topiatest" + File.separator + - "persistence"); - log.debug("persistenceDir : " + persistenceDir); + "target" + File.separator + + "test-classes" + File.separator + + "org" + File.separator + + "nuiton" + File.separator + + "topiatest" + File.separator + + "persistence"); + if (log.isDebugEnabled()) { + log.debug("persistenceDir : " + persistenceDir); + } File resourcesDir = new File(basedir, "target" + File.separator + "test-classes"); /** EXEC METHOD **/ - log.info("test 1 : load mappings from directory"); - + if (log.isInfoEnabled()) { + log.info("test 1 : load mappings from directory"); + } + properties.setProperty(TopiaContextFactory.CONFIG_PERSISTENCE_DIRECTORIES, - persistenceDir.getAbsolutePath()); + persistenceDir.getAbsolutePath()); context.config = properties; Configuration test1 = context.getHibernateConfiguration(); @@ -276,7 +331,9 @@ // log.debug("entity : " + o.getEntityName()); // } - log.info("test 2 : load mappings for all entities"); + if (log.isInfoEnabled()) { + log.info("test 2 : load mappings for all entities"); + } //reset from previous test context = new TopiaContextImpl(); context.services = new HashMap<String, TopiaService>(); @@ -284,7 +341,7 @@ // use property TOPIA_PERSISTENCE_CLASSES properties.setProperty(TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, - Entity1Impl.class.getName()); + Entity1Impl.class.getName()); context.config = properties; Configuration test2 = context.getHibernateConfiguration(); @@ -292,7 +349,9 @@ Assert.assertNotNull(persistentClass); Assert.assertEquals(Entity1.class, persistentClass.getProxyInterface()); - log.info("test 3 : add properties from file"); + if (log.isInfoEnabled()) { + log.info("test 3 : add properties from file"); + } //reset from previous test context = new TopiaContextImpl(); context.services = new HashMap<String, TopiaService>(); @@ -301,7 +360,7 @@ // use property TOPIA_PERSISTENCE_PROPERTIES_FILE to add default // properties from file properties.setProperty(TopiaContextFactory.CONFIG_PERSISTENCE_PROPERTIES_FILE, - resourcesDir + File.separator + "TopiaContextImpl.properties"); + resourcesDir + File.separator + "TopiaContextImpl.properties"); context.config = properties; Configuration test3 = context.getHibernateConfiguration(); @@ -311,6 +370,103 @@ // Note : maybe add a test to load classes from services } + + @Test + public void replicateEntity() throws Exception { + + Properties configSource = TestHelper.initTopiaContextConfiguration( + testBasedir, + "/TopiaContextImpl.properties", + "replicateSource"); + + Properties configTarget = TestHelper.initTopiaContextConfiguration( + testBasedir, + "/TopiaContextImpl.properties", + "replicateTarget"); + + + TopiaContext contextSource = null; + TopiaContext contextTarget = null; + + try { + contextSource = TopiaContextFactory.getContext(configSource); + contextTarget = TopiaContextFactory.getContext(configTarget); + + TopiaContext txSource; + TopiaContext txTarget; + PersonDAO daoSource, daoTarget; + PetDAO petDAOSource, petDAOTarget; + Person personSource, personTarget; + Pet petSource, petTarget; + + txSource = contextSource.beginTransaction(); + daoSource = TopiaTestDAOHelper.getPersonDAO(txSource); + petDAOSource = TopiaTestDAOHelper.getPetDAO(txSource); + + personSource = daoSource.create(Person.PROPERTY_FIRSTNAME, " firstName", + Person.PROPERTY_NAME, " name" + ); + + petSource = petDAOSource.create(Pet.PROPERTY_NAME, "name", + Pet.PROPERTY_TYPE, "type", + Pet.PROPERTY_PERSON, personSource + ); + + personSource.addPet(petSource); + + txSource.commitTransaction(); + + daoSource = TopiaTestDAOHelper.getPersonDAO(txSource); + + personSource = daoSource.findByTopiaId(personSource.getTopiaId()); + Assert.assertNotNull(personSource); + + petSource = petDAOSource.findByTopiaId(petSource.getTopiaId()); + Assert.assertNotNull(petSource); + Assert.assertEquals(1, personSource.sizePet()); + Assert.assertEquals(petSource, personSource.getPet().iterator().next()); + + txTarget = contextTarget.beginTransaction(); + + txSource.replicateEntity(txTarget, petSource); + txSource.replicateEntity(txTarget, personSource); + + txTarget.commitTransaction(); + + daoTarget = TopiaTestDAOHelper.getPersonDAO(txTarget); + petDAOTarget = TopiaTestDAOHelper.getPetDAO(txTarget); + + personTarget = daoTarget.findByTopiaId(personSource.getTopiaId()); + Assert.assertNotNull(personTarget); + Assert.assertEquals(personSource, personTarget); + Assert.assertEquals(1, personTarget.sizePet()); + + petTarget = petDAOTarget.findByTopiaId(petSource.getTopiaId()); + Assert.assertNotNull(petTarget); + Assert.assertEquals(petSource, petTarget); + + Assert.assertEquals(petTarget, personTarget.getPet().iterator().next()); + + + } finally { + closeDb(contextSource); + closeDb(contextTarget); + } + + } + + protected static void closeDb(TopiaContext contextSource) { + if (contextSource != null && !contextSource.isClosed()) + try { + contextSource.clear(false); + } catch (TopiaException e) { + if (log.isErrorEnabled()) { + log.error("Could not close db " + contextSource, e); + } + } + } + + // // @Test // public void testGetHibernateConfiguration() throws Exception { @@ -368,9 +524,6 @@ // public void testExportXML() throws Exception { // } // -// @Test -// public void testReplicate() throws Exception { -// } // // @Test // public void testReplicateEntity() throws Exception { Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -77,9 +77,10 @@ File testBasedir = TestHelper.getTestBasedir(TopiaTestCase.class); - config = TestHelper.initTopiaContextConfiguration(testBasedir, - "/TopiaContextImpl.properties", - "TopiaTestCaseDb"); + config = TestHelper.initTopiaContextConfiguration( + testBasedir, + "/TopiaContextImpl.properties", + "TopiaTestCaseDb"); // config = new Properties(); // config.setProperty("topia.persistence.classes", TopiaTestDAOHelper.getImplementationClassesAsString()); // @@ -95,8 +96,6 @@ public static void after() throws TopiaException { // destroy database context.clear(false); - - // TODO directory target/TopiaTestCase is not deleted } /** Create base with schema created. */ Modified: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml =================================================================== --- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.hbm.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -24,7 +24,8 @@ #L% --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!--<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">--> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-access="field" auto-import="true" package="org.nuiton.topiatest"> <class name="org.nuiton.topiatest.persistence.Entity1Impl" table="entity1" node="org.nuiton.topiatest.persistence.Entity1Impl" abstract="false" proxy="org.nuiton.topiatest.persistence.Entity1" > <id name="topiaId" type="string" length="255" node="@topiaId"/> Modified: trunk/topia-service-migration/pom.xml =================================================================== --- trunk/topia-service-migration/pom.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-migration/pom.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>topia</artifactId> - <version>2.5.5-SNAPSHOT</version> + <version>2.6-SNAPSHOT</version> </parent> <groupId>org.nuiton.topia</groupId> Modified: trunk/topia-service-migration/src/license/THIRD-PARTY.properties =================================================================== --- trunk/topia-service-migration/src/license/THIRD-PARTY.properties 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-migration/src/license/THIRD-PARTY.properties 2011-06-21 07:35:52 UTC (rev 2301) @@ -1,24 +1,23 @@ -# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # - Common Public License Version 1.0 -# - GNU Lesser General Public License -# - Lesser General Public License (LGPL) v 2.1 # - Lesser General Public License (LGPL) v 3.0 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 # - MIT License +# - MPL 1.1 # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 +# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Fri Nov 19 08:44:41 CET 2010 +#Fri Jun 03 13:51:02 CEST 2011 antlr--antlr--2.7.6--jar=BSD License commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1--jar=BSD License -javassist--javassist--3.8.0.GA--jar=Lesser General Public License (LGPL) v 2.1 javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -org.slf4j--slf4j-api--1.5.8--jar=MIT License -org.slf4j--slf4j-log4j12--1.5.8--jar=MIT License Modified: trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java =================================================================== --- trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-migration/src/main/java/org/nuiton/topia/migration/TopiaMigrationEngine.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -687,6 +687,7 @@ prop.putAll(config); configuration.setProperties(prop); + configuration.buildMappings(); return configuration; } Modified: trunk/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml =================================================================== --- trunk/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-migration/src/main/resources/org/nuiton/topia/migration/mappings/TMSVersion.hbm.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -24,7 +24,8 @@ #L% --> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<!--<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">--> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="org.nuiton.topia.migration.mappings.TMSVersion" table="tms_version"> <id column="version" name="version"/> Modified: trunk/topia-service-replication/pom.xml =================================================================== --- trunk/topia-service-replication/pom.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-replication/pom.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>topia</artifactId> - <version>2.5.5-SNAPSHOT</version> + <version>2.6-SNAPSHOT</version> </parent> <groupId>org.nuiton.topia</groupId> @@ -74,6 +74,11 @@ <artifactId>commons-logging</artifactId> </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + </dependency> + <!-- Depencies for test--> <dependency> <groupId>com.h2database</groupId> Modified: trunk/topia-service-replication/src/license/THIRD-PARTY.properties =================================================================== --- trunk/topia-service-replication/src/license/THIRD-PARTY.properties 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-replication/src/license/THIRD-PARTY.properties 2011-06-21 07:35:52 UTC (rev 2301) @@ -1,24 +1,23 @@ -# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # - Common Public License Version 1.0 -# - GNU Lesser General Public License -# - Lesser General Public License (LGPL) v 2.1 # - Lesser General Public License (LGPL) v 3.0 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 # - MIT License +# - MPL 1.1 # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 +# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Fri Nov 19 08:43:27 CET 2010 +#Fri Jun 03 13:50:38 CEST 2011 antlr--antlr--2.7.6--jar=BSD License commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1--jar=BSD License -javassist--javassist--3.8.0.GA--jar=Lesser General Public License (LGPL) v 2.1 javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -org.slf4j--slf4j-api--1.5.8--jar=MIT License -org.slf4j--slf4j-log4j12--1.5.8--jar=MIT License Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationOperation.java =================================================================== --- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationOperation.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/TopiaReplicationOperation.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -75,7 +75,9 @@ * removed in version 2.6 and never replaced */ @Deprecated - void register(ReplicationModel model, ReplicationNode ownerNode, ReplicationOperationPhase phase, + void register(ReplicationModel model, + ReplicationNode ownerNode, + ReplicationOperationPhase phase, Object... parameters) throws UnsupportedOperationException; @@ -91,8 +93,10 @@ * @param entities la liste des entités à traiter * @throws Exception pour toute erreur */ - void run(TopiaReplicationContext replicationContext, ReplicationOperationDef operationDef, - TopiaContextImplementor srcCtxt, TopiaContextImplementor dstCtxt, List<? extends TopiaEntity> entities) - throws Exception; + void run(TopiaReplicationContext replicationContext, + ReplicationOperationDef operationDef, + TopiaContextImplementor srcCtxt, + TopiaContextImplementor dstCtxt, + List<? extends TopiaEntity> entities) throws Exception; } Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/Duplicate.java =================================================================== --- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/Duplicate.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication/operation/Duplicate.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -76,6 +76,12 @@ TopiaContextImplementor dstCtxt, List<? extends TopiaEntity> entities) throws TopiaException { + // fix http://nuiton.org/issues/1547 + //FIXME tchemit-2011-06-03 : while using hibernate 3.5.6, while duplicating entities we can have some associations in double sessions + //FIXME This hack works but it should be better to resolve the bug :( perharps this is not possible + //FIXME since we can not have a fresh empty hibernate session... + srcCtxt.getHibernate().clear(); + // replication des donnees vers la destination srcCtxt.replicateEntities(dstCtxt, entities); Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractTopiaReplicationServiceTest.java =================================================================== --- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractTopiaReplicationServiceTest.java 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/AbstractTopiaReplicationServiceTest.java 2011-06-21 07:35:52 UTC (rev 2301) @@ -141,7 +141,7 @@ protected abstract Log getLog(); protected <E extends TopiaEntity> E update(E e) throws TopiaException { - return (E) ((TopiaContextImplementor) ctxt).findByTopiaId(e.getTopiaId()); + return (E) ctxt.findByTopiaId(e.getTopiaId()); } /** Modified: trunk/topia-service-security/pom.xml =================================================================== --- trunk/topia-service-security/pom.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-security/pom.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -35,7 +35,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>topia</artifactId> - <version>2.5.5-SNAPSHOT</version> + <version>2.6-SNAPSHOT</version> </parent> <groupId>org.nuiton.topia</groupId> Modified: trunk/topia-service-security/src/license/THIRD-PARTY.properties =================================================================== --- trunk/topia-service-security/src/license/THIRD-PARTY.properties 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-service-security/src/license/THIRD-PARTY.properties 2011-06-21 07:35:52 UTC (rev 2301) @@ -1,24 +1,23 @@ -# Generated by org.nuiton.license.plugin.AddThirdPartyMojo +# Generated by org.codehaus.mojo.license.AddThirdPartyMojo #------------------------------------------------------------------------------- # Already used licenses in project : # - BSD License # - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 # - Common Public License Version 1.0 -# - GNU Lesser General Public License -# - Lesser General Public License (LGPL) v 2.1 # - Lesser General Public License (LGPL) v 3.0 +# - Lesser General Public License (LPGL) +# - Lesser General Public License (LPGL) v 2.1 # - MIT License +# - MPL 1.1 # - The Apache Software License, Version 2.0 # - The H2 License, Version 1.0 +# - license.txt #------------------------------------------------------------------------------- # Please fill the missing licenses for dependencies : # # -#Fri Nov 19 08:44:46 CET 2010 +#Fri Jun 03 13:51:11 CEST 2011 antlr--antlr--2.7.6--jar=BSD License commons-primitives--commons-primitives--1.0--jar=The Apache Software License, Version 2.0 dom4j--dom4j--1.6.1--jar=BSD License -javassist--javassist--3.8.0.GA--jar=Lesser General Public License (LGPL) v 2.1 javax.transaction--jta--1.1--jar=COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 -org.slf4j--slf4j-api--1.5.8--jar=MIT License -org.slf4j--slf4j-log4j12--1.5.8--jar=MIT License Modified: trunk/topia-tutorial/pom.xml =================================================================== --- trunk/topia-tutorial/pom.xml 2011-06-20 16:59:45 UTC (rev 2300) +++ trunk/topia-tutorial/pom.xml 2011-06-21 07:35:52 UTC (rev 2301) @@ -5,7 +5,7 @@ <parent> <groupId>org.nuiton</groupId> <artifactId>topia</artifactId> - <version>2.5.5-SNAPSHOT</version> + <version>2.6-SNAPSHOT</version> </parent> <groupId>org.nuiton.topia</groupId>