Author: athimel Date: 2014-05-16 16:12:50 +0200 (Fri, 16 May 2014) New Revision: 3806 Url: http://forge.chorem.org/projects/lima/repository/revisions/3806 Log: refs #934 Migrate tests configuration Removed: trunk/lima-business/src/test/java/org/chorem/lima/business/ejb/ Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-05-16 14:04:54 UTC (rev 3805) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2014-05-16 14:12:50 UTC (rev 3806) @@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountingRules; import org.chorem.lima.business.LimaBusinessException; -import org.chorem.lima.business.LimaDaoHelper; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.LimaInterceptor; import org.chorem.lima.entity.Account; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2014-05-16 14:04:54 UTC (rev 3805) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2014-05-16 14:12:50 UTC (rev 3806) @@ -27,7 +27,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaDaoHelper; import org.chorem.lima.business.LimaInterceptor; import org.chorem.lima.entity.LimaCallaoTopiaDaoSupplier; Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-05-16 14:04:54 UTC (rev 3805) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/AbstractLimaTest.java 2014-05-16 14:12:50 UTC (rev 3806) @@ -45,7 +45,6 @@ import org.chorem.lima.business.api.FiscalPeriodService; import org.chorem.lima.business.api.ImportService; import org.chorem.lima.business.api.ReportService; -import org.chorem.lima.business.ejb.ClearService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.entity.Entry; @@ -64,7 +63,6 @@ import org.nuiton.i18n.I18n; import org.nuiton.i18n.init.ClassPathI18nInitializer; import org.nuiton.topia.persistence.TopiaApplicationContextCache; -import org.nuiton.topia.persistence.TopiaNotFoundException; import com.google.common.base.Function; @@ -89,7 +87,6 @@ protected static DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.ENGLISH); - protected static ClearService clearService; protected static AccountService accountService; protected static EntryBookService entryBookService; protected static FinancialPeriodService financialPeriodService; @@ -121,7 +118,6 @@ * @throws IOException */ protected static void initServices() throws IOException { - clearService = LimaServiceFactory.getService(ClearService.class); accountService = LimaServiceFactory.getService(AccountService.class); entryBookService = LimaServiceFactory.getService(EntryBookService.class); financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); @@ -211,7 +207,8 @@ protected void initTestDatabase() throws LimaException, ParseException { // clear database - clearService.clearDatabase(); +// clearService.clearDatabase(); + getTestContext().createSchema(); initTestAccounts(); initTestTransactions(); Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-05-16 14:04:54 UTC (rev 3805) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/ImportServiceImplTest.java 2014-05-16 14:12:50 UTC (rev 3806) @@ -55,7 +55,7 @@ */ protected void importEBPData() throws IOException, LimaException, ParseException { - clearService.clearDatabase(); + getTestContext().createSchema(); // create fiscal period (mandatory for import) FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); @@ -142,7 +142,7 @@ */ @Test public void testImportCSVPCG() throws Exception { - clearService.clearDatabase(); + getTestContext().createSchema(); String pcg = IOUtils.toString(ImportServiceImplTest.class.getResourceAsStream("/import/pcg_base.csv")); importService.importAsCSV(pcg, ImportExportEntityEnum.ACCOUNT); @@ -155,7 +155,7 @@ */ @Test public void testImportCSVEb() throws Exception { - clearService.clearDatabase(); + getTestContext().createSchema(); String pcg = IOUtils.toString(ImportServiceImplTest.class.getResourceAsStream("/import/eb_default.csv")); importService.importAsCSV(pcg, ImportExportEntityEnum.ENTRYBOOK); Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-05-16 14:04:54 UTC (rev 3805) +++ trunk/lima-business/src/test/java/org/chorem/lima/business/accountingrules/TestAccountingRules.java 2014-05-16 14:12:50 UTC (rev 3806) @@ -29,7 +29,7 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodImpl; import org.chorem.lima.entity.FiscalPeriod; -import org.chorem.lima.entity.FiscalPeriodDAO; +import org.chorem.lima.entity.FiscalPeriodTopiaDao; import org.junit.Ignore; import org.nuiton.topia.persistence.TopiaException; @@ -67,7 +67,7 @@ super.createFiscalPeriodRules(fiscalPeriod); List<FinancialPeriod> financialPeriods = new ArrayList<FinancialPeriod>(); try { - FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO(); + FiscalPeriodTopiaDao fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDao(); //Checks if is not the first fiscalperiod to create if (fiscalPeriodDAO.count() != 0) { @@ -99,7 +99,7 @@ while (loopDate.before(endDate)) { FinancialPeriod financialPeriod = new FinancialPeriodImpl(); //important for fiscalperiod created from import, it can be locked, so financialperiods must be locked - financialPeriod.setLocked(fiscalPeriod.getLocked()); + financialPeriod.setLocked(fiscalPeriod.isLocked()); financialPeriod.setBeginDate(loopDate); loopDate = DateUtils.addMonths(loopDate, 1); loopDate = DateUtils.truncate(loopDate, Calendar.MONTH); Modified: trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-05-16 14:04:54 UTC (rev 3805) +++ trunk/lima-business/src/test/java/org/chorem/lima/entity/AccountDAOTest.java 2014-05-16 14:12:50 UTC (rev 3806) @@ -27,7 +27,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.nuiton.topia.TopiaContext; import org.nuiton.topia.persistence.TopiaException; import java.util.List; @@ -54,16 +53,16 @@ */ @Test public void testStringToListAccounts() throws TopiaException { - TopiaContext tx = getTestContext().beginTransaction(); + LimaCallaoTopiaPersistenceContext context = getTestContext().newPersistenceContext(); + + AccountTopiaDao accountDAO = context.getAccountDao(); - AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(tx); - List<Account> accounts = accountDAO.stringToListAccounts("50..511", false); Assert.assertEquals(5, accounts.size()); accounts = accountDAO.stringToListAccounts("60..99", false); Assert.assertEquals(0, accounts.size()); - tx.closeContext(); + context.closeContext(); } } Modified: trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java =================================================================== --- trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2014-05-16 14:04:54 UTC (rev 3805) +++ trunk/lima-business/src/test/java/org/chorem/lima/entity/FinancialTransactionDAOTest.java 2014-05-16 14:12:50 UTC (rev 3806) @@ -30,10 +30,10 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.nuiton.topia.TopiaContext; import org.nuiton.topia.persistence.TopiaException; + /** - * Test for {@link FinancialTransactionDAO}. + * Test for {@link FinancialTransactionTopiaDao}. * * @author chatellier * @version $Revision: 3585 $ @@ -60,8 +60,8 @@ FinancialPeriod financialPeriod = financialPeriodService.getAllFinancialPeriods().get(0); EntryBook journalDesVentes = entryBookService.getEntryBookByCode("jdv"); - TopiaContext tx = getTestContext().beginTransaction(); - FinancialTransactionDAO ftDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(tx); + LimaCallaoTopiaPersistenceContext context = getTestContext().newPersistenceContext(); + FinancialTransactionTopiaDao ftDAO = context.getFinancialTransactionDao(); List<FinancialTransaction> fTransactions = ftDAO.getAllUnbalancedTransaction(financialPeriod.getBeginDate(), financialPeriod.getEndDate(), journalDesVentes); Assert.assertNotNull(fTransactions);