[jbpm-commits] JBoss JBPM SVN: r3931 - in jbpm3/trunk/modules/core: src/main/java/org/jbpm/db and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Feb 18 19:28:36 EST 2009


Author: alex.guizar at jboss.com
Date: 2009-02-18 19:28:36 -0500 (Wed, 18 Feb 2009)
New Revision: 3931

Added:
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
Removed:
   jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
Modified:
   jbpm3/trunk/modules/core/pom.xml
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
Log:
JBPM-1810: fix clean, drop, create schema with JbpmSchema

Modified: jbpm3/trunk/modules/core/pom.xml
===================================================================
--- jbpm3/trunk/modules/core/pom.xml	2009-02-18 17:19:18 UTC (rev 3930)
+++ jbpm3/trunk/modules/core/pom.xml	2009-02-19 00:28:36 UTC (rev 3931)
@@ -250,12 +250,6 @@
         <plugins>
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <excludes>
-                <!-- [JBPM-1810] Fix clean, drop, create schema with JbpmSchema  -->
-                <exclude>org/jbpm/db/JbpmSchemaDbTest.java</exclude>
-              </excludes>
-            </configuration>
           </plugin>
         </plugins>
       </build>
@@ -277,12 +271,6 @@
         <plugins>
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <excludes>
-                <!-- [JBPM-1810] Fix clean, drop, create schema with JbpmSchema  -->
-                <exclude>org/jbpm/db/JbpmSchemaDbTest.java</exclude>
-              </excludes>
-            </configuration>
           </plugin>
         </plugins>
       </build>
@@ -304,14 +292,6 @@
         <plugins>
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <excludes>
-                <!-- [JBPM-1166] SEAM timer transaction integration -->
-                <exclude>org/jbpm/seam/JobExecutorCustomizationTest.java</exclude>
-                <!-- [JBPM-1810] Fix clean, drop, create schema with JbpmSchema  -->
-                <exclude>org/jbpm/db/JbpmSchemaDbTest.java</exclude>
-              </excludes>
-            </configuration>
           </plugin>
         </plugins>
       </build>
@@ -333,12 +313,6 @@
         <plugins>
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <excludes>
-                <!-- [JBPM-1810] Fix clean, drop, create schema with JbpmSchema  -->
-                <exclude>org/jbpm/db/JbpmSchemaDbTest.java</exclude>
-              </excludes>
-            </configuration>
           </plugin>
         </plugins>
       </build>
@@ -360,12 +334,6 @@
         <plugins>
           <plugin>
             <artifactId>maven-surefire-plugin</artifactId>
-            <configuration>
-              <excludes>
-                <!-- [JBPM-1810] Fix clean, drop, create schema with JbpmSchema  -->
-                <exclude>org/jbpm/db/JbpmSchemaDbTest.java</exclude>
-              </excludes>
-            </configuration>
           </plugin>
         </plugins>
       </build>

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2009-02-18 17:19:18 UTC (rev 3930)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JbpmSchema.java	2009-02-19 00:28:36 UTC (rev 3931)
@@ -27,17 +27,19 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
-import java.io.Serializable;
 import java.sql.Connection;
+import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -53,10 +55,8 @@
 /**
  * utilities for the jBPM database schema.
  */
-public class JbpmSchema implements Serializable {
+public class JbpmSchema {
 
-  private static final long serialVersionUID = 1L;
-
   final Configuration configuration;
   final Settings settings;
 
@@ -82,33 +82,39 @@
     return concat(getDropSql(), getCreateSql());
   }
 
-  public List<String> getTableNames() {
-    List<String> tableNames = new ArrayList<String>();
+  public Set<String> getJbpmTables() {
+    Set<String> jbpmTables = new HashSet<String>();
     for (Iterator<?> i = configuration.getTableMappings(); i.hasNext();) {
       Table table = (Table) i.next();
       if (table.isPhysicalTable()) {
-        tableNames.add(table.getName());
+        jbpmTables.add(table.getName());
       }
     }
-    return tableNames;
+    return jbpmTables;
   }
 
-  public List<String> getAvailableTableNames() {
+  public Set<String> getExistingTables() {
     try {
       createConnection();
-      List<String> tableNames = new ArrayList<String>();
+      Set<String> existingTables = new HashSet<String>();
 
-      ResultSet resultSet = connection.getMetaData().getTables(settings.getDefaultCatalogName(),
-          settings.getDefaultSchemaName(), "JBPM_%", new String[] { "TABLE" });
+      DatabaseMetaData metaData = connection.getMetaData();
+      boolean storesLowerCaseIdentifiers = metaData.storesLowerCaseIdentifiers();
+      ResultSet resultSet = metaData.getTables(settings.getDefaultCatalogName(),
+          settings.getDefaultSchemaName(), null, new String[] { "TABLE" });
       try {
         while (resultSet.next()) {
-          tableNames.add(resultSet.getString("TABLE_NAME"));
+          String tableName = resultSet.getString("TABLE_NAME");
+          if (storesLowerCaseIdentifiers) {
+            tableName = tableName.toUpperCase();
+          }
+          existingTables.add(tableName);
         }
       }
       finally {
         resultSet.close();
       }
-      return tableNames;
+      return existingTables;
     }
     catch (SQLException e) {
       throw new JbpmException("could not get available table names", e);
@@ -123,7 +129,7 @@
     try {
       createConnection();
       Statement statement = connection.createStatement();
-      for (String tableName : getTableNames()) {
+      for (String tableName : getJbpmTables()) {
         String sql = "SELECT COUNT(*) FROM " + tableName;
         ResultSet resultSet = statement.executeQuery(sql);
         if (!resultSet.next()) throw new JbpmException("empty result set: " + sql);
@@ -345,7 +351,6 @@
         }
         catch (SQLException e) {
           exceptions.add(e);
-          log.debug("unsuccessful: " + sql);
           log.debug(e.getMessage());
         }
       }

Deleted: jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java	2009-02-18 17:19:18 UTC (rev 3930)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java	2009-02-19 00:28:36 UTC (rev 3931)
@@ -1,63 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This 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 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.db;
-
-import java.util.Map;
-
-import org.hibernate.cfg.Configuration;
-import org.jbpm.AbstractJbpmTestCase;
-
-/**
- * Test the JbpmSchema utility
- * 
- * @author thomas.diesler at jboss.com
- * @since 06-Nov-2008
- */
-public class JbpmSchemaDbTest extends AbstractJbpmTestCase {
-
-  JbpmSchema jbpmSchema;
-
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-    jbpmSchema = new JbpmSchema(new Configuration().configure());
-  }
-
-  public void testCreateSchema() {
-    jbpmSchema.createSchema();
-    assertEquals(28, jbpmSchema.getAvailableTableNames().size());
-  }
-
-  public void testDropSchema() {
-    jbpmSchema.dropSchema();
-    assertEquals(0, jbpmSchema.getAvailableTableNames().size());
-  }
-
-  public void testCleanSchema() {
-    jbpmSchema.cleanSchema();
-    Map<String, Long> rowsPerTable = jbpmSchema.getRowsPerTable();
-    assertEquals(28, rowsPerTable.size());
-    for (long rowCount : rowsPerTable.values()) {
-      assertEquals(0, rowCount);
-    }
-  }
-}

Copied: jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java (from rev 3909, jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java)
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java	                        (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/db/JbpmSchemaDbTest.java	2009-02-19 00:28:36 UTC (rev 3931)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.hibernate.cfg.Configuration;
+import org.jbpm.AbstractJbpmTestCase;
+
+/**
+ * Test the JbpmSchema utility
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 06-Nov-2008
+ */
+public class JbpmSchemaDbTest extends AbstractJbpmTestCase {
+
+  JbpmSchema jbpmSchema;
+
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    jbpmSchema = new JbpmSchema(new Configuration().configure());
+  }
+
+  public void testCreateSchema() {
+    jbpmSchema.createSchema();
+    Set<String> existingTables = jbpmSchema.getExistingTables();
+    assert existingTables.containsAll(jbpmSchema.getJbpmTables()) : existingTables;
+  }
+
+  public void testDropSchema() {
+    jbpmSchema.dropSchema();
+    Set<String> existingTables = jbpmSchema.getExistingTables();
+    for (String jbpmTable : jbpmSchema.getJbpmTables()) {
+      assert !existingTables.contains(jbpmTable) : existingTables;
+    }
+  }
+
+  public void testCleanSchema() {
+    jbpmSchema.cleanSchema();
+    Map<String, Long> rowsPerTable = jbpmSchema.getRowsPerTable();
+    Set<String> existingTables = jbpmSchema.getExistingTables();
+    assert existingTables.containsAll(rowsPerTable.keySet()) : existingTables;
+
+    for (long rowCount : rowsPerTable.values()) {
+      assertEquals(0, rowCount);
+    }
+  }
+}




More information about the jbpm-commits mailing list