details:   https://code.openbravo.com/erp/devel/pi/rev/c0d0ff12a14b
changeset: 24083:c0d0ff12a14b
user:      Inigo Sanchez <inigo.sanchez <at> openbravo.com>
date:      Mon Jul 21 08:40:58 2014 +0200
summary:   related to bug 27107: fixed test cases in TableNameTest

diffstat:

 src-test/org/openbravo/test/modularity/TableNameTest.java |  37 +++++++++++---
 1 files changed, 29 insertions(+), 8 deletions(-)

diffs (134 lines):

diff -r 4adfa3a31483 -r c0d0ff12a14b 
src-test/org/openbravo/test/modularity/TableNameTest.java
--- a/src-test/org/openbravo/test/modularity/TableNameTest.java Mon Jul 21 
10:18:17 2014 +0530
+++ b/src-test/org/openbravo/test/modularity/TableNameTest.java Mon Jul 21 
08:40:58 2014 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2009-2011 Openbravo SLU 
+ * All portions are Copyright (C) 2009-2014 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -39,6 +39,9 @@
  * be checkes the table name starts with the db prefix for the module and it 
is not possible to add
  * tables with non-allowed names.
  * 
+ * IMPORTANT: Test cases are called by one of them called testContent(). The 
name of the rest of the
+ * test cases NOT begin by "test...".
+ * 
  * @author alostale
  */
 public class TableNameTest extends BaseTest {
@@ -46,9 +49,22 @@
   private static final Logger log = Logger.getLogger(TableNameTest.class);
 
   /**
+   * This test contains the invocations for the rest of the test cases. By 
this way, we preserve the
+   * execution order of the test cases.
+   */
+  public void testContent() {
+    createModule();
+    createTable1();
+    createTable2();
+    createTable3();
+    changePackage();
+    cleanUp();
+  }
+
+  /**
    * Creates a test module to work with it in later tests
    */
-  public void testCreateModule() {
+  public void createModule() {
     setSystemAdministratorContext();
     Module module = OBProvider.getInstance().get(Module.class);
     module.setName("Test-table-names");
@@ -69,13 +85,14 @@
     pack.setModule(module);
     OBDal.getInstance().save(pack);
     commitTransaction();
+    OBDal.getInstance().flush();
   }
 
   /**
    * Creates a table that is valid, it has a valid name according with the db 
prefix for the module
    * it is assigned to
    */
-  public void testCreateTable1() {
+  public void createTable1() {
     setSystemAdministratorContext();
     Table table = OBProvider.getInstance().get(Table.class);
     table.setName("TEST1_Table1");
@@ -86,13 +103,14 @@
     table.setDataPackage(getPackage("org.openbravo.test.tablename.data"));
     OBDal.getInstance().save(table);
     commitTransaction();
+    OBDal.getInstance().flush();
   }
 
   /**
    * It tries to insert a table with a non-valid name prefix, it is tested 
that DB raises an
    * exception and thus the table is not inserted.
    */
-  public void testCreateTable2() {
+  public void createTable2() {
     setSystemAdministratorContext();
     Table table = OBProvider.getInstance().get(Table.class);
     table.setName("TEST_Table2");
@@ -111,13 +129,14 @@
     } catch (QueryTimeoutException e) { // thrown on oracle
       rollback();
     }
+    OBDal.getInstance().flush();
   }
 
   /**
    * Same test as testCreateTable2 but trying to insert the table in a package 
that for core module,
    * it should not insert anything
    */
-  public void testCreateTable3() {
+  public void createTable3() {
     setSystemAdministratorContext();
     Table table = OBProvider.getInstance().get(Table.class);
     table.setName("TEST1_Table3");
@@ -136,13 +155,14 @@
     } catch (QueryTimeoutException e) { // thrown on oracle
       rollback();
     }
+    OBDal.getInstance().flush();
   }
 
   /**
    * This test tryies to change the package for the table created in 
testCreateTable1 to a package
    * in core, this should fail because the naming rules are not filled
    */
-  public void testChangePackage() {
+  public void changePackage() {
     setSystemAdministratorContext();
     OBCriteria<Table> obCriteria = 
OBDal.getInstance().createCriteria(Table.class);
     obCriteria.add(Restrictions.eq(Module.PROPERTY_NAME, "TEST1_Table1"));
@@ -159,12 +179,13 @@
     } catch (QueryTimeoutException e) { // thrown on oracle
       rollback();
     }
+    OBDal.getInstance().flush();
   }
 
   /**
    * Removes all created objects from database.
    */
-  public void testCleanUp() {
+  public void cleanUp() {
     setSystemAdministratorContext();
     OBCriteria<Module> obCriteria = 
OBDal.getInstance().createCriteria(Module.class);
     obCriteria.add(Restrictions.eq(Module.PROPERTY_NAME, "Test-table-names"));
@@ -205,7 +226,7 @@
       OBDal.getInstance().remove(module);
       commitTransaction();
     }
-
+    OBDal.getInstance().flush();
   }
 
   private DataPackage getPackage(String name) {

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to