details: https://code.openbravo.com/erp/devel/pi/rev/3de9f6eb5863 changeset: 24088:3de9f6eb5863 user: Inigo Sanchez <inigo.sanchez <at> openbravo.com> date: Mon Jul 21 14:15:37 2014 +0200 summary: related to bug 27107: fixed test cases in ReadByNameTest and other.
diffstat: src-test/org/openbravo/test/dal/DalQueryTest.java | 46 +++++++++++++++----- src-test/org/openbravo/test/dal/ReadByNameTest.java | 27 +++++++++-- 2 files changed, 56 insertions(+), 17 deletions(-) diffs (236 lines): diff -r e00e9de4a280 -r 3de9f6eb5863 src-test/org/openbravo/test/dal/DalQueryTest.java --- a/src-test/org/openbravo/test/dal/DalQueryTest.java Mon Jul 21 12:41:20 2014 +0200 +++ b/src-test/org/openbravo/test/dal/DalQueryTest.java Mon Jul 21 14:15:37 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): * Martin Taal <[email protected]>, @@ -48,6 +48,9 @@ * * Note the testcases assume that they are run in the order defined in this class. * + * 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 */ @@ -55,9 +58,26 @@ private static final Logger log = Logger.getLogger(DalQueryTest.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() { + dalFirstWhereLeftJoinClause(); + dalExtraJoinWhereLeftJoinClause(); + dalWhereLeftJoinClause(); + dalOtherWhereLeftJoinClause(); + dalAnOtherWhereLeftJoinClause(); + createBPGroup(); + removeBPGroup(); + checkBPGroupRemoved(); + updateCurrencyByUser(); + transaction25PageRead(); + } + + /** * Tests a left join with {@link ModelImplementation} as the main class. */ - public void testDalFirstWhereLeftJoinClause() { + public void dalFirstWhereLeftJoinClause() { setTestAdminContext(); final String where = "as mo left join mo.callout moc left join mo.reference mor left join mo.specialForm mof left join mo.process mop left join mo.tab mot where moc.module.id='0' or mor.module.id='0' or mof.module.id='0' or mop.module.id='0' or mot.module.id='0'"; final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery( @@ -68,7 +88,7 @@ /** * Tests a left join with {@link ModelImplementation} as the main class. */ - public void testDalExtraJoinWhereLeftJoinClause() { + public void dalExtraJoinWhereLeftJoinClause() { setTestAdminContext(); final String where = "as mom left join mom." + ModelImplementationMapping.PROPERTY_MODELOBJECT @@ -91,7 +111,7 @@ /** * Tests a left join with {@link ModelImplementation} as the main class. */ - public void testDalWhereLeftJoinClause() { + public void dalWhereLeftJoinClause() { setTestAdminContext(); final String where = "as mo left join mo.callout moc left join mo.reference mor where moc.module.id='0' or mor.module.id='0'"; final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery( @@ -102,7 +122,7 @@ /** * Tests a left join with {@link ModelImplementation} as the main class. */ - public void testDalOtherWhereLeftJoinClause() { + public void dalOtherWhereLeftJoinClause() { setTestAdminContext(); final String where = "as mo left join mo.callout moc left join mo.reference mor where (moc.module.id='0' or mor.module.id='0') and exists(from ADUser where id<>'0')"; final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery( @@ -113,7 +133,7 @@ /** * Tests a left join with {@link ModelImplementation} as the main class. */ - public void testDalAnOtherWhereLeftJoinClause() { + public void dalAnOtherWhereLeftJoinClause() { setTestAdminContext(); final String where = "exists(from ADUser where id<>'0')"; final OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery( @@ -124,7 +144,7 @@ /** * Test creates a new {@link Category} and saves it. The new object is removed in the next test. */ - public void testCreateBPGroup() { + public void createBPGroup() { setTestUserContext(); addReadWriteAccess(Category.class); final Category bpg = OBProvider.getInstance().get(Category.class); @@ -134,12 +154,13 @@ bpg.setSearchKey("testvalue"); bpg.setActive(true); OBDal.getInstance().save(bpg); + OBDal.getInstance().flush(); } /** * Test queries for the created {@link Category} and removes it. */ - public void testRemoveBPGroup() { + public void removeBPGroup() { setTestUserContext(); addReadWriteAccess(Category.class); addReadWriteAccess(CategoryAccounts.class); @@ -169,28 +190,31 @@ " " + CategoryAccounts.PROPERTY_BUSINESSPARTNERCATEGORY + "=?", parameters); final List<CategoryAccounts> bpgas = q2.list(); for (final CategoryAccounts bga : bpgas) { + OBDal.getInstance().refresh(bga); OBDal.getInstance().remove(bga); } OBDal.getInstance().remove(bpgs.get(0)); + OBDal.getInstance().flush(); } /** * Check that the {@link Category} was indeed removed. */ - public void testCheckBPGroupRemoved() { + public void checkBPGroupRemoved() { setTestUserContext(); addReadWriteAccess(Category.class); final OBQuery<Category> obQuery = OBDal.getInstance().createQuery(Category.class, Category.PROPERTY_NAME + "='testname' or " + Category.PROPERTY_SEARCHKEY + "='testvalue'"); final List<Category> bpgs = obQuery.list(); assertEquals(0, bpgs.size()); + OBDal.getInstance().flush(); } /** * Tests queries for a currency and then updates it. The test should fail as the user does not * have update authorisation. */ - public void testUpdateCurrencyByUser() { + public void updateCurrencyByUser() { setUserContext("E12DC7B3FF8C4F64924A98195223B1F8"); final OBCriteria<Currency> obc = OBDal.getInstance().createCriteria(Currency.class); obc.add(Restrictions.eq(Currency.PROPERTY_ISOCODE, "USD")); @@ -214,7 +238,7 @@ * has been implemented such that it reads all the references (which are non-null) and uses their * identifier to create the identifier of the transaction. The test sorts on product.name. */ - public void testTransaction25PageRead() { + public void transaction25PageRead() { setTestUserContext(); addReadWriteAccess(MaterialTransaction.class); final OBQuery<MaterialTransaction> cq = OBDal.getInstance().createQuery( diff -r e00e9de4a280 -r 3de9f6eb5863 src-test/org/openbravo/test/dal/ReadByNameTest.java --- a/src-test/org/openbravo/test/dal/ReadByNameTest.java Mon Jul 21 12:41:20 2014 +0200 +++ b/src-test/org/openbravo/test/dal/ReadByNameTest.java Mon Jul 21 14:15:37 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) 2010-2011 Openbravo SLU + * All portions are Copyright (C) 2010-2014 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -32,6 +32,9 @@ /** * Tests creating a location and then reading it again using the {@link OBCriteria} api. * + * 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 iperdomo */ public class ReadByNameTest extends BaseTest { @@ -41,7 +44,18 @@ private static String locId; // Location Id private static String locName; // Location name - public void testCreateBP() { + /** + * 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() { + createBP(); + addLocation(); + findLocation(); + pBData(); + } + + public void createBP() { setTestUserContext(); addReadWriteAccess(BusinessPartner.class); @@ -66,7 +80,7 @@ bpId = bp.getId(); } - public void testAddLocation() { + public void addLocation() { setTestUserContext(); addReadWriteAccess(BusinessPartner.class); @@ -97,11 +111,12 @@ OBDal.getInstance().save(bpLoc); OBDal.getInstance().flush(); + OBDal.getInstance().commitAndClose(); locId = bpLoc.getId(); } - public void testFindLocation() { + public void findLocation() { // tests have run in the correct order assertNotNull(locName); assertNotNull(locId); @@ -126,7 +141,7 @@ assertEquals(locName, tmpLoc.getName()); } - public void testPBData() { + public void pBData() { setTestUserContext(); addReadWriteAccess(BusinessPartner.class); @@ -141,7 +156,7 @@ } setTestAdminContext(); OBDal.getInstance().remove(bp); - + OBDal.getInstance().flush(); assertNull(OBDal.getInstance().get(BusinessPartner.class, bpId)); assertNull(OBDal.getInstance().get(Location.class, locId)); } ------------------------------------------------------------------------------ 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
