JBoss JBPM SVN: r6879 - in jbpm4/trunk: test-base/src/main/java/org/jbpm/test and 2 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2010-12-22 21:29:52 -0500 (Wed, 22 Dec 2010)
New Revision: 6879
Removed:
jbpm4/trunk/test-enterprise/
Modified:
jbpm4/trunk/pom.xml
jbpm4/trunk/test-base/src/main/java/org/jbpm/test/Db.java
jbpm4/trunk/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/trunk/test-cactus/pom.xml
jbpm4/trunk/test-db/pom.xml
Log:
JBPM-2985 explicitly declare janino dependency in test-db and test-cactus;
guard against null configuration in Db.verifyClean to avoid NPE in spring test suite
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2010-12-21 03:22:34 UTC (rev 6878)
+++ jbpm4/trunk/pom.xml 2010-12-23 02:29:52 UTC (rev 6879)
@@ -316,6 +316,11 @@
<version>3.4.0.GA</version>
</dependency>
<dependency>
+ <groupId>janino</groupId>
+ <artifactId>janino</artifactId>
+ <version>2.5.10</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.javaee</groupId>
<artifactId>jboss-javaee</artifactId>
<version>5.0.1.GA</version>
Modified: jbpm4/trunk/test-base/src/main/java/org/jbpm/test/Db.java
===================================================================
--- jbpm4/trunk/test-base/src/main/java/org/jbpm/test/Db.java 2010-12-21 03:22:34 UTC (rev 6878)
+++ jbpm4/trunk/test-base/src/main/java/org/jbpm/test/Db.java 2010-12-23 02:29:52 UTC (rev 6879)
@@ -43,35 +43,31 @@
* @author Tom Baeyens
*/
public class Db {
-
+
private static final Map<ProcessEngine, String[]> cleanSqlCache = new HashMap<ProcessEngine, String[]>();
private static final Map<ProcessEngine, String[]> tableNamesCache = new HashMap<ProcessEngine, String[]>();
-
+
public static void clean(ProcessEngine processEngine) {
SessionFactory sessionFactory = processEngine.get(SessionFactory.class);
// when running this with a remote ejb invocation configuration, there is no
// session factory and no cleanup needs to be done
- if (sessionFactory==null) {
- return;
- }
-
+ if (sessionFactory == null) return;
+
String[] cleanSql = cleanSqlCache.get(processEngine);
if (cleanSql == null) {
Configuration configuration = processEngine.get(Configuration.class);
-
+
SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
Dialect dialect = sessionFactoryImplementor.getDialect();
// loop over all foreign key constraints
List<String> dropForeignKeysSql = new ArrayList<String>();
List<String> createForeignKeysSql = new ArrayList<String>();
-
- //if no session-factory is build, the configuration is not fully initialized.
- //Hence, the ForeignKey's won't have a referenced table. This is calculated on
- //second pass.
+
+ // build mappings so that ForeignKeys have a referenced table
configuration.buildMappings();
-
+
for (Iterator<?> iter = configuration.getTableMappings(); iter.hasNext();) {
Table table = (Table) iter.next();
if (table.isPhysicalTable()) {
@@ -88,7 +84,8 @@
// This index should be dropped or an error will be thrown during
// the creation phase
if (dialect instanceof MySQLDialect) {
- dropForeignKeysSql.add("alter table " + table.getName() + " drop key " + fk.getName());
+ dropForeignKeysSql.add("alter table " + table.getName() + " drop key "
+ + fk.getName());
}
// and collect the create foreign key constraint sql
createForeignKeysSql.add(fk.sqlCreateString(dialect, sessionFactoryImplementor, catalog, schema));
@@ -116,7 +113,6 @@
cleanSqlList.addAll(createForeignKeysSql);
cleanSql = cleanSqlList.toArray(new String[cleanSqlList.size()]);
-
cleanSqlCache.put(processEngine, cleanSql);
}
@@ -126,7 +122,8 @@
// log.trace(query);
session.createSQLQuery(query).executeUpdate();
}
- } finally {
+ }
+ finally {
session.close();
}
}
@@ -135,51 +132,55 @@
SessionFactory sessionFactory = processEngine.get(SessionFactory.class);
// when running this with a remote ejb invocation configuration, there is no
// session factory and no cleanup needs to be done
- if (sessionFactory==null) {
- return null;
- }
-
+ if (sessionFactory == null) return null;
+
String[] tableNames = tableNamesCache.get(processEngine);
if (tableNames == null) {
Configuration configuration = processEngine.get(Configuration.class);
-
- // loop over all foreign key constraints
- List<String> tableNamesList = new ArrayList<String>();
- for (Iterator<?> iter = configuration.getTableMappings(); iter.hasNext();) {
- Table table = (Table) iter.next();
- if (table.isPhysicalTable()) {
- tableNamesList.add(table.getName());
+ if (configuration != null) {
+ // loop over all foreign key constraints
+ List<String> tableNamesList = new ArrayList<String>();
+ for (Iterator<?> iter = configuration.getTableMappings(); iter.hasNext();) {
+ Table table = (Table) iter.next();
+ if (table.isPhysicalTable()) {
+ tableNamesList.add(table.getName());
+ }
}
+
+ tableNames = tableNamesList.toArray(new String[tableNamesList.size()]);
+ tableNamesCache.put(processEngine, tableNames);
}
-
- tableNames = tableNamesList.toArray(new String[tableNamesList.size()]);
-
- tableNamesCache.put(processEngine, tableNames);
}
- String recordsLeftMsg = "";
- Session session = sessionFactory.openSession();
- try {
- for (String tableName : tableNames) {
- if (!"JBPM4_PROPERTY".equals(tableName)) {
- String countSql = "select count(*) as RECORD_COUNT_ from "+tableName;
- SQLQuery sqlQuery = session.createSQLQuery(countSql);
- sqlQuery.addScalar("RECORD_COUNT_", Hibernate.LONG);
- Long recordCount = (Long) sqlQuery.uniqueResult();
- if (recordCount>0L) {
- recordsLeftMsg += tableName+":"+recordCount+", ";
+ if (tableNames != null) {
+ StringBuilder recordsLeftMsg = new StringBuilder();
+
+ Session session = sessionFactory.openSession();
+ try {
+ for (String tableName : tableNames) {
+ if (!"JBPM4_PROPERTY".equals(tableName)) {
+ String countSql = "select count(*) as RECORD_COUNT_ from " + tableName;
+ SQLQuery sqlQuery = session.createSQLQuery(countSql);
+ sqlQuery.addScalar("RECORD_COUNT_", Hibernate.LONG);
+ Long recordCount = (Long) sqlQuery.uniqueResult();
+ if (recordCount > 0L) {
+ if (recordsLeftMsg.length() > 0) recordsLeftMsg.append(", ");
+ recordsLeftMsg.append(tableName).append(':').append(recordCount);
+ }
}
}
}
- } finally {
- session.close();
+ finally {
+ session.close();
+ }
+
+ if (recordsLeftMsg.length() > 0) {
+ clean(processEngine);
+ return recordsLeftMsg.toString();
+ }
}
-
- if (recordsLeftMsg.length()>0) {
- clean(processEngine);
- }
-
- return recordsLeftMsg;
+
+ return null;
}
}
Modified: jbpm4/trunk/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2010-12-21 03:22:34 UTC (rev 6878)
+++ jbpm4/trunk/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2010-12-23 02:29:52 UTC (rev 6879)
@@ -164,7 +164,7 @@
protected String verifyDbClean() {
String recordsLeftMsg = Db.verifyClean(processEngine);
- if (recordsLeftMsg != null && recordsLeftMsg.length() > 0) {
+ if (recordsLeftMsg != null) {
return "database was not clean after test: " + recordsLeftMsg;
}
return null;
Modified: jbpm4/trunk/test-cactus/pom.xml
===================================================================
--- jbpm4/trunk/test-cactus/pom.xml 2010-12-21 03:22:34 UTC (rev 6878)
+++ jbpm4/trunk/test-cactus/pom.xml 2010-12-23 02:29:52 UTC (rev 6879)
@@ -70,6 +70,10 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
+ <groupId>janino</groupId>
+ <artifactId>janino</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-smtp</artifactId>
<version>1.2</version>
Modified: jbpm4/trunk/test-db/pom.xml
===================================================================
--- jbpm4/trunk/test-db/pom.xml 2010-12-21 03:22:34 UTC (rev 6878)
+++ jbpm4/trunk/test-db/pom.xml 2010-12-23 02:29:52 UTC (rev 6879)
@@ -54,6 +54,11 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>janino</groupId>
+ <artifactId>janino</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<scope>test</scope>