details: https://code.openbravo.com/erp/devel/pi/rev/c279870e202b
changeset: 24086:c279870e202b
user: Inigo Sanchez <inigo.sanchez <at> openbravo.com>
date: Mon Jul 21 12:35:34 2014 +0200
summary: related to bug 27107: fixed test cases in DynamicEntityTest and
other.
diffstat:
src-test/org/openbravo/test/dal/DynamicEntityTest.java | 25 ++++++++-
src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java | 16 +++++-
2 files changed, 34 insertions(+), 7 deletions(-)
diffs (149 lines):
diff -r 1009aa7d91bf -r c279870e202b
src-test/org/openbravo/test/dal/DynamicEntityTest.java
--- a/src-test/org/openbravo/test/dal/DynamicEntityTest.java Mon Jul 21
09:35:59 2014 +0200
+++ b/src-test/org/openbravo/test/dal/DynamicEntityTest.java Mon Jul 21
12:35:34 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) 2008-2011 Openbravo SLU
+ * All portions are Copyright (C) 2008-2014 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -38,6 +38,9 @@
/**
* Test the use of the {@link DynamicOBObject}.
*
+ * 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 mtaal
*/
@@ -45,9 +48,19 @@
private static final Logger log = Logger.getLogger(DynamicEntityTest.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() {
+ createBPGroup();
+ removeBPGroup();
+ checkBPGroupRemoved();
+ }
+
+ /**
* Create a record for the {@link Category} in the database using a {@link
DynamicOBObject}.
*/
- public void testCreateBPGroup() {
+ public void createBPGroup() {
setTestUserContext();
addReadWriteAccess(Category.class);
final DynamicOBObject bpGroup = new DynamicOBObject();
@@ -58,13 +71,14 @@
bpGroup.set(Category.PROPERTY_SEARCHKEY, "hello world");
bpGroup.setActive(true);
OBDal.getInstance().save(bpGroup);
+ OBDal.getInstance().commitAndClose();
printXML(bpGroup);
}
/**
* Queries for the created {@link Category} and then removes.
*/
- public void testRemoveBPGroup() {
+ public void removeBPGroup() {
setTestUserContext();
addReadWriteAccess(Category.class);
addReadWriteAccess(CategoryAccounts.class);
@@ -95,21 +109,24 @@
obc2.add(Restrictions.eq(CategoryAccounts.PROPERTY_BUSINESSPARTNERCATEGORY,
bpgs.get(0)));
final List<CategoryAccounts> bogas = obc2.list();
for (final CategoryAccounts bga : bogas) {
+ OBDal.getInstance().refresh(bga);
OBDal.getInstance().remove(bga);
}
OBDal.getInstance().remove(bpgs.get(0));
+ OBDal.getInstance().flush();
}
/**
* Checks if the removal did occur.
*/
- public void testCheckBPGroupRemoved() {
+ public void checkBPGroupRemoved() {
setTestUserContext();
addReadWriteAccess(Category.class);
final OBCriteria<Category> obc =
OBDal.getInstance().createCriteria(Category.class);
obc.add(Restrictions.eq(Category.PROPERTY_NAME, "hello world"));
final List<Category> bpgs = obc.list();
assertEquals(0, bpgs.size());
+ OBDal.getInstance().flush();
}
private void printXML(BaseOBObject bob) {
diff -r 1009aa7d91bf -r c279870e202b
src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java
--- a/src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java Mon Jul
21 09:35:59 2014 +0200
+++ b/src-test/org/openbravo/test/xml/UniqueConstraintImportTest.java Mon Jul
21 12:35:34 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) 2008-2011 Openbravo SLU
+ * All portions are Copyright (C) 2008-2014 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
@@ -44,6 +44,9 @@
* there is an object with B which also has the value V1 for the unique key
field. Then object A
* will overwrite object B in the database.
*
+ * 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 mtaal
*/
@@ -51,10 +54,15 @@
private static final Logger log =
Logger.getLogger(UniqueConstraintImportTest.class);
+ public void testContent() {
+ aCreateCountryTrl();
+ countryTrlImport();
+ }
+
/**
* Builds the testdata, {@link CountryTrl} objects for a specific {@link
Country}.
*/
- public void testACreateCountryTrl() {
+ public void aCreateCountryTrl() {
setSystemAdministratorContext();
final Country country = getCountry("Norway");
final OBCriteria<CountryTrl> obc =
OBDal.getInstance().createCriteria(CountryTrl.class);
@@ -81,6 +89,7 @@
OBDal.getInstance().save(countryTrl);
created++;
}
+ OBDal.getInstance().commitAndClose();
log.debug("Created " + created + " countrytrl objects");
}
@@ -91,7 +100,7 @@
*
* This method also cleans up the testdata.
*/
- public void testCountryTrlImport() {
+ public void countryTrlImport() {
setTestAdminContext();
// read countrytrl
@@ -113,6 +122,7 @@
"eventhough it does not belong to the target organization") != -1);
for (final BaseOBObject bob : ir.getUpdatedObjects()) {
+ OBDal.getInstance().refresh(bob);
assertEquals(CountryTrl.class.getName(), bob.getClass().getName());
// and clean up
OBDal.getInstance().remove(bob);
------------------------------------------------------------------------------
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