Topia-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
May 2012
- 4 participants
- 135 discussions
Author: athimel
Date: 2012-05-09 16:32:00 +0200 (Wed, 09 May 2012)
New Revision: 2450
Url: http://nuiton.org/repositories/revision/topia/2450
Log:
Remove iml file
Removed:
trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
Deleted: trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
===================================================================
--- trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml 2012-05-09 14:31:12 UTC (rev 2449)
+++ trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml 2012-05-09 14:32:00 UTC (rev 2450)
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
- <content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/i18n" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-xmi" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
- <excludeFolder url="file://$MODULE_DIR$/target/antrun" />
- <excludeFolder url="file://$MODULE_DIR$/target/classes" />
- <excludeFolder url="file://$MODULE_DIR$/target/processed-sources" />
- <excludeFolder url="file://$MODULE_DIR$/target/surefire-workdir" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.1.3.Final" level="project" />
- <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
- <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.0.GA" level="project" />
- <orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.0.Final" level="project" />
- <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
- <orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
- <orderEntry type="library" name="Maven: org.javassist:javassist:3.15.0-GA" level="project" />
- <orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.1.Final" level="project" />
- <orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:4.1.3.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: org.hibernate:hibernate-ehcache:4.1.3.Final" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: net.sf.ehcache:ehcache-core:2.4.3" level="project" />
- <orderEntry type="module" module-name="topia-persistence" />
- <orderEntry type="library" name="Maven: org.nuiton:nuiton-utils:2.4.6" level="project" />
- <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
- <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
- <orderEntry type="library" name="Maven: commons-primitives:commons-primitives:1.0" level="project" />
- <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
- <orderEntry type="library" name="Maven: commons-io:commons-io:2.3" level="project" />
- <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.3" level="project" />
- <orderEntry type="library" name="Maven: commons-jxpath:commons-jxpath:1.3" level="project" />
- <orderEntry type="library" name="Maven: org.nuiton.i18n:nuiton-i18n:2.4.1" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: javassist:javassist:3.12.1.GA" level="project" />
- <orderEntry type="library" scope="TEST" name="Maven: com.h2database:h2:1.3.165" level="project" />
- <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
- <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
- <orderEntry type="library" scope="TEST" name="Maven: log4j:log4j:1.2.16" level="project" />
- <orderEntry type="module" module-name="topia-persistence-tck" scope="TEST" />
- </component>
-</module>
-
1
0
09 May '12
Author: athimel
Date: 2012-05-09 16:31:12 +0200 (Wed, 09 May 2012)
New Revision: 2449
Url: http://nuiton.org/repositories/revision/topia/2449
Log:
Move Hibernate dependant tests from t-p-tck to t-p-hibernate
Added:
trunk/topia-persistence-hibernate/src/main/resources/i18n/topia-persistence-hibernate_en_GB.properties
trunk/topia-persistence-hibernate/src/main/resources/i18n/topia-persistence-hibernate_es_ES.properties
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java
Removed:
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java
Modified:
trunk/topia-persistence-hibernate/pom.xml
trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
Modified: trunk/topia-persistence-hibernate/pom.xml
===================================================================
--- trunk/topia-persistence-hibernate/pom.xml 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-hibernate/pom.xml 2012-05-09 14:31:12 UTC (rev 2449)
@@ -66,6 +66,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>topia-persistence-tck</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
@@ -154,7 +161,7 @@
</executions>
</plugin>
- <plugin>
+ <!--plugin>
<groupId>org.nuiton.eugene</groupId>
<artifactId>maven-eugene-plugin</artifactId>
<configuration>
@@ -182,7 +189,7 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin-->
<!-- expose tests -->
<plugin>
Added: trunk/topia-persistence-hibernate/src/main/resources/i18n/topia-persistence-hibernate_en_GB.properties
===================================================================
Added: trunk/topia-persistence-hibernate/src/main/resources/i18n/topia-persistence-hibernate_es_ES.properties
===================================================================
Deleted: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -1,158 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-//import org.hibernate.cfg.Environment;
-import org.junit.Ignore;
-import org.nuiton.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * Helper for all topia tests.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5
- */
-@Ignore
-// this is not a test :)
-public class TestHelper {
-
- private static final Log log = LogFactory.getLog(TestHelper.class);
-
- protected static File testBasedir;
-
- protected static File targetdir;
-
- protected static File dirDatabase;
-
- public static final String DEFAULT_CONFIGURATION_LOCATION = "/TopiaContextImpl.properties";
-
- public static File getTestWorkdir() {
- if (testBasedir == null) {
- String base = System.getProperty("java.io.tmpdir");
- if (base == null || base.isEmpty()) {
- base = new File("").getAbsolutePath();
- }
- testBasedir = new File(base);
- log.info("basedir for test " + testBasedir);
- }
- return testBasedir;
- }
-
- public static File getTestBasedir(Class<?> testClass) throws IOException {
- File dir = getTestWorkdir();
- File result = new File(dir, testClass.getName());
- if (result.exists()) {
-
- // when calling this method (always in a BeforeClass method), we wants
- // to clean the directory, this is a new build
- FileUtil.deleteRecursively(result);
- }
-
- // always create the directory
- FileUtil.createDirectoryIfNecessary(result);
- return result;
- }
-
- public static TopiaContext initTopiaContext(File testDirectory,
- String dbname)
- throws IOException, TopiaNotFoundException {
-
-
- TopiaContext topiaContext = initTopiaContext(
- testDirectory,
- DEFAULT_CONFIGURATION_LOCATION,
- dbname
- );
- return topiaContext;
- }
-
- public static TopiaContext initTopiaContext(File testDirectory,
- String dbPropertiesPath,
- String dbname)
- throws IOException, TopiaNotFoundException {
-
- Properties configuration = initTopiaContextConfiguration(
- testDirectory,
- dbPropertiesPath,
- dbname);
- return TopiaContextFactory.getContext(configuration);
- }
-
- public static Properties initTopiaContextConfiguration(File testDirectory,
- String dbPropertiesPath,
- String dbname)
- throws IOException {
-
- Properties configuration = loadHibernateConfiguration(dbPropertiesPath);
-
- // make sure we always use a different directory
-
- String dbPath = getDbName(testDirectory, dbname);
-
- if (log.isInfoEnabled()) {
- log.info("dbPath = " + dbPath);
- }
- configuration.setProperty(
- TopiaContextFactory.CONFIG_URL,
- "jdbc:h2:file:" + dbPath);
-
- return configuration;
- }
-
- public static Properties loadHibernateConfiguration(String dbPropertiesPath) throws IOException {
- InputStream stream = TestHelper.class.getResourceAsStream(dbPropertiesPath);
-
- Properties configuration = new Properties();
-
- configuration.load(stream);
- configuration.setProperty(
- TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
- TopiaTestDAOHelper.getImplementationClassesAsString());
- return configuration;
- }
-
- public static String getDbName(File testDirectory, String dbname) {
- return new File(testDirectory,
- dbname + '_' + System.nanoTime()).getAbsolutePath();
- }
-
- public static Properties initTopiaContextConfiguration(File testDirectory,
- String dbname)
- throws IOException {
-
- return initTopiaContextConfiguration(
- testDirectory,
- DEFAULT_CONFIGURATION_LOCATION,
- dbname
- );
- }
-}
Deleted: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -1,192 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2012 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * Put this class as a Rule in test to obtain a new isolated db for each test.
- * <p/>
- * Here is a simple example of usage :
- * <pre>
- * public class MyTest {
- *
- * \@Rule
- * public final TopiaDatabase db = new TopiaDatabase();
- *
- * \@Test
- * public void testMethod() throws TopiaException {
- *
- * TopiaContext tx = db.beginTransaction();
- * ...
- * }
- * </pre>
- * The db created will be unique for each test method (and for each build also).
- * <p/>
- * You don't need to close any transaction, it will be done for you and the end
- * of each method test.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.6.8
- */
-public class TopiaDatabase extends TestWatcher {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(TopiaDatabase.class);
-
- /** A time-stamp, allow to make multiple build and keep the tests data. */
- public static final String TIMESTAMP = String.valueOf(System.nanoTime());
-
- private File testBasedir;
-
- private Properties dbConfiguration;
-
- private TopiaContext rootCtxt;
-
- private final String configurationPath;
-
- public TopiaDatabase() {
- this(TestHelper.DEFAULT_CONFIGURATION_LOCATION);
- }
-
- public TopiaDatabase(String configurationPath) {
- this.configurationPath = configurationPath;
- }
-
- @Override
- protected void starting(Description description) {
-
- // get test directory
- testBasedir = getTestSpecificDirectory(
- description.getTestClass(),
- description.getMethodName());
-
- if (log.isDebugEnabled()) {
- log.debug("testBasedir = " + testBasedir);
- }
-
- // create the root context
- try {
-
- dbConfiguration = new Properties();
- InputStream stream =
- getClass().getResourceAsStream(configurationPath);
-
- try {
- dbConfiguration.load(stream);
- } finally {
- stream.close();
- }
- dbConfiguration.setProperty(
- TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
- TopiaTestDAOHelper.getImplementationClassesAsString());
-
- // make sure we always use a different directory
-
- String dbPath = new File(testBasedir, "db").getAbsolutePath();
-
- if (log.isDebugEnabled()) {
- log.debug("dbPath = " + dbPath);
- }
- dbConfiguration.setProperty(
- TopiaContextFactory.CONFIG_URL, "jdbc:h2:file:" + dbPath);
-
- onDbConfigurationCreate(dbConfiguration, testBasedir, dbPath);
-
- rootCtxt = TopiaContextFactory.getContext(dbConfiguration);
- } catch (Exception e) {
- throw new IllegalStateException(
- "Could not start db at " + testBasedir, e);
- }
- }
-
- @Override
- public void finished(Description description) {
-
- if (rootCtxt != null && !rootCtxt.isClosed()) {
- try {
- rootCtxt.closeContext();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Could not close topia root context", e);
- }
- }
- }
- rootCtxt = null;
- dbConfiguration = null;
- }
-
- public File getTestBasedir() {
- return testBasedir;
- }
-
- public TopiaContext getRootCtxt() {
- return rootCtxt;
- }
-
- public Properties getDbConfiguration() {
- return dbConfiguration;
- }
-
- public TopiaContext beginTransaction() throws TopiaException {
- return rootCtxt.beginTransaction();
- }
-
- protected void onDbConfigurationCreate(Properties configuration,
- File testDir,
- String dbPath) {
-
- }
-
- public static File getTestSpecificDirectory(Class<?> testClassName, String methodName) {
- // Trying to look for the temporary folder to store data for the test
- String tempDirPath = System.getProperty("java.io.tmpdir");
- if (tempDirPath == null) {
- // can this really occur ?
- tempDirPath = "";
- if (log.isWarnEnabled()) {
- log.warn("'\"java.io.tmpdir\" not defined");
- }
- }
- File tempDirFile = new File(tempDirPath);
-
- // create the directory to store database data
- String dataBasePath = testClassName.getName()
- + File.separator // a directory with the test class name
- + methodName// a sub-directory with the method name
- + '_'
- + TIMESTAMP; // and a timestamp
- File databaseFile = new File(tempDirFile, dataBasePath);
- return databaseFile;
- }
-}
-
Copied: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java (from rev 2446, trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java)
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java (rev 0)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -0,0 +1,222 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.framework;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.cfg.Environment;
+import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
+import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Properties;
+
+/**
+ * Customized connection provider.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.3
+ */
+public class TopiaConnectionProviderHardCoded implements ConnectionProvider {
+
+ private String url;
+
+ private Properties connectionProps;
+
+ private Integer isolation;
+
+ private final ArrayList pool = new ArrayList();
+
+ private int poolSize;
+
+ private int checkedOut = 0;
+
+ private boolean autocommit;
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(TopiaConnectionProviderHardCoded.class);
+
+ public TopiaConnectionProviderHardCoded() {
+ System.out.println("created");
+ }
+ public void configure(Properties props) throws HibernateException {
+ String driverClass = props.getProperty(Environment.DRIVER);
+
+// poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
+ poolSize = 20; //default pool size 20
+ log.info("Using Hibernate built-in connection pool (not for production use!)");
+ log.info("Hibernate connection pool size: " + poolSize);
+
+// autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
+ autocommit = true;
+ log.info("autocommit mode: " + autocommit);
+
+// isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
+ isolation = 0;
+ if (isolation != null)
+ log.info("JDBC isolation level: " + Environment.isolationLevelToString(isolation));
+
+ if (driverClass == null) {
+ log.warn("no JDBC Driver class was specified by property " + Environment.DRIVER);
+ } else {
+ try {
+ // trying via forName() first to be as close to DriverManager's semantics
+ Class.forName(driverClass);
+ } catch (ClassNotFoundException cnfe) {
+// try {
+// ReflectHelper.classForName(driverClass);
+// } catch (ClassNotFoundException e) {
+// String msg = "JDBC Driver class not found: " + driverClass;
+// log.error(msg, e);
+// throw new HibernateException(msg, e);
+// }
+ }
+ }
+
+ // use a dummy directory to make sure only the connection provider knows
+ // the real directory where db is and then make sure hibernate always
+ // use the connection provider...
+ String directory =
+ props.getProperty(TopiaConnectionProviderTest.TEST_URL);
+
+ url = directory;
+// url = props.getProperty(Environment.URL);
+
+// if (url == null) {
+// String msg = "JDBC URL was not specified by property " + Environment.URL;
+// log.error(msg);
+// throw new HibernateException(msg);
+// }
+
+ connectionProps = ConnectionProviderInitiator.getConnectionProperties(props);
+
+ log.info("using driver: " + driverClass + " at URL: " + url);
+ // if debug level is enabled, then log the password, otherwise mask it
+ if (log.isDebugEnabled()) {
+ log.info("connection properties: " + connectionProps);
+ } else if (log.isInfoEnabled()) {
+// log.info("connection properties: " + PropertiesHelper.maskOut(connectionProps, "password"));
+ }
+ }
+
+ @Override
+ public Connection getConnection() throws SQLException {
+ if (log.isTraceEnabled())
+ log.trace("total checked-out connections: " + checkedOut);
+
+ synchronized (pool) {
+ if (!pool.isEmpty()) {
+ int last = pool.size() - 1;
+ if (log.isTraceEnabled()) {
+ log.trace("using pooled JDBC connection, pool size: " + last);
+ }
+ checkedOut++;
+ Connection pooled = (Connection) pool.remove(last);
+ if (isolation != null)
+ pooled.setTransactionIsolation(isolation.intValue());
+ if (pooled.getAutoCommit() != autocommit)
+ pooled.setAutoCommit(autocommit);
+ return pooled;
+ }
+ }
+
+ log.debug("opening new JDBC connection");
+ Connection conn = DriverManager.getConnection(url, connectionProps);
+ if (isolation != null) conn.setTransactionIsolation(isolation);
+ if (conn.getAutoCommit() != autocommit) conn.setAutoCommit(autocommit);
+
+ if (log.isDebugEnabled()) {
+ log.debug("created connection to: " + url + ", Isolation Level: " + conn.getTransactionIsolation());
+ }
+// if ( log.isTraceEnabled() )
+ checkedOut++;
+
+ return conn;
+ }
+
+ @Override
+ public void closeConnection(Connection conn) throws SQLException {
+// if ( log.isDebugEnabled() )
+ checkedOut--;
+
+ synchronized (pool) {
+ int currentSize = pool.size();
+ if (currentSize < poolSize) {
+ if (log.isTraceEnabled()) {
+ log.trace("returning connection to pool, pool size: " + (currentSize + 1));
+ }
+ pool.add(conn);
+ return;
+ }
+ }
+
+ log.debug("closing JDBC connection");
+
+ conn.close();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ close();
+ }
+
+ public void close() {
+
+ log.info("cleaning up connection pool: " + url);
+
+ Iterator iter = pool.iterator();
+ while (iter.hasNext()) {
+ try {
+ ((Connection) iter.next()).close();
+ } catch (SQLException sqle) {
+ log.warn("problem closing pooled connection", sqle);
+ }
+ }
+ pool.clear();
+
+ }
+
+ @Override
+ public boolean supportsAggressiveRelease() {
+ return false;
+ }
+
+ @Override
+ public boolean isUnwrappableAs(Class unwrapType) {
+ return false;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> unwrapType) {
+ return null;
+ }
+}
Copied: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java (from rev 2448, trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java)
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java (rev 0)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -0,0 +1,140 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.framework;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaTckItDAOHelper;
+import org.nuiton.topia.tck.TopiaDatabase;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.tck.it.Personne;
+import org.nuiton.topia.test.entities.Person;
+import org.nuiton.topia.test.entities.PersonDAO;
+
+import java.io.File;
+import java.util.Locale;
+import java.util.Properties;
+
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * To test the {@link TopiaConnectionProvider} and make sure all connections
+ * are done from here...
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5.3
+ */
+public class TopiaConnectionProviderTest {
+
+// private static final Log log =
+// LogFactory.getLog(TopiaConnectionProviderTest.class);
+
+ public static final String TEST_URL = "testURL";
+
+ @Rule
+ public final TopiaDatabase db =
+ new TopiaDatabase("/TopiaConnectionProviderHardcoded.properties") {
+
+ @Override
+ protected void onDbConfigurationCreate(Properties configuration,
+ File testdir,
+ String dbPath) {
+
+ Assert.assertFalse(testdir.exists());
+
+ String dbPathFake = new File(testdir, "fake" + File.separator + "db").getAbsolutePath();
+
+ Assert.assertFalse(new File(dbPathFake).getParentFile().exists());
+
+ configuration.setProperty("dbPath", dbPath);
+ configuration.setProperty("dbPathFake", dbPathFake);
+
+ // give the path where connection provider will create db
+ configuration.setProperty(TEST_URL,
+ "jdbc:h2:file:" + dbPath);
+
+ // give a fake db path (we will make sure it is never create after hibernate usage).
+ configuration.setProperty(TopiaContextFactory.CONFIG_URL,
+ "jdbc:h2:file:" + dbPathFake);
+ }
+ };
+
+ @Test
+ public void testWithHardcoded() throws Exception {
+
+// Properties dbProperties = TestHelper.loadHibernateConfiguration(
+// "/TopiaConnectionProviderHardcoded.properties");
+//
+// File directory = new File(TestHelper.getDbName(testBasedir, "testWithHardcoded"));
+
+ String dbPath = (String) db.getDbConfiguration().get("dbPath");
+ String dbPathFake = (String) db.getDbConfiguration().get("dbPathFake");
+
+// new File(directory, "real" + File.separator + "db").getAbsolutePath();
+// Assert.assertFalse(new File(dbPath).getParentFile().exists());
+
+// String dbPathFake = new File(directory, "fake" + File.separator + "db").getAbsolutePath();
+
+// Assert.assertFalse(new File(dbPathFake).getParentFile().exists());
+
+// // give the path where connection provider will create db
+// dbProperties.setProperty(TEST_URL, "jdbc:h2:file:" + dbPath);
+//
+// // give a fake db path (we will make sure it is never create after hibernate usage).
+// dbProperties.setProperty(Environment.URL, "jdbc:h2:file:" + dbPathFake);
+//
+// root = TopiaContextFactory.getContext(dbProperties);
+
+ Locale.setDefault(Locale.FRANCE);
+
+ doStuffOnDb();
+
+ // the db file must have been created
+ Assert.assertTrue(new File(dbPath).getParentFile().exists());
+
+ // make sure the fake db path was never used
+ Assert.assertFalse(new File(dbPathFake).getParentFile().exists());
+ }
+
+ private void doStuffOnDb() throws TopiaException {
+ TopiaContext transaction = db.beginTransaction();
+
+ try {
+ PersonDAO dao = TopiaTckItDAOHelper.getPersonDAO(transaction);
+
+ Person personne = dao.create(Personne.PROPERTY_NAME, "Jack Bauer");
+ transaction.commitTransaction();
+ String idPersonne = personne.getTopiaId();
+ assertNotNull(idPersonne);
+
+ transaction.commitTransaction();
+ } finally {
+ transaction.closeContext();
+ }
+ }
+}
Deleted: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -1,89 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.topia.persistence;
-
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
-import org.nuiton.topia.TopiaTestDAOHelper;
-import org.nuiton.topia.test.entities.Person;
-import org.nuiton.topia.test.entities.PersonDAO;
-
-import java.util.List;
-
-/**
- * Test on {@link TopiaDAO}.
- * <p/>
- * Last update : $Date$
- * By : $Author$
- *
- * @author chatellier
- * @version $Revision$
- */
-public class TopiaDAOTest {
-
- @Rule
- public final TopiaDatabase db = new TopiaDatabase();
-
- /**
- * Test de creer une entité et de verifier qu'elle est
- * présente dans la persistence au sein de la transaction.
- *
- * @throws Exception if any exception while test
- */
- @Test
- public void testCreateAndFindInTransaction() throws Exception {
-
- TopiaContext context = db.beginTransaction();
-
- PersonDAO personDAO = TopiaTestDAOHelper.getPersonDAO(context);
-
- // appel 1 find all
- Person person = personDAO.create(Person.PROPERTY_NAME, "toto");
- List<Person> allPerson = personDAO.findAll();
- Assert.assertEquals(1, allPerson.size());
- context.commitTransaction();
-
- // recherce la personne créée dans la même transaction
- Person person2 = personDAO.create(Person.PROPERTY_NAME, "titi");
- allPerson = personDAO.findAll();
- Assert.assertEquals(2, allPerson.size());
- Assert.assertThat(allPerson, JUnitMatchers.hasItem(person2));
-
- context.rollbackTransaction();
-
- // meme test apres roolback
- Person person3 = personDAO.create(Person.PROPERTY_NAME, "tata");
- allPerson = personDAO.findAll();
- Assert.assertEquals(2, allPerson.size());
- Assert.assertThat(allPerson, JUnitMatchers.hasItem(person3));
-
- context.commitTransaction();
- }
-}
Modified: trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
===================================================================
--- trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml 2012-05-09 14:31:12 UTC (rev 2449)
@@ -3,12 +3,17 @@
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
- <exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
- <excludeFolder url="file://$MODULE_DIR$/target" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/i18n" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-xmi" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target/antrun" />
+ <excludeFolder url="file://$MODULE_DIR$/target/classes" />
+ <excludeFolder url="file://$MODULE_DIR$/target/processed-sources" />
+ <excludeFolder url="file://$MODULE_DIR$/target/surefire-workdir" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
@@ -38,6 +43,7 @@
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: log4j:log4j:1.2.16" level="project" />
+ <orderEntry type="module" module-name="topia-persistence-tck" scope="TEST" />
</component>
</module>
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -1,222 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia.framework;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
-import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Properties;
-
-/**
- * Customized connection provider.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5.3
- */
-public class TopiaConnectionProviderHardCoded implements ConnectionProvider {
-
- private String url;
-
- private Properties connectionProps;
-
- private Integer isolation;
-
- private final ArrayList pool = new ArrayList();
-
- private int poolSize;
-
- private int checkedOut = 0;
-
- private boolean autocommit;
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(TopiaConnectionProviderHardCoded.class);
-
- public TopiaConnectionProviderHardCoded() {
- System.out.println("created");
- }
- public void configure(Properties props) throws HibernateException {
- String driverClass = props.getProperty(Environment.DRIVER);
-
-// poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
- poolSize = 20; //default pool size 20
- log.info("Using Hibernate built-in connection pool (not for production use!)");
- log.info("Hibernate connection pool size: " + poolSize);
-
-// autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
- autocommit = true;
- log.info("autocommit mode: " + autocommit);
-
-// isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
- isolation = 0;
- if (isolation != null)
- log.info("JDBC isolation level: " + Environment.isolationLevelToString(isolation));
-
- if (driverClass == null) {
- log.warn("no JDBC Driver class was specified by property " + Environment.DRIVER);
- } else {
- try {
- // trying via forName() first to be as close to DriverManager's semantics
- Class.forName(driverClass);
- } catch (ClassNotFoundException cnfe) {
-// try {
-// ReflectHelper.classForName(driverClass);
-// } catch (ClassNotFoundException e) {
-// String msg = "JDBC Driver class not found: " + driverClass;
-// log.error(msg, e);
-// throw new HibernateException(msg, e);
-// }
- }
- }
-
- // use a dummy directory to make sure only the connection provider knows
- // the real directory where db is and then make sure hibernate always
- // use the connection provider...
- String directory =
- props.getProperty(TopiaConnectionProviderTest.TEST_URL);
-
- url = directory;
-// url = props.getProperty(Environment.URL);
-
-// if (url == null) {
-// String msg = "JDBC URL was not specified by property " + Environment.URL;
-// log.error(msg);
-// throw new HibernateException(msg);
-// }
-
- connectionProps = ConnectionProviderInitiator.getConnectionProperties(props);
-
- log.info("using driver: " + driverClass + " at URL: " + url);
- // if debug level is enabled, then log the password, otherwise mask it
- if (log.isDebugEnabled()) {
- log.info("connection properties: " + connectionProps);
- } else if (log.isInfoEnabled()) {
-// log.info("connection properties: " + PropertiesHelper.maskOut(connectionProps, "password"));
- }
- }
-
- @Override
- public Connection getConnection() throws SQLException {
- if (log.isTraceEnabled())
- log.trace("total checked-out connections: " + checkedOut);
-
- synchronized (pool) {
- if (!pool.isEmpty()) {
- int last = pool.size() - 1;
- if (log.isTraceEnabled()) {
- log.trace("using pooled JDBC connection, pool size: " + last);
- }
- checkedOut++;
- Connection pooled = (Connection) pool.remove(last);
- if (isolation != null)
- pooled.setTransactionIsolation(isolation.intValue());
- if (pooled.getAutoCommit() != autocommit)
- pooled.setAutoCommit(autocommit);
- return pooled;
- }
- }
-
- log.debug("opening new JDBC connection");
- Connection conn = DriverManager.getConnection(url, connectionProps);
- if (isolation != null) conn.setTransactionIsolation(isolation);
- if (conn.getAutoCommit() != autocommit) conn.setAutoCommit(autocommit);
-
- if (log.isDebugEnabled()) {
- log.debug("created connection to: " + url + ", Isolation Level: " + conn.getTransactionIsolation());
- }
-// if ( log.isTraceEnabled() )
- checkedOut++;
-
- return conn;
- }
-
- @Override
- public void closeConnection(Connection conn) throws SQLException {
-// if ( log.isDebugEnabled() )
- checkedOut--;
-
- synchronized (pool) {
- int currentSize = pool.size();
- if (currentSize < poolSize) {
- if (log.isTraceEnabled()) {
- log.trace("returning connection to pool, pool size: " + (currentSize + 1));
- }
- pool.add(conn);
- return;
- }
- }
-
- log.debug("closing JDBC connection");
-
- conn.close();
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- close();
- }
-
- public void close() {
-
- log.info("cleaning up connection pool: " + url);
-
- Iterator iter = pool.iterator();
- while (iter.hasNext()) {
- try {
- ((Connection) iter.next()).close();
- } catch (SQLException sqle) {
- log.warn("problem closing pooled connection", sqle);
- }
- }
- pool.clear();
-
- }
-
- @Override
- public boolean supportsAggressiveRelease() {
- return false;
- }
-
- @Override
- public boolean isUnwrappableAs(Class unwrapType) {
- return false;
- }
-
- @Override
- public <T> T unwrap(Class<T> unwrapType) {
- return null;
- }
-}
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -1,140 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia.framework;
-
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaTckItDAOHelper;
-import org.nuiton.topia.tck.TopiaDatabase;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.tck.it.Personne;
-import org.nuiton.topia.test.entities.Person;
-import org.nuiton.topia.test.entities.PersonDAO;
-
-import java.io.File;
-import java.util.Locale;
-import java.util.Properties;
-
-import static org.junit.Assert.assertNotNull;
-
-/**
- * To test the {@link TopiaConnectionProvider} and make sure all connections
- * are done from here...
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5.3
- */
-public class TopiaConnectionProviderTest {
-
-// private static final Log log =
-// LogFactory.getLog(TopiaConnectionProviderTest.class);
-
- public static final String TEST_URL = "testURL";
-
- @Rule
- public final TopiaDatabase db =
- new TopiaDatabase("/TopiaConnectionProviderHardcoded.properties") {
-
- @Override
- protected void onDbConfigurationCreate(Properties configuration,
- File testdir,
- String dbPath) {
-
- Assert.assertFalse(testdir.exists());
-
- String dbPathFake = new File(testdir, "fake" + File.separator + "db").getAbsolutePath();
-
- Assert.assertFalse(new File(dbPathFake).getParentFile().exists());
-
- configuration.setProperty("dbPath", dbPath);
- configuration.setProperty("dbPathFake", dbPathFake);
-
- // give the path where connection provider will create db
- configuration.setProperty(TEST_URL,
- "jdbc:h2:file:" + dbPath);
-
- // give a fake db path (we will make sure it is never create after hibernate usage).
- configuration.setProperty(TopiaContextFactory.CONFIG_URL,
- "jdbc:h2:file:" + dbPathFake);
- }
- };
-
- @Test
- public void testWithHardcoded() throws Exception {
-
-// Properties dbProperties = TestHelper.loadHibernateConfiguration(
-// "/TopiaConnectionProviderHardcoded.properties");
-//
-// File directory = new File(TestHelper.getDbName(testBasedir, "testWithHardcoded"));
-
- String dbPath = (String) db.getDbConfiguration().get("dbPath");
- String dbPathFake = (String) db.getDbConfiguration().get("dbPathFake");
-
-// new File(directory, "real" + File.separator + "db").getAbsolutePath();
-// Assert.assertFalse(new File(dbPath).getParentFile().exists());
-
-// String dbPathFake = new File(directory, "fake" + File.separator + "db").getAbsolutePath();
-
-// Assert.assertFalse(new File(dbPathFake).getParentFile().exists());
-
-// // give the path where connection provider will create db
-// dbProperties.setProperty(TEST_URL, "jdbc:h2:file:" + dbPath);
-//
-// // give a fake db path (we will make sure it is never create after hibernate usage).
-// dbProperties.setProperty(Environment.URL, "jdbc:h2:file:" + dbPathFake);
-//
-// root = TopiaContextFactory.getContext(dbProperties);
-
- Locale.setDefault(Locale.FRANCE);
-
- doStuffOnDb();
-
- // the db file must have been created
- Assert.assertTrue(new File(dbPath).getParentFile().exists());
-
- // make sure the fake db path was never used
- Assert.assertFalse(new File(dbPathFake).getParentFile().exists());
- }
-
- private void doStuffOnDb() throws TopiaException {
- TopiaContext transaction = db.beginTransaction();
-
- try {
- PersonDAO dao = TopiaTckItDAOHelper.getPersonDAO(transaction);
-
- Person personne = dao.create(Personne.PROPERTY_NAME, "Jack Bauer");
- transaction.commitTransaction();
- String idPersonne = personne.getTopiaId();
- assertNotNull(idPersonne);
-
- transaction.commitTransaction();
- } finally {
- transaction.closeContext();
- }
- }
-}
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-09 14:22:27 UTC (rev 2448)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-09 14:31:12 UTC (rev 2449)
@@ -27,7 +27,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-//import org.hibernate.PropertyValueException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
1
0
Author: athimel
Date: 2012-05-09 16:22:27 +0200 (Wed, 09 May 2012)
New Revision: 2448
Url: http://nuiton.org/repositories/revision/topia/2448
Log:
Move back some generator tests to topia-persistence
Added:
trunk/topia-persistence/src/test/java/org/
trunk/topia-persistence/src/test/java/org/nuiton/
trunk/topia-persistence/src/test/java/org/nuiton/topia/
trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/
trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java
trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java
Removed:
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java
Modified:
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaQueryTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/evo1912/EntityDTOTransformerTest.java
trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java
trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplAllTest.java
trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplTest.java
Copied: trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java (from rev 2446, trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java)
===================================================================
--- trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java (rev 0)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -0,0 +1,68 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.generator;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.nuiton.eugene.java.JavaBuilder;
+import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl;
+
+import java.util.HashMap;
+
+/**
+ * Created: 24 juin 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class QueryHelperTransformerTest {
+
+ @Test
+ public void testCreateAliasConstant() {
+ QueryHelperTransformer transformer = new QueryHelperTransformer();
+ transformer.aliases = new HashMap<String, String>();
+ transformer.helperClass = new ObjectModelClassImpl();
+ transformer.setBuilder(new JavaBuilder("TopiaTest"));
+
+ String entityName = "Department";
+ transformer.createAliasConstant(entityName);
+ Assert.assertEquals(1, transformer.aliases.size());
+ Assert.assertTrue(transformer.aliases.containsKey("D"));
+
+ entityName = "Depot";
+ transformer.createAliasConstant(entityName);
+ Assert.assertEquals(2, transformer.aliases.size());
+ Assert.assertTrue(transformer.aliases.containsKey("DE"));
+
+ entityName = "Deposite";
+ transformer.createAliasConstant(entityName);
+ Assert.assertEquals(3, transformer.aliases.size());
+ Assert.assertTrue(transformer.aliases.containsKey("DEP"));
+
+ entityName = "Dep";
+ transformer.createAliasConstant(entityName);
+ Assert.assertEquals(4, transformer.aliases.size());
+ }
+}
Copied: trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java (from rev 2446, trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java)
===================================================================
--- trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java (rev 0)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -0,0 +1,80 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.generator;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.eugene.ModelPropertiesUtil;
+import org.nuiton.eugene.models.object.ObjectModelClassifier;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+
+/**
+ * To test {@link TopiaGeneratorUtil.TopiaModelPropertiesProvider}.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.3
+ */
+public class TopiaModelPropertiesProviderTest {
+
+ protected ModelPropertiesUtil.ModelPropertiesProvider provider;
+
+ @Before
+ public void setUp() throws Exception {
+ provider = new TopiaGeneratorUtil.TopiaModelPropertiesProvider();
+ provider.init();
+ }
+
+ @Test
+ public void testGetTagValueTarget() throws Exception {
+ testTagValue(TopiaTagValues.TAG_PERSISTENCE_TYPE, ObjectModelClassifier.class);
+ //TODO Finish with other tag values...
+ }
+
+ @Test
+ public void testGetStereotypeTarget() throws Exception {
+
+ testStereotype(TopiaStereoTypes.STEREOTYPE_DAO, ObjectModelClassifier.class, ObjectModelOperation.class);
+ //TODO Finish with other stereotypes...
+ }
+
+ @Test
+ public void testGetStore() throws Exception {
+ }
+
+ protected void testStereotype(String name, Class<?>... expected) {
+ Class<?>[] classes = provider.getStereotypeTarget(name);
+ Assert.assertNotNull("Could not find target for " + name, classes);
+ Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length);
+ Assert.assertArrayEquals(expected, classes);
+ }
+
+ protected void testTagValue(String name, Class<?>... expected) {
+ Class<?>[] classes = provider.getTagValueTarget(name);
+ Assert.assertNotNull("Could not find target for " + name, classes);
+ Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length);
+ Assert.assertArrayEquals(expected, classes);
+ }
+}
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -29,8 +29,10 @@
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.tck.it.Personne;
import org.nuiton.topia.test.entities.Person;
import org.nuiton.topia.test.entities.PersonDAO;
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -37,6 +37,9 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.tck.it.persistence.Entity1Impl;
+import org.nuiton.topia.tck.it.service.FakeService;
+import org.nuiton.topia.tck.it.service.TestService;
import java.io.File;
import java.util.HashMap;
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaQueryTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaQueryTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaQueryTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -30,7 +30,7 @@
import org.junit.Assert;
import org.junit.Test;
import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topiatest.QueriedEntity;
+import org.nuiton.topia.tck.it.QueriedEntity;
/** @author fdesbois */
public class TopiaQueryTest {
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -29,8 +29,8 @@
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.tck.TopiaDatabase;
+import org.nuiton.topia.tck.it.Personne;
import org.nuiton.topia.test.entities.PersonImpl;
-import org.nuiton.topiatest.Personne;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/QueryHelperTransformerTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -1,68 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia.generator;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.nuiton.eugene.java.JavaBuilder;
-import org.nuiton.eugene.models.object.xml.ObjectModelClassImpl;
-
-import java.util.HashMap;
-
-/**
- * Created: 24 juin 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- * @version $Id$
- */
-public class QueryHelperTransformerTest {
-
- @Test
- public void testCreateAliasConstant() {
- QueryHelperTransformer transformer = new QueryHelperTransformer();
- transformer.aliases = new HashMap<String, String>();
- transformer.helperClass = new ObjectModelClassImpl();
- transformer.setBuilder(new JavaBuilder("TopiaTest"));
-
- String entityName = "Department";
- transformer.createAliasConstant(entityName);
- Assert.assertEquals(1, transformer.aliases.size());
- Assert.assertTrue(transformer.aliases.containsKey("D"));
-
- entityName = "Depot";
- transformer.createAliasConstant(entityName);
- Assert.assertEquals(2, transformer.aliases.size());
- Assert.assertTrue(transformer.aliases.containsKey("DE"));
-
- entityName = "Deposite";
- transformer.createAliasConstant(entityName);
- Assert.assertEquals(3, transformer.aliases.size());
- Assert.assertTrue(transformer.aliases.containsKey("DEP"));
-
- entityName = "Dep";
- transformer.createAliasConstant(entityName);
- Assert.assertEquals(4, transformer.aliases.size());
- }
-}
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaModelPropertiesProviderTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -1,80 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia.generator;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.nuiton.eugene.ModelPropertiesUtil;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-
-/**
- * To test {@link TopiaGeneratorUtil.TopiaModelPropertiesProvider}.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.3
- */
-public class TopiaModelPropertiesProviderTest {
-
- protected ModelPropertiesUtil.ModelPropertiesProvider provider;
-
- @Before
- public void setUp() throws Exception {
- provider = new TopiaGeneratorUtil.TopiaModelPropertiesProvider();
- provider.init();
- }
-
- @Test
- public void testGetTagValueTarget() throws Exception {
- testTagValue(TopiaTagValues.TAG_PERSISTENCE_TYPE, ObjectModelClassifier.class);
- //TODO Finish with other tag values...
- }
-
- @Test
- public void testGetStereotypeTarget() throws Exception {
-
- testStereotype(TopiaStereoTypes.STEREOTYPE_DAO, ObjectModelClassifier.class, ObjectModelOperation.class);
- //TODO Finish with other stereotypes...
- }
-
- @Test
- public void testGetStore() throws Exception {
- }
-
- protected void testStereotype(String name, Class<?>... expected) {
- Class<?>[] classes = provider.getStereotypeTarget(name);
- Assert.assertNotNull("Could not find target for " + name, classes);
- Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length);
- Assert.assertArrayEquals(expected, classes);
- }
-
- protected void testTagValue(String name, Class<?>... expected) {
- Class<?>[] classes = provider.getTagValueTarget(name);
- Assert.assertNotNull("Could not find target for " + name, classes);
- Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length);
- Assert.assertArrayEquals(expected, classes);
- }
-}
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -34,10 +34,10 @@
import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaTckItDAOHelper;
-import org.nuiton.topiatest.Company;
-import org.nuiton.topiatest.CompanyDAO;
-import org.nuiton.topiatest.Department;
-import org.nuiton.topiatest.DepartmentDAO;
+import org.nuiton.topia.tck.it.Company;
+import org.nuiton.topia.tck.it.CompanyDAO;
+import org.nuiton.topia.tck.it.Department;
+import org.nuiton.topia.tck.it.DepartmentDAO;
/**
* TopiaTestCase.
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -34,14 +34,14 @@
import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaTckItDAOHelper;
-import org.nuiton.topiatest.Address;
-import org.nuiton.topiatest.AddressDAO;
-import org.nuiton.topiatest.Company;
-import org.nuiton.topiatest.CompanyDAO;
-import org.nuiton.topiatest.Department;
-import org.nuiton.topiatest.DepartmentDAO;
-import org.nuiton.topiatest.Employe;
-import org.nuiton.topiatest.EmployeDAO;
+import org.nuiton.topia.tck.it.Address;
+import org.nuiton.topia.tck.it.AddressDAO;
+import org.nuiton.topia.tck.it.Company;
+import org.nuiton.topia.tck.it.CompanyDAO;
+import org.nuiton.topia.tck.it.Department;
+import org.nuiton.topia.tck.it.DepartmentDAO;
+import org.nuiton.topia.tck.it.Employe;
+import org.nuiton.topia.tck.it.EmployeDAO;
/**
* Test de visitor.
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -35,8 +35,8 @@
import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaTckItDAOHelper;
-import org.nuiton.topiatest.NaturalizedEntity;
-import org.nuiton.topiatest.NaturalizedEntityDAO;
+import org.nuiton.topia.tck.it.NaturalizedEntity;
+import org.nuiton.topia.tck.it.NaturalizedEntityDAO;
/**
* NaturalIdTest
@@ -162,8 +162,8 @@
public void testNaturalIdAreGeneralized() throws Exception {
// test that natural ids are generalized
- String[] generalizedNaturalizedNaturalIds = TopiaTckItDAOHelper.TopiaTestEntityEnum.GeneralizedNaturalizedEntity.getNaturalIds();
- String[] naturalizedNaturalIds = TopiaTckItDAOHelper.TopiaTestEntityEnum.NaturalizedEntity.getNaturalIds();
+ String[] generalizedNaturalizedNaturalIds = TopiaTckItDAOHelper.TopiaTckItEntityEnum.GeneralizedNaturalizedEntity.getNaturalIds();
+ String[] naturalizedNaturalIds = TopiaTckItDAOHelper.TopiaTckItEntityEnum.NaturalizedEntity.getNaturalIds();
Assert.assertArrayEquals(generalizedNaturalizedNaturalIds, naturalizedNaturalIds);
}
@@ -171,8 +171,8 @@
public void testNotNullsAreGeneralized() throws Exception {
// test that not nulls are generalized
- String[] generalizedNaturalizedNotNulls = TopiaTckItDAOHelper.TopiaTestEntityEnum.GeneralizedNaturalizedEntity.getNotNulls();
- String[] naturalizedNotNulls = TopiaTckItDAOHelper.TopiaTestEntityEnum.NaturalizedEntity.getNotNulls();
+ String[] generalizedNaturalizedNotNulls = TopiaTckItDAOHelper.TopiaTckItEntityEnum.GeneralizedNaturalizedEntity.getNotNulls();
+ String[] naturalizedNotNulls = TopiaTckItDAOHelper.TopiaTckItEntityEnum.NaturalizedEntity.getNotNulls();
Assert.assertArrayEquals(generalizedNaturalizedNotNulls, naturalizedNotNulls);
}
}
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -35,11 +35,11 @@
import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
-import org.nuiton.topiatest.Company;
-import org.nuiton.topiatest.CompanyImpl;
-import org.nuiton.topiatest.Department;
-import org.nuiton.topiatest.DepartmentImpl;
-import org.nuiton.topiatest.EmployeImpl;
+import org.nuiton.topia.tck.it.Company;
+import org.nuiton.topia.tck.it.CompanyImpl;
+import org.nuiton.topia.tck.it.Department;
+import org.nuiton.topia.tck.it.DepartmentImpl;
+import org.nuiton.topia.tck.it.EmployeImpl;
/** @author tchemit <chemit(a)codelutin.com> */
public class CollectorTest {
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -30,10 +30,15 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.tck.it.Company;
+import org.nuiton.topia.tck.it.CompanyImpl;
import org.nuiton.topia.tck.it.Department;
+import org.nuiton.topia.tck.it.DepartmentImpl;
import org.nuiton.topia.tck.it.Employe;
+import org.nuiton.topia.tck.it.EmployeImpl;
import org.nuiton.topia.tck.it.Personne;
+import org.nuiton.topia.tck.it.PersonneImpl;
import java.util.Collection;
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -33,7 +33,7 @@
import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
-import org.nuiton.topiatest.Company;
+import org.nuiton.topia.tck.it.Company;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import org.nuiton.util.beans.BinderModelBuilder;
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -34,16 +34,16 @@
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.persistence.TopiaId;
-import org.nuiton.topiatest.Company;
-import org.nuiton.topiatest.CompanyImpl;
-import org.nuiton.topiatest.Department;
-import org.nuiton.topiatest.DepartmentImpl;
-import org.nuiton.topiatest.Employe;
-import org.nuiton.topiatest.EmployeAbstract;
-import org.nuiton.topiatest.EmployeImpl;
-import org.nuiton.topiatest.Personne;
-import org.nuiton.topiatest.PersonneAbstract;
-import org.nuiton.topiatest.PersonneImpl;
+import org.nuiton.topia.tck.it.Company;
+import org.nuiton.topia.tck.it.CompanyImpl;
+import org.nuiton.topia.tck.it.Department;
+import org.nuiton.topia.tck.it.DepartmentImpl;
+import org.nuiton.topia.tck.it.Employe;
+import org.nuiton.topia.tck.it.EmployeAbstract;
+import org.nuiton.topia.tck.it.EmployeImpl;
+import org.nuiton.topia.tck.it.Personne;
+import org.nuiton.topia.tck.it.PersonneAbstract;
+import org.nuiton.topia.tck.it.PersonneImpl;
import java.util.HashSet;
import java.util.List;
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -28,7 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
-import org.nuiton.topia.TopiaTckItDAOHelper.TopiaTestEntityEnum;
+import org.nuiton.topia.TopiaTckItDAOHelper.TopiaTckItEntityEnum;
import org.nuiton.topia.test.entities.Person;
import org.nuiton.topia.test.entities.Pet;
import org.nuiton.topia.test.entities.Race;
@@ -42,7 +42,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.3.1
*/
-public class TopiaEntityRefTesterTest extends TopiaEntityRefTester<TopiaTestEntityEnum> {
+public class TopiaEntityRefTesterTest extends TopiaEntityRefTester<TopiaTckItEntityEnum> {
/** Logger */
private static final Log log =
@@ -57,26 +57,26 @@
private static final String PERSON1 = "person1";
@Override
- protected TopiaTestEntityEnum[] getContracts0() {
- return new TopiaTestEntityEnum[]{
- TopiaTestEntityEnum.Pet,
- TopiaTestEntityEnum.Person,
- TopiaTestEntityEnum.Race,
+ protected TopiaTckItEntityEnum[] getContracts0() {
+ return new TopiaTckItEntityEnum[]{
+ TopiaTckItEntityEnum.Pet,
+ TopiaTckItEntityEnum.Person,
+ TopiaTckItEntityEnum.Race,
};
}
@Test
public void testNoReferences() throws Exception {
- Pet pet = newEntity(TopiaTestEntityEnum.Pet, PET1);
+ Pet pet = newEntity(TopiaTckItEntityEnum.Pet, PET1);
detectReferences(pet, 0);
- Race race = newEntity(TopiaTestEntityEnum.Race, RACE1);
+ Race race = newEntity(TopiaTckItEntityEnum.Race, RACE1);
detectReferences(race, 0);
- Person person = newEntity(TopiaTestEntityEnum.Person, PERSON1);
+ Person person = newEntity(TopiaTckItEntityEnum.Person, PERSON1);
detectReferences(person, 0);
@@ -85,10 +85,10 @@
@Test
public void testReferences() throws Exception {
- Pet pet = newEntity(TopiaTestEntityEnum.Pet, PET1);
- Race race = newEntity(TopiaTestEntityEnum.Race, RACE1);
+ Pet pet = newEntity(TopiaTckItEntityEnum.Pet, PET1);
+ Race race = newEntity(TopiaTckItEntityEnum.Race, RACE1);
pet.setRace(race);
- Person person = newEntity(TopiaTestEntityEnum.Person, PERSON1);
+ Person person = newEntity(TopiaTckItEntityEnum.Person, PERSON1);
detectReferences(pet, 1, RACE1);
@@ -116,7 +116,7 @@
assertCurrentEntry(pet, 1);
assertNextAssociationEntityRef(person, Person.PROPERTY_PET, PET1, person, pet);
- Pet pet2 = newEntity(TopiaTestEntityEnum.Pet, PET2);
+ Pet pet2 = newEntity(TopiaTckItEntityEnum.Pet, PET2);
person.addPet(pet2);
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/evo1912/EntityDTOTransformerTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/evo1912/EntityDTOTransformerTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/evo1912/EntityDTOTransformerTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -26,7 +26,7 @@
import org.junit.Assert;
import org.junit.Test;
-import org.nuiton.topiatest.CompanyDTO;
+import org.nuiton.topia.tck.it.CompanyDTO;
/** @author ymartel <martel(a)codelutin.com> */
public class EntityDTOTransformerTest {
Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java
===================================================================
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationOperationTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -35,7 +35,7 @@
import org.nuiton.topia.TestHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaTestDAOHelper.TopiaTestEntityEnum;
+import org.nuiton.topia.TopiaTestDAOHelper.TopiaTckItEntityEnum;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.replication.model.ReplicationOperationPhase;
@@ -70,9 +70,9 @@
LogFactory.getLog(TopiaReplicationOperationTest.class);
protected static final TopiaEntityEnum[] contracts = {
- TopiaTestEntityEnum.Person,
- TopiaTestEntityEnum.Pet,
- TopiaTestEntityEnum.Race
+ TopiaTckItEntityEnum.Person,
+ TopiaTckItEntityEnum.Pet,
+ TopiaTckItEntityEnum.Race
};
protected static final String entitiesList =
@@ -158,14 +158,14 @@
public void testCreateOperation_nullPhase() throws Exception {
model = getModelBuilder().createModel(context, contracts, true);
- getModelBuilder().createOperation(model, TopiaTestEntityEnum.Pet, null, null);
+ getModelBuilder().createOperation(model, TopiaTckItEntityEnum.Pet, null, null);
}
@Test(expected = NullPointerException.class)
public void testCreateOperation_nullOperationClass() throws Exception {
model = getModelBuilder().createModel(context, contracts, true);
- getModelBuilder().createOperation(model, TopiaTestEntityEnum.Pet, ReplicationOperationPhase.before, null);
+ getModelBuilder().createOperation(model, TopiaTckItEntityEnum.Pet, ReplicationOperationPhase.before, null);
}
@Test(expected = IllegalArgumentException.class)
@@ -173,7 +173,7 @@
model = getModelBuilder().createModel(context, contracts, true);
// le noeud Pet n'existe pas
- getModelBuilder().addAfterOperation(model, TopiaTestEntityEnum.Pet, Duplicate.class);
+ getModelBuilder().addAfterOperation(model, TopiaTckItEntityEnum.Pet, Duplicate.class);
}
@Test(expected = IllegalArgumentException.class)
@@ -181,59 +181,59 @@
model = getModelBuilder().createModel(context, contracts, true);
// le noeud Pet n'existe pas
- getModelBuilder().addAfterOperation(model, TopiaTestEntityEnum.Pet, UnregistredOperation.class);
+ getModelBuilder().addAfterOperation(model, TopiaTckItEntityEnum.Pet, UnregistredOperation.class);
}
@Test
// @Test(expected = UnsupportedOperationException.class)
public void testCreateSupportedBeforeOperation_Duplicate() throws Exception {
- createSupportedBeforeOperation(TopiaTestEntityEnum.Person, person, Duplicate.class);
+ createSupportedBeforeOperation(TopiaTckItEntityEnum.Person, person, Duplicate.class);
}
// @Test(expected = UnsupportedOperationException.class)
// public void testCreateUnsupportedBeforeOperation_AttachAssociation() throws Exception {
-// createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person, AttachAssociation.class);
+// createUnsupportedBeforeOperation(TopiaTckItEntityEnum.Person, person, AttachAssociation.class);
// }
@Test
// @Test(expected = UnsupportedOperationException.class)
public void testCreateSupportedBeforeOperation_DetachAssociation() throws Exception {
- createSupportedBeforeOperation(TopiaTestEntityEnum.Person, person, DettachAssociation.class);
+ createSupportedBeforeOperation(TopiaTckItEntityEnum.Person, person, DettachAssociation.class);
}
@Test
// @Test(expected = UnsupportedOperationException.class)
public void testCreateSupportedAfterOperation_Duplicate() throws Exception {
- createSupportedAfterOperation(TopiaTestEntityEnum.Person, person, Duplicate.class);
+ createSupportedAfterOperation(TopiaTckItEntityEnum.Person, person, Duplicate.class);
}
// @Test(expected = UnsupportedOperationException.class)
// public void testCreateSupportedAfterOperation_AttachAssociation() throws Exception {
-// createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, AttachAssociation.class);
+// createUnsupportedAfterOperation(TopiaTckItEntityEnum.Person, person, AttachAssociation.class);
// }
@Test
// @Test(expected = UnsupportedOperationException.class)
public void testCreateSupportedAfterOperation_DetachAssociation() throws Exception {
- createSupportedAfterOperation(TopiaTestEntityEnum.Person, person, DettachAssociation.class);
+ createSupportedAfterOperation(TopiaTckItEntityEnum.Person, person, DettachAssociation.class);
}
// @Test(expected = UnsupportedOperationException.class)
// public void testCreateUnsupportedBeforeOperation_UncreatableOperation() throws Exception {
-// createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person, UncreatableOperation.class);
+// createUnsupportedBeforeOperation(TopiaTckItEntityEnum.Person, person, UncreatableOperation.class);
// }
// @Test(expected = UnsupportedOperationException.class)
// public void testCreateUnsupportedAfterOperation_UncreatableOperation() throws Exception {
-// createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, UncreatableOperation.class);
+// createUnsupportedAfterOperation(TopiaTckItEntityEnum.Person, person, UncreatableOperation.class);
// }
@Test
public void testCreateOperation() throws Exception {
model = getModelBuilder().createModel(context, contracts, true, pet.getTopiaId());
- getModelBuilder().addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOperation.class, "before");
- getModelBuilder().addAfterOperation(model, TopiaTestEntityEnum.Race, FakeOperation.class, "after");
+ getModelBuilder().addBeforeOperation(model, TopiaTckItEntityEnum.Pet, FakeOperation.class, "before");
+ getModelBuilder().addAfterOperation(model, TopiaTckItEntityEnum.Race, FakeOperation.class, "after");
}
@Test(expected = NullPointerException.class)
Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplAllTest.java
===================================================================
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplAllTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplAllTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -36,7 +36,7 @@
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper.TopiaTestEntityEnum;
+import org.nuiton.topia.TopiaTestDAOHelper.TopiaTckItEntityEnum;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
@@ -65,9 +65,9 @@
private static final Log log = LogFactory.getLog(TopiaReplicationServiceImplTest.class);
protected static final TopiaEntityEnum[] contracts = {
- TopiaTestEntityEnum.Person,
- TopiaTestEntityEnum.Pet,
- TopiaTestEntityEnum.Race
+ TopiaTckItEntityEnum.Person,
+ TopiaTckItEntityEnum.Pet,
+ TopiaTckItEntityEnum.Race
};
protected static final String entitiesList =
@@ -148,7 +148,7 @@
@Override
public void testDetectAssociations() throws Exception {
- detectAssociations(person, TopiaTestEntityEnum.Person, Person.PROPERTY_PET);
+ detectAssociations(person, TopiaTckItEntityEnum.Person, Person.PROPERTY_PET);
detectAssociations(race);
detectAssociations(pet);
@@ -166,7 +166,7 @@
detectDirectDependencies(person);
detectDirectDependencies(race);
- detectDirectDependencies(pet, TopiaTestEntityEnum.Pet, Pet.PROPERTY_PERSON, TopiaTestEntityEnum.Pet, Pet.PROPERTY_RACE);
+ detectDirectDependencies(pet, TopiaTckItEntityEnum.Pet, Pet.PROPERTY_PERSON, TopiaTckItEntityEnum.Pet, Pet.PROPERTY_RACE);
detectDirectDependencies(person2);
detectDirectDependencies(race2);
@@ -179,12 +179,12 @@
@Override
public void testDetectShell() throws Exception {
- detectShell(person, TopiaTestEntityEnum.Pet, TopiaTestEntityEnum.Race);
+ detectShell(person, TopiaTckItEntityEnum.Pet, TopiaTckItEntityEnum.Race);
detectShell(race);
- detectShell(pet, TopiaTestEntityEnum.Person, TopiaTestEntityEnum.Race);
- detectShell(person2, TopiaTestEntityEnum.Pet, TopiaTestEntityEnum.Race);
+ detectShell(pet, TopiaTckItEntityEnum.Person, TopiaTckItEntityEnum.Race);
+ detectShell(person2, TopiaTckItEntityEnum.Pet, TopiaTckItEntityEnum.Race);
detectShell(race2);
- detectShell(pet2, TopiaTestEntityEnum.Person, TopiaTestEntityEnum.Race);
+ detectShell(pet2, TopiaTckItEntityEnum.Person, TopiaTckItEntityEnum.Race);
}
// @Ignore
@@ -194,7 +194,7 @@
public void testDetectDependencies() throws Exception {
detectDependencies(null,
- new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Race}, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Person}, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Pet});
+ new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Race}, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Person}, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Pet});
}
// @Ignore
@@ -203,7 +203,7 @@
@Override
public void testDetectObjectsToDettach() throws Exception {
- detectObjectsToDettach(null, TopiaTestEntityEnum.Person, new String[]{Person.PROPERTY_PET});
+ detectObjectsToDettach(null, TopiaTckItEntityEnum.Person, new String[]{Person.PROPERTY_PET});
}
// @Ignore
Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplTest.java
===================================================================
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplTest.java 2012-05-09 14:10:52 UTC (rev 2447)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication/TopiaReplicationServiceImplTest.java 2012-05-09 14:22:27 UTC (rev 2448)
@@ -36,7 +36,7 @@
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper.TopiaTestEntityEnum;
+import org.nuiton.topia.TopiaTestDAOHelper.TopiaTckItEntityEnum;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
@@ -71,7 +71,7 @@
private static final Log log =
LogFactory.getLog(TopiaReplicationServiceImplTest.class);
- protected static final TopiaEntityEnum[] contracts = {TopiaTestEntityEnum.Person, TopiaTestEntityEnum.Pet, TopiaTestEntityEnum.Race};
+ protected static final TopiaEntityEnum[] contracts = {TopiaTckItEntityEnum.Person, TopiaTckItEntityEnum.Pet, TopiaTckItEntityEnum.Race};
protected static final String entitiesList = PersonImpl.class.getName() + "," + PetImpl.class.getName() + "," + RaceImpl.class.getName();
@@ -149,7 +149,7 @@
@Override
public void testDetectAssociations() throws Exception {
- detectAssociations(person, TopiaTestEntityEnum.Person, Person.PROPERTY_PET);
+ detectAssociations(person, TopiaTckItEntityEnum.Person, Person.PROPERTY_PET);
detectAssociations(race);
detectAssociations(pet);
@@ -164,7 +164,7 @@
detectDirectDependencies(person);
detectDirectDependencies(race);
- detectDirectDependencies(pet, TopiaTestEntityEnum.Pet, Pet.PROPERTY_PERSON, TopiaTestEntityEnum.Pet, Pet.PROPERTY_RACE);
+ detectDirectDependencies(pet, TopiaTckItEntityEnum.Pet, Pet.PROPERTY_PERSON, TopiaTckItEntityEnum.Pet, Pet.PROPERTY_RACE);
detectDirectDependencies(person2);
detectDirectDependencies(race2);
@@ -175,9 +175,9 @@
@Override
public void testDetectShell() throws Exception {
- detectShell(person, TopiaTestEntityEnum.Pet, TopiaTestEntityEnum.Race);
+ detectShell(person, TopiaTckItEntityEnum.Pet, TopiaTckItEntityEnum.Race);
detectShell(race);
- detectShell(pet, TopiaTestEntityEnum.Person, TopiaTestEntityEnum.Race);
+ detectShell(pet, TopiaTckItEntityEnum.Person, TopiaTckItEntityEnum.Race);
detectShell(person2);
detectShell(race2);
detectShell(pet2);
@@ -187,22 +187,22 @@
@Override
public void testDetectDependencies() throws Exception {
- detectDependencies(person, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Race}, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Person}, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Pet});
- detectDependencies(race, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Race});
- detectDependencies(pet, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Race}, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Person}, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Pet});
+ detectDependencies(person, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Race}, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Person}, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Pet});
+ detectDependencies(race, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Race});
+ detectDependencies(pet, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Race}, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Person}, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Pet});
- detectDependencies(person2, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Person});
- detectDependencies(race2, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Race});
- detectDependencies(pet2, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Pet});
+ detectDependencies(person2, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Person});
+ detectDependencies(race2, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Race});
+ detectDependencies(pet2, new TopiaTckItEntityEnum[]{TopiaTckItEntityEnum.Pet});
}
@Test
@Override
public void testDetectObjectsToDettach() throws Exception {
- detectObjectsToDettach(person, TopiaTestEntityEnum.Person, new String[]{Person.PROPERTY_PET});
+ detectObjectsToDettach(person, TopiaTckItEntityEnum.Person, new String[]{Person.PROPERTY_PET});
detectObjectsToDettach(race);
- detectObjectsToDettach(pet, TopiaTestEntityEnum.Person, new String[]{Person.PROPERTY_PET});
+ detectObjectsToDettach(pet, TopiaTckItEntityEnum.Person, new String[]{Person.PROPERTY_PET});
detectObjectsToDettach(person2);
detectObjectsToDettach(race2);
@@ -234,18 +234,18 @@
@Override
public void testDoReplicate() throws Exception {
- doReplicate(TopiaTestEntityEnum.Person, person);
- doReplicate(TopiaTestEntityEnum.Person, person2);
- doReplicate(TopiaTestEntityEnum.Person, person, person2);
+ doReplicate(TopiaTckItEntityEnum.Person, person);
+ doReplicate(TopiaTckItEntityEnum.Person, person2);
+ doReplicate(TopiaTckItEntityEnum.Person, person, person2);
- doReplicate(TopiaTestEntityEnum.Pet, pet);
- doReplicate(TopiaTestEntityEnum.Pet, pet2);
- doReplicate(TopiaTestEntityEnum.Pet, pet, pet2, pet3);
- doReplicate(TopiaTestEntityEnum.Pet, person2, pet3);
+ doReplicate(TopiaTckItEntityEnum.Pet, pet);
+ doReplicate(TopiaTckItEntityEnum.Pet, pet2);
+ doReplicate(TopiaTckItEntityEnum.Pet, pet, pet2, pet3);
+ doReplicate(TopiaTckItEntityEnum.Pet, person2, pet3);
- doReplicate(TopiaTestEntityEnum.Race, race);
- doReplicate(TopiaTestEntityEnum.Race, race2);
- doReplicate(TopiaTestEntityEnum.Race, race, race2);
+ doReplicate(TopiaTckItEntityEnum.Race, race);
+ doReplicate(TopiaTckItEntityEnum.Race, race2);
+ doReplicate(TopiaTckItEntityEnum.Race, race, race2);
}
1
0
Author: athimel
Date: 2012-05-09 16:10:52 +0200 (Wed, 09 May 2012)
New Revision: 2447
Url: http://nuiton.org/repositories/revision/topia/2447
Log:
topia-persistence-tck compiles (skipping tests)
Added:
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TestHelper.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TopiaDatabase.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/EnumTest.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/ExtraDAOEntityDAOImpl.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Gender.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Title.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/beangen/
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/deletetest/
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/
trunk/topia-persistence-tck/src/main/resources/i18n/topia-persistence-tck_en_GB.properties
trunk/topia-persistence-tck/src/main/resources/i18n/topia-persistence-tck_es_ES.properties
trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.properties
trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.zargo
Removed:
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java
trunk/topia-persistence-tck/src/main/xmi/topiatest.properties
trunk/topia-persistence-tck/src/main/xmi/topiatest.zargo
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TestHelper.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaDatabase.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/EnumTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/ExtraDAOEntityDAOImpl.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/beangen/
trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/deletetest/
trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/persistence/
trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/service/
Modified:
trunk/topia-persistence-tck/pom.xml
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/beangen/RoueImpl.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/deletetest/Contact2DAOImpl.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/deletetest/DeleteEntityTest.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1Abstract.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1Impl.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/package-info.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/FakeService.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/TestService.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/package-info.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaContextFactoryTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextReplicateTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1882/DAOAbstractTransformerTest.java
trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1991/TopiaQueryTest.java
Modified: trunk/topia-persistence-tck/pom.xml
===================================================================
--- trunk/topia-persistence-tck/pom.xml 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/pom.xml 2012-05-09 14:10:52 UTC (rev 2447)
@@ -33,6 +33,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
+ <scope>compile</scope>
</dependency>
<dependency>
Deleted: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -1,29 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia.tck;
-
-public enum Gender {
- MALE, FEMALE
-}
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TestHelper.java (from rev 2446, trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TestHelper.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TestHelper.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TestHelper.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -0,0 +1,162 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.Ignore;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.TopiaTckItDAOHelper;
+import org.nuiton.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Helper for all topia tests.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+@Ignore
+// this is not a test :)
+public class TestHelper {
+
+ private static final Log log = LogFactory.getLog(TestHelper.class);
+
+ protected static File testBasedir;
+
+ protected static File targetdir;
+
+ protected static File dirDatabase;
+
+ public static final String DEFAULT_CONFIGURATION_LOCATION = "/TopiaContextImpl.properties";
+
+ public static File getTestWorkdir() {
+ if (testBasedir == null) {
+ String base = System.getProperty("java.io.tmpdir");
+ if (base == null || base.isEmpty()) {
+ base = new File("").getAbsolutePath();
+ }
+ testBasedir = new File(base);
+ log.info("basedir for test " + testBasedir);
+ }
+ return testBasedir;
+ }
+
+ public static File getTestBasedir(Class<?> testClass) throws IOException {
+ File dir = getTestWorkdir();
+ File result = new File(dir, testClass.getName());
+ if (result.exists()) {
+
+ // when calling this method (always in a BeforeClass method), we wants
+ // to clean the directory, this is a new build
+ FileUtil.deleteRecursively(result);
+ }
+
+ // always create the directory
+ FileUtil.createDirectoryIfNecessary(result);
+ return result;
+ }
+
+ public static TopiaContext initTopiaContext(File testDirectory,
+ String dbname)
+ throws IOException, TopiaNotFoundException {
+
+
+ TopiaContext topiaContext = initTopiaContext(
+ testDirectory,
+ DEFAULT_CONFIGURATION_LOCATION,
+ dbname
+ );
+ return topiaContext;
+ }
+
+ public static TopiaContext initTopiaContext(File testDirectory,
+ String dbPropertiesPath,
+ String dbname)
+ throws IOException, TopiaNotFoundException {
+
+ Properties configuration = initTopiaContextConfiguration(
+ testDirectory,
+ dbPropertiesPath,
+ dbname);
+ return TopiaContextFactory.getContext(configuration);
+ }
+
+ public static Properties initTopiaContextConfiguration(File testDirectory,
+ String dbPropertiesPath,
+ String dbname)
+ throws IOException {
+
+ Properties configuration = loadHibernateConfiguration(dbPropertiesPath);
+
+ // make sure we always use a different directory
+
+ String dbPath = getDbName(testDirectory, dbname);
+
+ if (log.isInfoEnabled()) {
+ log.info("dbPath = " + dbPath);
+ }
+ configuration.setProperty(
+// Environment.URL,
+ "hibernate.connection.url",
+ "jdbc:h2:file:" + dbPath);
+
+ return configuration;
+ }
+
+ public static Properties loadHibernateConfiguration(String dbPropertiesPath) throws IOException {
+ InputStream stream = TestHelper.class.getResourceAsStream(dbPropertiesPath);
+
+ Properties configuration = new Properties();
+
+ configuration.load(stream);
+ configuration.setProperty(
+ TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
+ TopiaTckItDAOHelper.getImplementationClassesAsString());
+ return configuration;
+ }
+
+ public static String getDbName(File testDirectory, String dbname) {
+ return new File(testDirectory,
+ dbname + '_' + System.nanoTime()).getAbsolutePath();
+ }
+
+ public static Properties initTopiaContextConfiguration(File testDirectory,
+ String dbname)
+ throws IOException {
+
+ return initTopiaContextConfiguration(
+ testDirectory,
+ DEFAULT_CONFIGURATION_LOCATION,
+ dbname
+ );
+ }
+}
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TestHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -1,37 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia.tck;
-
-/**
- * To test http://nuiton.org/issues/1732.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.6.2
- */
-public enum Title {
- Mr,
- Madam,
- Other
-}
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TopiaDatabase.java (from rev 2446, trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaDatabase.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TopiaDatabase.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TopiaDatabase.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -0,0 +1,196 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaTckItDAOHelper;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Put this class as a Rule in test to obtain a new isolated db for each test.
+ * <p/>
+ * Here is a simple example of usage :
+ * <pre>
+ * public class MyTest {
+ *
+ * \@Rule
+ * public final TopiaDatabase db = new TopiaDatabase();
+ *
+ * \@Test
+ * public void testMethod() throws TopiaException {
+ *
+ * TopiaContext tx = db.beginTransaction();
+ * ...
+ * }
+ * </pre>
+ * The db created will be unique for each test method (and for each build also).
+ * <p/>
+ * You don't need to close any transaction, it will be done for you and the end
+ * of each method test.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.8
+ */
+public class TopiaDatabase extends TestWatcher {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(TopiaDatabase.class);
+
+ /** A time-stamp, allow to make multiple build and keep the tests data. */
+ public static final String TIMESTAMP = String.valueOf(System.nanoTime());
+
+ private File testBasedir;
+
+ private Properties dbConfiguration;
+
+ private TopiaContext rootCtxt;
+
+ private final String configurationPath;
+
+ public TopiaDatabase() {
+ this(TestHelper.DEFAULT_CONFIGURATION_LOCATION);
+ }
+
+ public TopiaDatabase(String configurationPath) {
+ this.configurationPath = configurationPath;
+ }
+
+ @Override
+ protected void starting(Description description) {
+
+ // get test directory
+ testBasedir = getTestSpecificDirectory(
+ description.getTestClass(),
+ description.getMethodName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("testBasedir = " + testBasedir);
+ }
+
+ // create the root context
+ try {
+
+ dbConfiguration = new Properties();
+ InputStream stream =
+ getClass().getResourceAsStream(configurationPath);
+
+ try {
+ dbConfiguration.load(stream);
+ } finally {
+ stream.close();
+ }
+ dbConfiguration.setProperty(
+ TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
+ TopiaTckItDAOHelper.getImplementationClassesAsString());
+
+ // make sure we always use a different directory
+
+ String dbPath = new File(testBasedir, "db").getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("dbPath = " + dbPath);
+ }
+ dbConfiguration.setProperty(
+ TopiaContextFactory.CONFIG_URL, "jdbc:h2:file:" + dbPath);
+
+ onDbConfigurationCreate(dbConfiguration, testBasedir, dbPath);
+
+ rootCtxt = TopiaContextFactory.getContext(dbConfiguration);
+ } catch (Exception e) {
+ throw new IllegalStateException(
+ "Could not start db at " + testBasedir, e);
+ }
+ }
+
+ @Override
+ public void finished(Description description) {
+
+ if (rootCtxt != null && !rootCtxt.isClosed()) {
+ try {
+ rootCtxt.closeContext();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not close topia root context", e);
+ }
+ }
+ }
+ rootCtxt = null;
+ dbConfiguration = null;
+ }
+
+ public File getTestBasedir() {
+ return testBasedir;
+ }
+
+ public TopiaContext getRootCtxt() {
+ return rootCtxt;
+ }
+
+ public Properties getDbConfiguration() {
+ return dbConfiguration;
+ }
+
+ public TopiaContext beginTransaction() throws TopiaException {
+ return rootCtxt.beginTransaction();
+ }
+
+ protected void onDbConfigurationCreate(Properties configuration,
+ File testDir,
+ String dbPath) {
+
+ }
+
+ public static File getTestSpecificDirectory(Class<?> testClassName, String methodName) {
+ // Trying to look for the temporary folder to store data for the test
+ String tempDirPath = System.getProperty("java.io.tmpdir");
+ if (tempDirPath == null) {
+ // can this really occur ?
+ tempDirPath = "";
+ if (log.isWarnEnabled()) {
+ log.warn("'\"java.io.tmpdir\" not defined");
+ }
+ }
+ File tempDirFile = new File(tempDirPath);
+
+ // create the directory to store database data
+ String dataBasePath = testClassName.getName()
+ + File.separator // a directory with the test class name
+ + methodName// a sub-directory with the method name
+ + '_'
+ + TIMESTAMP; // and a timestamp
+ File databaseFile = new File(tempDirFile, dataBasePath);
+ return databaseFile;
+ }
+}
+
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/TopiaDatabase.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/EnumTest.java (from rev 2446, trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/EnumTest.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/EnumTest.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/EnumTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -0,0 +1,75 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck.it;
+
+import junit.framework.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.tck.TopiaDatabase;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.TopiaTckItDAOHelper;
+
+/**
+ * Test the support of possibility to have an attribute of type enumeration
+ * in a entity
+ */
+public class EnumTest {
+
+ @Rule
+ public final TopiaDatabase db = new TopiaDatabase();
+
+ /**
+ * Create an entity having two field of type enumeration. One is stored
+ * using ordinal, the other using the name.
+ * <p/>
+ * The test check that values are stored, and that find methods works
+ *
+ * @throws TopiaException if any exception with db
+ */
+ @Test
+ public void storeEntityWithEnumValue() throws TopiaException {
+ TopiaContext transaction = db.beginTransaction();
+
+ PersonneDAO dao = TopiaTckItDAOHelper.getPersonneDAO(transaction);
+ Personne personne = new PersonneImpl();
+ personne.setGender(Gender.FEMALE);
+ personne.setOtherGender(Gender.MALE);
+ dao.create(personne);
+ String topiaId = personne.getTopiaId();
+ transaction.commitTransaction();
+ transaction.closeContext();
+
+ transaction = db.beginTransaction();
+ dao = TopiaTckItDAOHelper.getPersonneDAO(transaction);
+ dao.findByTopiaId(topiaId);
+ Assert.assertEquals(Gender.FEMALE, personne.getGender());
+ Assert.assertEquals(Gender.MALE, personne.getOtherGender());
+
+ Assert.assertNotNull(dao.findByGender(Gender.FEMALE));
+ Assert.assertNotNull(dao.findByOtherGender(Gender.MALE));
+ transaction.closeContext();
+ }
+}
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/EnumTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/ExtraDAOEntityDAOImpl.java (from rev 2446, trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/ExtraDAOEntityDAOImpl.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/ExtraDAOEntityDAOImpl.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/ExtraDAOEntityDAOImpl.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -0,0 +1,42 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck.it;
+
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.tck.it.ExtraDAOEntity;
+import org.nuiton.topia.tck.it.ExtraDAOEntityDAOAbstract;
+
+/**
+ * Created: 26 mai 2010
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @version $Id$
+ */
+public class ExtraDAOEntityDAOImpl<E extends ExtraDAOEntity> extends ExtraDAOEntityDAOAbstract<E> {
+
+ @Override
+ public void extra() throws TopiaException {
+ }
+}
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/ExtraDAOEntityDAOImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Gender.java (from rev 2445, trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Gender.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Gender.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -0,0 +1,29 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck.it;
+
+public enum Gender {
+ MALE, FEMALE
+}
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Gender.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Title.java (from rev 2445, trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Title.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Title.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck.it;
+
+/**
+ * To test http://nuiton.org/issues/1732.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.2
+ */
+public enum Title {
+ Mr,
+ Madam,
+ Other
+}
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/Title.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/beangen/RoueImpl.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/beangen/RoueImpl.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/beangen/RoueImpl.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -23,9 +23,9 @@
* #L%
*/
-package org.nuiton.topiatest.beangen;
+package org.nuiton.topia.tck.it.beangen;
-import org.nuiton.topiatest.Product;
+import org.nuiton.topia.tck.it.Product;
/**
* RoueImpl
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/deletetest/Contact2DAOImpl.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/deletetest/Contact2DAOImpl.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/deletetest/Contact2DAOImpl.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -23,14 +23,14 @@
* #L%
*/
-package org.nuiton.topiatest.deletetest;
+package org.nuiton.topia.tck.it.deletetest;
import java.util.Set;
import java.util.TreeSet;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topiatest.Company;
-import org.nuiton.topiatest.Employe;
+import org.nuiton.topia.tck.it.Company;
+import org.nuiton.topia.tck.it.Employe;
/**
*
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/deletetest/DeleteEntityTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/deletetest/DeleteEntityTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/deletetest/DeleteEntityTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -36,18 +36,18 @@
* par : $Author$
*/
-package org.nuiton.topiatest.deletetest;
+package org.nuiton.topia.tck.it.deletetest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Rule;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
-import org.nuiton.topiatest.Personne;
-import org.nuiton.topiatest.PersonneDAO;
+import org.nuiton.topia.TopiaTckItDAOHelper;
+import org.nuiton.topia.tck.TopiaDatabase;
+import org.nuiton.topia.tck.it.Personne;
+import org.nuiton.topia.tck.it.PersonneDAO;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -55,7 +55,7 @@
/**
* Deleting tests with DAO and Entities generated with ToPIA (diagram
- * delete-test in topiatest.zargo). Different case of deleting, with inheritance
+ * delete-test in topia-tck-it.zargo). Different case of deleting, with inheritance
* or NMultiplicity relationship between two entities, or both. Initiate from an
* issue with DAOAbstractGenerator delete method generation. Tests with H2
* Database. Configuration in src/test/resources/TopiaContextImpl.properties
@@ -82,7 +82,7 @@
TopiaContext transaction = db.beginTransaction();
log.debug("DAO : PersonneDAO");
- PersonneDAO dao = TopiaTestDAOHelper.getPersonneDAO(transaction);
+ PersonneDAO dao = TopiaTckItDAOHelper.getPersonneDAO(transaction);
log.debug("CREATE PERSONNE : Bob Marley");
Personne personne = dao.create(Personne.PROPERTY_NAME, "Bob Marley");
@@ -106,7 +106,7 @@
log.debug("ENTITY PERSONNE SAVED !");
log.debug("DAO parent (abstract) : PartyDAO");
- Party2DAO dao2 = TopiaTestDAOHelper.getParty2DAO(transaction);
+ Party2DAO dao2 = TopiaTckItDAOHelper.getParty2DAO(transaction);
log.debug("DELETE PERSONNE with PartyDAO");
dao2.delete(personne2);
@@ -133,7 +133,7 @@
TopiaContext transaction = db.beginTransaction();
- PersonneDAO dao = TopiaTestDAOHelper.getPersonneDAO(transaction);
+ PersonneDAO dao = TopiaTckItDAOHelper.getPersonneDAO(transaction);
log.debug("CREATE PERSONNE : Bob Marley");
Personne personne = dao.create(Personne.PROPERTY_NAME, "Bob Marley");
@@ -142,7 +142,7 @@
assertNotNull(idPersonne);
log.debug("ENTITY PERSONNE SAVED !");
- Contact2DAO contactDAO = TopiaTestDAOHelper.getContact2DAO(transaction);
+ Contact2DAO contactDAO = TopiaTckItDAOHelper.getContact2DAO(transaction);
log.debug("CREATE CONTACT : jaja(a)codelutin.com");
Contact2 contact = contactDAO.create(Contact2.PROPERTY_CONTACT_VALUE, "jaja(a)codelutin.com");
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/persistence/Entity1.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -22,7 +22,7 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
-package org.nuiton.topiatest.persistence;
+package org.nuiton.topia.tck.it.persistence;
import org.nuiton.topia.persistence.TopiaEntity;
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1Abstract.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/persistence/Entity1Abstract.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1Abstract.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -22,7 +22,7 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
-package org.nuiton.topiatest.persistence;
+package org.nuiton.topia.tck.it.persistence;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.persistence.EntityVisitor;
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1Impl.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/persistence/Entity1Impl.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/Entity1Impl.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -22,11 +22,8 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
-package org.nuiton.topiatest.persistence;
+package org.nuiton.topia.tck.it.persistence;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.EntityVisitor;
-
/**
* Created: 11 mai 2010
*
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/package-info.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/persistence/package-info.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/persistence/package-info.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -25,4 +25,4 @@
/**
* Contains persistent entities for Tests.
*/
-package org.nuiton.topiatest.persistence;
\ No newline at end of file
+package org.nuiton.topia.tck.it.persistence;
\ No newline at end of file
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/FakeService.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/service/FakeService.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/FakeService.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -22,10 +22,9 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
-package org.nuiton.topiatest.service;
+package org.nuiton.topia.tck.it.service;
import org.nuiton.topia.framework.TopiaContextImpl;
-import org.nuiton.topia.framework.TopiaContextImplTest;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaService;
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/TestService.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/service/TestService.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/TestService.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -22,11 +22,10 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/
-package org.nuiton.topiatest.service;
+package org.nuiton.topia.tck.it.service;
import org.junit.Ignore;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.framework.TopiaContextImplTest;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaService;
Modified: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/package-info.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/service/package-info.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/it/service/package-info.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -26,4 +26,4 @@
* This package contains classes which implements {@link
* org.nuiton.topia.framework.TopiaService} to test services API.
*/
-package org.nuiton.topiatest.service;
\ No newline at end of file
+package org.nuiton.topia.tck.it.service;
\ No newline at end of file
Added: trunk/topia-persistence-tck/src/main/resources/i18n/topia-persistence-tck_en_GB.properties
===================================================================
Added: trunk/topia-persistence-tck/src/main/resources/i18n/topia-persistence-tck_es_ES.properties
===================================================================
Copied: trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.properties (from rev 2445, trunk/topia-persistence-tck/src/main/xmi/topiatest.properties)
===================================================================
--- trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.properties (rev 0)
+++ trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.properties 2012-05-09 14:10:52 UTC (rev 2447)
@@ -0,0 +1,39 @@
+###
+# #%L
+# ToPIA :: Persistence
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2004 - 2010 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+model.tagvalue.i18n=topia.test.common.
+model.tagvalue.generateOperatorForDAOHelper=true
+model.tagvalue.constantPrefix=PROPERTY_
+model.tagvalue.generateDTOTopiaId=true
+
+#org.nuiton.topiatest.Company.class.tagvalue.naturalIdMutable=false
+#org.nuiton.topiatest.Company.attribute.siret.tagvalue.naturalId=true
+#org.nuiton.topiatest.Company.attribute.name.tagvalue.naturalId=true
+#org.nuiton.topiatest.Company.attribute.name.tagvalue.notNull=false
+
+org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNotNull.tagvalue.naturalId=true
+org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNull.tagvalue.naturalId=true
+org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNull.tagvalue.notNull=false
+
+org.nuiton.topiatest.Personne.attribute.otherGender.tagValue.useEnumerationName=true
\ No newline at end of file
Property changes on: trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.zargo (from rev 2445, trunk/topia-persistence-tck/src/main/xmi/topiatest.zargo)
===================================================================
(Binary files differ)
Property changes on: trunk/topia-persistence-tck/src/main/xmi/topia-tck-it.zargo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/topia-persistence-tck/src/main/xmi/topiatest.properties
===================================================================
--- trunk/topia-persistence-tck/src/main/xmi/topiatest.properties 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/main/xmi/topiatest.properties 2012-05-09 14:10:52 UTC (rev 2447)
@@ -1,39 +0,0 @@
-###
-# #%L
-# ToPIA :: Persistence
-#
-# $Id$
-# $HeadURL$
-# %%
-# Copyright (C) 2004 - 2010 CodeLutin
-# %%
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Lesser Public License for more details.
-#
-# You should have received a copy of the GNU General Lesser Public
-# License along with this program. If not, see
-# <http://www.gnu.org/licenses/lgpl-3.0.html>.
-# #L%
-###
-model.tagvalue.i18n=topia.test.common.
-model.tagvalue.generateOperatorForDAOHelper=true
-model.tagvalue.constantPrefix=PROPERTY_
-model.tagvalue.generateDTOTopiaId=true
-
-#org.nuiton.topiatest.Company.class.tagvalue.naturalIdMutable=false
-#org.nuiton.topiatest.Company.attribute.siret.tagvalue.naturalId=true
-#org.nuiton.topiatest.Company.attribute.name.tagvalue.naturalId=true
-#org.nuiton.topiatest.Company.attribute.name.tagvalue.notNull=false
-
-org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNotNull.tagvalue.naturalId=true
-org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNull.tagvalue.naturalId=true
-org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNull.tagvalue.notNull=false
-
-org.nuiton.topiatest.Personne.attribute.otherGender.tagValue.useEnumerationName=true
\ No newline at end of file
Deleted: trunk/topia-persistence-tck/src/main/xmi/topiatest.zargo
===================================================================
(Binary files differ)
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TestHelper.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TestHelper.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TestHelper.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -1,159 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.Environment;
-import org.junit.Ignore;
-import org.nuiton.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * Helper for all topia tests.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.5
- */
-@Ignore
-// this is not a test :)
-public class TestHelper {
-
- private static final Log log = LogFactory.getLog(TestHelper.class);
-
- protected static File testBasedir;
-
- protected static File targetdir;
-
- protected static File dirDatabase;
-
- public static final String DEFAULT_CONFIGURATION_LOCATION = "/TopiaContextImpl.properties";
-
- public static File getTestWorkdir() {
- if (testBasedir == null) {
- String base = System.getProperty("java.io.tmpdir");
- if (base == null || base.isEmpty()) {
- base = new File("").getAbsolutePath();
- }
- testBasedir = new File(base);
- log.info("basedir for test " + testBasedir);
- }
- return testBasedir;
- }
-
- public static File getTestBasedir(Class<?> testClass) throws IOException {
- File dir = getTestWorkdir();
- File result = new File(dir, testClass.getName());
- if (result.exists()) {
-
- // when calling this method (always in a BeforeClass method), we wants
- // to clean the directory, this is a new build
- FileUtil.deleteRecursively(result);
- }
-
- // always create the directory
- FileUtil.createDirectoryIfNecessary(result);
- return result;
- }
-
- public static TopiaContext initTopiaContext(File testDirectory,
- String dbname)
- throws IOException, TopiaNotFoundException {
-
-
- TopiaContext topiaContext = initTopiaContext(
- testDirectory,
- DEFAULT_CONFIGURATION_LOCATION,
- dbname
- );
- return topiaContext;
- }
-
- public static TopiaContext initTopiaContext(File testDirectory,
- String dbPropertiesPath,
- String dbname)
- throws IOException, TopiaNotFoundException {
-
- Properties configuration = initTopiaContextConfiguration(
- testDirectory,
- dbPropertiesPath,
- dbname);
- return TopiaContextFactory.getContext(configuration);
- }
-
- public static Properties initTopiaContextConfiguration(File testDirectory,
- String dbPropertiesPath,
- String dbname)
- throws IOException {
-
- Properties configuration = loadHibernateConfiguration(dbPropertiesPath);
-
- // make sure we always use a different directory
-
- String dbPath = getDbName(testDirectory, dbname);
-
- if (log.isInfoEnabled()) {
- log.info("dbPath = " + dbPath);
- }
- configuration.setProperty(
- Environment.URL,
-// "hibernate.connection.url",
- "jdbc:h2:file:" + dbPath);
-
- return configuration;
- }
-
- public static Properties loadHibernateConfiguration(String dbPropertiesPath) throws IOException {
- InputStream stream = TestHelper.class.getResourceAsStream(dbPropertiesPath);
-
- Properties configuration = new Properties();
-
- configuration.load(stream);
- configuration.setProperty(
- TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
- TopiaTestDAOHelper.getImplementationClassesAsString());
- return configuration;
- }
-
- public static String getDbName(File testDirectory, String dbname) {
- return new File(testDirectory,
- dbname + '_' + System.nanoTime()).getAbsolutePath();
- }
-
- public static Properties initTopiaContextConfiguration(File testDirectory,
- String dbname)
- throws IOException {
-
- return initTopiaContextConfiguration(
- testDirectory,
- DEFAULT_CONFIGURATION_LOCATION,
- dbname
- );
- }
-}
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaContextFactoryTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaContextFactoryTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaContextFactoryTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -31,6 +31,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.topia.framework.TopiaContextImpl;
+import org.nuiton.topia.tck.TopiaDatabase;
import java.io.File;
import java.io.IOException;
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaDatabase.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaDatabase.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/TopiaDatabase.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -1,192 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2012 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topia;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * Put this class as a Rule in test to obtain a new isolated db for each test.
- * <p/>
- * Here is a simple example of usage :
- * <pre>
- * public class MyTest {
- *
- * \@Rule
- * public final TopiaDatabase db = new TopiaDatabase();
- *
- * \@Test
- * public void testMethod() throws TopiaException {
- *
- * TopiaContext tx = db.beginTransaction();
- * ...
- * }
- * </pre>
- * The db created will be unique for each test method (and for each build also).
- * <p/>
- * You don't need to close any transaction, it will be done for you and the end
- * of each method test.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.6.8
- */
-public class TopiaDatabase extends TestWatcher {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(TopiaDatabase.class);
-
- /** A time-stamp, allow to make multiple build and keep the tests data. */
- public static final String TIMESTAMP = String.valueOf(System.nanoTime());
-
- private File testBasedir;
-
- private Properties dbConfiguration;
-
- private TopiaContext rootCtxt;
-
- private final String configurationPath;
-
- public TopiaDatabase() {
- this(TestHelper.DEFAULT_CONFIGURATION_LOCATION);
- }
-
- public TopiaDatabase(String configurationPath) {
- this.configurationPath = configurationPath;
- }
-
- @Override
- protected void starting(Description description) {
-
- // get test directory
- testBasedir = getTestSpecificDirectory(
- description.getTestClass(),
- description.getMethodName());
-
- if (log.isDebugEnabled()) {
- log.debug("testBasedir = " + testBasedir);
- }
-
- // create the root context
- try {
-
- dbConfiguration = new Properties();
- InputStream stream =
- getClass().getResourceAsStream(configurationPath);
-
- try {
- dbConfiguration.load(stream);
- } finally {
- stream.close();
- }
- dbConfiguration.setProperty(
- TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
- TopiaTestDAOHelper.getImplementationClassesAsString());
-
- // make sure we always use a different directory
-
- String dbPath = new File(testBasedir, "db").getAbsolutePath();
-
- if (log.isDebugEnabled()) {
- log.debug("dbPath = " + dbPath);
- }
- dbConfiguration.setProperty(
- TopiaContextFactory.CONFIG_URL, "jdbc:h2:file:" + dbPath);
-
- onDbConfigurationCreate(dbConfiguration, testBasedir, dbPath);
-
- rootCtxt = TopiaContextFactory.getContext(dbConfiguration);
- } catch (Exception e) {
- throw new IllegalStateException(
- "Could not start db at " + testBasedir, e);
- }
- }
-
- @Override
- public void finished(Description description) {
-
- if (rootCtxt != null && !rootCtxt.isClosed()) {
- try {
- rootCtxt.closeContext();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Could not close topia root context", e);
- }
- }
- }
- rootCtxt = null;
- dbConfiguration = null;
- }
-
- public File getTestBasedir() {
- return testBasedir;
- }
-
- public TopiaContext getRootCtxt() {
- return rootCtxt;
- }
-
- public Properties getDbConfiguration() {
- return dbConfiguration;
- }
-
- public TopiaContext beginTransaction() throws TopiaException {
- return rootCtxt.beginTransaction();
- }
-
- protected void onDbConfigurationCreate(Properties configuration,
- File testDir,
- String dbPath) {
-
- }
-
- public static File getTestSpecificDirectory(Class<?> testClassName, String methodName) {
- // Trying to look for the temporary folder to store data for the test
- String tempDirPath = System.getProperty("java.io.tmpdir");
- if (tempDirPath == null) {
- // can this really occur ?
- tempDirPath = "";
- if (log.isWarnEnabled()) {
- log.warn("'\"java.io.tmpdir\" not defined");
- }
- }
- File tempDirFile = new File(tempDirPath);
-
- // create the directory to store database data
- String dataBasePath = testClassName.getName()
- + File.separator // a directory with the test class name
- + methodName// a sub-directory with the method name
- + '_'
- + TIMESTAMP; // and a timestamp
- File databaseFile = new File(tempDirFile, dataBasePath);
- return databaseFile;
- }
-}
-
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -29,12 +29,10 @@
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
import org.nuiton.topia.test.entities.Person;
import org.nuiton.topia.test.entities.PersonDAO;
-import org.nuiton.topiatest.Personne;
import java.io.File;
import java.util.Locale;
@@ -125,7 +123,7 @@
TopiaContext transaction = db.beginTransaction();
try {
- PersonDAO dao = TopiaTestDAOHelper.getPersonDAO(transaction);
+ PersonDAO dao = TopiaTckItDAOHelper.getPersonDAO(transaction);
Person personne = dao.create(Personne.PROPERTY_NAME, "Jack Bauer");
transaction.commitTransaction();
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -35,11 +35,8 @@
import org.junit.Test;
import org.nuiton.i18n.I18n;
import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topiatest.persistence.Entity1Impl;
-import org.nuiton.topiatest.service.FakeService;
-import org.nuiton.topiatest.service.TestService;
import java.io.File;
import java.util.HashMap;
@@ -374,8 +371,8 @@
// Pet petSource, petTarget;
//
// txSource = contextSource.beginTransaction();
-// daoSource = TopiaTestDAOHelper.getPersonDAO(txSource);
-// petDAOSource = TopiaTestDAOHelper.getPetDAO(txSource);
+// daoSource = TopiaTckItDAOHelper.getPersonDAO(txSource);
+// petDAOSource = TopiaTckItDAOHelper.getPetDAO(txSource);
//
// personSource = daoSource.create(Person.PROPERTY_FIRSTNAME, " firstName",
// Person.PROPERTY_NAME, " name"
@@ -390,7 +387,7 @@
//
// txSource.commitTransaction();
//
-// daoSource = TopiaTestDAOHelper.getPersonDAO(txSource);
+// daoSource = TopiaTckItDAOHelper.getPersonDAO(txSource);
//
// personSource = daoSource.findByTopiaId(personSource.getTopiaId());
// Assert.assertNotNull(personSource);
@@ -407,8 +404,8 @@
//
// txTarget.commitTransaction();
//
-// daoTarget = TopiaTestDAOHelper.getPersonDAO(txTarget);
-// petDAOTarget = TopiaTestDAOHelper.getPetDAO(txTarget);
+// daoTarget = TopiaTckItDAOHelper.getPersonDAO(txTarget);
+// petDAOTarget = TopiaTckItDAOHelper.getPetDAO(txTarget);
//
// personTarget = daoTarget.findByTopiaId(personSource.getTopiaId());
// Assert.assertNotNull(personTarget);
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextReplicateTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextReplicateTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaContextReplicateTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -29,8 +29,8 @@
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaDatabase;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.tck.TopiaDatabase;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.test.entities.Person;
import org.nuiton.topia.test.entities.PersonDAO;
import org.nuiton.topia.test.entities.Pet;
@@ -100,8 +100,8 @@
Pet petSource, petTarget;
txSource = contextSource.beginTransaction();
- daoSource = TopiaTestDAOHelper.getPersonDAO(txSource);
- petDAOSource = TopiaTestDAOHelper.getPetDAO(txSource);
+ daoSource = TopiaTckItDAOHelper.getPersonDAO(txSource);
+ petDAOSource = TopiaTckItDAOHelper.getPetDAO(txSource);
personSource = daoSource.create(Person.PROPERTY_FIRSTNAME, " firstName",
Person.PROPERTY_NAME, " name"
@@ -116,7 +116,7 @@
txSource.commitTransaction();
- daoSource = TopiaTestDAOHelper.getPersonDAO(txSource);
+ daoSource = TopiaTckItDAOHelper.getPersonDAO(txSource);
personSource = daoSource.findByTopiaId(personSource.getTopiaId());
Assert.assertNotNull(personSource);
@@ -133,8 +133,8 @@
txTarget.commitTransaction();
- daoTarget = TopiaTestDAOHelper.getPersonDAO(txTarget);
- petDAOTarget = TopiaTestDAOHelper.getPetDAO(txTarget);
+ daoTarget = TopiaTckItDAOHelper.getPersonDAO(txTarget);
+ petDAOTarget = TopiaTckItDAOHelper.getPetDAO(txTarget);
personTarget = daoTarget.findByTopiaId(personSource.getTopiaId());
Assert.assertNotNull(personTarget);
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/framework/TopiaUtilTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -28,7 +28,7 @@
import org.junit.Rule;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.test.entities.PersonImpl;
import org.nuiton.topiatest.Personne;
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/generator/TopiaTestCase.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -31,9 +31,9 @@
import org.junit.Rule;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topiatest.Company;
import org.nuiton.topiatest.CompanyDAO;
import org.nuiton.topiatest.Department;
@@ -77,7 +77,7 @@
// "/TopiaContextImpl.properties",
// "TopiaTestCaseDb");
//// config = new Properties();
-//// config.setProperty("topia.persistence.classes", TopiaTestDAOHelper.getImplementationClassesAsString());
+//// config.setProperty("topia.persistence.classes", TopiaTckItDAOHelper.getImplementationClassesAsString());
////
//// config.setProperty(Environment.USER, "sa");
//// config.setProperty(Environment.PASS, "");
@@ -123,8 +123,8 @@
// try {
TopiaContext newContext = db.beginTransaction();
- CompanyDAO companyDAO = TopiaTestDAOHelper.getCompanyDAO(newContext);
- DepartmentDAO departmentDAO = TopiaTestDAOHelper.getDepartmentDAO(newContext);
+ CompanyDAO companyDAO = TopiaTckItDAOHelper.getCompanyDAO(newContext);
+ DepartmentDAO departmentDAO = TopiaTckItDAOHelper.getDepartmentDAO(newContext);
Company company = companyDAO.create();
company.setName("Ma société");
@@ -154,7 +154,7 @@
newContext = db.beginTransaction();
- companyDAO = TopiaTestDAOHelper.getCompanyDAO(newContext);
+ companyDAO = TopiaTckItDAOHelper.getCompanyDAO(newContext);
company = companyDAO.findByTopiaId(company.getTopiaId());
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/EntityVisitorExportXmlTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -31,9 +31,9 @@
import org.junit.Rule;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topiatest.Address;
import org.nuiton.topiatest.AddressDAO;
import org.nuiton.topiatest.Company;
@@ -73,14 +73,14 @@
TopiaContext newContext = db.beginTransaction();
try {
// company
- CompanyDAO companyDAO = TopiaTestDAOHelper.getCompanyDAO(newContext);
+ CompanyDAO companyDAO = TopiaTckItDAOHelper.getCompanyDAO(newContext);
Company clCompany = companyDAO.create(Company.PROPERTY_NAME, "CodeLutin");
// employe
- EmployeDAO employeDAO = TopiaTestDAOHelper.getEmployeDAO(newContext);
+ EmployeDAO employeDAO = TopiaTckItDAOHelper.getEmployeDAO(newContext);
Employe empl1 = employeDAO.create(Employe.PROPERTY_NAME, "boss", Employe.PROPERTY_SALARY, 30000);
- AddressDAO adressDAO = TopiaTestDAOHelper.getAddressDAO(newContext);
+ AddressDAO adressDAO = TopiaTckItDAOHelper.getAddressDAO(newContext);
Address addr1 = adressDAO.create(Address.PROPERTY_CITY, "Nantes", Address.PROPERTY_ADRESS, "12 Avenue Jules Vernes");
empl1.setAddress(addr1);
@@ -89,7 +89,7 @@
empl2.setAddress(addr2);
// departement
- DepartmentDAO departmentDAO = TopiaTestDAOHelper.getDepartmentDAO(newContext);
+ DepartmentDAO departmentDAO = TopiaTckItDAOHelper.getDepartmentDAO(newContext);
Department depComm = departmentDAO.create(Department.PROPERTY_NAME, "Commercial");
depComm.setLeader(empl1);
@@ -118,7 +118,7 @@
TopiaContext context = db.beginTransaction();
- CompanyDAO companyDAO = TopiaTestDAOHelper.getCompanyDAO(context);
+ CompanyDAO companyDAO = TopiaTckItDAOHelper.getCompanyDAO(context);
Company clCompany = companyDAO.findByName("CodeLutin");
EntityVisitor delegateVisitor = new ExportXMLVisitor();
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -32,9 +32,9 @@
import org.junit.Rule;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topiatest.NaturalizedEntity;
import org.nuiton.topiatest.NaturalizedEntityDAO;
@@ -62,7 +62,7 @@
TopiaContext transaction = db.beginTransaction();
NaturalizedEntityDAO dao =
- TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction);
+ TopiaTckItDAOHelper.getNaturalizedEntityDAO(transaction);
// No exception will be thrown with the two properties
dao.createByNaturalId(5, "str");
@@ -83,7 +83,7 @@
TopiaContext transaction = db.beginTransaction();
NaturalizedEntityDAO dao =
- TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction);
+ TopiaTckItDAOHelper.getNaturalizedEntityDAO(transaction);
// Exception will be throw
// try {
@@ -104,7 +104,7 @@
TopiaContext transaction = db.beginTransaction();
NaturalizedEntityDAO dao =
- TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction);
+ TopiaTckItDAOHelper.getNaturalizedEntityDAO(transaction);
NaturalizedEntity entity =
dao.createByNaturalId(5, "str");
@@ -126,7 +126,7 @@
TopiaContext transaction = db.beginTransaction();
NaturalizedEntityDAO dao =
- TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction);
+ TopiaTckItDAOHelper.getNaturalizedEntityDAO(transaction);
NaturalizedEntity entity =
dao.createByNaturalId(5, "str");
@@ -143,7 +143,7 @@
TopiaContext transaction = db.beginTransaction();
NaturalizedEntityDAO dao =
- TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction);
+ TopiaTckItDAOHelper.getNaturalizedEntityDAO(transaction);
dao.createByNaturalId(5, "str");
transaction.commitTransaction();
@@ -162,8 +162,8 @@
public void testNaturalIdAreGeneralized() throws Exception {
// test that natural ids are generalized
- String[] generalizedNaturalizedNaturalIds = TopiaTestDAOHelper.TopiaTestEntityEnum.GeneralizedNaturalizedEntity.getNaturalIds();
- String[] naturalizedNaturalIds = TopiaTestDAOHelper.TopiaTestEntityEnum.NaturalizedEntity.getNaturalIds();
+ String[] generalizedNaturalizedNaturalIds = TopiaTckItDAOHelper.TopiaTestEntityEnum.GeneralizedNaturalizedEntity.getNaturalIds();
+ String[] naturalizedNaturalIds = TopiaTckItDAOHelper.TopiaTestEntityEnum.NaturalizedEntity.getNaturalIds();
Assert.assertArrayEquals(generalizedNaturalizedNaturalIds, naturalizedNaturalIds);
}
@@ -171,8 +171,8 @@
public void testNotNullsAreGeneralized() throws Exception {
// test that not nulls are generalized
- String[] generalizedNaturalizedNotNulls = TopiaTestDAOHelper.TopiaTestEntityEnum.GeneralizedNaturalizedEntity.getNotNulls();
- String[] naturalizedNotNulls = TopiaTestDAOHelper.TopiaTestEntityEnum.NaturalizedEntity.getNotNulls();
+ String[] generalizedNaturalizedNotNulls = TopiaTckItDAOHelper.TopiaTestEntityEnum.GeneralizedNaturalizedEntity.getNotNulls();
+ String[] naturalizedNotNulls = TopiaTckItDAOHelper.TopiaTestEntityEnum.NaturalizedEntity.getNotNulls();
Assert.assertArrayEquals(generalizedNaturalizedNotNulls, naturalizedNotNulls);
}
}
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/CollectorTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -32,7 +32,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topiatest.Company;
@@ -52,7 +52,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- contracts = TopiaTestDAOHelper.getContracts();
+ contracts = TopiaTckItDAOHelper.getContracts();
}
@AfterClass
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/EntityOperatorTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -30,15 +30,10 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.nuiton.topia.TopiaTestDAOHelper;
-import org.nuiton.topiatest.Company;
-import org.nuiton.topiatest.CompanyImpl;
-import org.nuiton.topiatest.Department;
-import org.nuiton.topiatest.DepartmentImpl;
-import org.nuiton.topiatest.Employe;
-import org.nuiton.topiatest.EmployeImpl;
-import org.nuiton.topiatest.Personne;
-import org.nuiton.topiatest.PersonneImpl;
+import org.nuiton.topia.tck.it.Company;
+import org.nuiton.topia.tck.it.Department;
+import org.nuiton.topia.tck.it.Employe;
+import org.nuiton.topia.tck.it.Personne;
import java.util.Collection;
@@ -72,10 +67,10 @@
@BeforeClass
public static void setUpClass() throws Exception {
- operationC = TopiaTestDAOHelper.getOperator(Company.class);
- operationE = TopiaTestDAOHelper.getOperator(Employe.class);
- operationP = TopiaTestDAOHelper.getOperator(Personne.class);
- operationD = TopiaTestDAOHelper.getOperator(Department.class);
+ operationC = TopiaTckItDAOHelper.getOperator(Company.class);
+ operationE = TopiaTckItDAOHelper.getOperator(Employe.class);
+ operationP = TopiaTckItDAOHelper.getOperator(Personne.class);
+ operationD = TopiaTckItDAOHelper.getOperator(Department.class);
}
@AfterClass
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityBinderTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -30,7 +30,7 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topiatest.Company;
@@ -44,7 +44,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- contracts = TopiaTestDAOHelper.getContracts();
+ contracts = TopiaTckItDAOHelper.getContracts();
}
public static class CompanyDTO {
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityHelperTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -30,7 +30,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityEnum;
import org.nuiton.topia.persistence.TopiaId;
@@ -70,7 +70,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- contracts = TopiaTestDAOHelper.getContracts();
+ contracts = TopiaTckItDAOHelper.getContracts();
}
@AfterClass
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/persistence/util/TopiaEntityRefTesterTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -28,7 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
-import org.nuiton.topia.TopiaTestDAOHelper.TopiaTestEntityEnum;
+import org.nuiton.topia.TopiaTckItDAOHelper.TopiaTestEntityEnum;
import org.nuiton.topia.test.entities.Person;
import org.nuiton.topia.test.entities.Pet;
import org.nuiton.topia.test.entities.Race;
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1882/DAOAbstractTransformerTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1882/DAOAbstractTransformerTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1882/DAOAbstractTransformerTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -27,8 +27,8 @@
import org.junit.Rule;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.tck.TopiaDatabase;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import java.util.Arrays;
@@ -41,8 +41,8 @@
public void testAno1882() throws Exception {
TopiaContext transaction = db.beginTransaction();
- FrenchCompanyDAO dao = TopiaTestDAOHelper.getFrenchCompanyDAO(transaction);
- SIRETDAO siretDAO = TopiaTestDAOHelper.getSIRETDAO(transaction);
+ FrenchCompanyDAO dao = TopiaTckItDAOHelper.getFrenchCompanyDAO(transaction);
+ SIRETDAO siretDAO = TopiaTckItDAOHelper.getSIRETDAO(transaction);
SIRET siret = siretDAO.create();
FrenchCompany entity =
dao.create(
Modified: trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1991/TopiaQueryTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1991/TopiaQueryTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topia/test/ano1991/TopiaQueryTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -28,9 +28,9 @@
import org.junit.Rule;
import org.junit.Test;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.tck.TopiaDatabase;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.TopiaTckItDAOHelper;
import org.nuiton.topia.framework.TopiaQuery;
import org.nuiton.topia.test.entities.Person;
import org.nuiton.topia.test.entities.PersonDAO;
@@ -56,7 +56,7 @@
TopiaContext context = db.beginTransaction();
- PersonDAO personDAO = TopiaTestDAOHelper.getPersonDAO(context);
+ PersonDAO personDAO = TopiaTckItDAOHelper.getPersonDAO(context);
// appel 1 find all
Person toto = personDAO.create(Person.PROPERTY_NAME, "toto");
@@ -89,8 +89,8 @@
TopiaContext context = db.beginTransaction();
- PetDAO petDAO = TopiaTestDAOHelper.getPetDAO(context);
- PersonDAO personDAO = TopiaTestDAOHelper.getPersonDAO(context);
+ PetDAO petDAO = TopiaTckItDAOHelper.getPetDAO(context);
+ PersonDAO personDAO = TopiaTckItDAOHelper.getPersonDAO(context);
Pet bernard = petDAO.create(Pet.PROPERTY_NAME, "bernard");
Pet bianca = petDAO.create(Pet.PROPERTY_NAME, "bianca");
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/EnumTest.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/EnumTest.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/EnumTest.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -1,75 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topiatest;
-
-import junit.framework.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.TopiaTestDAOHelper;
-
-/**
- * Test the support of possibility to have an attribute of type enumeration
- * in a entity
- */
-public class EnumTest {
-
- @Rule
- public final TopiaDatabase db = new TopiaDatabase();
-
- /**
- * Create an entity having two field of type enumeration. One is stored
- * using ordinal, the other using the name.
- * <p/>
- * The test check that values are stored, and that find methods works
- *
- * @throws TopiaException if any exception with db
- */
- @Test
- public void storeEntityWithEnumValue() throws TopiaException {
- TopiaContext transaction = db.beginTransaction();
-
- PersonneDAO dao = TopiaTestDAOHelper.getPersonneDAO(transaction);
- Personne personne = new PersonneImpl();
- personne.setGender(Gender.FEMALE);
- personne.setOtherGender(Gender.MALE);
- dao.create(personne);
- String topiaId = personne.getTopiaId();
- transaction.commitTransaction();
- transaction.closeContext();
-
- transaction = db.beginTransaction();
- dao = TopiaTestDAOHelper.getPersonneDAO(transaction);
- dao.findByTopiaId(topiaId);
- Assert.assertEquals(Gender.FEMALE, personne.getGender());
- Assert.assertEquals(Gender.MALE, personne.getOtherGender());
-
- Assert.assertNotNull(dao.findByGender(Gender.FEMALE));
- Assert.assertNotNull(dao.findByOtherGender(Gender.MALE));
- transaction.closeContext();
- }
-}
Deleted: trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/ExtraDAOEntityDAOImpl.java
===================================================================
--- trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/ExtraDAOEntityDAOImpl.java 2012-05-09 13:57:04 UTC (rev 2446)
+++ trunk/topia-persistence-tck/src/test/java/org/nuiton/topiatest/ExtraDAOEntityDAOImpl.java 2012-05-09 14:10:52 UTC (rev 2447)
@@ -1,40 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topiatest;
-
-import org.nuiton.topia.TopiaException;
-
-/**
- * Created: 26 mai 2010
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- * @version $Id$
- */
-public class ExtraDAOEntityDAOImpl<E extends ExtraDAOEntity> extends ExtraDAOEntityDAOAbstract<E> {
-
- @Override
- public void extra() throws TopiaException {
- }
-}
1
0
r2446 - in trunk: topia-persistence/src/test topia-persistence/src/test/java topia-persistence-hibernate topia-persistence-tck/src topia-persistence-tck/src/test topia-persistence-tck/src/test/java
by athimel@users.nuiton.org 09 May '12
by athimel@users.nuiton.org 09 May '12
09 May '12
Author: athimel
Date: 2012-05-09 15:57:04 +0200 (Wed, 09 May 2012)
New Revision: 2446
Url: http://nuiton.org/repositories/revision/topia/2446
Log:
Move all tests to topia-persistence-tck
Added:
trunk/topia-persistence-tck/src/test/
trunk/topia-persistence-tck/src/test/java/
trunk/topia-persistence-tck/src/test/java/org/
trunk/topia-persistence-tck/src/test/resources/
Removed:
trunk/topia-persistence/src/test/java/org/
trunk/topia-persistence/src/test/resources/
Modified:
trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
Modified: trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
===================================================================
--- trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml 2012-05-09 13:48:32 UTC (rev 2445)
+++ trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml 2012-05-09 13:57:04 UTC (rev 2446)
@@ -3,21 +3,12 @@
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-java" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-models" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/i18n" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-xmi" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-test-sources/test-annotations" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
- <excludeFolder url="file://$MODULE_DIR$/target/antrun" />
- <excludeFolder url="file://$MODULE_DIR$/target/classes" />
- <excludeFolder url="file://$MODULE_DIR$/target/processed-sources" />
- <excludeFolder url="file://$MODULE_DIR$/target/surefire-workdir" />
- <excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
1
0
Author: athimel
Date: 2012-05-09 15:48:32 +0200 (Wed, 09 May 2012)
New Revision: 2445
Url: http://nuiton.org/repositories/revision/topia/2445
Log:
Create module t-p-tck and t-p-hibernate (still in work)
Added:
trunk/topia-persistence-hibernate/
trunk/topia-persistence-hibernate/LICENSE.txt
trunk/topia-persistence-hibernate/README.txt
trunk/topia-persistence-hibernate/changelog.txt
trunk/topia-persistence-hibernate/pom.xml
trunk/topia-persistence-hibernate/src/
trunk/topia-persistence-hibernate/src/main/
trunk/topia-persistence-hibernate/src/main/java/
trunk/topia-persistence-hibernate/src/main/java/org/
trunk/topia-persistence-hibernate/src/main/java/org/nuiton/
trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/
trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/
trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/hibernate/
trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/hibernate/TopiaHibernatePersistenceProvider.java
trunk/topia-persistence-hibernate/src/main/resources/
trunk/topia-persistence-hibernate/src/main/resources/META-INF/
trunk/topia-persistence-hibernate/src/main/resources/META-INF/services/
trunk/topia-persistence-hibernate/src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider
trunk/topia-persistence-hibernate/src/main/resources/i18n/
trunk/topia-persistence-hibernate/src/main/resources/i18n/topia-persistence-hibernate_fr_FR.properties
trunk/topia-persistence-hibernate/src/test/
trunk/topia-persistence-hibernate/src/test/java/
trunk/topia-persistence-hibernate/src/test/java/org/
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/framework/
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/
trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
trunk/topia-persistence-tck/
trunk/topia-persistence-tck/LICENSE.txt
trunk/topia-persistence-tck/README.txt
trunk/topia-persistence-tck/changelog.txt
trunk/topia-persistence-tck/pom.xml
trunk/topia-persistence-tck/src/
trunk/topia-persistence-tck/src/main/
trunk/topia-persistence-tck/src/main/java/
trunk/topia-persistence-tck/src/main/java/org/
trunk/topia-persistence-tck/src/main/java/org/nuiton/
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java
trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java
trunk/topia-persistence-tck/src/main/resources/
trunk/topia-persistence-tck/src/main/resources/i18n/
trunk/topia-persistence-tck/src/main/resources/i18n/topia-persistence-tck_fr_FR.properties
trunk/topia-persistence-tck/src/main/xmi/
trunk/topia-persistence-tck/src/main/xmi/topiatest.properties
trunk/topia-persistence-tck/src/main/xmi/topiatest.zargo
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java
trunk/topia-persistence/src/test/resources/META-INF/
trunk/topia-persistence/src/test/resources/META-INF/persistence2.xml
trunk/topia-persistence/src/test/resources/META-INF/services/
Removed:
trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Gender.java
trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Title.java
trunk/topia-persistence/src/test/xmi/
Modified:
trunk/pom.xml
trunk/topia-persistence/pom.xml
trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDAOTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java
trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java
trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java
trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/pom.xml 2012-05-09 13:48:32 UTC (rev 2445)
@@ -40,6 +40,8 @@
<modules>
<module>topia-persistence</module>
+ <module>topia-persistence-tck</module>
+ <module>topia-persistence-hibernate</module>
<module>topia-service-replication</module>
<module>topia-service-migration</module>
<module>topia-service-security</module>
@@ -105,7 +107,7 @@
<scope>compile</scope>
</dependency>
- <!--dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernateVersion}</version>
@@ -134,9 +136,15 @@
</exclusion>
</exclusions>
<scope>runtime</scope>
- </dependency-->
+ </dependency>
<dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <version>1.0.1.Final</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
Modified: trunk/topia-persistence/pom.xml
===================================================================
--- trunk/topia-persistence/pom.xml 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/pom.xml 2012-05-09 13:48:32 UTC (rev 2445)
@@ -82,27 +82,29 @@
<artifactId>dom4j</artifactId>
</dependency>
- <!--dependency>
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
+ <scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
- <version>${hibernateVersion}</version>
+ <scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
- </dependency-->
+ <scope>test</scope>
+ </dependency>
-
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
</dependency>
-
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
@@ -137,7 +139,7 @@
<!-- ************************************************************* -->
<name>ToPIA :: Persistence</name>
- <description>Hibernate based persistence module</description>
+ <description>JPA based persistence module</description>
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
@@ -218,7 +220,7 @@
</executions>
</plugin>
- <plugin>
+ <!--plugin>
<groupId>org.nuiton.eugene</groupId>
<artifactId>maven-eugene-plugin</artifactId>
<configuration>
@@ -246,10 +248,10 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin-->
<!-- expose tests -->
- <plugin>
+ <!--plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
@@ -260,7 +262,7 @@
</execution>
</executions>
- </plugin>
+ </plugin-->
</plugins>
</build>
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -29,7 +29,7 @@
import org.apache.commons.collections.map.ReferenceMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.Environment;
+//import org.hibernate.cfg.Environment;
import org.nuiton.topia.framework.TopiaContextImpl;
import org.nuiton.topia.framework.TopiaUtil;
@@ -60,34 +60,34 @@
new ReferenceMap(AbstractReferenceMap.HARD,
AbstractReferenceMap.SOFT);
- public final static String CONFIG_DEFAULT_SCHEMA = Environment.DEFAULT_SCHEMA;
+// public final static String CONFIG_DEFAULT_SCHEMA = Environment.DEFAULT_SCHEMA;
+//
+// public final static String CONFIG_USER = Environment.USER;
+//
+// public final static String CONFIG_PASS = Environment.PASS;
+//
+// public final static String CONFIG_DRIVER = Environment.DRIVER;
+//
+// public final static String CONFIG_DIALECT = Environment.DIALECT;
+//
+// public final static String CONFIG_CONNECTION_PROVIDER = Environment.CONNECTION_PROVIDER;
+//
+// public final static String CONFIG_BYTECODE_PROVIDER = Environment.BYTECODE_PROVIDER;
+//
+// public final static String CONFIG_CURRENT_SESSION_CONTEXT_CLASS = Environment.CURRENT_SESSION_CONTEXT_CLASS;
+//
+// public final static String CONFIG_GENERATE_STATISTICS = Environment.GENERATE_STATISTICS;
+//
+// public final static String CONFIG_FORMAT_SQL = Environment.FORMAT_SQL;
+//
+// public final static String CONFIG_HBM2DDL_AUTO = Environment.HBM2DDL_AUTO;
+//
+// public final static String CONFIG_POOL_SIZE = Environment.POOL_SIZE;
+//
+// public final static String CONFIG_SHOW_SQL = Environment.SHOW_SQL;
- public final static String CONFIG_USER = Environment.USER;
+ public final static String CONFIG_URL = "hibernate.connection.url";//Environment.URL;
- public final static String CONFIG_PASS = Environment.PASS;
-
- public final static String CONFIG_DRIVER = Environment.DRIVER;
-
- public final static String CONFIG_DIALECT = Environment.DIALECT;
-
- public final static String CONFIG_CONNECTION_PROVIDER = Environment.CONNECTION_PROVIDER;
-
- public final static String CONFIG_BYTECODE_PROVIDER = Environment.BYTECODE_PROVIDER;
-
- public final static String CONFIG_CURRENT_SESSION_CONTEXT_CLASS = Environment.CURRENT_SESSION_CONTEXT_CLASS;
-
- public final static String CONFIG_GENERATE_STATISTICS = Environment.GENERATE_STATISTICS;
-
- public final static String CONFIG_FORMAT_SQL = Environment.FORMAT_SQL;
-
- public final static String CONFIG_HBM2DDL_AUTO = Environment.HBM2DDL_AUTO;
-
- public final static String CONFIG_POOL_SIZE = Environment.POOL_SIZE;
-
- public final static String CONFIG_SHOW_SQL = Environment.SHOW_SQL;
-
- public final static String CONFIG_URL = Environment.URL;
-
public final static String CONFIG_PERSISTENCE_DIRECTORIES =
"topia.persistence.directories";
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -61,7 +61,8 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.5.3
*/
-public class TopiaConnectionProvider implements ConnectionProvider {
+public class TopiaConnectionProvider {
+// implements ConnectionProvider {
/** Logger. */
private static final Log log =
@@ -111,74 +112,74 @@
pool = new ArrayList<Connection>();
}
- @Override
+// @Override
public void configure(Properties props) throws PersistenceException {
- String driverClass = props.getProperty(Environment.DRIVER);
-
- poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
- if (log.isDebugEnabled()) {
- log.debug("Connection pool size: " + poolSize);
- }
-
- autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
- if (log.isDebugEnabled())
- log.debug("autocommit mode: " + autocommit);
-
- isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
- if (isolation != null) {
- if (log.isDebugEnabled()) {
- log.debug("JDBC isolation level: " +
- Environment.isolationLevelToString(isolation));
- }
- }
-
- if (driverClass == null) {
-
- if (log.isWarnEnabled()) {
- log.warn("no JDBC Driver class was specified by property " +
- Environment.DRIVER);
- }
- } else {
- try {
- // trying via forName() first to be as close to DriverManager's semantics
- Class.forName(driverClass);
- } catch (ClassNotFoundException cnfe) {
- try {
- ReflectHelper.classForName(driverClass);
- } catch (ClassNotFoundException e) {
- String msg = "JDBC Driver class not found: " + driverClass;
- log.error(msg, e);
- throw new PersistenceException(msg, e);
- }
- }
- }
-
- url = props.getProperty(Environment.URL);
- if (url == null) {
- String msg = "JDBC URL was not specified by property " +
- Environment.URL;
- if (log.isErrorEnabled()) {
- log.error(msg);
- }
- throw new PersistenceException(msg);
- }
-
- connectionProps =
- ConnectionProviderFactory.getConnectionProperties(props);
-
- if (log.isDebugEnabled()) {
- log.debug("using driver: " + driverClass + " at URL: " + url);
- }
- // if debug level is enabled, then log the password, otherwise mask it
- if (log.isTraceEnabled()) {
- log.debug("connection properties: " + connectionProps);
- } else if (log.isDebugEnabled()) {
- log.debug("connection properties: " +
- PropertiesHelper.maskOut(connectionProps, "password"));
- }
+// String driverClass = props.getProperty(Environment.DRIVER);
+//
+// poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
+// if (log.isDebugEnabled()) {
+// log.debug("Connection pool size: " + poolSize);
+// }
+//
+// autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
+// if (log.isDebugEnabled())
+// log.debug("autocommit mode: " + autocommit);
+//
+// isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
+// if (isolation != null) {
+// if (log.isDebugEnabled()) {
+// log.debug("JDBC isolation level: " +
+// Environment.isolationLevelToString(isolation));
+// }
+// }
+//
+// if (driverClass == null) {
+//
+// if (log.isWarnEnabled()) {
+// log.warn("no JDBC Driver class was specified by property " +
+// Environment.DRIVER);
+// }
+// } else {
+// try {
+// // trying via forName() first to be as close to DriverManager's semantics
+// Class.forName(driverClass);
+// } catch (ClassNotFoundException cnfe) {
+// try {
+// ReflectHelper.classForName(driverClass);
+// } catch (ClassNotFoundException e) {
+// String msg = "JDBC Driver class not found: " + driverClass;
+// log.error(msg, e);
+// throw new PersistenceException(msg, e);
+// }
+// }
+// }
+//
+// url = props.getProperty(Environment.URL);
+// if (url == null) {
+// String msg = "JDBC URL was not specified by property " +
+// Environment.URL;
+// if (log.isErrorEnabled()) {
+// log.error(msg);
+// }
+// throw new PersistenceException(msg);
+// }
+//
+// connectionProps =
+// ConnectionProviderFactory.getConnectionProperties(props);
+//
+// if (log.isDebugEnabled()) {
+// log.debug("using driver: " + driverClass + " at URL: " + url);
+// }
+// // if debug level is enabled, then log the password, otherwise mask it
+// if (log.isTraceEnabled()) {
+// log.debug("connection properties: " + connectionProps);
+// } else if (log.isDebugEnabled()) {
+// log.debug("connection properties: " +
+// PropertiesHelper.maskOut(connectionProps, "password"));
+// }
}
- @Override
+// @Override
public Connection getConnection() throws SQLException {
Connection connection = null;
@@ -230,7 +231,7 @@
return connection;
}
- @Override
+// @Override
public void closeConnection(Connection conn) throws SQLException {
// if connection is already closed, nothing has to be done
@@ -275,7 +276,7 @@
close();
}
- @Override
+// @Override
public void close() {
if (log.isDebugEnabled()) {
@@ -295,7 +296,7 @@
}
- @Override
+// @Override
public boolean supportsAggressiveRelease() {
return false;
}
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 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -53,6 +53,7 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.TopiaRuntimeException;
import org.nuiton.topia.event.TopiaContextListener;
import org.nuiton.topia.event.TopiaEntitiesVetoable;
import org.nuiton.topia.event.TopiaEntityListener;
@@ -69,6 +70,7 @@
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType;
+import javax.persistence.Persistence;
import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.persistence.metamodel.EntityType;
@@ -135,8 +137,8 @@
/** Le pere de ce context, les contexts initaux n'ont pas de context pere */
protected TopiaContextImplementor parentContext;
- /** L'objet configuration utilisé pour la creation de la factory hibernate */
- protected Configuration hibernateConfiguration;
+ /** L'objet configuration utilisé pour la creation de la factory JPA */
+ protected Map jpaConfiguration;
/**
* la factory permettant de recuperer la session hibernate. Seul les
@@ -213,7 +215,7 @@
this.config = config;
services = loadServices(config);
preInitServices(services);
- getHibernateConfiguration(); // force mapping loading
+// getHibernateConfiguration(); // force mapping loading
postInitServices(services);
}
@@ -439,50 +441,50 @@
@Override
public void createSchema() throws TopiaException {
- try {
- boolean showSchema = false;
- if (log.isDebugEnabled()) {
- showSchema = true;
- }
- getFiresSupport().firePreCreateSchema(this);
- new SchemaExport(getHibernateConfiguration()).create(showSchema,
- true);
- getFiresSupport().firePostCreateSchema(this);
- } catch (PersistenceException eee) {
- throw new TopiaException(
- _("topia.persistence.error.create.schema",
- eee.getMessage()), eee);
- }
+// try {
+// boolean showSchema = false;
+// if (log.isDebugEnabled()) {
+// showSchema = true;
+// }
+// getFiresSupport().firePreCreateSchema(this);
+// new SchemaExport(getHibernateConfiguration()).create(showSchema,
+// true);
+// getFiresSupport().firePostCreateSchema(this);
+// } catch (PersistenceException eee) {
+// throw new TopiaException(
+// _("topia.persistence.error.create.schema",
+// eee.getMessage()), eee);
+// }
}
@Override
public void showCreateSchema() throws TopiaException {
- try {
- new SchemaExport(getHibernateConfiguration()).
- execute(true, false, false, true);
- } catch (PersistenceException eee) {
- throw new TopiaException(
- _("topia.persistence.error.create.schema",
- eee.getMessage()), eee);
- }
+// try {
+// new SchemaExport(getHibernateConfiguration()).
+// execute(true, false, false, true);
+// } catch (PersistenceException eee) {
+// throw new TopiaException(
+// _("topia.persistence.error.create.schema",
+// eee.getMessage()), eee);
+// }
}
@Override
public void updateSchema() throws TopiaException {
- try {
- boolean showSchema = false;
- if (log.isDebugEnabled()) {
- showSchema = true;
- }
- getFiresSupport().firePreUpdateSchema(this);
- new SchemaUpdate(getHibernateConfiguration()).execute(showSchema,
- true);
- getFiresSupport().firePostUpdateSchema(this);
- } catch (PersistenceException eee) {
- throw new TopiaException(
- _("topia.persistence.error.update.schema",
- eee.getMessage()), eee);
- }
+// try {
+// boolean showSchema = false;
+// if (log.isDebugEnabled()) {
+// showSchema = true;
+// }
+// getFiresSupport().firePreUpdateSchema(this);
+// new SchemaUpdate(getHibernateConfiguration()).execute(showSchema,
+// true);
+// getFiresSupport().firePostUpdateSchema(this);
+// } catch (PersistenceException eee) {
+// throw new TopiaException(
+// _("topia.persistence.error.update.schema",
+// eee.getMessage()), eee);
+// }
}
@Override
@@ -500,116 +502,31 @@
if (getParentContext() != null) {
hibernateFactory = getParentContext().getHibernateFactory();
} else {
- hibernateFactory = getHibernateConfiguration().buildSessionFactory();
+// hibernateFactory = getHibernateConfiguration().buildSessionFactory();
+ Map params = getJPAConfiguration();
+
+ hibernateFactory = Persistence.createEntityManagerFactory("topia", params); // FIXME AThimel 07/05/2012 Map will probably contain Configuration
}
}
return hibernateFactory;
}
- @Override
- public Configuration getHibernateConfiguration()
- throws TopiaNotFoundException {
- if (hibernateConfiguration == null) {
+ public Map getJPAConfiguration() throws TopiaNotFoundException {
+ if (jpaConfiguration == null) {
if (getParentContext() != null) {
- hibernateConfiguration = getParentContext().getHibernateConfiguration();
+ jpaConfiguration = getParentContext().getJPAConfiguration();
} else {
- hibernateConfiguration = new Configuration();
+ jpaConfiguration = new HashMap();
- // Ajout du listeners pour les events
- TopiaFiresSupport.TopiaHibernateEvent listener =
- new TopiaFiresSupport.TopiaHibernateEvent(this);
- PreInsertEventListener[] preInsertEventListeners =
- hibernateConfiguration.getEventListeners().
- getPreInsertEventListeners();
- preInsertEventListeners = ArrayUtil.concatElems(
- preInsertEventListeners, listener);
-
- PreLoadEventListener[] preLoadEventListeners =
- hibernateConfiguration.getEventListeners().
- getPreLoadEventListeners();
- preLoadEventListeners = ArrayUtil.concatElems(
- preLoadEventListeners, listener);
-
- PreUpdateEventListener[] preUpdateEventListeners =
- hibernateConfiguration.getEventListeners().
- getPreUpdateEventListeners();
- preUpdateEventListeners = ArrayUtil.concatElems(
- preUpdateEventListeners, listener);
-
- PreDeleteEventListener[] preDeleteEventListeners =
- hibernateConfiguration.getEventListeners().
- getPreDeleteEventListeners();
- preDeleteEventListeners = ArrayUtil.concatElems(
- preDeleteEventListeners, listener);
-
- PostInsertEventListener[] postInsertEventListeners =
- hibernateConfiguration.getEventListeners().
- getPostInsertEventListeners();
- postInsertEventListeners = ArrayUtil.concatElems(
- postInsertEventListeners, listener);
-
- PostLoadEventListener[] postLoadEventListeners =
- hibernateConfiguration.getEventListeners().
- getPostLoadEventListeners();
- postLoadEventListeners = ArrayUtil.concatElems(
- postLoadEventListeners, listener);
-
- PostUpdateEventListener[] postUpdateEventListeners =
- hibernateConfiguration.getEventListeners().
- getPostUpdateEventListeners();
- postUpdateEventListeners = ArrayUtil.concatElems(
- postUpdateEventListeners, listener);
-
- PostDeleteEventListener[] postDeleteEventListeners =
- hibernateConfiguration.getEventListeners().
- getPostDeleteEventListeners();
- postDeleteEventListeners = ArrayUtil.concatElems(
- postDeleteEventListeners, listener);
-
- hibernateConfiguration.getEventListeners().
- setPreInsertEventListeners(preInsertEventListeners);
- hibernateConfiguration.getEventListeners().
- setPreLoadEventListeners(preLoadEventListeners);
- hibernateConfiguration.getEventListeners().
- setPreUpdateEventListeners(preUpdateEventListeners);
- hibernateConfiguration.getEventListeners().
- setPreDeleteEventListeners(preDeleteEventListeners);
-
- hibernateConfiguration.getEventListeners().
- setPostInsertEventListeners(postInsertEventListeners);
- hibernateConfiguration.getEventListeners().
- setPostLoadEventListeners(postLoadEventListeners);
- hibernateConfiguration.getEventListeners().
- setPostUpdateEventListeners(postUpdateEventListeners);
- hibernateConfiguration.getEventListeners().
- setPostDeleteEventListeners(postDeleteEventListeners);
-
- // ajout des repertoires contenant les mappings hibernate
- String[] dirs = getConfig().getProperty(
- TopiaContextFactory.CONFIG_PERSISTENCE_DIRECTORIES, "").split(",");
- for (String dir : dirs) {
- dir = dir.trim();
- if (StringUtils.isNotEmpty(dir)) {
- if (log.isDebugEnabled()) {
- log.debug("Load persistence from dir : " + dir);
- }
- hibernateConfiguration.addDirectory(new File(dir));
- }
- }
-
// ajout des classes dites persistentes
- Set<Class<?>> hibernatePersistanceClasses = new HashSet<Class<?>>();
for (TopiaService service : getServices().values()) {
Class<?>[] classes = service.getPersistenceClasses();
// certains service n'ont pas de classe persistantes
if (classes != null) {
// sletellier 20110411 : http://www.nuiton.org/issues/show/1454
- hibernatePersistanceClasses.addAll(Arrays.asList(classes));
-// for (Class<?> clazz : classes) {
-// hibernateConfiguration.addClass(clazz);
-// }
+ this.persistenceClasses.addAll(Arrays.asList(classes));
}
}
@@ -642,48 +559,195 @@
_("topia.persistence.error.class.not.found",
classname));
}
- persistenceClasses.add(clazz);
-
- // sletellier 20110411 : http://www.nuiton.org/issues/show/1454
-// hibernateConfiguration.addClass(clazz);
- hibernatePersistanceClasses.add(clazz);
+ this.persistenceClasses.add(clazz);
}
}
- // sletellier 20110411 : http://www.nuiton.org/issues/show/1454
- // Add persistance classes in hibernate config
- for (Class<?> persistanceClass : hibernatePersistanceClasses) {
- hibernateConfiguration.addClass(persistanceClass);
- }
- Properties prop = new Properties();
- prop.putAll(hibernateConfiguration.getProperties());
- prop.putAll(getConfig());
-
- // Strange behavior, all properties are already loaded from
- // constructor. Difficult to use this behavior, need to have
- // TOPIA_PERSISTENCE_PROPERTIES_FILE in config.
- Properties propertiesFromClasspath =
- TopiaUtil.getProperties(getConfig().
- getProperty(TopiaContextFactory.CONFIG_PERSISTENCE_PROPERTIES_FILE));
-
- if (!propertiesFromClasspath.isEmpty()) {
- if (log.isDebugEnabled()) {
- log.debug("Load properties from file : " +
- propertiesFromClasspath);
- }
- prop.putAll(propertiesFromClasspath);
- }
-
- 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();
+ jpaConfiguration.put("topia.entities", this.persistenceClasses);
}
}
- return hibernateConfiguration;
+ return jpaConfiguration;
}
+// @Override
+// public Configuration getHibernateConfiguration()
+// throws TopiaNotFoundException {
+// if (hibernateConfiguration == null) {
+// if (getParentContext() != null) {
+// hibernateConfiguration = getParentContext().getHibernateConfiguration();
+// } else {
+// hibernateConfiguration = new Configuration();
+//
+// // Ajout du listeners pour les events
+// TopiaFiresSupport.TopiaHibernateEvent listener =
+// new TopiaFiresSupport.TopiaHibernateEvent(this);
+//
+// PreInsertEventListener[] preInsertEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPreInsertEventListeners();
+// preInsertEventListeners = ArrayUtil.concatElems(
+// preInsertEventListeners, listener);
+//
+// PreLoadEventListener[] preLoadEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPreLoadEventListeners();
+// preLoadEventListeners = ArrayUtil.concatElems(
+// preLoadEventListeners, listener);
+//
+// PreUpdateEventListener[] preUpdateEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPreUpdateEventListeners();
+// preUpdateEventListeners = ArrayUtil.concatElems(
+// preUpdateEventListeners, listener);
+//
+// PreDeleteEventListener[] preDeleteEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPreDeleteEventListeners();
+// preDeleteEventListeners = ArrayUtil.concatElems(
+// preDeleteEventListeners, listener);
+//
+// PostInsertEventListener[] postInsertEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPostInsertEventListeners();
+// postInsertEventListeners = ArrayUtil.concatElems(
+// postInsertEventListeners, listener);
+//
+// PostLoadEventListener[] postLoadEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPostLoadEventListeners();
+// postLoadEventListeners = ArrayUtil.concatElems(
+// postLoadEventListeners, listener);
+//
+// PostUpdateEventListener[] postUpdateEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPostUpdateEventListeners();
+// postUpdateEventListeners = ArrayUtil.concatElems(
+// postUpdateEventListeners, listener);
+//
+// PostDeleteEventListener[] postDeleteEventListeners =
+// hibernateConfiguration.getEventListeners().
+// getPostDeleteEventListeners();
+// postDeleteEventListeners = ArrayUtil.concatElems(
+// postDeleteEventListeners, listener);
+//
+// hibernateConfiguration.getEventListeners().
+// setPreInsertEventListeners(preInsertEventListeners);
+// hibernateConfiguration.getEventListeners().
+// setPreLoadEventListeners(preLoadEventListeners);
+// hibernateConfiguration.getEventListeners().
+// setPreUpdateEventListeners(preUpdateEventListeners);
+// hibernateConfiguration.getEventListeners().
+// setPreDeleteEventListeners(preDeleteEventListeners);
+//
+// hibernateConfiguration.getEventListeners().
+// setPostInsertEventListeners(postInsertEventListeners);
+// hibernateConfiguration.getEventListeners().
+// setPostLoadEventListeners(postLoadEventListeners);
+// hibernateConfiguration.getEventListeners().
+// setPostUpdateEventListeners(postUpdateEventListeners);
+// hibernateConfiguration.getEventListeners().
+// setPostDeleteEventListeners(postDeleteEventListeners);
+//
+// // ajout des repertoires contenant les mappings hibernate
+// String[] dirs = getConfig().getProperty(
+// TopiaContextFactory.CONFIG_PERSISTENCE_DIRECTORIES, "").split(",");
+// for (String dir : dirs) {
+// dir = dir.trim();
+// if (StringUtils.isNotEmpty(dir)) {
+// if (log.isDebugEnabled()) {
+// log.debug("Load persistence from dir : " + dir);
+// }
+// hibernateConfiguration.addDirectory(new File(dir));
+// }
+// }
+//
+// // ajout des classes dites persistentes
+// Set<Class<?>> hibernatePersistanceClasses = new HashSet<Class<?>>();
+// for (TopiaService service : getServices().values()) {
+// Class<?>[] classes = service.getPersistenceClasses();
+//
+// // certains service n'ont pas de classe persistantes
+// if (classes != null) {
+// // sletellier 20110411 : http://www.nuiton.org/issues/show/1454
+// hibernatePersistanceClasses.addAll(Arrays.asList(classes));
+//// for (Class<?> clazz : classes) {
+//// hibernateConfiguration.addClass(clazz);
+//// }
+// }
+// }
+//
+// String listPersistenceClasses = getConfig().getProperty(
+// TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, "");
+//
+// String[] classes = listPersistenceClasses.split(",");
+// for (String classname : classes) {
+// classname = classname.trim();
+// if (StringUtils.isNotEmpty(classname)) {
+// if (log.isDebugEnabled()) {
+// log.debug("Load persistent class : " + classname);
+// }
+//
+// // XXX echatellier 20111007 ce cqui est dommage ici, c'est
+// // la definition de cette classe ne sert a rien (apart security)
+// // car pour hibernate hibernateConfiguration.addClass(persistanceClass)
+// // il ne se sert pas de la classe en fait et fait seulement
+// // un classname.replace( '.', '/' ) + ".hbm.xml";
+// // pour obtenir le mapping et la reinstancier ensuite
+//
+// Class<?> clazz;
+// try {
+// clazz = Class.forName(classname);
+// } catch (ClassNotFoundException eee) {
+// if (log.isDebugEnabled()) {
+// log.debug("Class " + classname + " not found");
+// }
+// throw new TopiaNotFoundException(
+// _("topia.persistence.error.class.not.found",
+// classname));
+// }
+// persistenceClasses.add(clazz);
+//
+// // sletellier 20110411 : http://www.nuiton.org/issues/show/1454
+//// hibernateConfiguration.addClass(clazz);
+// hibernatePersistanceClasses.add(clazz);
+// }
+// }
+//
+// // sletellier 20110411 : http://www.nuiton.org/issues/show/1454
+// // Add persistance classes in hibernate config
+// for (Class<?> persistanceClass : hibernatePersistanceClasses) {
+// hibernateConfiguration.addClass(persistanceClass);
+// }
+//
+// Properties prop = new Properties();
+// prop.putAll(hibernateConfiguration.getProperties());
+// prop.putAll(getConfig());
+//
+// // Strange behavior, all properties are already loaded from
+// // constructor. Difficult to use this behavior, need to have
+// // TOPIA_PERSISTENCE_PROPERTIES_FILE in config.
+// Properties propertiesFromClasspath =
+// TopiaUtil.getProperties(getConfig().
+// getProperty(TopiaContextFactory.CONFIG_PERSISTENCE_PROPERTIES_FILE));
+//
+// if (!propertiesFromClasspath.isEmpty()) {
+// if (log.isDebugEnabled()) {
+// log.debug("Load properties from file : " +
+// propertiesFromClasspath);
+// }
+// prop.putAll(propertiesFromClasspath);
+// }
+//
+// 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;
+// }
+
/* -------------------- CHILD CONTEXT AND DAOS --------------------------*/
@SuppressWarnings({"unchecked"})
@@ -699,19 +763,25 @@
throw new TopiaException(
_("topia.persistence.error.rootContext.access"));
}
- if (getHibernateFactory().getMetamodel().entity(entityClass) == null
-// && getHibernateFactory().getClassMetadata(
-// entityClass.getName() + "Impl") == null
-// && getHibernateFactory().getClassMetadata(
-// entityClass.getName() + "Abstract") == null
- ) {
-
- log.info(_("topia.persistence.supported.classes.for.context",
- getHibernateFactory().getMetamodel().getEntities()));
- throw new TopiaException(
- _("topia.persistence.error.unsupported.class",
- entityClass.getName()));
+ Set<EntityType<?>> entities = getHibernateFactory().getMetamodel().getEntities();
+ boolean found = false;
+ for (EntityType<?> entityType : entities) {
+ String entityName = entityType.getName();
+ found =
+ entityClass.getName().equals(entityName)
+ || (entityClass.getName() + "Impl").equals(entityName)
+ || (entityClass.getName() + "Abstract").equals(entityName);
+ if (found) {
+ break;
+ }
}
+// if (!found) {
+// log.info(_("topia.persistence.supported.classes.for.context",
+// getHibernateFactory().getMetamodel().getEntities()));
+// throw new TopiaException(
+// _("topia.persistence.error.unsupported.class",
+// entityClass.getName()));
+// }
TopiaDAO<E> result = (TopiaDAO<E>) daoCache.get(entityClass);
if (result == null) {
@@ -1067,111 +1137,111 @@
@Override
public void importXML(Reader xml) throws TopiaException {
- checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context",
- "importXML"));
-
- Document doc;
-
- SAXReader xmlReader = new SAXReader();
- try {
- doc = xmlReader.read(xml);
- if (log.isDebugEnabled()) {
- log.debug("Lecture du document terminee");
- }
- } catch (DocumentException de) {
- throw new TopiaException(
- _("topia.persistence.error.on.loding.xml.doc",
- de.getMessage()), de);
- }
-
- if (doc != null) {
- Session sessionDom4j = getHibernate().getSession(EntityMode.DOM4J);
- Element rootElement = doc.getRootElement();
- Iterator<?> it = rootElement.elementIterator();
- while (it.hasNext()) {
- Element entity = (Element) it.next();
- try {
- sessionDom4j.replicate(entity, ReplicationMode.EXCEPTION);
- } catch (PersistenceException he) {
- log.warn(_("topia.persistence.error.replicate.entity",
- entity, he.getMessage()), he);
- }
- }
- // must commit data, otherwise : no effects...
- sessionDom4j.flush();
- } else {
- throw new TopiaException(
- _("topia.persistence.error.empty.doc"));
- }
+// checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context",
+// "importXML"));
+//
+// Document doc;
+//
+// SAXReader xmlReader = new SAXReader();
+// try {
+// doc = xmlReader.read(xml);
+// if (log.isDebugEnabled()) {
+// log.debug("Lecture du document terminee");
+// }
+// } catch (DocumentException de) {
+// throw new TopiaException(
+// _("topia.persistence.error.on.loding.xml.doc",
+// de.getMessage()), de);
+// }
+//
+// if (doc != null) {
+// Session sessionDom4j = getHibernate().getSession(EntityMode.DOM4J);
+// Element rootElement = doc.getRootElement();
+// Iterator<?> it = rootElement.elementIterator();
+// while (it.hasNext()) {
+// Element entity = (Element) it.next();
+// try {
+// sessionDom4j.replicate(entity, ReplicationMode.EXCEPTION);
+// } catch (PersistenceException he) {
+// log.warn(_("topia.persistence.error.replicate.entity",
+// entity, he.getMessage()), he);
+// }
+// }
+// // must commit data, otherwise : no effects...
+// sessionDom4j.flush();
+// } else {
+// throw new TopiaException(
+// _("topia.persistence.error.empty.doc"));
+// }
}
@Override
public void exportXML(Writer xml, Object... entityAndcondition)
throws TopiaException {
- checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context",
- "exportXML"));
-
- String[] queries = buildQueries(entityAndcondition);
-
- // performs queries
- try {
- Session sessionDom4j = getHibernate().getSession(EntityMode.DOM4J);
-
- Document doc = DocumentFactory.getInstance().createDocument();
- Element rootElement = doc.addElement("topiaExport");
- DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
- String date = format.format(new Date(System.currentTimeMillis()));
- rootElement.addAttribute("date", date);
-
- for (String query : queries) {
- List<?> list = sessionDom4j.createQuery(query).list();
- for (Object o : list) {
- rootElement.add((Element) o);
- }
- }
-
- /*for (int i = 0; i < entityAndcondition.length;) {
- try {
- entityClass = (Class) entityAndcondition[i++];
- condition = (String) entityAndcondition[i++];
-
- String query = "from " + entityClass.getName();
- if (condition != null && !condition.isEmpty()) {
- query += " where " + condition;
- }
-
- for (Object o : sessionDom4j.createQuery(query).list()) {
- rootElement.add((Element) o);
- }
- } catch (ClassCastException eee) {
- if (i % 2 == 0) {
- throw new IllegalArgumentException(
- "Others arguement must be String not "
- + entityAndcondition[i - 1], eee);
- } else {
- throw new IllegalArgumentException(
- "Others arguement must be Class not "
- + entityAndcondition[i - 1], eee);
- }
- } catch (IndexOutOfBoundsException eee) {
- throw new IllegalArgumentException(
- "Others arguement must be couple of (Class, String)",
- eee);
- }
- }*/
-
- XMLWriter result = new XMLWriter(xml,
- OutputFormat.createPrettyPrint());
- result.write(doc);
- result.close();
-
- } catch (PersistenceException eee) {
- throw new TopiaException(_("topia.persistence.error.on.export",
- eee.getMessage()), eee);
- } catch (IOException eee) {
- throw new TopiaException(_("topia.persistence.error.on.export",
- eee.getMessage()), eee);
- }
+// checkClosed(_("topia.persistence.error.unsupported.operation.on.closed.context",
+// "exportXML"));
+//
+// String[] queries = buildQueries(entityAndcondition);
+//
+// // performs queries
+// try {
+// Session sessionDom4j = getHibernate().getSession(EntityMode.DOM4J);
+//
+// Document doc = DocumentFactory.getInstance().createDocument();
+// Element rootElement = doc.addElement("topiaExport");
+// DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
+// String date = format.format(new Date(System.currentTimeMillis()));
+// rootElement.addAttribute("date", date);
+//
+// for (String query : queries) {
+// List<?> list = sessionDom4j.createQuery(query).list();
+// for (Object o : list) {
+// rootElement.add((Element) o);
+// }
+// }
+//
+// /*for (int i = 0; i < entityAndcondition.length;) {
+// try {
+// entityClass = (Class) entityAndcondition[i++];
+// condition = (String) entityAndcondition[i++];
+//
+// String query = "from " + entityClass.getName();
+// if (condition != null && !condition.isEmpty()) {
+// query += " where " + condition;
+// }
+//
+// for (Object o : sessionDom4j.createQuery(query).list()) {
+// rootElement.add((Element) o);
+// }
+// } catch (ClassCastException eee) {
+// if (i % 2 == 0) {
+// throw new IllegalArgumentException(
+// "Others arguement must be String not "
+// + entityAndcondition[i - 1], eee);
+// } else {
+// throw new IllegalArgumentException(
+// "Others arguement must be Class not "
+// + entityAndcondition[i - 1], eee);
+// }
+// } catch (IndexOutOfBoundsException eee) {
+// throw new IllegalArgumentException(
+// "Others arguement must be couple of (Class, String)",
+// eee);
+// }
+// }*/
+//
+// XMLWriter result = new XMLWriter(xml,
+// OutputFormat.createPrettyPrint());
+// result.write(doc);
+// result.close();
+//
+// } catch (PersistenceException eee) {
+// throw new TopiaException(_("topia.persistence.error.on.export",
+// eee.getMessage()), eee);
+// } catch (IOException eee) {
+// throw new TopiaException(_("topia.persistence.error.on.export",
+// eee.getMessage()), eee);
+// }
}
@Override
@@ -1548,14 +1618,14 @@
protected void replicate0(TopiaContextImpl dstContextImpl,
Object... entities) throws TopiaException {
try {
- for (Object entity : entities) {
- // dettach entity to source session, to make possible copy of
- // collection without a hibernate exception (list opened in
- // two session...)
- getHibernate().detach(entity);
- dstContextImpl.getHibernate().replicate(entity,
- ReplicationMode.EXCEPTION);
- }
+// for (Object entity : entities) {
+// // dettach entity to source session, to make possible copy of
+// // collection without a hibernate exception (list opened in
+// // two session...)
+// getHibernate().detach(entity);
+// dstContextImpl.getHibernate().replicate(entity,
+// ReplicationMode.EXCEPTION);
+// }
} catch (PersistenceException eee) {
throw new TopiaException(_("topia.persistence.error.on.replicate",
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -78,13 +78,15 @@
*/
EntityManagerFactory getHibernateFactory() throws TopiaNotFoundException;
- /**
- * @return Returns the hibernate configuration
- * @throws TopiaNotFoundException
- */
- Configuration getHibernateConfiguration()
- throws TopiaNotFoundException;
+// /**
+// * @return Returns the hibernate configuration
+// * @throws TopiaNotFoundException
+// */
+// Configuration getHibernateConfiguration()
+// throws TopiaNotFoundException;
+ Map getJPAConfiguration() throws TopiaNotFoundException;
+
/**
* Tells to the context if it has to use a flush mode before each query.
*
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -63,6 +63,13 @@
import org.nuiton.util.ListenerSet;
import javax.persistence.EntityManager;
+import javax.persistence.PostLoad;
+import javax.persistence.PostPersist;
+import javax.persistence.PostRemove;
+import javax.persistence.PostUpdate;
+import javax.persistence.PrePersist;
+import javax.persistence.PreRemove;
+import javax.persistence.PreUpdate;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -539,11 +546,7 @@
*
* @author poussin <poussin(a)codelutin.com>
*/
- static public class TopiaHibernateEvent implements PreInsertEventListener,
- PostInsertEventListener, PreLoadEventListener,
- PostLoadEventListener, PreUpdateEventListener,
- PostUpdateEventListener, PreDeleteEventListener,
- PostDeleteEventListener {
+ static public class TopiaHibernateEvent {
private static final long serialVersionUID = 7303593133642169218L;
@@ -615,112 +618,152 @@
}
/* Création */
+//
+// @Override
+// public boolean onPreInsert(PreInsertEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// context.getFiresSupport().fireOnPreCreate(context,
+// (TopiaEntity) event.getEntity(), event.getState());
+// }
+// return false;
+// }
+//
+// @Override
+// public void onPostInsert(PostInsertEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// context.getFiresSupport().fireOnPostCreate(context,
+// (TopiaEntity) event.getEntity(), event.getState());
+// }
+// }
+//
+// /* Chargement */
+//
+// @Override
+// public void onPreLoad(PreLoadEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// // try {
+// context.getFiresSupport().fireOnPreLoad(context,
+// (TopiaEntity) event.getEntity(), event.getState());
+// //TODO (thimel 20071213) On commente pour le moment @see(TopiaDAOHibernate#filterElements)
+// // } catch (TopiaVetoException tve) {
+// // //On ne fait pas de remontee d'exception
+// // vers Hibernate pour le preLoad, on va agir au niveau du DAO
+// // }
+// }
+// }
+//
+// @Override
+// public void onPostLoad(PostLoadEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// attachContext(event.getEntity(), context);
+// context.getFiresSupport().fireOnPostLoad(context,
+// (TopiaEntity) event.getEntity(), new Object[]{});
+// }
+// }
+//
+// /* Modification */
+//
+// @Override
+// public boolean onPreUpdate(PreUpdateEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// context.getFiresSupport().fireOnPreUpdate(context,
+// (TopiaEntity) event.getEntity(), event.getOldState());
+// }
+// return false;
+// }
+//
+// @Override
+// public void onPostUpdate(PostUpdateEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// context.getFiresSupport().fireOnPostUpdate(context,
+// (TopiaEntity) event.getEntity(), event.getState());
+// }
+// // FIXME indexation
+// // if (!(entity instanceof NotIndexable) && context.isIndexEnabled()) {
+// // context.getIndexEnginImplementor().recordForIndexation(id, event.getState());
+// // }
+// }
+//
+// /* Suppression */
+//
+// @Override
+// public boolean onPreDelete(PreDeleteEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// context.getFiresSupport().fireOnPreDelete(context,
+// (TopiaEntity) event.getEntity(),
+// event.getDeletedState());
+// }
+// return false;
+// }
+//
+// @Override
+// public void onPostDelete(PostDeleteEvent event) {
+// TopiaContextImplementor context = getContext(rootContext, event
+// .getSession());
+// if (context != null && event.getEntity() instanceof TopiaEntity) {
+// context.getFiresSupport().fireOnPostDelete(context,
+// (TopiaEntity) event.getEntity(),
+// event.getDeletedState());
+// }
+//// FIXME indexation
+//// if (!(entity instanceof NotIndexable) && context.isIndexEnabled()) {
+//// context.getIndexEnginImplementor().recordForIndexation(id, null);
+//// }
+// }
- @Override
- public boolean onPreInsert(PreInsertEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- context.getFiresSupport().fireOnPreCreate(context,
- (TopiaEntity) event.getEntity(), event.getState());
- }
- return false;
+
+ @PrePersist
+ public void onPreInsert(final Object entity) {
+ System.out.println("onPrePersist");
}
- @Override
- public void onPostInsert(PostInsertEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- context.getFiresSupport().fireOnPostCreate(context,
- (TopiaEntity) event.getEntity(), event.getState());
- }
+ @PostPersist
+ public void onPostInsert(final Object entity) {
+ System.out.println("onPostInsert");
}
- /* Chargement */
- @Override
- public void onPreLoad(PreLoadEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- // try {
- context.getFiresSupport().fireOnPreLoad(context,
- (TopiaEntity) event.getEntity(), event.getState());
- //TODO (thimel 20071213) On commente pour le moment @see(TopiaDAOHibernate#filterElements)
- // } catch (TopiaVetoException tve) {
- // //On ne fait pas de remontee d'exception
- // vers Hibernate pour le preLoad, on va agir au niveau du DAO
- // }
- }
+ @PostLoad
+ public void onPostLoad(final Object entity) {
+ System.out.println("onPostLoad");
}
- @Override
- public void onPostLoad(PostLoadEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- attachContext(event.getEntity(), context);
- context.getFiresSupport().fireOnPostLoad(context,
- (TopiaEntity) event.getEntity(), new Object[]{});
- }
- }
- /* Modification */
-
- @Override
- public boolean onPreUpdate(PreUpdateEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- context.getFiresSupport().fireOnPreUpdate(context,
- (TopiaEntity) event.getEntity(), event.getOldState());
- }
- return false;
+ @PreUpdate
+ public void onPreUpdate(final Object entity) {
+ System.out.println("onPreUpdate");
}
- @Override
- public void onPostUpdate(PostUpdateEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- context.getFiresSupport().fireOnPostUpdate(context,
- (TopiaEntity) event.getEntity(), event.getState());
- }
- // FIXME indexation
- // if (!(entity instanceof NotIndexable) && context.isIndexEnabled()) {
- // context.getIndexEnginImplementor().recordForIndexation(id, event.getState());
- // }
+ @PostUpdate
+ public void onPostUpdate(final Object entity) {
+ System.out.println("onPostUpdate");
}
- /* Suppression */
- @Override
- public boolean onPreDelete(PreDeleteEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- context.getFiresSupport().fireOnPreDelete(context,
- (TopiaEntity) event.getEntity(),
- event.getDeletedState());
- }
- return false;
+ @PreRemove
+ public void onPrRemove(final Object entity) {
+ System.out.println("onPreRemove");
}
- @Override
- public void onPostDelete(PostDeleteEvent event) {
- TopiaContextImplementor context = getContext(rootContext, event
- .getSession());
- if (context != null && event.getEntity() instanceof TopiaEntity) {
- context.getFiresSupport().fireOnPostDelete(context,
- (TopiaEntity) event.getEntity(),
- event.getDeletedState());
- }
-// FIXME indexation
-// if (!(entity instanceof NotIndexable) && context.isIndexEnabled()) {
-// context.getIndexEnginImplementor().recordForIndexation(id, null);
-// }
+ @PostRemove
+ public void onPostRemove(final Object entity) {
+ System.out.println("onPostRemove");
}
+
}
/**
Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java (rev 0)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaPersistenceProvider.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,57 @@
+package org.nuiton.topia.framework;
+
+import org.nuiton.topia.TopiaRuntimeException;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.spi.PersistenceProvider;
+import javax.persistence.spi.PersistenceUnitInfo;
+import javax.persistence.spi.ProviderUtil;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public abstract class TopiaPersistenceProvider implements PersistenceProvider {
+
+ public abstract EntityManagerFactory configureSpecific(String emName, Map map, Set<Class<?>> entities);
+
+ @Override
+ public EntityManagerFactory createEntityManagerFactory(String emName, Map map) {
+ System.out.println("createEntityManagerFactory " + emName);
+ if ("topia".equals(emName)) {
+ // Use PersistenceProvider of the underlying JPA library
+
+
+ map.put("javax.persistence.jdbc.driver", "org.h2.Driver");
+ map.put("javax.persistence.jdbc.url", "jdbc:h2:file:target/surefire-workdir/h2data");
+ map.put("javax.persistence.jdbc.user", "sa");
+ map.put("javax.persistence.jdbc.password", "");
+
+ Set<Class<?>> entityClasses = (Set<Class<?>>) map.get("topia.entities");
+ if (entityClasses == null) {
+ throw new TopiaRuntimeException("topia.entities list must be provided");
+ }
+
+ configureSpecific(emName, map, entityClasses);
+ }
+ return null;
+ }
+
+ @Override
+ public EntityManagerFactory createContainerEntityManagerFactory(PersistenceUnitInfo info, Map map) {
+ System.out.println("createContainerEntityManagerFactory " + info);
+ return null;
+ }
+
+ @Override
+ public ProviderUtil getProviderUtil() {
+ System.out.println("getProviderUtil");
+ return null;
+ }
+}
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -75,25 +75,25 @@
public O findSingleResult(TopiaContextImplementor tx) throws TopiaException {
final List<O> result = new ArrayList<O>();
- tx.getHibernate().doWork(new Work() {
-
- @Override
- public void execute(Connection connection) throws SQLException {
-
- PreparedStatement ps = prepareQuery(connection);
-
- try {
- ResultSet set = ps.executeQuery();
-
- findSingleResult(result, set);
-
- } catch (Exception e) {
- throw new TopiaRuntimeException("Could not execute query", e);
- } finally {
- ps.close();
- }
- }
- });
+// tx.getHibernate().doWork(new Work() {
+//
+// @Override
+// public void execute(Connection connection) throws SQLException {
+//
+// PreparedStatement ps = prepareQuery(connection);
+//
+// try {
+// ResultSet set = ps.executeQuery();
+//
+// findSingleResult(result, set);
+//
+// } catch (Exception e) {
+// throw new TopiaRuntimeException("Could not execute query", e);
+// } finally {
+// ps.close();
+// }
+// }
+// });
return result.isEmpty() ? null : result.get(0);
}
@@ -107,24 +107,24 @@
public List<O> findMultipleResult(TopiaContextImplementor tx) throws TopiaException {
final List<O> result = new ArrayList<O>();
- tx.getHibernate().doWork(new Work() {
-
- @Override
- public void execute(Connection connection) throws SQLException {
-
- PreparedStatement ps = prepareQuery(connection);
- try {
- ResultSet set = ps.executeQuery();
-
- findMultipleResult(result, set);
-
- } catch (Exception e) {
- throw new TopiaRuntimeException("Could not execute query", e);
- } finally {
- ps.close();
- }
- }
- });
+// tx.getHibernate().doWork(new Work() {
+//
+// @Override
+// public void execute(Connection connection) throws SQLException {
+//
+// PreparedStatement ps = prepareQuery(connection);
+// try {
+// ResultSet set = ps.executeQuery();
+//
+// findMultipleResult(result, set);
+//
+// } catch (Exception e) {
+// throw new TopiaRuntimeException("Could not execute query", e);
+// } finally {
+// ps.close();
+// }
+// }
+// });
return result;
}
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaUtil.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -26,14 +26,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Table;
-import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
-import org.hibernate.tool.hbm2ddl.TableMetadata;
+//import org.hibernate.cfg.Configuration;
+//import org.hibernate.connection.ConnectionProvider;
+//import org.hibernate.connection.ConnectionProviderFactory;
+//import org.hibernate.dialect.Dialect;
+//import org.hibernate.mapping.PersistentClass;
+//import org.hibernate.mapping.Table;
+//import org.hibernate.tool.hbm2ddl.DatabaseMetadata;
+//import org.hibernate.tool.hbm2ddl.TableMetadata;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaNotFoundException;
@@ -165,127 +165,127 @@
boolean exist = false;
- try {
- Configuration configuration =
- ((TopiaContextImplementor) tx).getHibernateConfiguration();
- PersistentClass classMapping =
- configuration.getClassMapping(entityName);
- if (classMapping == null) {
- if (log.isInfoEnabled()) {
- Iterator<?> itr = configuration.getClassMappings();
- while (itr.hasNext()) {
- log.info("available mapping " + itr.next());
- }
- }
- throw new IllegalArgumentException(
- "could not find entity with name " + entityName);
- }
- Table testTable = classMapping.getTable();
+// try {
+// Configuration configuration =
+// ((TopiaContextImplementor) tx).getHibernateConfiguration();
+// PersistentClass classMapping =
+// configuration.getClassMapping(entityName);
+// if (classMapping == null) {
+// if (log.isInfoEnabled()) {
+// Iterator<?> itr = configuration.getClassMappings();
+// while (itr.hasNext()) {
+// log.info("available mapping " + itr.next());
+// }
+// }
+// throw new IllegalArgumentException(
+// "could not find entity with name " + entityName);
+// }
+// Table testTable = classMapping.getTable();
+//
+// if (testTable == null) {
+// throw new IllegalArgumentException(
+// "could not find entity with name " + entityName);
+// }
+// ConnectionProvider connectionProvider =
+// ConnectionProviderFactory.newConnectionProvider(
+// configuration.getProperties());
+//
+// Dialect dialect = Dialect.getDialect(configuration.getProperties());
+//
+// Connection connection = null;
+// try {
+// connection = connectionProvider.getConnection();
+//
+// DatabaseMetadata meta = new DatabaseMetadata(connection, dialect);
+//
+// TableMetadata tmd = meta.getTableMetadata(
+// testTable.getName(), testTable.getSchema(),
+// testTable.getCatalog(), testTable.isQuoted());
+//
+// if (tmd != null) {
+// //table exist
+// exist = true;
+// }
+// } finally {
+// if (connection != null) {
+// connection.close();
+// }
+// }
+//
+// } catch (SQLException e) {
+// log.error("Cant connect to database", e);
+// } catch (TopiaNotFoundException e) {
+// log.error("Cant connect to database", e);
+// }
- if (testTable == null) {
- throw new IllegalArgumentException(
- "could not find entity with name " + entityName);
- }
- ConnectionProvider connectionProvider =
- ConnectionProviderFactory.newConnectionProvider(
- configuration.getProperties());
-
- Dialect dialect = Dialect.getDialect(configuration.getProperties());
-
- Connection connection = null;
- try {
- connection = connectionProvider.getConnection();
-
- DatabaseMetadata meta = new DatabaseMetadata(connection, dialect);
-
- TableMetadata tmd = meta.getTableMetadata(
- testTable.getName(), testTable.getSchema(),
- testTable.getCatalog(), testTable.isQuoted());
-
- if (tmd != null) {
- //table exist
- exist = true;
- }
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
-
- } catch (SQLException e) {
- log.error("Cant connect to database", e);
- } catch (TopiaNotFoundException e) {
- log.error("Cant connect to database", e);
- }
-
return exist;
}
- /**
- * Test si une entite donnee correspondant a une configuration existe en
- * base.
- *
- * @param configuration la configuration hibernate
- * @param entityName le nom de l'entite a tester
- * @return <tt>true</tt> si le schema de la table existe
- */
- public static boolean isSchemaExist(Configuration configuration,
- String entityName) {
+// /**
+// * Test si une entite donnee correspondant a une configuration existe en
+// * base.
+// *
+// * @param configuration la configuration hibernate
+// * @param entityName le nom de l'entite a tester
+// * @return <tt>true</tt> si le schema de la table existe
+// */
+// public static boolean isSchemaExist(Configuration configuration,
+// String entityName) {
+//
+// boolean exist = false;
+//
+// try {
+// PersistentClass classMapping =
+// configuration.getClassMapping(entityName);
+// if (classMapping == null) {
+// if (log.isInfoEnabled()) {
+// Iterator<?> itr = configuration.getClassMappings();
+// while (itr.hasNext()) {
+// log.info("available mapping " + itr.next());
+// }
+// }
+// throw new IllegalArgumentException(
+// "could not find entity with name " + entityName);
+// }
+// Table testTable = classMapping.getTable();
+//
+// if (testTable == null) {
+// throw new IllegalArgumentException(
+// "could not find entity with name " + entityName);
+// }
+// ConnectionProvider connectionProvider =
+// ConnectionProviderFactory.newConnectionProvider(
+// configuration.getProperties());
+//
+// Dialect dialect = Dialect.getDialect(configuration.getProperties());
+//
+// Connection connection = null;
+// try {
+// connection = connectionProvider.getConnection();
+//
+// DatabaseMetadata meta = new DatabaseMetadata(connection, dialect);
+//
+// TableMetadata tmd = meta.getTableMetadata(
+// testTable.getName(), testTable.getSchema(),
+// testTable.getCatalog(), testTable.isQuoted());
+//
+// if (tmd != null) {
+// //table exist
+// exist = true;
+// }
+// } finally {
+// if (connection != null) {
+// connection.close();
+// }
+// }
+//
+// } catch (SQLException e) {
+// log.error("Cant connect to database", e);
+// }
+//
+// return exist;
+// }
- boolean exist = false;
-
- try {
- PersistentClass classMapping =
- configuration.getClassMapping(entityName);
- if (classMapping == null) {
- if (log.isInfoEnabled()) {
- Iterator<?> itr = configuration.getClassMappings();
- while (itr.hasNext()) {
- log.info("available mapping " + itr.next());
- }
- }
- throw new IllegalArgumentException(
- "could not find entity with name " + entityName);
- }
- Table testTable = classMapping.getTable();
-
- if (testTable == null) {
- throw new IllegalArgumentException(
- "could not find entity with name " + entityName);
- }
- ConnectionProvider connectionProvider =
- ConnectionProviderFactory.newConnectionProvider(
- configuration.getProperties());
-
- Dialect dialect = Dialect.getDialect(configuration.getProperties());
-
- Connection connection = null;
- try {
- connection = connectionProvider.getConnection();
-
- DatabaseMetadata meta = new DatabaseMetadata(connection, dialect);
-
- TableMetadata tmd = meta.getTableMetadata(
- testTable.getName(), testTable.getSchema(),
- testTable.getCatalog(), testTable.isQuoted());
-
- if (tmd != null) {
- //table exist
- exist = true;
- }
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
-
- } catch (SQLException e) {
- log.error("Cant connect to database", e);
- }
-
- return exist;
- }
-
/**
* Test if the db associated to the given {@code configuration} contaisn any of
* the dealed entities.
@@ -295,63 +295,63 @@
* {@code false} otherwise.
* @since 2.5.3
*/
- public static boolean isSchemaEmpty(Configuration configuration) {
+ public static boolean isSchemaEmpty(/*Configuration configuration*/) {
- try {
+// try {
+//
+// ConnectionProvider connectionProvider =
+// ConnectionProviderFactory.newConnectionProvider(
+// configuration.getProperties());
+//
+// Dialect dialect = Dialect.getDialect(configuration.getProperties());
+//
+// Connection connection = null;
+// try {
+// connection = connectionProvider.getConnection();
+//
+// DatabaseMetadata meta = new DatabaseMetadata(connection, dialect);
+//
+// Iterator<?> itr = configuration.getClassMappings();
+// while (itr.hasNext()) {
+// PersistentClass classMapping = (PersistentClass) itr.next();
+// Table testTable = classMapping.getTable();
+//
+// if (testTable == null) {
+// throw new IllegalArgumentException(
+// "could not find entity with name " +
+// classMapping.getClassName());
+// }
+//
+//
+// TableMetadata tmd = meta.getTableMetadata(
+// testTable.getName(), testTable.getSchema(),
+// testTable.getCatalog(), testTable.isQuoted());
+//
+// if (tmd != null) {
+// //table exist
+//
+//
+// if (log.isDebugEnabled()) {
+// log.debug("Existing table found " +
+// testTable.getName() + " for entity " +
+// classMapping.getClassName() +
+// ", db is not empty.");
+// }
+//
+// return false;
+// }
+// }
+//
+// } finally {
+// if (connection != null) {
+// connection.close();
+// }
+// }
+//
+// } catch (SQLException e) {
+// log.error("Cant connect to database", e);
+// }
- ConnectionProvider connectionProvider =
- ConnectionProviderFactory.newConnectionProvider(
- configuration.getProperties());
-
- Dialect dialect = Dialect.getDialect(configuration.getProperties());
-
- Connection connection = null;
- try {
- connection = connectionProvider.getConnection();
-
- DatabaseMetadata meta = new DatabaseMetadata(connection, dialect);
-
- Iterator<?> itr = configuration.getClassMappings();
- while (itr.hasNext()) {
- PersistentClass classMapping = (PersistentClass) itr.next();
- Table testTable = classMapping.getTable();
-
- if (testTable == null) {
- throw new IllegalArgumentException(
- "could not find entity with name " +
- classMapping.getClassName());
- }
-
-
- TableMetadata tmd = meta.getTableMetadata(
- testTable.getName(), testTable.getSchema(),
- testTable.getCatalog(), testTable.isQuoted());
-
- if (tmd != null) {
- //table exist
-
-
- if (log.isDebugEnabled()) {
- log.debug("Existing table found " +
- testTable.getName() + " for entity " +
- classMapping.getClassName() +
- ", db is not empty.");
- }
-
- return false;
- }
- }
-
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
-
- } catch (SQLException e) {
- log.error("Cant connect to database", e);
- }
-
return true;
}
@@ -361,7 +361,10 @@
* @param config of hibernate
* @return schema name
*/
- public static String getSchemaName(Configuration config) {
- return config.getProperty(TopiaContextFactory.CONFIG_DEFAULT_SCHEMA);
+ public static String getSchemaName() {
+ return "azerty";
}
+// public static String getSchemaName(Configuration config) {
+// return config.getProperty(TopiaContextFactory.CONFIG_DEFAULT_SCHEMA);
+// }
}
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDAOTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDAOTransformer.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDAOTransformer.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -611,12 +611,13 @@
body.append(""
/*{
{
- List<<%=attrType%>> list = getContext().getHibernate().createSQLQuery(
+ List<<%=attrType%>> list = getContext().getHibernate().createNativeQuery(
"SELECT main.topiaid " +
"from <%=attrClassifierDBName%> main, <%=attrJoinTableName%> secondary " +
"where main.topiaid=secondary.<%=attrDBName%>" +
" and secondary.<%=attrReverseDBName%>='" + entity.getTopiaId() + "'")
- .addEntity("main", <%=providerFQN%>(<%=attrType%>.class)).list();
+ //.addEntity("main", <%=providerFQN%>(<%=attrType%>.class))
+ .getResultList();
for (<%=attrType%> item : list) {
item.<%=removeName%>(entity);
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 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -489,7 +489,7 @@
if (attrIsEnumeration) {
/*{>
<%=prefix%> <type name="javax.persistence.EnumType">
-<%=prefix%> <param name="<%=javax.persistence.EnumType.ENUM%>"><%=attrType%></param>}*/
+<%=prefix%> <param name="<%="javax.persistence.EnumType.ENUM"%>"><%=attrType%></param>}*/
// if the user tuned the model to use name instead of
// ordinal to store the values, we must add a clause
@@ -498,7 +498,7 @@
String enumSQLType = String.valueOf(Types.VARCHAR);
/*{
<%=prefix%> <!-- using name instead of ordinal to store enumeration value -->
-<%=prefix%> <param name="<%=javax.persistence.EnumType.TYPE%>"><%=enumSQLType%></param>}*/
+<%=prefix%> <param name="<%="javax.persistence.EnumType.TYPE"%>"><%=enumSQLType%></param>}*/
}
/*{
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -512,15 +512,15 @@
// it's more easy than create different for all persistence
EntityType<E> meta = getClassMetadata();
// TODO AThimel 07/05/2012 See if it is possible to do it with EntityType
- if (meta.hasNaturalIdentifier()) {
+// if (meta.hasNaturalIdentifier()) {
E result = findByProperties(keys);
return result;
- }
+// }
} catch (PersistenceException eee) {
throw new TopiaException(eee);
}
- throw new TopiaException("La classe " + entityClass.getName()
- + " n'a pas de cle primaire naturelle");
+// throw new TopiaException("La classe " + entityClass.getName()
+// + " n'a pas de cle primaire naturelle");
}
@@ -532,23 +532,23 @@
try {
EntityType<E> meta = getClassMetadata();
// TODO AThimel 07/05/2012 See if it is possible to do it with EntityType
- if (meta.hasNaturalIdentifier()) {
- int[] ikeys = meta.getNaturalIdentifierProperties();
- String[] pnames = meta.getPropertyNames();
+// if (meta.hasNaturalIdentifier()) {
+// int[] ikeys = meta.getNaturalIdentifierProperties();
+// String[] pnames = meta.getPropertyNames();
Map<String, Object> keys = new HashMap<String, Object>();
- for (int ikey : ikeys) {
- keys.put(pnames[ikey], k[ikey]);
- }
+// for (int ikey : ikeys) {
+// keys.put(pnames[ikey], k[ikey]);
+// }
E result = findByProperties(keys);
return result;
- }
+// }
} catch (PersistenceException eee) {
throw new TopiaException(eee);
}
- throw new TopiaException("La classe " + entityClass.getName()
- + " n'a pas de cle primaire naturelle");
+// throw new TopiaException("La classe " + entityClass.getName()
+// + " n'a pas de cle primaire naturelle");
}
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -35,6 +35,7 @@
//import org.hibernate.SQLQuery;
//import org.hibernate.jdbc.Work;
+import javax.persistence.Query;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
@@ -216,7 +217,8 @@
} catch (TopiaException e) {
// the sequence's name does not exist in database, so it is a grammer exception
- if (e.getCause() != null && e.getCause().getClass() == SQLGrammarException.class) {
+// if (e.getCause() != null && e.getCause().getClass() == SQLGrammarException.class) {
+ if (e.getCause() != null) {
return false;
}
throw e;
@@ -329,9 +331,10 @@
BigInteger size = defaultSize;
if (ctxt != null) {
try {
- SQLQuery query = ((TopiaContextImpl) ctxt).getHibernate().createSQLQuery(sql);
- size = (BigInteger) query.list().get(0);
- } catch (SQLGrammarException e) {
+ Query query = ((TopiaContextImpl) ctxt).getHibernate().createNativeQuery(sql);
+ size = (BigInteger) query.getResultList().get(0);
+// } catch (SQLGrammarException e) {
+ } catch (Exception e) {
// could not obtain sequence
throw new TopiaException(e);
}
@@ -342,15 +345,7 @@
protected void doSQLWork(TopiaContext ctxt, final String sql) throws TopiaException {
if (ctxt != null) {
//ctxt.beginTransaction();
- ((TopiaContextImpl) ctxt).getHibernate().doWork(new Work() {
- public void execute(Connection connection) throws SQLException {
- if (log.isDebugEnabled()) {
- log.debug(sql);
- }
- Statement stmt = connection.createStatement();
- stmt.execute(sql);
- }
- });
+ ctxt.executeSQL(sql);
//ctxt.commitTransaction();
}
}
Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java
===================================================================
--- trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaConnectionProviderHardCoded.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -28,10 +28,8 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.util.PropertiesHelper;
-import org.hibernate.util.ReflectHelper;
+import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
+import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -66,18 +64,23 @@
private static final Log log =
LogFactory.getLog(TopiaConnectionProviderHardCoded.class);
- @Override
+ public TopiaConnectionProviderHardCoded() {
+ System.out.println("created");
+ }
public void configure(Properties props) throws HibernateException {
String driverClass = props.getProperty(Environment.DRIVER);
- poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
+// poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
+ poolSize = 20; //default pool size 20
log.info("Using Hibernate built-in connection pool (not for production use!)");
log.info("Hibernate connection pool size: " + poolSize);
- autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
+// autocommit = PropertiesHelper.getBoolean(Environment.AUTOCOMMIT, props);
+ autocommit = true;
log.info("autocommit mode: " + autocommit);
- isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
+// isolation = PropertiesHelper.getInteger(Environment.ISOLATION, props);
+ isolation = 0;
if (isolation != null)
log.info("JDBC isolation level: " + Environment.isolationLevelToString(isolation));
@@ -88,13 +91,13 @@
// trying via forName() first to be as close to DriverManager's semantics
Class.forName(driverClass);
} catch (ClassNotFoundException cnfe) {
- try {
- ReflectHelper.classForName(driverClass);
- } catch (ClassNotFoundException e) {
- String msg = "JDBC Driver class not found: " + driverClass;
- log.error(msg, e);
- throw new HibernateException(msg, e);
- }
+// try {
+// ReflectHelper.classForName(driverClass);
+// } catch (ClassNotFoundException e) {
+// String msg = "JDBC Driver class not found: " + driverClass;
+// log.error(msg, e);
+// throw new HibernateException(msg, e);
+// }
}
}
@@ -113,14 +116,14 @@
// throw new HibernateException(msg);
// }
- connectionProps = ConnectionProviderFactory.getConnectionProperties(props);
+ connectionProps = ConnectionProviderInitiator.getConnectionProperties(props);
log.info("using driver: " + driverClass + " at URL: " + url);
// if debug level is enabled, then log the password, otherwise mask it
if (log.isDebugEnabled()) {
log.info("connection properties: " + connectionProps);
} else if (log.isInfoEnabled()) {
- log.info("connection properties: " + PropertiesHelper.maskOut(connectionProps, "password"));
+// log.info("connection properties: " + PropertiesHelper.maskOut(connectionProps, "password"));
}
}
@@ -206,4 +209,14 @@
public boolean supportsAggressiveRelease() {
return false;
}
+
+ @Override
+ public boolean isUnwrappableAs(Class unwrapType) {
+ return false;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> unwrapType) {
+ return null;
+ }
}
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 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topia/framework/TopiaContextImplTest.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -26,9 +26,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.h2.Driver;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.mapping.PersistentClass;
+//import org.hibernate.cfg.Configuration;
+//import org.hibernate.mapping.PersistentClass;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -38,7 +37,6 @@
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaDatabase;
import org.nuiton.topia.TopiaNotFoundException;
-import org.nuiton.topiatest.persistence.Entity1;
import org.nuiton.topiatest.persistence.Entity1Impl;
import org.nuiton.topiatest.service.FakeService;
import org.nuiton.topiatest.service.TestService;
@@ -252,23 +250,6 @@
// Note : existing test is already done for concurrency problem on
// getChildContext(). Go to : http://www.nuiton.org/repositories/browse/sandbox/testTopiaPostgresError/tr…
}
-//
-// @Test
-// public void testCreateSchema() throws Exception {
-// }
-//
-// @Test
-// public void testShowCreateSchema() throws Exception {
-// }
-//
-// @Test
-// public void testUpdateSchema() throws Exception {
-// }
-//
-// @Test
-// public void testGetHibernate() throws Exception {
-// }
-//
@Test
public void testGetHibernateFactory() throws Exception {
@@ -313,11 +294,11 @@
persistenceDir.getAbsolutePath());
context.config = properties;
- Configuration test1 = context.getHibernateConfiguration();
- PersistentClass persistentClass =
- test1.getClassMapping(Entity1Impl.class.getName());
- Assert.assertNotNull(persistentClass);
- Assert.assertEquals(Entity1.class, persistentClass.getProxyInterface());
+// Configuration test1 = context.getHibernateConfiguration();
+// PersistentClass persistentClass =
+// test1.getClassMapping(Entity1Impl.class.getName());
+// Assert.assertNotNull(persistentClass);
+// Assert.assertEquals(Entity1.class, persistentClass.getProxyInterface());
// for (Iterator<RootClass> it = test1.getClassMappings(); it.hasNext();) {
// RootClass o = it.next();
@@ -337,10 +318,10 @@
Entity1Impl.class.getName());
context.config = properties;
- Configuration test2 = context.getHibernateConfiguration();
- persistentClass = test2.getClassMapping(Entity1Impl.class.getName());
- Assert.assertNotNull(persistentClass);
- Assert.assertEquals(Entity1.class, persistentClass.getProxyInterface());
+// Configuration test2 = context.getHibernateConfiguration();
+// persistentClass = test2.getClassMapping(Entity1Impl.class.getName());
+// Assert.assertNotNull(persistentClass);
+// Assert.assertEquals(Entity1.class, persistentClass.getProxyInterface());
if (log.isInfoEnabled()) {
log.info("test 3 : add properties from file");
@@ -356,10 +337,10 @@
resourcesDir + File.separator + "TopiaContextImpl.properties");
context.config = properties;
- Configuration test3 = context.getHibernateConfiguration();
- Assert.assertEquals(
- test3.getProperty("hibernate.connection.driver_class"),
- Driver.class.getName());
+// Configuration test3 = context.getHibernateConfiguration();
+// Assert.assertEquals(
+// test3.getProperty("hibernate.connection.driver_class"),
+// Driver.class.getName());
// Note : maybe add a test to load classes from services
}
@@ -460,93 +441,4 @@
// }
-//
-// @Test
-// public void testGetHibernateConfiguration() throws Exception {
-// }
-//
-// @Test
-// public void testGetDAO() throws Exception {
-// }
-//
-// @Test
-// public void testBeginTransaction() throws Exception {
-// }
-//
-// @Test
-// public void testCommitTransaction() throws Exception {
-// }
-//
-// @Test
-// public void testRollbackTransaction() throws Exception {
-// }
-//
-// @Test
-// public void testCloseContext() throws Exception {
-// }
-//
-// @Test
-// public void testIsClosed() throws Exception {
-// }
-//
-// @Test
-// public void testFindByTopiaId() throws Exception {
-// }
-//
-// @Test
-// public void testFind() throws Exception {
-// }
-//
-// @Test
-// public void testFind2() throws Exception {
-// }
-//
-// @Test
-// public void testExecute() throws Exception {
-// }
-//
-// @Test
-// public void testAdd() throws Exception {
-// }
-//
-// @Test
-// public void testImportXML() throws Exception {
-// }
-//
-// @Test
-// public void testExportXML() throws Exception {
-// }
-//
-//
-// @Test
-// public void testReplicateEntity() throws Exception {
-// }
-//
-// @Test
-// public void testReplicateEntities() throws Exception {
-// }
-//
-// @Test
-// public void testGetFiresSupport() throws Exception {
-// }
-//
-// @Test
-// public void testBackup() throws Exception {
-// }
-//
-// @Test
-// public void testRestore() throws Exception {
-// }
-//
-// @Test
-// public void testClear() throws Exception {
-// }
-//
-// @Test
-// public void testGetPersistenceClasses() throws Exception {
-// }
-//
-// @Test
-// public void testIsSchemaExist() throws Exception {
-// }
}
Modified: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java
===================================================================
--- trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/NaturalIdTest.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -27,7 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.PropertyValueException;
+//import org.hibernate.PropertyValueException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
@@ -86,15 +86,15 @@
TopiaTestDAOHelper.getNaturalizedEntityDAO(transaction);
// Exception will be throw
- try {
+// try {
dao.create();
transaction.commitTransaction();
// Note : this is possible to create an empty entity if the type
// is primitive like 'int' which have a default value of '0'
- } catch (PropertyValueException eee) {
- Assert.assertEquals("naturalIdNotNull", eee.getPropertyName());
- }
+// } catch (PropertyValueException eee) {
+// Assert.assertEquals("naturalIdNotNull", eee.getPropertyName());
+// }
}
@Test
Deleted: trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
===================================================================
--- trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -1,89 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.topia.persistence;
-
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaDatabase;
-import org.nuiton.topia.TopiaTestDAOHelper;
-import org.nuiton.topia.test.entities.Person;
-import org.nuiton.topia.test.entities.PersonDAO;
-
-import java.util.List;
-
-/**
- * Test on {@link TopiaDAO}.
- * <p/>
- * Last update : $Date$
- * By : $Author$
- *
- * @author chatellier
- * @version $Revision$
- */
-public class TopiaDAOTest {
-
- @Rule
- public final TopiaDatabase db = new TopiaDatabase();
-
- /**
- * Test de creer une entité et de verifier qu'elle est
- * présente dans la persistence au sein de la transaction.
- *
- * @throws Exception if any exception while test
- */
- @Test
- public void testCreateAndFindInTransaction() throws Exception {
-
- TopiaContext context = db.beginTransaction();
-
- PersonDAO personDAO = TopiaTestDAOHelper.getPersonDAO(context);
-
- // appel 1 find all
- Person person = personDAO.create(Person.PROPERTY_NAME, "toto");
- List<Person> allPerson = personDAO.findAll();
- Assert.assertEquals(1, allPerson.size());
- context.commitTransaction();
-
- // recherce la personne créée dans la même transaction
- Person person2 = personDAO.create(Person.PROPERTY_NAME, "titi");
- allPerson = personDAO.findAll();
- Assert.assertEquals(2, allPerson.size());
- Assert.assertThat(allPerson, JUnitMatchers.hasItem(person2));
-
- context.rollbackTransaction();
-
- // meme test apres roolback
- Person person3 = personDAO.create(Person.PROPERTY_NAME, "tata");
- allPerson = personDAO.findAll();
- Assert.assertEquals(2, allPerson.size());
- Assert.assertThat(allPerson, JUnitMatchers.hasItem(person3));
-
- context.commitTransaction();
- }
-}
Deleted: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Gender.java
===================================================================
--- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Gender.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Gender.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -1,29 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topiatest;
-
-public enum Gender {
- MALE, FEMALE
-}
Deleted: trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Title.java
===================================================================
--- trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Title.java 2012-05-07 15:52:54 UTC (rev 2444)
+++ trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Title.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -1,37 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-package org.nuiton.topiatest;
-
-/**
- * To test http://nuiton.org/issues/1732.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @since 2.6.2
- */
-public enum Title {
- Mr,
- Madam,
- Other
-}
Added: trunk/topia-persistence/src/test/resources/META-INF/persistence2.xml
===================================================================
--- trunk/topia-persistence/src/test/resources/META-INF/persistence2.xml (rev 0)
+++ trunk/topia-persistence/src/test/resources/META-INF/persistence2.xml 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+ <persistence-unit name="topia" transaction-type="RESOURCE_LOCAL">
+ <class>org.nuiton.topia.test.entities.PersonImpl</class>
+ <exclude-unlisted-classes>false</exclude-unlisted-classes>
+ <properties>
+ <property name="hibernate.archive.autodetection" value="class"/>
+ <property name="hibernate.connection.driver_class" value="org.h2.Driver"/>
+ <property name="hibernate.connection.url" value="jdbc:h2:file:target/surefire-workdir/h2data"/>
+ <property name="hibernate.connection.username" value="sa"/>
+ <property name="hibernate.connection.password" value=""/>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
\ No newline at end of file
Property changes on: trunk/topia-persistence-hibernate
___________________________________________________________________
Added: svn:ignore
+ *.iml
*.ipr
*.iws
target
.classpath
.settings
.project
Added: trunk/topia-persistence-hibernate/LICENSE.txt
===================================================================
Added: trunk/topia-persistence-hibernate/README.txt
===================================================================
Added: trunk/topia-persistence-hibernate/changelog.txt
===================================================================
Added: trunk/topia-persistence-hibernate/pom.xml
===================================================================
--- trunk/topia-persistence-hibernate/pom.xml (rev 0)
+++ trunk/topia-persistence-hibernate/pom.xml 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,312 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>topia</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence-hibernate</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-ehcache</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- BD H2 for testing -->
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>ToPIA :: Persistence :: Hibernate</name>
+ <description>Hibernate based persistence module</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <build>
+
+ <testResources>
+
+ <testResource>
+ <directory>${maven.gen.dir}/test-java</directory>
+ <includes>
+ <include>**/*.hbm.xml</include>
+ </includes>
+ </testResource>
+
+ <testResource>
+ <directory>${maven.src.dir}/test/resources</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+
+ <testResource>
+ <directory>${maven.src.dir}/test/java</directory>
+ <includes>
+ <include>**/*.hbm.xml</include>
+ </includes>
+ </testResource>
+
+ </testResources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.processor</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ <!-- restrict parsing beacause this is expensive -->
+ <!-- if you want to parse more, add your package in includes -->
+ <configuration>
+ <treateDefaultEntry>false</treateDefaultEntry>
+ <entries>
+ <entry>
+ <basedir>${maven.src.dir}/main/java</basedir>
+ <includes>
+ <include>org/nuiton/topia/framework/*.java</include>
+ </includes>
+ </entry>
+ </entries>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- expose new plexus components -->
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <configuration>
+
+ </configuration>
+ <executions>
+ <execution>
+ <id>Test Generator</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <testPhase>true</testPhase>
+ <templates>
+ org.nuiton.topia.generator.TopiaMetaTransformer,
+ org.nuiton.eugene.java.JavaInterfaceTransformer,
+ org.nuiton.eugene.java.JavaBeanTransformer,
+ org.nuiton.topia.generator.EntityDTOTransformer,
+ org.nuiton.topia.generator.BinderHelperTransformer,
+ org.nuiton.topia.generator.QueryHelperTransformer
+ </templates>
+ <fullPackagePath>org.nuiton.topia</fullPackagePath>
+ <defaultPackage>org.nuiton.topia</defaultPackage>
+ </configuration>
+ <goals>
+ <goal>smart-generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- expose tests -->
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <profiles>
+
+ <!-- perform only on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+
+ <!-- always expose tests source jar -->
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test-sources</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- always expose tests javadoc jar -->
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test-javadoc</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>run-its</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ <!-- Reuse this when MINVOKER-107 will be done (syas invoker 1.6 -->
+ <!--name>maven.test.skip</name>
+ <value>!false</value-->
+ </property>
+ </activation>
+ <build>
+ <defaultGoal>integration-test</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <localRepositoryPath>${basedir}/target/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
+ <debug>${maven.verbose}</debug>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ <phase>integration-test</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- reporting at release time -->
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <version>1.3.8</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ </profiles>
+
+</project>
Added: trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/hibernate/TopiaHibernatePersistenceProvider.java
===================================================================
--- trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/hibernate/TopiaHibernatePersistenceProvider.java (rev 0)
+++ trunk/topia-persistence-hibernate/src/main/java/org/nuiton/topia/persistence/hibernate/TopiaHibernatePersistenceProvider.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,81 @@
+package org.nuiton.topia.persistence.hibernate;
+
+import org.hibernate.ejb.Ejb3Configuration;
+import org.hibernate.ejb.packaging.NamedInputStream;
+import org.hibernate.ejb.packaging.PersistenceMetadata;
+import org.nuiton.topia.framework.TopiaPersistenceProvider;
+
+import javax.persistence.EntityManagerFactory;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ */
+public class TopiaHibernatePersistenceProvider extends TopiaPersistenceProvider {
+
+ @Override
+ public EntityManagerFactory configureSpecific(String entityManagerName, Map map, Set<Class<?>> entities) {
+
+ map.put("hibernate.connection.driver", "org.h2.Driver");
+ map.put("hibernate.connection.url", "jdbc:h2:file:target/surefire-workdir/h2data");
+ map.put("hibernate.connection.user", "sa");
+ map.put("hibernate.connection.password", "");
+
+ map.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
+ map.put("hibernate.hbm2ddl.auto", "create-drop");
+ map.put("hibernate.show_sql", "true");
+
+// map.put("hibernate.connection.provider_class", "org.nuiton.topia.framework.TopiaConnectionProviderHardCoded");
+// Set<Class<?>> entities = new HashSet<Class<?>>();
+// entities.add(PersonImpl.class);
+// entities.add(PetImpl.class);
+// entities.add(RaceImpl.class);
+// entities.add(NaturalizedEntityImpl.class);
+// entities.add(CompanyImpl.class);
+// entities.add(EmployeImpl.class);
+// entities.add(PersonneImpl.class);
+// entities.add(DepartmentImpl.class);
+// entities.add(BillImpl.class);
+// entities.add(ProductImpl.class);
+// entities.add(StoreImpl.class);
+// entities.add(Contact2Impl.class);
+// entities.add(Party2Impl.class);
+// entities.add(Telephone2Impl.class);
+// entities.add(AddressImpl.class);
+// entities.add(ExtraDAOEntityImpl.class);
+// entities.add(GeneralizedNaturalizedEntityImpl.class);
+// entities.add(QueriedEntityImpl.class);
+// entities.add(TypeImpl.class);
+
+ List<String> entitiesNames = new ArrayList<String>();
+ List<NamedInputStream> entitiesHbmFiles = new ArrayList<NamedInputStream>();
+
+ for (Class<?> entityClass : entities) {
+ String entityClassName = entityClass.getName();
+ entitiesNames.add(entityClassName);
+
+ String entityNameSlashed = entityClassName.replaceAll("[.]", "/");
+
+ InputStream entityHbmIS = TopiaPersistenceProvider.class.getResourceAsStream("/" + entityNameSlashed + ".hbm.xml");
+ NamedInputStream entityHbmNIS = new NamedInputStream(entityClassName, entityHbmIS);
+
+ entitiesHbmFiles.add(entityHbmNIS);
+ }
+
+
+ Ejb3Configuration cfg = new Ejb3Configuration();
+ PersistenceMetadata metadata = new PersistenceMetadata();
+ metadata.setName(entityManagerName);
+
+ metadata.setClasses(entitiesNames);
+ metadata.setHbmfiles(entitiesHbmFiles);
+
+ Ejb3Configuration configured = cfg.configure(metadata, map);
+ return configured != null ? configured.buildEntityManagerFactory() : null;
+ }
+}
Added: trunk/topia-persistence-hibernate/src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider
===================================================================
--- trunk/topia-persistence-hibernate/src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider (rev 0)
+++ trunk/topia-persistence-hibernate/src/main/resources/META-INF/services/javax.persistence.spi.PersistenceProvider 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1 @@
+org.nuiton.topia.framework.TopiaHibernatePersistenceProvider
Added: trunk/topia-persistence-hibernate/src/main/resources/i18n/topia-persistence-hibernate_fr_FR.properties
===================================================================
Copied: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java (from rev 2443, trunk/topia-persistence/src/test/java/org/nuiton/topia/TestHelper.java)
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java (rev 0)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,158 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+//import org.hibernate.cfg.Environment;
+import org.junit.Ignore;
+import org.nuiton.util.FileUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Helper for all topia tests.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.5
+ */
+@Ignore
+// this is not a test :)
+public class TestHelper {
+
+ private static final Log log = LogFactory.getLog(TestHelper.class);
+
+ protected static File testBasedir;
+
+ protected static File targetdir;
+
+ protected static File dirDatabase;
+
+ public static final String DEFAULT_CONFIGURATION_LOCATION = "/TopiaContextImpl.properties";
+
+ public static File getTestWorkdir() {
+ if (testBasedir == null) {
+ String base = System.getProperty("java.io.tmpdir");
+ if (base == null || base.isEmpty()) {
+ base = new File("").getAbsolutePath();
+ }
+ testBasedir = new File(base);
+ log.info("basedir for test " + testBasedir);
+ }
+ return testBasedir;
+ }
+
+ public static File getTestBasedir(Class<?> testClass) throws IOException {
+ File dir = getTestWorkdir();
+ File result = new File(dir, testClass.getName());
+ if (result.exists()) {
+
+ // when calling this method (always in a BeforeClass method), we wants
+ // to clean the directory, this is a new build
+ FileUtil.deleteRecursively(result);
+ }
+
+ // always create the directory
+ FileUtil.createDirectoryIfNecessary(result);
+ return result;
+ }
+
+ public static TopiaContext initTopiaContext(File testDirectory,
+ String dbname)
+ throws IOException, TopiaNotFoundException {
+
+
+ TopiaContext topiaContext = initTopiaContext(
+ testDirectory,
+ DEFAULT_CONFIGURATION_LOCATION,
+ dbname
+ );
+ return topiaContext;
+ }
+
+ public static TopiaContext initTopiaContext(File testDirectory,
+ String dbPropertiesPath,
+ String dbname)
+ throws IOException, TopiaNotFoundException {
+
+ Properties configuration = initTopiaContextConfiguration(
+ testDirectory,
+ dbPropertiesPath,
+ dbname);
+ return TopiaContextFactory.getContext(configuration);
+ }
+
+ public static Properties initTopiaContextConfiguration(File testDirectory,
+ String dbPropertiesPath,
+ String dbname)
+ throws IOException {
+
+ Properties configuration = loadHibernateConfiguration(dbPropertiesPath);
+
+ // make sure we always use a different directory
+
+ String dbPath = getDbName(testDirectory, dbname);
+
+ if (log.isInfoEnabled()) {
+ log.info("dbPath = " + dbPath);
+ }
+ configuration.setProperty(
+ TopiaContextFactory.CONFIG_URL,
+ "jdbc:h2:file:" + dbPath);
+
+ return configuration;
+ }
+
+ public static Properties loadHibernateConfiguration(String dbPropertiesPath) throws IOException {
+ InputStream stream = TestHelper.class.getResourceAsStream(dbPropertiesPath);
+
+ Properties configuration = new Properties();
+
+ configuration.load(stream);
+ configuration.setProperty(
+ TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
+ TopiaTestDAOHelper.getImplementationClassesAsString());
+ return configuration;
+ }
+
+ public static String getDbName(File testDirectory, String dbname) {
+ return new File(testDirectory,
+ dbname + '_' + System.nanoTime()).getAbsolutePath();
+ }
+
+ public static Properties initTopiaContextConfiguration(File testDirectory,
+ String dbname)
+ throws IOException {
+
+ return initTopiaContextConfiguration(
+ testDirectory,
+ DEFAULT_CONFIGURATION_LOCATION,
+ dbname
+ );
+ }
+}
Property changes on: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TestHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java (from rev 2443, trunk/topia-persistence/src/test/java/org/nuiton/topia/TopiaDatabase.java)
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java (rev 0)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,192 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * Put this class as a Rule in test to obtain a new isolated db for each test.
+ * <p/>
+ * Here is a simple example of usage :
+ * <pre>
+ * public class MyTest {
+ *
+ * \@Rule
+ * public final TopiaDatabase db = new TopiaDatabase();
+ *
+ * \@Test
+ * public void testMethod() throws TopiaException {
+ *
+ * TopiaContext tx = db.beginTransaction();
+ * ...
+ * }
+ * </pre>
+ * The db created will be unique for each test method (and for each build also).
+ * <p/>
+ * You don't need to close any transaction, it will be done for you and the end
+ * of each method test.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.8
+ */
+public class TopiaDatabase extends TestWatcher {
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(TopiaDatabase.class);
+
+ /** A time-stamp, allow to make multiple build and keep the tests data. */
+ public static final String TIMESTAMP = String.valueOf(System.nanoTime());
+
+ private File testBasedir;
+
+ private Properties dbConfiguration;
+
+ private TopiaContext rootCtxt;
+
+ private final String configurationPath;
+
+ public TopiaDatabase() {
+ this(TestHelper.DEFAULT_CONFIGURATION_LOCATION);
+ }
+
+ public TopiaDatabase(String configurationPath) {
+ this.configurationPath = configurationPath;
+ }
+
+ @Override
+ protected void starting(Description description) {
+
+ // get test directory
+ testBasedir = getTestSpecificDirectory(
+ description.getTestClass(),
+ description.getMethodName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("testBasedir = " + testBasedir);
+ }
+
+ // create the root context
+ try {
+
+ dbConfiguration = new Properties();
+ InputStream stream =
+ getClass().getResourceAsStream(configurationPath);
+
+ try {
+ dbConfiguration.load(stream);
+ } finally {
+ stream.close();
+ }
+ dbConfiguration.setProperty(
+ TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES,
+ TopiaTestDAOHelper.getImplementationClassesAsString());
+
+ // make sure we always use a different directory
+
+ String dbPath = new File(testBasedir, "db").getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("dbPath = " + dbPath);
+ }
+ dbConfiguration.setProperty(
+ TopiaContextFactory.CONFIG_URL, "jdbc:h2:file:" + dbPath);
+
+ onDbConfigurationCreate(dbConfiguration, testBasedir, dbPath);
+
+ rootCtxt = TopiaContextFactory.getContext(dbConfiguration);
+ } catch (Exception e) {
+ throw new IllegalStateException(
+ "Could not start db at " + testBasedir, e);
+ }
+ }
+
+ @Override
+ public void finished(Description description) {
+
+ if (rootCtxt != null && !rootCtxt.isClosed()) {
+ try {
+ rootCtxt.closeContext();
+ } catch (TopiaException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Could not close topia root context", e);
+ }
+ }
+ }
+ rootCtxt = null;
+ dbConfiguration = null;
+ }
+
+ public File getTestBasedir() {
+ return testBasedir;
+ }
+
+ public TopiaContext getRootCtxt() {
+ return rootCtxt;
+ }
+
+ public Properties getDbConfiguration() {
+ return dbConfiguration;
+ }
+
+ public TopiaContext beginTransaction() throws TopiaException {
+ return rootCtxt.beginTransaction();
+ }
+
+ protected void onDbConfigurationCreate(Properties configuration,
+ File testDir,
+ String dbPath) {
+
+ }
+
+ public static File getTestSpecificDirectory(Class<?> testClassName, String methodName) {
+ // Trying to look for the temporary folder to store data for the test
+ String tempDirPath = System.getProperty("java.io.tmpdir");
+ if (tempDirPath == null) {
+ // can this really occur ?
+ tempDirPath = "";
+ if (log.isWarnEnabled()) {
+ log.warn("'\"java.io.tmpdir\" not defined");
+ }
+ }
+ File tempDirFile = new File(tempDirPath);
+
+ // create the directory to store database data
+ String dataBasePath = testClassName.getName()
+ + File.separator // a directory with the test class name
+ + methodName// a sub-directory with the method name
+ + '_'
+ + TIMESTAMP; // and a timestamp
+ File databaseFile = new File(tempDirFile, dataBasePath);
+ return databaseFile;
+ }
+}
+
Property changes on: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/TopiaDatabase.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java (from rev 2443, trunk/topia-persistence/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java)
===================================================================
--- trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java (rev 0)
+++ trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,89 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package org.nuiton.topia.persistence;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.matchers.JUnitMatchers;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaDatabase;
+import org.nuiton.topia.TopiaTestDAOHelper;
+import org.nuiton.topia.test.entities.Person;
+import org.nuiton.topia.test.entities.PersonDAO;
+
+import java.util.List;
+
+/**
+ * Test on {@link TopiaDAO}.
+ * <p/>
+ * Last update : $Date$
+ * By : $Author$
+ *
+ * @author chatellier
+ * @version $Revision$
+ */
+public class TopiaDAOTest {
+
+ @Rule
+ public final TopiaDatabase db = new TopiaDatabase();
+
+ /**
+ * Test de creer une entité et de verifier qu'elle est
+ * présente dans la persistence au sein de la transaction.
+ *
+ * @throws Exception if any exception while test
+ */
+ @Test
+ public void testCreateAndFindInTransaction() throws Exception {
+
+ TopiaContext context = db.beginTransaction();
+
+ PersonDAO personDAO = TopiaTestDAOHelper.getPersonDAO(context);
+
+ // appel 1 find all
+ Person person = personDAO.create(Person.PROPERTY_NAME, "toto");
+ List<Person> allPerson = personDAO.findAll();
+ Assert.assertEquals(1, allPerson.size());
+ context.commitTransaction();
+
+ // recherce la personne créée dans la même transaction
+ Person person2 = personDAO.create(Person.PROPERTY_NAME, "titi");
+ allPerson = personDAO.findAll();
+ Assert.assertEquals(2, allPerson.size());
+ Assert.assertThat(allPerson, JUnitMatchers.hasItem(person2));
+
+ context.rollbackTransaction();
+
+ // meme test apres roolback
+ Person person3 = personDAO.create(Person.PROPERTY_NAME, "tata");
+ allPerson = personDAO.findAll();
+ Assert.assertEquals(2, allPerson.size());
+ Assert.assertThat(allPerson, JUnitMatchers.hasItem(person3));
+
+ context.commitTransaction();
+ }
+}
Property changes on: trunk/topia-persistence-hibernate/src/test/java/org/nuiton/topia/persistence/TopiaDAOTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml
===================================================================
--- trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml (rev 0)
+++ trunk/topia-persistence-hibernate/topia-persistence-hibernate.iml 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-java" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-models" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/i18n" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/test-xmi" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-test-sources/test-annotations" isTestSource="true" />
+ <sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target/antrun" />
+ <excludeFolder url="file://$MODULE_DIR$/target/classes" />
+ <excludeFolder url="file://$MODULE_DIR$/target/processed-sources" />
+ <excludeFolder url="file://$MODULE_DIR$/target/surefire-workdir" />
+ <excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="Maven: org.hibernate:hibernate-core:4.1.3.Final" level="project" />
+ <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
+ <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.1.0.GA" level="project" />
+ <orderEntry type="library" name="Maven: org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.0.Final" level="project" />
+ <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
+ <orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final" level="project" />
+ <orderEntry type="library" name="Maven: org.javassist:javassist:3.15.0-GA" level="project" />
+ <orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:4.0.1.Final" level="project" />
+ <orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:4.1.3.Final" level="project" />
+ <orderEntry type="library" scope="RUNTIME" name="Maven: org.hibernate:hibernate-ehcache:4.1.3.Final" level="project" />
+ <orderEntry type="library" scope="RUNTIME" name="Maven: net.sf.ehcache:ehcache-core:2.4.3" level="project" />
+ <orderEntry type="module" module-name="topia-persistence" />
+ <orderEntry type="library" name="Maven: org.nuiton:nuiton-utils:2.4.6" level="project" />
+ <orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-primitives:commons-primitives:1.0" level="project" />
+ <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-io:commons-io:2.3" level="project" />
+ <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.3" level="project" />
+ <orderEntry type="library" name="Maven: commons-jxpath:commons-jxpath:1.3" level="project" />
+ <orderEntry type="library" name="Maven: org.nuiton.i18n:nuiton-i18n:2.4.1" level="project" />
+ <orderEntry type="library" scope="RUNTIME" name="Maven: javassist:javassist:3.12.1.GA" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: com.h2database:h2:1.3.165" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.10" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
+ <orderEntry type="library" scope="TEST" name="Maven: log4j:log4j:1.2.16" level="project" />
+ </component>
+</module>
+
Property changes on: trunk/topia-persistence-tck
___________________________________________________________________
Added: svn:ignore
+ target
*.iml
*.ipr
*.iws
.settings
.classpath
.project
Added: trunk/topia-persistence-tck/LICENSE.txt
===================================================================
Added: trunk/topia-persistence-tck/README.txt
===================================================================
Added: trunk/topia-persistence-tck/changelog.txt
===================================================================
Added: trunk/topia-persistence-tck/pom.xml
===================================================================
--- trunk/topia-persistence-tck/pom.xml (rev 0)
+++ trunk/topia-persistence-tck/pom.xml 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>topia</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-persistence-tck</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>topia-persistence</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- BD H2 for testing -->
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>ToPIA :: Persistence :: Test Compatibility Kit</name>
+ <description>Tests to be shared between topia-persistence implementations</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <build>
+
+ <testResources>
+
+ <!--testResource>
+ <directory>${maven.gen.dir}/test-java</directory>
+ <includes>
+ <include>**/*.hbm.xml</include>
+ </includes>
+ </testResource>
+
+ <testResource>
+ <directory>${maven.src.dir}/test/resources</directory>
+ <includes>
+ <include>**/*.properties</include>
+ </includes>
+ </testResource>
+
+ <testResource>
+ <directory>${maven.src.dir}/test/java</directory>
+ <includes>
+ <include>**/*.hbm.xml</include>
+ </includes>
+ </testResource-->
+
+ </testResources>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.processor</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ <!-- restrict parsing beacause this is expensive -->
+ <!-- if you want to parse more, add your package in includes -->
+ <configuration>
+ <treateDefaultEntry>false</treateDefaultEntry>
+ <entries>
+ <entry>
+ <basedir>${maven.src.dir}/main/java</basedir>
+ <includes>
+ <include>org/nuiton/topia/framework/*.java</include>
+ </includes>
+ </entry>
+ </entries>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- expose new plexus components -->
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <configuration>
+
+ </configuration>
+ <executions>
+ <execution>
+ <id>Test Generator</id>
+ <phase>generate-sources</phase>
+ <configuration>
+ <testPhase>false</testPhase>
+ <templates>
+ org.nuiton.topia.generator.TopiaMetaTransformer,
+ org.nuiton.eugene.java.JavaInterfaceTransformer,
+ org.nuiton.eugene.java.JavaBeanTransformer,
+ org.nuiton.topia.generator.EntityDTOTransformer,
+ org.nuiton.topia.generator.BinderHelperTransformer,
+ org.nuiton.topia.generator.QueryHelperTransformer
+ </templates>
+ <fullPackagePath>org.nuiton.topia</fullPackagePath>
+ <defaultPackage>org.nuiton.topia</defaultPackage>
+ </configuration>
+ <goals>
+ <goal>smart-generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- expose tests -->
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <profiles>
+
+ <!-- perform only on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <build>
+ <plugins>
+
+ <!-- always expose tests source jar -->
+ <plugin>
+ <artifactId>maven-source-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test-sources</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- always expose tests javadoc jar -->
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-test-javadoc</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>run-its</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ <!-- Reuse this when MINVOKER-107 will be done (syas invoker 1.6 -->
+ <!--name>maven.test.skip</name>
+ <value>!false</value-->
+ </property>
+ </activation>
+ <build>
+ <defaultGoal>integration-test</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <localRepositoryPath>${basedir}/target/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
+ <debug>${maven.verbose}</debug>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ <phase>integration-test</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- reporting at release time -->
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <version>1.3.8</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+
+ </profiles>
+
+</project>
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java (from rev 2443, trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Gender.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,29 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck;
+
+public enum Gender {
+ MALE, FEMALE
+}
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Gender.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java (from rev 2443, trunk/topia-persistence/src/test/java/org/nuiton/topiatest/Title.java)
===================================================================
--- trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java (rev 0)
+++ trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * ToPIA :: Persistence
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+package org.nuiton.topia.tck;
+
+/**
+ * To test http://nuiton.org/issues/1732.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.2
+ */
+public enum Title {
+ Mr,
+ Madam,
+ Other
+}
Property changes on: trunk/topia-persistence-tck/src/main/java/org/nuiton/topia/tck/Title.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/topia-persistence-tck/src/main/resources/i18n/topia-persistence-tck_fr_FR.properties
===================================================================
Property changes on: trunk/topia-persistence-tck/src/main/xmi
___________________________________________________________________
Added: svn:ignore
+ topiatest.zargo~*
Added: trunk/topia-persistence-tck/src/main/xmi/topiatest.properties
===================================================================
--- trunk/topia-persistence-tck/src/main/xmi/topiatest.properties (rev 0)
+++ trunk/topia-persistence-tck/src/main/xmi/topiatest.properties 2012-05-09 13:48:32 UTC (rev 2445)
@@ -0,0 +1,39 @@
+###
+# #%L
+# ToPIA :: Persistence
+#
+# $Id$
+# $HeadURL$
+# %%
+# Copyright (C) 2004 - 2010 CodeLutin
+# %%
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Lesser Public License for more details.
+#
+# You should have received a copy of the GNU General Lesser Public
+# License along with this program. If not, see
+# <http://www.gnu.org/licenses/lgpl-3.0.html>.
+# #L%
+###
+model.tagvalue.i18n=topia.test.common.
+model.tagvalue.generateOperatorForDAOHelper=true
+model.tagvalue.constantPrefix=PROPERTY_
+model.tagvalue.generateDTOTopiaId=true
+
+#org.nuiton.topiatest.Company.class.tagvalue.naturalIdMutable=false
+#org.nuiton.topiatest.Company.attribute.siret.tagvalue.naturalId=true
+#org.nuiton.topiatest.Company.attribute.name.tagvalue.naturalId=true
+#org.nuiton.topiatest.Company.attribute.name.tagvalue.notNull=false
+
+org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNotNull.tagvalue.naturalId=true
+org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNull.tagvalue.naturalId=true
+org.nuiton.topiatest.NaturalizedEntity.attribute.naturalIdNull.tagvalue.notNull=false
+
+org.nuiton.topiatest.Personne.attribute.otherGender.tagValue.useEnumerationName=true
\ No newline at end of file
Property changes on: trunk/topia-persistence-tck/src/main/xmi/topiatest.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/topia-persistence-tck/src/main/xmi/topiatest.zargo
===================================================================
(Binary files differ)
Property changes on: trunk/topia-persistence-tck/src/main/xmi/topiatest.zargo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r2444 - in trunk: . topia-persistence topia-persistence/src/main/java/org/nuiton/topia/framework topia-persistence/src/main/java/org/nuiton/topia/generator topia-persistence/src/main/java/org/nuiton/topia/persistence topia-persistence/src/main/java/org/nuiton/topia/persistence/util
by athimel@users.nuiton.org 07 May '12
by athimel@users.nuiton.org 07 May '12
07 May '12
Author: athimel
Date: 2012-05-07 17:52:54 +0200 (Mon, 07 May 2012)
New Revision: 2444
Url: http://nuiton.org/repositories/revision/topia/2444
Log:
Remove explicit Hibernate dependency
Removed:
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java
Modified:
trunk/pom.xml
trunk/topia-persistence/pom.xml
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/pom.xml 2012-05-07 15:52:54 UTC (rev 2444)
@@ -71,8 +71,8 @@
<processorPluginVersion>1.2.1</processorPluginVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<xmlrpcVersion>3.1.2</xmlrpcVersion>
- <hibernateVersion>3.6.10.Final</hibernateVersion>
- <!--<hibernateVersion>4.0.0.CR1</hibernateVersion>-->
+ <!--<hibernateVersion>3.6.10.Final</hibernateVersion>-->
+ <hibernateVersion>4.1.3.Final</hibernateVersion>
<sl4jVersion>1.6.4</sl4jVersion>
<h2Version>1.3.165</h2Version>
@@ -105,7 +105,7 @@
<scope>compile</scope>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernateVersion}</version>
@@ -134,6 +134,13 @@
</exclusion>
</exclusions>
<scope>runtime</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
+ <scope>compile</scope>
</dependency>
<dependency>
Modified: trunk/topia-persistence/pom.xml
===================================================================
--- trunk/topia-persistence/pom.xml 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/pom.xml 2012-05-07 15:52:54 UTC (rev 2444)
@@ -82,7 +82,7 @@
<artifactId>dom4j</artifactId>
</dependency>
- <dependency>
+ <!--dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
@@ -94,8 +94,15 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
+ </dependency-->
+
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
</dependency>
+
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaConnectionProvider.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -26,13 +26,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.cfg.Environment;
-import org.hibernate.connection.ConnectionProvider;
-import org.hibernate.connection.ConnectionProviderFactory;
-import org.hibernate.util.PropertiesHelper;
-import org.hibernate.util.ReflectHelper;
+//import org.hibernate.cfg.Environment;
+//import org.hibernate.connection.ConnectionProvider;
+//import org.hibernate.connection.ConnectionProviderFactory;
+//import org.hibernate.util.PropertiesHelper;
+//import org.hibernate.util.ReflectHelper;
+import javax.persistence.PersistenceException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -112,7 +112,7 @@
}
@Override
- public void configure(Properties props) throws HibernateException {
+ public void configure(Properties props) throws PersistenceException {
String driverClass = props.getProperty(Environment.DRIVER);
poolSize = PropertiesHelper.getInt(Environment.POOL_SIZE, props, 20); //default pool size 20
@@ -148,7 +148,7 @@
} catch (ClassNotFoundException e) {
String msg = "JDBC Driver class not found: " + driverClass;
log.error(msg, e);
- throw new HibernateException(msg, e);
+ throw new PersistenceException(msg, e);
}
}
}
@@ -160,7 +160,7 @@
if (log.isErrorEnabled()) {
log.error(msg);
}
- throw new HibernateException(msg);
+ throw new PersistenceException(msg);
}
connectionProps =
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 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImpl.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -35,27 +35,20 @@
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
-import org.hibernate.EntityMode;
-import org.hibernate.FlushMode;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.ReplicationMode;
-import org.hibernate.SQLQuery;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostLoadEventListener;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.event.PreDeleteEventListener;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.event.PreLoadEventListener;
-import org.hibernate.event.PreUpdateEventListener;
-import org.hibernate.jdbc.Work;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.hibernate.tool.hbm2ddl.SchemaUpdate;
+//import org.hibernate.EntityMode;
+//import org.hibernate.FlushMode;
+//import org.hibernate.ReplicationMode;
+//import org.hibernate.cfg.Configuration;
+//import org.hibernate.event.PostDeleteEventListener;
+//import org.hibernate.event.PostInsertEventListener;
+//import org.hibernate.event.PostLoadEventListener;
+//import org.hibernate.event.PostUpdateEventListener;
+//import org.hibernate.event.PreDeleteEventListener;
+//import org.hibernate.event.PreInsertEventListener;
+//import org.hibernate.event.PreLoadEventListener;
+//import org.hibernate.event.PreUpdateEventListener;
+//import org.hibernate.tool.hbm2ddl.SchemaExport;
+//import org.hibernate.tool.hbm2ddl.SchemaUpdate;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -72,6 +65,13 @@
import org.nuiton.topia.persistence.TopiaId;
import org.nuiton.util.ArrayUtil;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.EntityTransaction;
+import javax.persistence.FlushModeType;
+import javax.persistence.PersistenceException;
+import javax.persistence.Query;
+import javax.persistence.metamodel.EntityType;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
import java.io.File;
@@ -81,9 +81,6 @@
import java.io.Reader;
import java.io.Writer;
import java.lang.reflect.Field;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -145,10 +142,10 @@
* la factory permettant de recuperer la session hibernate. Seul les
* TopiaContextImpl initiaux contiennent un hibernateFactory
*/
- protected SessionFactory hibernateFactory;
+ protected EntityManagerFactory hibernateFactory;
/** La session utilisé par le TopiaContextImpl */
- protected Session hibernate;
+ protected EntityManager hibernate;
/** Indique si le contexte a ete ferme */
protected boolean closed;
@@ -159,7 +156,7 @@
* The normal usage is to says yes (that's why the default value is
* {@code true}), in that case whebn doing queries (says in method
* {@link #find(String, Object...)} or {@link #find(String, int, int, Object...)})
- * it will use the flush mode {@link FlushMode#AUTO}).
+ * it will use the flush mode {@link javax.persistence.FlushModeType#AUTO}).
*
* But sometimes, when doing a lot of queries (for some imports for example),
* we do NOT want the session to be flushed each time we do a find, then you
@@ -451,7 +448,7 @@
new SchemaExport(getHibernateConfiguration()).create(showSchema,
true);
getFiresSupport().firePostCreateSchema(this);
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(
_("topia.persistence.error.create.schema",
eee.getMessage()), eee);
@@ -463,7 +460,7 @@
try {
new SchemaExport(getHibernateConfiguration()).
execute(true, false, false, true);
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(
_("topia.persistence.error.create.schema",
eee.getMessage()), eee);
@@ -481,7 +478,7 @@
new SchemaUpdate(getHibernateConfiguration()).execute(showSchema,
true);
getFiresSupport().firePostUpdateSchema(this);
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(
_("topia.persistence.error.update.schema",
eee.getMessage()), eee);
@@ -489,7 +486,7 @@
}
@Override
- public Session getHibernate() throws TopiaException {
+ public EntityManager getHibernate() throws TopiaException {
if (hibernate == null) {
throw new TopiaException(
_("topia.persistence.error.no.hibernate.session"));
@@ -498,7 +495,7 @@
}
@Override
- public SessionFactory getHibernateFactory() throws TopiaNotFoundException {
+ public EntityManagerFactory getHibernateFactory() throws TopiaNotFoundException {
if (hibernateFactory == null) {
if (getParentContext() != null) {
hibernateFactory = getParentContext().getHibernateFactory();
@@ -626,7 +623,7 @@
if (log.isDebugEnabled()) {
log.debug("Load persistent class : " + classname);
}
-
+
// XXX echatellier 20111007 ce cqui est dommage ici, c'est
// la definition de cette classe ne sert a rien (apart security)
// car pour hibernate hibernateConfiguration.addClass(persistanceClass)
@@ -702,14 +699,15 @@
throw new TopiaException(
_("topia.persistence.error.rootContext.access"));
}
- if (getHibernateFactory().getClassMetadata(entityClass) == null &&
- getHibernateFactory().getClassMetadata(
- entityClass.getName() + "Impl") == null &&
- getHibernateFactory().getClassMetadata(
- entityClass.getName() + "Abstract") == null) {
+ if (getHibernateFactory().getMetamodel().entity(entityClass) == null
+// && getHibernateFactory().getClassMetadata(
+// entityClass.getName() + "Impl") == null
+// && getHibernateFactory().getClassMetadata(
+// entityClass.getName() + "Abstract") == null
+ ) {
log.info(_("topia.persistence.supported.classes.for.context",
- getHibernateFactory().getAllClassMetadata().keySet()));
+ getHibernateFactory().getMetamodel().getEntities()));
throw new TopiaException(
_("topia.persistence.error.unsupported.class",
entityClass.getName()));
@@ -751,13 +749,13 @@
checkClosed(_("topia.persistence.error.context.is.closed"));
TopiaContextImpl result = new TopiaContextImpl(this);
- SessionFactory factory = getHibernateFactory();
- result.hibernate = factory.openSession();
+ EntityManagerFactory factory = getHibernateFactory();
+ result.hibernate = factory.createEntityManager(); // TODO AThimel 07/05/2012 Maybe provide a Map ? cf Configuration
// new TopiaInterceptor(result));
// on ne synchronise jamais les données avec la base tant que
// l'utilisateur n'a pas fait de commit du context
- result.hibernate.setFlushMode(FlushMode.MANUAL);
+ result.hibernate.setFlushMode(FlushModeType.COMMIT); // TODO AThimel 07/05/2012 Was MANUAL
// tchemit 2010-12-06 propagates the value of the flag
result.useFlushMode = useFlushMode;
@@ -768,14 +766,15 @@
// transaction par defaut est utilisé mais elle n'est jamais vraiment
// fermé ce qui pose des problemes de lock sur les tables.
try {
- result.hibernate.beginTransaction();
+// result.hibernate.beginTransaction();
+ result.hibernate.getTransaction().begin();
} catch (Exception eee) {
// on a pas pu ouvrir la transaction, on faut donc tout fermer
// et declancher une exception
try {
result.hibernate.close();
- } catch (HibernateException e1) {
+ } catch (PersistenceException e1) {
if (log.isErrorEnabled()) {
log.error("Could not close hibernate session", e1);
}
@@ -809,8 +808,7 @@
// // TODO-fdesbois-20100507 : need to be removed for 2.5 version
// dao.commitTransaction();
// }
- Transaction tx = hibernate.getTransaction();
- // Transaction tx = hibernate.beginTransaction();
+ EntityTransaction tx = hibernate.getTransaction();
hibernate.flush();
tx.commit();
@@ -820,7 +818,8 @@
parent.getFiresSupport().fireOnPostCommit(this);
}
- hibernate.beginTransaction();
+// hibernate.beginTransaction();
+ hibernate.getTransaction().begin();
// it's seem necessary to change session after commit
// NON, NON, NON, il ne faut surtout pas le faire, ca pose plein de
@@ -846,17 +845,17 @@
// // TODO-fdesbois-20100507 : need to be removed for 2.5 version
// dao.rollbackTransaction();
// }
- Transaction tx = hibernate.getTransaction();
- // Transaction tx = hibernate.beginTransaction();
+ EntityTransaction tx = hibernate.getTransaction();
hibernate.clear();
tx.rollback();
hibernate.close();
// it's very important to change the session after rollback
// otherwize there are many error during next Entity's modification
- hibernate = getHibernateFactory().openSession();
- hibernate.setFlushMode(FlushMode.MANUAL);
+ hibernate = getHibernateFactory().createEntityManager(); // TODO AThimel 07/05/2012 Maybe provide a Map ? cf Configuration
+ hibernate.setFlushMode(FlushModeType.COMMIT); // TODO AThimel 07/05/2012 Was MANUAL
- hibernate.beginTransaction();
+// hibernate.beginTransaction();
+ hibernate.getTransaction().begin();
getFiresSupport().fireOnPostRollback(this);
TopiaContextImplementor parent = getParentContext();
@@ -864,7 +863,7 @@
parent.getFiresSupport().fireOnPostRollback(this);
}
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(
_("topia.persistence.error.on.rollback",
eee.getMessage()), eee);
@@ -926,10 +925,10 @@
@Override
public void executeSQL(String sqlScript) throws TopiaException {
- SQLWork sqlWork = new SQLWork(sqlScript);
try {
- getHibernate().doWork(sqlWork);
- } catch (HibernateException e) {
+ Query nativeQuery = getHibernate().createNativeQuery(sqlScript);
+ nativeQuery.executeUpdate();
+ } catch (PersistenceException e) {
throw new TopiaException("Could not execute sql code", e);
}
}
@@ -976,22 +975,22 @@
for (int j = 0; j < args.length; j += 2) {
String name = (String) args[j];
Object value = args[j + 1];
- if (value.getClass().isArray()) {
- query.setParameterList(name, (Object[]) value);
- } else if (value instanceof Collection<?>) {
- query.setParameterList(name, (Collection<?>) value);
- } else {
+// if (value.getClass().isArray()) {
+// query.setParameterList(name, (Object[]) value);
+// } else if (value instanceof Collection<?>) {
+// query.setParameterList(name, (Collection<?>) value);
+// } else {
query.setParameter(name, value);
- }
+// }
}
// tchemit 2010-11-30 reproduce the same behaviour than before with the dao legacy
if (useFlushMode) {
- query.setFlushMode(FlushMode.AUTO);
+ query.setFlushMode(FlushModeType.AUTO);
}
- List result = query.list();
+ List result = query.getResultList();
result = firesSupport.fireEntitiesLoad(this, result);
return result;
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(_("topia.persistence.error.on.query",
hql, eee.getMessage()), eee);
}
@@ -1008,22 +1007,22 @@
for (int j = 0; j < args.length; j += 2) {
String name = (String) args[j];
Object value = args[j + 1];
- if (value.getClass().isArray()) {
- query.setParameterList(name, (Object[]) value);
- } else {
+// if (value.getClass().isArray()) {
+// query.setParameterList(name, (Object[]) value);
+// } else {
query.setParameter(name, value);
- }
+// }
}
query.setFirstResult(startIndex);
query.setMaxResults(endIndex - startIndex + 1);
// tchemit 2010-11-30 reproduce the same behaviour than before with the dao legacy
if (useFlushMode) {
- query.setFlushMode(FlushMode.AUTO);
+ query.setFlushMode(FlushModeType.AUTO);
}
- List result = query.list();
+ List result = query.getResultList();
result = firesSupport.fireEntitiesLoad(this, result);
return result;
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(_("topia.persistence.error.on.query",
hql, eee.getMessage()), eee);
}
@@ -1049,7 +1048,7 @@
}
int result = query.executeUpdate();
return result;
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(_("topia.persistence.error.on.query",
hql, eee.getMessage()), eee);
}
@@ -1093,7 +1092,7 @@
Element entity = (Element) it.next();
try {
sessionDom4j.replicate(entity, ReplicationMode.EXCEPTION);
- } catch (HibernateException he) {
+ } catch (PersistenceException he) {
log.warn(_("topia.persistence.error.replicate.entity",
entity, he.getMessage()), he);
}
@@ -1166,7 +1165,7 @@
result.write(doc);
result.close();
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(_("topia.persistence.error.on.export",
eee.getMessage()), eee);
} catch (IOException eee) {
@@ -1205,7 +1204,7 @@
" was sucessfully done.");
}
}
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(_("topia.persistence.error.on.replicate",
eee.getMessage()), eee);
}
@@ -1270,9 +1269,9 @@
options += " COMPRESSION GZIP";
}
- SQLQuery query = getHibernate().createSQLQuery(
+ Query query = getHibernate().createNativeQuery(
"SCRIPT TO '" + file.getAbsolutePath() + "'" + options);
- query.list();
+ query.getResultList();
} catch (Exception eee) {
throw new TopiaException(_(
@@ -1317,7 +1316,7 @@
in.close();
}
- SQLQuery query = getHibernate().createSQLQuery(
+ Query query = getHibernate().createNativeQuery(
"RUNSCRIPT FROM '" + file.getAbsolutePath() + "'" + options);
query.executeUpdate();
@@ -1346,7 +1345,7 @@
if (dropDatabase) {
sql += " DELETE FILES";
}
- Query query = tx.getHibernate().createSQLQuery(sql);
+ Query query = tx.getHibernate().createNativeQuery(sql);
query.executeUpdate();
tx.closeContext();
root.finalize();
@@ -1498,12 +1497,14 @@
// si entityAndcondition est vide alors il faut le remplir
// avec toutes les entités du mapping (class, null)
if (entityAndCondition.length == 0) {
- Map<?,?> classMetadata = getHibernateFactory().getAllClassMetadata();
+// Map<?,?> classMetadata = getHibernateFactory().getAllClassMetadata();
+ Set<EntityType<?>> classMetadata = getHibernateFactory().getMetamodel().getEntities();
entityAndCondition = new Object[classMetadata.size() * 2];
int i = 0;
- for (Object className : classMetadata.keySet()) {
+ for (EntityType entityType : classMetadata) {
+ String className = entityType.getName();
try {
- entityAndCondition[i++] = Class.forName((String) className);
+ entityAndCondition[i++] = Class.forName(className);
} catch (ClassNotFoundException e) {
// should never happen!
throw new TopiaException(
@@ -1551,33 +1552,33 @@
// dettach entity to source session, to make possible copy of
// collection without a hibernate exception (list opened in
// two session...)
- getHibernate().evict(entity);
+ getHibernate().detach(entity);
dstContextImpl.getHibernate().replicate(entity,
ReplicationMode.EXCEPTION);
}
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(_("topia.persistence.error.on.replicate",
eee.getMessage()), eee);
}
}
- public static class SQLWork implements Work {
- private final String script;
-
- public SQLWork(String script) {
- this.script = script;
- }
-
- @Override
- public void execute(Connection connection) throws SQLException {
- PreparedStatement sta = connection.prepareStatement(script);
- try {
- sta.execute();
- } finally {
- sta.close();
- }
- }
- }
+// public static class SQLWork implements Work {
+// private final String script;
+//
+// public SQLWork(String script) {
+// this.script = script;
+// }
+//
+// @Override
+// public void execute(Connection connection) throws SQLException {
+// PreparedStatement sta = connection.prepareStatement(script);
+// try {
+// sta.execute();
+// } finally {
+// sta.close();
+// }
+// }
+// }
} //TopiaContextImpl
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaContextImplementor.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -25,15 +25,15 @@
package org.nuiton.topia.framework;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
+//import org.hibernate.cfg.Configuration;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
import org.nuiton.topia.persistence.TopiaDAO;
import org.nuiton.topia.persistence.TopiaEntity;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -70,13 +70,13 @@
* @return Returns the hibernate.
* @throws TopiaException si aucune transaction n'est ouverte
*/
- Session getHibernate() throws TopiaException;
+ EntityManager getHibernate() throws TopiaException;
/**
* @return Returns the hibernateFactory.
* @throws TopiaNotFoundException
*/
- SessionFactory getHibernateFactory() throws TopiaNotFoundException;
+ EntityManagerFactory getHibernateFactory() throws TopiaNotFoundException;
/**
* @return Returns the hibernate configuration
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaFiresSupport.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -28,23 +28,22 @@
import org.apache.commons.collections.map.IdentityMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.Session;
-import org.hibernate.event.PostDeleteEvent;
-import org.hibernate.event.PostDeleteEventListener;
-import org.hibernate.event.PostInsertEvent;
-import org.hibernate.event.PostInsertEventListener;
-import org.hibernate.event.PostLoadEvent;
-import org.hibernate.event.PostLoadEventListener;
-import org.hibernate.event.PostUpdateEvent;
-import org.hibernate.event.PostUpdateEventListener;
-import org.hibernate.event.PreDeleteEvent;
-import org.hibernate.event.PreDeleteEventListener;
-import org.hibernate.event.PreInsertEvent;
-import org.hibernate.event.PreInsertEventListener;
-import org.hibernate.event.PreLoadEvent;
-import org.hibernate.event.PreLoadEventListener;
-import org.hibernate.event.PreUpdateEvent;
-import org.hibernate.event.PreUpdateEventListener;
+//import org.hibernate.event.PostDeleteEvent;
+//import org.hibernate.event.PostDeleteEventListener;
+//import org.hibernate.event.PostInsertEvent;
+//import org.hibernate.event.PostInsertEventListener;
+//import org.hibernate.event.PostLoadEvent;
+//import org.hibernate.event.PostLoadEventListener;
+//import org.hibernate.event.PostUpdateEvent;
+//import org.hibernate.event.PostUpdateEventListener;
+//import org.hibernate.event.PreDeleteEvent;
+//import org.hibernate.event.PreDeleteEventListener;
+//import org.hibernate.event.PreInsertEvent;
+//import org.hibernate.event.PreInsertEventListener;
+//import org.hibernate.event.PreLoadEvent;
+//import org.hibernate.event.PreLoadEventListener;
+//import org.hibernate.event.PreUpdateEvent;
+//import org.hibernate.event.PreUpdateEventListener;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaVetoException;
@@ -63,6 +62,7 @@
import org.nuiton.util.CategorisedListenerSet;
import org.nuiton.util.ListenerSet;
+import javax.persistence.EntityManager;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -564,7 +564,7 @@
* aucun TopiaContext n'utilise cette session.
*/
protected TopiaContextImplementor getContext(
- TopiaContextImplementor parent, Session hibernate) {
+ TopiaContextImplementor parent, EntityManager hibernate) {
TopiaContextImplementor result = null;
// FD-20100421 : Ano #546 : no need to copy childContext, the
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaSQLQuery.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -24,7 +24,6 @@
*/
package org.nuiton.topia.framework;
-import org.hibernate.jdbc.Work;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaRuntimeException;
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 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -488,8 +488,8 @@
/*{ column="<%=attrColumn%>" node="<%=attrName%>"<%=optionalAttributes%>}*/
if (attrIsEnumeration) {
/*{>
-<%=prefix%> <type name="org.hibernate.type.EnumType">
-<%=prefix%> <param name="<%=org.hibernate.type.EnumType.ENUM%>"><%=attrType%></param>}*/
+<%=prefix%> <type name="javax.persistence.EnumType">
+<%=prefix%> <param name="<%=javax.persistence.EnumType.ENUM%>"><%=attrType%></param>}*/
// if the user tuned the model to use name instead of
// ordinal to store the values, we must add a clause
@@ -498,7 +498,7 @@
String enumSQLType = String.valueOf(Types.VARCHAR);
/*{
<%=prefix%> <!-- using name instead of ordinal to store enumeration value -->
-<%=prefix%> <param name="<%=org.hibernate.type.EnumType.TYPE%>"><%=enumSQLType%></param>}*/
+<%=prefix%> <param name="<%=javax.persistence.EnumType.TYPE%>"><%=enumSQLType%></param>}*/
}
/*{
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -331,7 +331,6 @@
* <p/>
* If none given, will use the {@code org.nuiton.topia.persistence.TopiaDAOImpl}.
* <p/>
- * Other value possible is {@code org.nuiton.topia.persistence.TopiaDAOLegacy}
*
* @see TopiaGeneratorUtil#getDaoImplementationTagValue(ObjectModel)
* @since 2.5
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -453,7 +453,7 @@
* @return l'entite trouvé
* @throws TopiaException if any pb while getting datas
*/
- E findByPrimaryKey(Map<String, Object> keys) throws TopiaException;
+ E findByNaturalIds(Map<String, Object> keys) throws TopiaException;
/**
* Recherche la classe en utilisant la cle naturelle, si la cle naturelle
@@ -464,7 +464,7 @@
* @return l'entité trouvé
* @throws TopiaException if any pb while getting datas
*/
- E findByPrimaryKey(Object... k) throws TopiaException;
+ E findByNaturalIds(Object... k) throws TopiaException;
} //TopiaDAO
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -40,16 +40,16 @@
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.Session;
-import org.hibernate.metadata.ClassMetadata;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.event.TopiaEntityListener;
import org.nuiton.topia.event.TopiaEntityVetoable;
import org.nuiton.topia.framework.TopiaContextImplementor;
import org.nuiton.topia.framework.TopiaQuery;
-import java.io.Serializable;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceException;
+import javax.persistence.metamodel.EntityType;
+import javax.persistence.metamodel.Metamodel;
import java.lang.reflect.InvocationTargetException;
import java.security.Permission;
import java.util.HashMap;
@@ -93,47 +93,6 @@
}
/**
- * Retourne l'id de l'entity
- *
- * @param e l'entity
- * @return l'id de l'entity ou null si pas trouvé
- * @throws TopiaException Si une erreur survient durant la recherche
- */
- protected Serializable getId(E e) throws TopiaException {
- ClassMetadata meta = getClassMetadata();
- String idPropName = meta.getIdentifierPropertyName();
-
- try {
- Serializable result;
- result = (Serializable) PropertyUtils.getSimpleProperty(e,
- idPropName);
- return result;
- } catch (Exception eee) {
- throw new TopiaException("Impossible de récuperer l'identifiant "
- + idPropName + " de l'entite: " + e);
- }
- }
-
- /**
- * Retourne l'id de l'entity representer comme une map
- *
- * @param map l'entity en representation map
- * @return l'id de l'entity ou null si pas trouvé
- * @throws TopiaException Si une erreur survient durant la recherche
- */
- protected Serializable getId(Map map) throws TopiaException {
- try {
- ClassMetadata meta = getClassMetadata();
- String idPropName = meta.getIdentifierPropertyName();
-
- Serializable id = (Serializable) map.get(idPropName);
- return id;
- } catch (HibernateException eee) {
- throw new TopiaException(eee);
- }
- }
-
- /**
* When TopiaContextImpl create the TopiaDAOHibernate, it must call this
* method just after.
*
@@ -223,10 +182,10 @@
entityAbstract.setTopiaContext(getContext());
// save entity
- getSession().save(entity);
+ getSession().persist(entity);
getContext().getFiresSupport().warnOnUpdateEntity(entity);
return entity;
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(eee);
}
}
@@ -295,7 +254,7 @@
// on fait un save maintenant, car puisqu'on a creer l'entity au
// travers du DAO, on s'attend a l'avoir a disposition tout de
// suite pour les requetes sans avoir a faire un update dessus
- getSession().save(result);
+ getSession().persist(result);
getContext().getFiresSupport().warnOnCreateEntity(result);
return result;
}
@@ -303,10 +262,10 @@
@Override
public E update(E e) throws TopiaException {
try {
- getSession().saveOrUpdate(e);
+ getSession().merge(e);
getContext().getFiresSupport().warnOnUpdateEntity(e);
return e;
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(eee);
}
}
@@ -314,9 +273,9 @@
@Override
public void delete(E e) throws TopiaException {
try {
- getSession().delete(e);
+ getSession().remove(e);
getContext().getFiresSupport().warnOnDeleteEntity(e);
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(eee);
}
}
@@ -546,17 +505,18 @@
}
@Override
- public E findByPrimaryKey(Map<String, Object> keys)
+ public E findByNaturalIds(Map<String, Object> keys)
throws TopiaException {
try {
// we used hibernate meta information for all persistence type
// it's more easy than create different for all persistence
- ClassMetadata meta = getClassMetadata();
+ EntityType<E> meta = getClassMetadata();
+ // TODO AThimel 07/05/2012 See if it is possible to do it with EntityType
if (meta.hasNaturalIdentifier()) {
E result = findByProperties(keys);
return result;
}
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(eee);
}
throw new TopiaException("La classe " + entityClass.getName()
@@ -565,12 +525,13 @@
}
@Override
- public E findByPrimaryKey(Object... k) throws TopiaException {
+ public E findByNaturalIds(Object... k) throws TopiaException {
// TODO pour une meilleur gestion des problemes a la compilation
// mettre un premier couple (propName, value) en argument ca evitera
// de pouvoir appeler cette methode sans argument
try {
- ClassMetadata meta = getClassMetadata();
+ EntityType<E> meta = getClassMetadata();
+ // TODO AThimel 07/05/2012 See if it is possible to do it with EntityType
if (meta.hasNaturalIdentifier()) {
int[] ikeys = meta.getNaturalIdentifierProperties();
String[] pnames = meta.getPropertyNames();
@@ -583,7 +544,7 @@
E result = findByProperties(keys);
return result;
}
- } catch (HibernateException eee) {
+ } catch (PersistenceException eee) {
throw new TopiaException(eee);
}
throw new TopiaException("La classe " + entityClass.getName()
@@ -597,7 +558,7 @@
* @return hibernate session
* @throws TopiaException if any pb
*/
- Session getSession() throws TopiaException {
+ EntityManager getSession() throws TopiaException {
return getContext().getHibernate();
}
@@ -608,13 +569,15 @@
* @return the meta-data of the entity
* @throws TopiaException if any pb
*/
- ClassMetadata getClassMetadata() throws TopiaException {
- ClassMetadata meta = getContext().getHibernateFactory()
- .getClassMetadata(entityClass);
- if (meta == null) {
- meta = getContext().getHibernateFactory().getClassMetadata(
- getTopiaEntityEnum().getImplementationFQN());
- }
+ EntityType<E> getClassMetadata() throws TopiaException {
+ Metamodel metamodel = getContext().getHibernateFactory()
+ .getMetamodel();
+ EntityType<E> meta = metamodel.entity(getEntityClass());
+ // TODO AThimel 07/05/2012 Maybe there is no need to call this ?
+// if (meta == null) {
+// Class<E> implementationClass = getTopiaEntityEnum().getImplementation();
+// meta = metamodel.entity(implementationClass);
+// }
return meta;
}
Deleted: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -1,546 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-/* *##%
- * ToPIA :: Persistence
- * Copyright (C) 2004 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*/
-
-package org.nuiton.topia.persistence;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.Criteria;
-import org.hibernate.FlushMode;
-import org.hibernate.HibernateException;
-import org.hibernate.criterion.Criterion;
-import org.hibernate.criterion.Order;
-import org.hibernate.criterion.Restrictions;
-import org.hibernate.metadata.ClassMetadata;
-import org.nuiton.topia.TopiaException;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Surcharge du {@link TopiaDAOImpl} pour utiliser l'api criteria au lieu du hql
- * pour tout ce qui est requétage.
- *
- * Created: 31 déc. 2005 13:10:34
- *
- * @param <E> le type de l'entite
- * @author bpoussin <poussin(a)codelutin.com>
- * @author tchemit <chemit(a)codelutin.com>
- */
-
-public class TopiaDAOLegacy<E extends TopiaEntity> extends TopiaDAOImpl<E> { // TopiaDAOLegacy
-
- /** Logger. */
- private static Log log = LogFactory.getLog(TopiaDAOLegacy.class);
-
- @SuppressWarnings("unchecked")
- protected E instanciateNew() throws TopiaException {
- E result = newInstance();
- return result;
- }
-
- @Override
- public E create(Object... properties) throws TopiaException {
- Map<String, Object> map = new HashMap<String, Object>();
- Object propertyName = null;
- Object value = null;
- try {
- for (int i = 0; i < properties.length;) {
- propertyName = properties[i++];
- value = properties[i++];
- map.put((String) propertyName, value);
- }
- } catch (ArrayIndexOutOfBoundsException eee) {
- throw new IllegalArgumentException("Wrong number of argument "
- + properties.length
- + ", you must have even number. Last property name read: "
- + propertyName);
- } catch (ClassCastException eee) {
- throw new IllegalArgumentException(
- "Wrong argument type, wait property name as String and have "
- + propertyName.getClass().getName());
- }
-
- E result = create(map);
- return result;
- }
-
- @Override
- public E findByPrimaryKey(Map<String, Object> keys)
- throws TopiaException {
- try {
- // we used hibernate meta information for all persistence type
- // it's more easy than create different for all persistence
- ClassMetadata meta = getClassMetadata();
- if (meta.hasNaturalIdentifier()) {
- E result = findByProperties(keys);
- return result;
- }
- } catch (HibernateException eee) {
- throw new TopiaException(eee);
- }
- throw new TopiaException("La classe " + entityClass.getName()
- + " n'a pas de cle primaire naturelle");
-
- }
-
- @Override
- public E findByPrimaryKey(Object... k) throws TopiaException {
- // TODO pour une meilleur gestion des problemes a la compilation
- // mettre un premier couple (propName, value) en argument ca evitera
- // de pouvoir appeler cette methode sans argument
- try {
- ClassMetadata meta = getClassMetadata();
- if (meta.hasNaturalIdentifier()) {
- int[] ikeys = meta.getNaturalIdentifierProperties();
- String[] pnames = meta.getPropertyNames();
-
- Map<String, Object> keys = new HashMap<String, Object>();
- for (int ikey : ikeys) {
- keys.put(pnames[ikey], k[ikey]);
- }
-
- E result = findByProperties(keys);
- return result;
- }
- } catch (HibernateException eee) {
- throw new TopiaException(eee);
- }
- throw new TopiaException("La classe " + entityClass.getName()
- + " n'a pas de cle primaire naturelle");
-
- }
-
- @Override
- public E findByProperties(String propertyName, Object value,
- Object... others) throws TopiaException {
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put(propertyName, value);
- Object name = null;
- for (int i = 0; i < others.length;) {
- try {
- name = others[i++];
- value = others[i++];
- properties.put((String) name, value);
- } catch (ClassCastException eee) {
- throw new IllegalArgumentException(
- "Les noms des propriétés doivent être des chaines et non pas "
- + propertyName.getClass().getName(), eee);
- } catch (ArrayIndexOutOfBoundsException eee) {
- throw new IllegalArgumentException(
- "Le nombre d'argument n'est pas un nombre pair: "
- + (others.length + 2)
- + " La dernière propriété était: " + name, eee);
- }
- }
- E result = findByProperties(properties);
- return result;
- }
-
- @Override
- public List<E> findAllByProperties(String propertyName, Object value,
- Object... others) throws TopiaException {
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put(propertyName, value);
- Object name = null;
- for (int i = 0; i < others.length;) {
- try {
- name = others[i++];
- value = others[i++];
- properties.put((String) name, value);
- } catch (ClassCastException eee) {
- throw new IllegalArgumentException(
- "Les noms des propriétés doivent être des chaines et non pas "
- + propertyName.getClass().getName(), eee);
- } catch (ArrayIndexOutOfBoundsException eee) {
- throw new IllegalArgumentException(
- "Le nombre d'argument n'est pas un nombre pair: "
- + (others.length + 2)
- + " La dernière propriété était: " + name, eee);
- }
- }
- List<E> result = findAllByProperties(properties);
- return result;
- }
-
-// @Override
-// public E findContainsProperties(Map<String, Collection<?>> properties)
-// throws TopiaException {
-// List<E> results = findAllContainsProperties(properties);
-// E result = null;
-// if (results.size() > 0) {
-// result = results.get(0);
-// }
-// return result;
-// }
-//
-// @Override
-// public E findContainsProperties(String propertyName,
-// Collection values, Object... others) throws TopiaException {
-// Map<String, Collection<?>> properties = new HashMap<String, Collection<?>>();
-// properties.put(propertyName, values);
-// Object name = null;
-// for (int i = 0; i < others.length;) {
-// try {
-// name = others[i++];
-// values = (Collection) others[i++];
-// properties.put((String) name, values);
-// } catch (ClassCastException eee) {
-// throw new IllegalArgumentException(
-// "Les noms des propriétés doivent être des chaines et non pas "
-// + propertyName.getClass().getName(), eee);
-// } catch (ArrayIndexOutOfBoundsException eee) {
-// throw new IllegalArgumentException(
-// "Le nombre d'argument n'est pas un nombre pair: "
-// + (others.length + 2)
-// + " La dernière propriété était: " + name, eee);
-// }
-// }
-// E result = findContainsProperties(properties);
-// return result;
-// }
-//
-// /**
-// * Find all entities with a specific rule :
-// * When the entity have a Collection type property, you want to find all entites where some values are
-// * contained in the collection type property.
-// * Example entity parameter : private Collection<Date> historicalDates;
-// * You want some dates to be contained in historicalDates.
-// * Collection<Date> myDates...
-// * myDates.add(date1) ...
-// * Map<String, Collection> properties = new HashMap<String,Collection>();
-// * properties.put("historicalDates",myDates);
-// * findAllContainsProperties(properties);
-// * @param properties
-// * @return the list of entities corresponding to the request
-// * @throws org.nuiton.topia.TopiaException if any pb
-// */
-// @Override
-// public List<E> findAllContainsProperties(Map<String, Collection<?>> properties) throws TopiaException {
-// List<E> all = findAll();
-// List<E> result = new ArrayList<E>();
-// for (E e : all) {
-// boolean ok = true;
-// try {
-// for (Entry<String, Collection<?>> kv : properties.entrySet()) {
-// Collection entityValues = (Collection) PropertyUtils
-// .getProperty(e, kv.getKey());
-// Collection values = kv.getValue();
-// if (!entityValues.containsAll(values)) {
-// ok = false;
-// break;
-// }
-// }
-// } catch (IllegalAccessException eee) {
-// ok = false;
-// if (log.isWarnEnabled()) {
-// log.warn(
-// "Impossible d'acceder a la methode demandé pour l'obbjet "
-// + e, eee);
-// }
-// } catch (InvocationTargetException eee) {
-// ok = false;
-// if (log.isWarnEnabled()) {
-// log.warn(
-// "Impossible d'acceder a la methode demandé pour l'obbjet "
-// + e, eee);
-// }
-// } catch (NoSuchMethodException eee) {
-// ok = false;
-// if (log.isWarnEnabled()) {
-// log.warn(
-// "Impossible d'acceder a la methode demandé pour l'obbjet "
-// + e, eee);
-// }
-// }
-// if (ok) {
-// result.add(e);
-// }
-// }
-// return result;
-// }
-//
-// @Override
-// public List<E> findAllContainsProperties(String propertyName,
-// Collection values, Object... others) throws TopiaException {
-// Map<String, Collection<?>> properties = new HashMap<String, Collection<?>>();
-// properties.put(propertyName, values);
-// Object name = null;
-// for (int i = 0; i < others.length;) {
-// try {
-// name = others[i++];
-// values = (Collection) others[i++];
-// properties.put((String) name, values);
-// } catch (ClassCastException eee) {
-// throw new IllegalArgumentException(
-// "Les noms des propriétés doivent être des chaines et non pas "
-// + propertyName.getClass().getName(), eee);
-// } catch (ArrayIndexOutOfBoundsException eee) {
-// throw new IllegalArgumentException(
-// "Le nombre d'argument n'est pas un nombre pair: "
-// + (others.length + 2)
-// + " La dernière propriété était: " + name, eee);
-// }
-// }
-// List<E> result = findAllContainsProperties(properties);
-// return result;
-// }
-
- @Override
- public List<E> findAllByProperty(String propertyName, Object value)
- throws TopiaException {
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put(propertyName, value);
- List<E> result = findAllByProperties(properties);
- return result;
- }
-
- @Override
- public E findByProperty(String propertyName, Object value)
- throws TopiaException {
- Map<String, Object> properties = new HashMap<String, Object>();
- properties.put(propertyName, value);
- E result = findByProperties(properties);
- return result;
- }
-
- /**
- * Cette methode appelle fireVetoableCreate et fireOnCreated
- * Si vous la surchargé, faites attention a appeler le super
- * ou a appeler vous aussi ces deux methodes.
- */
- @Override
- public E create(Map<String, Object> properties) throws TopiaException {
- E result = instanciateNew();
-
- // TODO reflechir s'il ne faudrait pas creer l'id avant l'event precedent
- // reflechir toujours dans un context on les E pourrait ne pas
- // etre des TopiaEntity
- if (result instanceof TopiaEntity) {
- String topiaId = TopiaId.create(entityClass);
- TopiaEntityAbstract entity = (TopiaEntityAbstract) result;
- entity.setTopiaId(topiaId);
- entity.setTopiaContext(getContext());
- }
- try {
- for (Map.Entry<String, Object> e : properties.entrySet()) {
- String propertyName = e.getKey();
- Object value = e.getValue();
- PropertyUtils.setProperty(result, propertyName, value);
- }
- } catch (IllegalAccessException eee) {
- throw new IllegalArgumentException(
- "Can't put properties on new Object", eee);
- } catch (InvocationTargetException eee) {
- throw new IllegalArgumentException(
- "Can't put properties on new Object", eee);
- } catch (NoSuchMethodException eee) {
- throw new IllegalArgumentException(
- "Can't put properties on new Object", eee);
- }
-
- // on fait un save maintenant, car puisqu'on a creer l'entity au
- // travers du DAO, on s'attend a l'avoir a disposition tout de
- // suite pour les requetes sans avoir a faire un update dessus
- getSession().save(result);
- getContext().getFiresSupport().warnOnCreateEntity(result);
- return result;
- }
-
- @Override
- public E findByTopiaId(String k) throws TopiaException {
- return query(Restrictions.idEq(k));
- }
-
- @Override
- public List<E> findAll() throws TopiaException {
- try {
- Criteria criteria = createCriteria(FlushMode.AUTO);
- List<E> result = (List<E>) criteria.list();
- result = getContext().getFiresSupport().fireEntitiesLoad(context,
- result);
- return result;
- } catch (HibernateException eee) {
- throw new TopiaException(eee);
- }
- }
-
- @Override
- public List<String> findAllIds() throws TopiaException {
-// List<String> find = context.find("select src.topiaId from " + entityClass.getSimpleName() + "Impl src");
- List<String> find = context.find("select src.topiaId from " + getEntityClass() + " src");
- return find;
- }
-
-
-
- @Override
- public List<E> findAllWithOrder(String... propertyNames)
- throws TopiaException {
- try {
- Criteria criteria = createCriteria(FlushMode.AUTO);
- for (String propertyName : propertyNames) {
- criteria.addOrder(Order.asc(propertyName));
- }
- List<E> result = (List<E>) criteria.list();
- result = getContext().getFiresSupport().fireEntitiesLoad(context,
- result);
- return result;
- } catch (HibernateException eee) {
- throw new TopiaException(eee);
- }
- }
-
- @Override
- public E findByProperties(Map<String, Object> properties)
- throws TopiaException {
- return query(Restrictions.allEq(properties));
- }
-
- @Override
- public List<E> findAllByProperties(Map<String, Object> properties)
- throws TopiaException {
- return queryAll(Restrictions.allEq(properties));
- }
-
- private List<E> queryAll(Criterion criterion) throws TopiaException {
- try {
- Criteria criteria = createCriteria(FlushMode.AUTO);
- criteria.add(criterion);
- List<E> result = (List<E>) criteria.list();
- result = getContext().getFiresSupport().fireEntitiesLoad(context,
- result);
- return result;
- } catch (HibernateException eee) {
- throw new TopiaException(eee);
- }
- }
-
- private E query(Criterion criterion) throws TopiaException {
- try {
- Criteria criteria = createCriteria(FlushMode.AUTO);
- criteria.add(criterion);
- criteria.setMaxResults(1);
- List<E> result = (List<E>) criteria.list();
- int sizeBefore = result != null ? result.size() : 0;
- result = getContext().getFiresSupport().fireEntitiesLoad(context,
- result);
- int sizeAfter = result != null ? result.size() : 0;
- if (sizeAfter < sizeBefore) {
- if (log.isDebugEnabled()) {
- log.debug((sizeBefore - sizeAfter)
- + " element(s) removed. Filter entity: "
- + entityClass.getName() + " - criterion: "
- + criterion);
- }
- }
- if (result != null && result.size() > 0) {
- E elem = result.get(0);
- return elem;
- }
- return null;
- } catch (HibernateException eee) {
- throw new TopiaException(eee);
- }
- }
-
- //FIXME : Commenté car impossible de trouver le bon Criterion
- // ATTENTION ancienne methode du TopiaDAOAbstract deja presente dans le fichier
-
- // /* (non-Javadoc)
- // * @see org.nuiton.topia.persistence.TopiaDAO#findContainsProperties(java.util.Map)
- // */
- // public E findContainsProperties(Map<String, Collection> properties) throws TopiaException {
- // try {
- // Criteria criteria = createCriteria(FlushMode.AUTO);
- // for (Entry<String, Collection> entry : properties.entrySet()) {
- // for (Object value : entry.getValue()) {
- // criteria.add(Restrictions.eq(entry.getKey(), value));
- // }
- // }
- // criteria.setMaxResults(1);
- // List<E> results = (List<E>)criteria.list();
- // if (results.size() > 0) {
- // return (E)results.get(0);
- // } else {
- // return null;
- // }
- // } catch (HibernateException eee) {
- // throw new TopiaException(eee);
- // }
- // }
- //
- // /* (non-Javadoc)
- // * @see org.nuiton.topia.persistence.TopiaDAO#findAllContainsProperties(java.util.Map)
- // */
- // public List<E> findAllContainsProperties(Map<String, Collection> properties) throws TopiaException {
- // try {
- // Criteria criteria = createCriteria(FlushMode.AUTO);
- // for (Entry<String, Collection> entry : properties.entrySet()) {
- // for (Object value : entry.getValue()) {
- // criteria.add(Restrictions.eq(entry.getKey(), value));
- // }
- // }
- // List<E> result = (List<E>)criteria.list();
- // return result;
- // } catch (HibernateException eee) {
- // throw new TopiaException(eee);
- // }
- // }
-
- /**
- * Renvoie un Criteria créé avec l'entityClass
- * @param mode le FlushMode du Criteria
- * @return le Criteria nouvellement créé
- * @throws TopiaException if any pb
- */
- private Criteria createCriteria(FlushMode mode) throws TopiaException {
- Criteria criteria = getSession().createCriteria(entityClass);
- criteria.setFlushMode(mode);
- return criteria;
- }
-
-} //TopiaDAOLegacy
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java 2012-05-07 10:27:52 UTC (rev 2443)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java 2012-05-07 15:52:54 UTC (rev 2444)
@@ -27,13 +27,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.hibernate.exception.SQLGrammarException;
+//import org.hibernate.exception.SQLGrammarException;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.framework.TopiaContextImpl;
import org.nuiton.topia.persistence.TopiaEntity;
-import org.hibernate.SQLQuery;
-import org.hibernate.jdbc.Work;
+//import org.hibernate.SQLQuery;
+//import org.hibernate.jdbc.Work;
import java.io.IOException;
import java.io.InputStream;
1
0
r2443 - in trunk/topia-persistence/src/main/java/org/nuiton/topia: . framework generator persistence persistence/util
by athimel@users.nuiton.org 07 May '12
by athimel@users.nuiton.org 07 May '12
07 May '12
Author: athimel
Date: 2012-05-07 12:27:52 +0200 (Mon, 07 May 2012)
New Revision: 2443
Url: http://nuiton.org/repositories/revision/topia/2443
Log:
fixes #2076 Deprecate some code (.util package + TopiaQuery + ServiceTransformer)
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContext.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Collector.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Creator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Deletor.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DiffState.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityListUpdator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperatorStore.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/ListUpdator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Loador.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityBinder.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityIdsMap.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContext.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContext.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContext.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -182,7 +182,9 @@
* @param query TopiaQuery to execute
* @return a List of results as hibernate give us
* @throws TopiaException
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
List findByQuery(TopiaQuery query) throws TopiaException;
/**
@@ -192,7 +194,9 @@
* @param alias alias of the entity in the Query
* @return a new TopiaQuery
* @see TopiaQuery
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
TopiaQuery createQuery(Class<?> entityClass, String alias);
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -229,7 +229,10 @@
* <p/>
* Mise a jour: $Date$ par
* : $Author$
+ * @deprecated since 3.0. TopiaQuery does not provide the expected satisfaction.
+ * Will not be replaced for the moment.
*/
+@Deprecated
public class TopiaQuery {
private static final Log log = LogFactory.getLog(TopiaQuery.class);
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -182,8 +182,11 @@
* @version $Id$
* @since 2.3.1
* @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.generator.ServiceTransformer"
+ * @deprecated since 3.0. ServiceTransformer does not match the expected result.
+ * Will not be replaced.
*/
-// TODO : may be refactor to integrate JTA or webservice or may be not in this transformer.
+// TODO : may be refactor to integrate JTA or webservice or may be not in this transformer.
+@Deprecated
public class ServiceTransformer extends ObjectModelTransformerToJava {
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaStereoTypes.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -64,9 +64,11 @@
*
* @see ServiceTransformer
* @see TopiaGeneratorUtil#hasServiceStereotype(ObjectModelClassifier)
+ * @deprecated since ServiceTransformer is deprecated in 3.0
*/
@StereotypeDefinition(target = ObjectModelClassifier.class,
documentation = "To specify that a class is a Service")
+ @Deprecated
String STEREOTYPE_SERVICE = "service";
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaTagValues.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -342,10 +342,9 @@
/**
- * Tag pour specifier l'exception principale de l'application.
- * Utiliser dans le ServiceTransformer ou QueryHelperTransformer pour etre
- * automatiquement jeter
- * depuis les methodes des services.
+ * Tag pour spécifier l'exception principale de l'application.
+ * Utilisé dans le ServiceTransformer ou QueryHelperTransformer pour être
+ * automatiquement jeté depuis les méthodes des services.
*
* @see ServiceTransformer
* @see QueryHelperTransformer
@@ -368,9 +367,11 @@
* @see TopiaGeneratorUtil#getTransactionTagValue(ObjectModelClassifier)
* @see TopiaGeneratorUtil#getTransactionTagValue(ObjectModelOperation)
* @since 2.3.1
+ * @deprecated since ServiceTransformer is deprecated in 3.0
*/
@TagValueDefinition(target = {ObjectModelClassifier.class, ObjectModelOperation.class},
documentation = "Sets if an operation or a complete service required transaction (if set to true then a TopiaContext parameter will be added to methods)")
+ @Deprecated
String TAG_TRANSACTION = "transaction";
/**
@@ -380,9 +381,11 @@
* @see ServiceTransformer
* @see TopiaGeneratorUtil#getDoCommitTagValue(ObjectModelOperation, ObjectModel)
* @since 2.5
+ * @deprecated since ServiceTransformer is deprecated in 3.0
*/
@TagValueDefinition(target = {ObjectModelOperation.class},
documentation = "Sets if an operation needs a commit")
+ @Deprecated
String TAG_DO_COMMIT = "doCommit";
/**
@@ -392,9 +395,11 @@
* @see ServiceTransformer
* @see TopiaGeneratorUtil#getErrorArgsTagValue(ObjectModelOperation)
* @since 2.3.1
+ * @deprecated since ServiceTransformer is deprecated in 3.0
*/
@TagValueDefinition(target = {ObjectModelOperation.class},
documentation = "Sets if an operation required errors arguments ?")
+ @Deprecated
String TAG_ERROR_ARGS = "errorArgs";
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -53,9 +53,8 @@
* TopiaQuery}.
* <p/>
* This interface is implemented by {@link TopiaDAOImpl} overridden by generation
- * from {@link DAOTransformer} for specific entity interface, {@link
- * DAOAbstractTransformer} for abstract implementation and {@link
- * DAOImplTransformer} for final implementation class.
+ * from {@link org.nuiton.topia.generator.EntityDAOTransformer} for specific
+ * entity interface, abstract implementation and final implementation classes.
* <p/>
*
* @param <E> the entity type linked with the dao
@@ -220,7 +219,9 @@
* @return une nouvelle TopiaQuery vide. (uniquement avec le From sur le
* type d'entité)
* @since 2.3
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
TopiaQuery createQuery();
/**
@@ -233,7 +234,9 @@
* requête
* @return une nouvelle TopiaQuery
* @since 2.3
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
TopiaQuery createQuery(String entityAlias);
/**
@@ -272,7 +275,9 @@
* @throws TopiaException if any pb while getting datas
* @see TopiaQuery#executeToEntity(TopiaContext, Class)
* @since 2.3
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
E findByQuery(TopiaQuery query) throws TopiaException;
List<E> findAll() throws TopiaException;
@@ -311,7 +316,9 @@
* @throws TopiaException if any pb while getting datas
* @see TopiaQuery#executeToEntityList(TopiaContext, Class)
* @since 2.3
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
List<E> findAllByQuery(TopiaQuery query) throws TopiaException;
/**
@@ -324,7 +331,9 @@
* @throws TopiaException if any pb while getting datas
* @see TopiaQuery#executeToEntityMap(TopiaContext, Class)
* @since 2.3
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
Map<String, E> findAllMappedByQuery(TopiaQuery query) throws TopiaException;
/**
@@ -340,7 +349,9 @@
* @throws TopiaException if any pb while getting datas
* @see TopiaQuery#executeToEntityMap(TopiaContext, Class)
* @since 2.3
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
<K> Map<K, E> findAllMappedByQuery(TopiaQuery query,
String keyName, Class<K> keyClass) throws TopiaException;
@@ -408,7 +419,9 @@
* @return true if entity exists, false otherwise
* @throws TopiaException
* @since 2.3.4
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
boolean existByQuery(TopiaQuery query) throws TopiaException;
/**
@@ -427,7 +440,9 @@
* @return number of entities filtered by the query
* @throws TopiaException if any pb while getting datas
* @since 2.3.4
+ * @deprecated since TopiaQuery is deprecated in 3.0.
*/
+ @Deprecated
int countByQuery(TopiaQuery query) throws TopiaException;
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -322,11 +322,13 @@
}
@Override
+ @Deprecated
public TopiaQuery createQuery() {
return new TopiaQuery(getEntityClass());
}
@Override
+ @Deprecated
public TopiaQuery createQuery(String entityAlias) {
return new TopiaQuery(getEntityClass(), entityAlias);
}
@@ -369,6 +371,7 @@
}
@Override
+ @Deprecated
public E findByQuery(TopiaQuery query) throws TopiaException {
E result = query.executeToEntity(getContext(), getEntityClass());
return result;
@@ -414,12 +417,14 @@
}
@Override
+ @Deprecated
public List<E> findAllByQuery(TopiaQuery query) throws TopiaException {
List<E> results = query.executeToEntityList(getContext(), getEntityClass());
return results;
}
@Override
+ @Deprecated
public Map<String, E> findAllMappedByQuery(TopiaQuery query)
throws TopiaException {
Map<String, E> results =
@@ -428,6 +433,7 @@
}
@Override
+ @Deprecated
public <K> Map<K, E> findAllMappedByQuery(TopiaQuery query, String keyName,
Class<K> keyClass)
throws TopiaException {
@@ -480,6 +486,7 @@
}
@Override
+ @Deprecated
public boolean existByQuery(TopiaQuery query) throws TopiaException {
int count = countByQuery(query);
boolean result = count > 0;
@@ -493,6 +500,7 @@
}
@Override
+ @Deprecated
public int countByQuery(TopiaQuery query) throws TopiaException {
int result = query.executeCount(getContext());
return result;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaFilterPagerUtil.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -48,6 +48,7 @@
protected TopiaFilterPagerUtil() {
}
+ @Deprecated
public static TopiaQuery addPagerToQuery(TopiaQuery query,
FilterPagerBean pager) {
PagerUtil.computeRecordIndexesAndPagesNumber(pager);
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Collector.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Collector.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Collector.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -48,7 +48,9 @@
* @author tchemit <chemit(a)codelutin.com>
* @param <R> les donnes a retourner
* @since 2.2.0
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public abstract class Collector<R> {
private static final Log log = LogFactory.getLog(Collector.class);
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Creator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Creator.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Creator.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -37,7 +37,9 @@
* @param <P> the type of the parent of the entity to create (if entity has
* no parent then used the {@link Void} type).
* @param <E> the type of entity to create
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public interface Creator<P, E> {
/**
* Perform the creation of an entity.
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DBMapping.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -55,7 +55,9 @@
* On retrouve aussi ici des méthodes utils pour executer du code sql sur la base (notamment la gestion des séquences).
*
* @author tchemit <chemit(a)codelutin.com>
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public abstract class DBMapping {
/** log */
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Deletor.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Deletor.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Deletor.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -35,7 +35,9 @@
* says is not in a association)
* of another entity, just used the {@link Void} type).
* @param <E> the type of the entity to delete.
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public interface Deletor<P, E> {
/**
* Hook to delete an entity from a prent entity.
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DiffState.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DiffState.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/DiffState.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -37,7 +37,9 @@
* @author tchemit <chemit(a)codelutin.com>
* @see TopiaEntityHelper#buildDifferentiel(List, List)
* @since 2.2.0
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public enum DiffState {
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityListUpdator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityListUpdator.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityListUpdator.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -44,7 +44,9 @@
* @author tchemit <chemit(a)codelutin.com>
* @param <P> type of parent of childs
* @param <E> type of child
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public class EntityListUpdator<P extends TopiaEntity, E extends TopiaEntity> implements ListUpdator<P, E> {
public static <P extends TopiaEntity, E extends TopiaEntity> EntityListUpdator<P, E> newEntityListUpdator(Class<P> parentClass, Class<E> childClass, String propertyName) {
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperator.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperator.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -76,7 +76,9 @@
* @param <B> type de l'entite
* @author tchemit <chemit(a)codelutin.com>
* @since 2.2.0
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public class EntityOperator<B extends TopiaEntity> {
/** Logger */
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperatorStore.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperatorStore.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/EntityOperatorStore.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -35,7 +35,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @see EntityOperator
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public class EntityOperatorStore {
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/ListUpdator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/ListUpdator.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/ListUpdator.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -38,7 +38,9 @@
* @author tchemit <chemit(a)codelutin.com>
* @param <P> the type of the entity which contains the collection to update.
* @param <E> the type of entities in the collection.
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public interface ListUpdator<P, E> {
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Loador.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Loador.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/Loador.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -33,7 +33,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @param <E> type of bean to load
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public interface Loador<E> extends Serializable {
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityBinder.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityBinder.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityBinder.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -40,7 +40,9 @@
* @author tchemit < chemit(a)codelutin.com >
* @param <E> the type of entity
* @since 2.3.0
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public class TopiaEntityBinder<E extends TopiaEntity> extends Binder<E, E>
implements Loador<E> {
private static final long serialVersionUID = 1L;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityHelper.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -62,7 +62,9 @@
* Une classe avec des méthodes utiles sur les entités.
*
* @author tchemit <chemit(a)codelutin.com>
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public class TopiaEntityHelper {
/** to use log facility, just put in your code: log.info(\"...\"); */
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityIdsMap.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityIdsMap.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityIdsMap.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -35,7 +35,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.4.3
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public class TopiaEntityIdsMap extends HashMap<Class<? extends TopiaEntity>, List<String>> {
private static final long serialVersionUID = 1L;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityMap.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -37,7 +37,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.5.3
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public abstract class TopiaEntityMap<K extends TopiaEntityEnum, V extends TopiaEntity> extends HashMap<K, List<? extends V>> {
private static final long serialVersionUID = 1L;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java 2012-05-07 09:47:59 UTC (rev 2442)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/util/TopiaEntityRef.java 2012-05-07 10:27:52 UTC (rev 2443)
@@ -36,7 +36,9 @@
* TODO Javadoc...
*
* @since 2.2.0
+ * @deprecated since 3.0 not useful anymore
*/
+@Deprecated
public class TopiaEntityRef implements Comparable<TopiaEntityRef> {
public static final String SEPARATOR = "/";
1
0
r2442 - in trunk: . topia-persistence topia-service-migration topia-service-replication topia-service-security
by tchemit@users.nuiton.org 07 May '12
by tchemit@users.nuiton.org 07 May '12
07 May '12
Author: tchemit
Date: 2012-05-07 11:47:59 +0200 (Mon, 07 May 2012)
New Revision: 2442
Url: http://nuiton.org/repositories/revision/topia/2442
Log:
remove svn Id property on pom.xml
Modified:
trunk/pom.xml
trunk/topia-persistence/pom.xml
trunk/topia-service-migration/pom.xml
trunk/topia-service-replication/pom.xml
trunk/topia-service-security/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-07 09:46:50 UTC (rev 2441)
+++ trunk/pom.xml 2012-05-07 09:47:59 UTC (rev 2442)
@@ -3,7 +3,6 @@
#%L
ToPIA
- $Id$
$HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
Modified: trunk/topia-persistence/pom.xml
===================================================================
--- trunk/topia-persistence/pom.xml 2012-05-07 09:46:50 UTC (rev 2441)
+++ trunk/topia-persistence/pom.xml 2012-05-07 09:47:59 UTC (rev 2442)
@@ -3,7 +3,6 @@
#%L
ToPIA :: Persistence
- $Id$
$HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
Modified: trunk/topia-service-migration/pom.xml
===================================================================
--- trunk/topia-service-migration/pom.xml 2012-05-07 09:46:50 UTC (rev 2441)
+++ trunk/topia-service-migration/pom.xml 2012-05-07 09:47:59 UTC (rev 2442)
@@ -3,7 +3,6 @@
#%L
ToPIA :: Service Migration
- $Id$
$HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
Modified: trunk/topia-service-replication/pom.xml
===================================================================
--- trunk/topia-service-replication/pom.xml 2012-05-07 09:46:50 UTC (rev 2441)
+++ trunk/topia-service-replication/pom.xml 2012-05-07 09:47:59 UTC (rev 2442)
@@ -3,7 +3,6 @@
#%L
ToPIA :: Service Replication
- $Id$
$HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
Modified: trunk/topia-service-security/pom.xml
===================================================================
--- trunk/topia-service-security/pom.xml 2012-05-07 09:46:50 UTC (rev 2441)
+++ trunk/topia-service-security/pom.xml 2012-05-07 09:47:59 UTC (rev 2442)
@@ -3,7 +3,6 @@
#%L
ToPIA :: Service Security
- $Id$
$HeadURL$
%%
Copyright (C) 2004 - 2010 CodeLutin
1
0
r2441 - in trunk: . src/site src/site/resources src/site/resources/images src/site/resources/images/logos topia-persistence topia-persistence/src/site topia-service-migration/src/site topia-service-replication/src/site topia-service-security/src/site
by tchemit@users.nuiton.org 07 May '12
by tchemit@users.nuiton.org 07 May '12
07 May '12
Author: tchemit
Date: 2012-05-07 11:46:50 +0200 (Mon, 07 May 2012)
New Revision: 2441
Url: http://nuiton.org/repositories/revision/topia/2441
Log:
updates to mavenpom 3.3.1 and migrates to fluido skin
Added:
trunk/src/site/resources/
trunk/src/site/resources/images/
trunk/src/site/resources/images/logos/
trunk/src/site/resources/images/logos/jrst-logo.png
trunk/src/site/resources/images/logos/restructuredtext-logo.png
Modified:
trunk/pom.xml
trunk/src/site/site_fr.xml
trunk/topia-persistence/pom.xml
trunk/topia-persistence/src/site/site_fr.xml
trunk/topia-service-migration/src/site/site_fr.xml
trunk/topia-service-replication/src/site/site_fr.xml
trunk/topia-service-security/src/site/site_fr.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-07 09:40:37 UTC (rev 2440)
+++ trunk/pom.xml 2012-05-07 09:46:50 UTC (rev 2441)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.2</version>
+ <version>3.3.1</version>
</parent>
<artifactId>topia</artifactId>
@@ -118,6 +118,11 @@
</exclusions>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${hibernateVersion}</version>
+ </dependency>
<dependency>
<groupId>org.hibernate</groupId>
Added: trunk/src/site/resources/images/logos/jrst-logo.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/images/logos/jrst-logo.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/src/site/resources/images/logos/restructuredtext-logo.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/site/resources/images/logos/restructuredtext-logo.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2012-05-07 09:40:37 UTC (rev 2440)
+++ trunk/src/site/site_fr.xml 2012-05-07 09:46:50 UTC (rev 2441)
@@ -26,11 +26,35 @@
<project name="ToPIA">
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.2.1</version>
+ </skin>
+
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <googleSearch/>
+ <sideBarEnabled>false</sideBarEnabled>
+ <searchEnabled>true</searchEnabled>
+ <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled>
+ </fluidoSkin>
+ </custom>
+
<bannerLeft>
<name>${project.name}</name>
<href>index.html</href>
</bannerLeft>
+ <bannerRight>
+ <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
+ <href>http://www.codelutin.com</href>
+ </bannerRight>
+
+ <publishDate position="right" />
+ <version position="right" />
+
<poweredBy>
<logo href="http://maven.apache.org" name="Maven"
img="${project.url}/images/logos/maven-feather.png"/>
@@ -48,8 +72,15 @@
<body>
+ <links>
+ <item name="Nuiton.org" href="http://nuiton.org"/>
+ <item name="Code Lutin" href="http://www.codelutin.com"/>
+ <item name="Libre entreprise" href="http://www.libre-entreprise.org"/>
+ </links>
+
<breadcrumbs>
- <item href="http://maven-site.nuiton.org/topia" name="${project.name}"/>
+ <item href="http://maven-site.nuiton.org/topia/index.html"
+ name="${project.name}"/>
</breadcrumbs>
<menu name="Utilisateur">
@@ -60,5 +91,23 @@
<menu ref="reports"/>
+ <footer>
+
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+
+ <div id='projectMetas'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.url}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
</body>
</project>
Modified: trunk/topia-persistence/pom.xml
===================================================================
--- trunk/topia-persistence/pom.xml 2012-05-07 09:40:37 UTC (rev 2440)
+++ trunk/topia-persistence/pom.xml 2012-05-07 09:46:50 UTC (rev 2441)
@@ -89,6 +89,11 @@
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <version>${hibernateVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
</dependency>
Modified: trunk/topia-persistence/src/site/site_fr.xml
===================================================================
--- trunk/topia-persistence/src/site/site_fr.xml 2012-05-07 09:40:37 UTC (rev 2440)
+++ trunk/topia-persistence/src/site/site_fr.xml 2012-05-07 09:46:50 UTC (rev 2441)
@@ -83,5 +83,24 @@
<menu ref="reports"/>
+ <footer>
+
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+
+ <div id='projectMetas'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.url}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
</body>
</project>
Modified: trunk/topia-service-migration/src/site/site_fr.xml
===================================================================
--- trunk/topia-service-migration/src/site/site_fr.xml 2012-05-07 09:40:37 UTC (rev 2440)
+++ trunk/topia-service-migration/src/site/site_fr.xml 2012-05-07 09:46:50 UTC (rev 2441)
@@ -55,5 +55,23 @@
<menu ref="reports"/>
+ <footer>
+
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+
+ <div id='projectMetas'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.url}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
</body>
</project>
Modified: trunk/topia-service-replication/src/site/site_fr.xml
===================================================================
--- trunk/topia-service-replication/src/site/site_fr.xml 2012-05-07 09:40:37 UTC (rev 2440)
+++ trunk/topia-service-replication/src/site/site_fr.xml 2012-05-07 09:46:50 UTC (rev 2441)
@@ -52,5 +52,23 @@
<menu ref="reports"/>
+ <footer>
+
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+
+ <div id='projectMetas'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.url}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
</body>
</project>
Modified: trunk/topia-service-security/src/site/site_fr.xml
===================================================================
--- trunk/topia-service-security/src/site/site_fr.xml 2012-05-07 09:40:37 UTC (rev 2440)
+++ trunk/topia-service-security/src/site/site_fr.xml 2012-05-07 09:46:50 UTC (rev 2441)
@@ -59,5 +59,24 @@
<menu ref="reports"/>
+ <footer>
+
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+
+ <div id='projectMetas'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.url}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
</body>
</project>
1
0