r163 - in trunk: . tutti-persistence/src/main/xmi tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence tutti-persistence-adagio/src/main/resources tutti-persistence-adagio/src/test tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence
Author: tchemit Date: 2013-01-10 10:10:19 +0100 (Thu, 10 Jan 2013) New Revision: 163 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/163 Log: refs #1807: [Persistence] Adagio r?\195?\169f?\195?\169rentiel refs #1809: [Persistence] Adagio Donn?\195?\169es th?\195?\169matiques Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/AccidentalBatchTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BenthosBatchTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/FishingOperationTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/MacroWasteBatchTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/PlanktonBatchTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProtocolTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/SpeciesBatchTest.java Removed: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BaseDaoTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramDaoTest.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TestUtil.java trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImplTest.java Modified: trunk/pom.xml trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ReferentialTest.java trunk/tutti-persistence-adagio/src/test/server.properties trunk/tutti-persistence-adagio/src/test/startServer.sh trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/pom.xml 2013-01-10 09:10:19 UTC (rev 163) @@ -124,7 +124,7 @@ <h2Version>1.3.168</h2Version> <postgresqlVersion>9.1-901-1.jdbc4</postgresqlVersion> - <jaxxVersion>2.5.9</jaxxVersion> + <jaxxVersion>2.5.10-SNAPSHOT</jaxxVersion> <swingXVersion>1.6.4</swingXVersion> <xworkVersion>2.3.7</xworkVersion> Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo =================================================================== (Binary files differ) Modified: trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java =================================================================== --- trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImpl.java 2013-01-10 09:10:19 UTC (rev 163) @@ -26,6 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import fr.ifremer.adagio.core.dao.administration.programStrategy.ProgramDao; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; @@ -53,9 +54,11 @@ import org.hibernate.SessionFactory; import org.hibernate.type.DateType; import org.hibernate.type.IntegerType; +import org.hibernate.type.StringType; import org.hibernate.type.Type; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; import java.io.IOException; import java.util.Date; import java.util.Iterator; @@ -81,6 +84,9 @@ */ protected SessionFactory sessionFactory; + @Resource(name = "programDao") + protected ProgramDao programDao; + protected Properties enumerations; public void setSessionFactory(SessionFactory sessionFactory) { @@ -454,12 +460,48 @@ @Override public List<Program> getAllProgram() { - throw new UnsupportedOperationException(); + Iterator<Object[]> list = queryList("allPrograms"); + + List<Program> result = Lists.newArrayList(); + while (list.hasNext()) { + Object[] source = list.next(); + Program target = new Program(); + target.setId((String) source[0]); + target.setName((String) source[1]); + result.add(target); + } + return result; } @Override public Program getProgram(String id) { - throw new UnsupportedOperationException(); + Object[] source = queryUnique( + "program", + "programCode", StringType.INSTANCE, id); + + Program result = new Program(); + result.setId((String) source[0]); + result.setName((String) source[1]); + + // get program locations + Iterator<Object[]> list = queryList( + "allProgramLocations", + "programCode", StringType.INSTANCE, id); + + List<Zone> zones = Lists.newArrayList(); + while (list.hasNext()) { + Object[] zoneSource = list.next(); + Zone target = new Zone(); + target.setId(String.valueOf(zoneSource[0])); + target.setLabel((String) zoneSource[1]); + target.setName((String) zoneSource[2]); + zones.add(target); + } + if (!zones.isEmpty()) { + result.setZone(zones.get(0)); + } + + return result; } @Override @@ -478,12 +520,50 @@ @Override public List<Cruise> getAllCruise(String programId) { - throw new UnsupportedOperationException(); + Iterator<Object[]> list = queryList( + "allCruises", + "programCode", StringType.INSTANCE, programId); + + List<Cruise> result = Lists.newArrayList(); + while (list.hasNext()) { + Object[] source = list.next(); + Cruise target = new Cruise(); + target.setId((String) source[0]); + target.setName((String) source[1]); + target.setBeginDate((Date) source[2]); + result.add(target); + } + return result; } @Override public Cruise getCruise(String id) { - throw new UnsupportedOperationException(); + Object[] source = queryUnique( + "cruise", + "cruiseId", StringType.INSTANCE, id); + + Cruise result = new Cruise(); + result.setId((String) source[0]); + result.setName((String) source[1]); + + // get secondary gears + Iterator<Object[]> list = queryList( + "allCruiseSecondaryGears", + "cruiseId", StringType.INSTANCE, id); + + List<Gear> gears = Lists.newArrayList(); + while (list.hasNext()) { + Object[] zoneSource = list.next(); + Gear target = new Gear(); + target.setId((String) zoneSource[0]); + target.setLabel((String) zoneSource[1]); + target.setName((String) zoneSource[2]); + gears.add(target); + } + result.setGear(gears); + + + return result; } @Override Modified: trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml =================================================================== --- trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/main/resources/queries-override.hbm.xml 2013-01-10 09:10:19 UTC (rev 163) @@ -31,6 +31,87 @@ <!--TODO Create fetch profile to avoid eager loading --> <!--</fetch-profile>--> + <!-- Get all programs (to list with no detail) [DAT-01] --> + <query cacheable="true" name="allPrograms"> + <![CDATA[ + SELECT + p.code, + p.name + FROM ProgramImpl p + WHERE p.code LIKE 'CAM-%' + ]]> + </query> + + <!-- Get all cruises for a given program (to list with no detail) [DAT-02] --> + <query cacheable="true" name="allCruises"> + <![CDATA[ + SELECT + c.id, + c.name, + c.departureDateTime + FROM ScientificCruiseImpl c + WHERE c.program.code = :programCode + ORDER BY c.departureDateTime desc + ]]> + <query-param name="programCode" type="java.lang.String"/> + </query> + + <!-- Get a detail program [DAT-03] --> + <query cacheable="true" name="program"> + <![CDATA[ + SELECT + p.code, + p.name, + p.description + FROM ProgramImpl p + WHERE p.code = :programCode + ]]> + <query-param name="programCode" type="java.lang.String"/> + </query> + + <!-- Get a program locations [DAT-03-1] --> + <query cacheable="true" name="allProgramLocations"> + <![CDATA[ + SELECT + l.id, + l.label, + l.name + FROM ProgramImpl p + LEFT OUTER JOIN p.locations l + WHERE p.code = :programCode + ]]> + <query-param name="programCode" type="java.lang.String"/> + </query> + + <!-- Get a detail cruise [DAT-04] --> + <query cacheable="true" name="cruise"> + <![CDATA[ + select + sc.program.code as programCode, + year(sc.departureDateTime) as year, + -- partialSerie - pas stockée sous H2 ?? + sc.name, + lh.locationHierarchyPk.parent.label as countryLabel, + lh.locationHierarchyPk.parent.name as countryName, + sc.departureDateTime, + sc.returnDateTime, + sc.vessel.code as vesselCode, + mp.lastname as managerLastname, + mp.firstname as managerFirstName, + coalesce(sc.comments, ft.comments) as comments +from + ScientificCruiseImpl sc + left outer join sc.fishingTrips ft + left outer join sc.managerPerson mp, + LocationHierarchyImpl lh +where 1=1 + and sc.id = 100000 -- :scientificCruiseId + and lh.locationHierarchyPk.location.id = ft.departureLocation.id + and lh.locationHierarchyPk.parent.locationLevel.id = 21 -- locationLevel=Pays ISO 3 + ]]> + <query-param name="programCode" type="java.lang.String"/> + </query> + <!-- Get all program zones [REF-01] --> <query cacheable="true" name="allProgramZones"> <![CDATA[ Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/AccidentalBatchTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/AccidentalBatchTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/AccidentalBatchTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,67 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link Program}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class AccidentalBatchTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllAccidentalBatch(/*String fishingOperationId*/) { + + } + + @Test + public void getAccidentalBatch(/*String id*/) { + + } + + @Test + public void createAccidentalBatch(/*AccidentalBatch bean*/) { + + } + + @Test + public void saveAccidentalBatch(/*AccidentalBatch bean*/) { + + } + + @Test + public void deleteAccidentalBatch(/*String id*/) { + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/AccidentalBatchTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BaseDaoTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BaseDaoTest.java 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BaseDaoTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -1,112 +0,0 @@ -package fr.ifremer.tutti.persistence; - -/* - * #%L - * Tutti :: Persistence Adagio (impl) - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfig; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.SessionFactory; -import org.hibernate.classic.Session; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.springframework.context.ApplicationContext; - -//@RunWith(SpringJUnit4ClassRunner.class) -// Skip bean definition for services, in the Spring context for DAO unit testing -// This is need to increase test execution -//@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml", -// "classpath:applicationContext-dataSource-local.xml", -// "classpath:applicationContext-entities.xml"}) -//@TransactionConfiguration(transactionManager = "transactionManager") -//@Transactional -public abstract class BaseDaoTest { - - /** Logger. */ - private static final Log log = LogFactory.getLog(BaseDaoTest.class); - - // @Resource - private SessionFactory sessionFactory; - - private Session session; - - @Rule - public TestName name = new TestName(); - - protected TuttiPersistenceAdagioConfig config; - - @BeforeClass - public static void beforeClass() { - - TestUtil.checkDbExists(); - } - - @Before - public void setUp() throws Exception { - - config = TestUtil.createConfig(getClass(), name.getMethodName()); - - if (log.isDebugEnabled()) { - log.debug("Use conf.properties at " + config.getDbConfigurationPath()); - } - - ApplicationContext context = TestUtil.createSpringContext(); - - sessionFactory = (SessionFactory) context.getBean("sessionFactory"); - } - - @After - public void tearDown() throws Exception { - - TestUtil.resetClassLoader(); - - // close hibernate session if was used - try { - if (session != null) { - session.close(); - } - } finally { - - // close session factory - sessionFactory.close(); - } - - } - - protected Session getSession() { - if (session == null) { - session = sessionFactory.openSession(); - } - return session; - } - - protected SessionFactory getSessionFactory() { - return sessionFactory; - } - - -} Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BenthosBatchTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BenthosBatchTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BenthosBatchTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,67 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link Program}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class BenthosBatchTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllBenthosBatch(/*String fishingOperationId*/) { + + } + + @Test + public void getBenthosBatch(/*String id*/) { + + } + + @Test + public void createBenthosBatch(/*BenthosBatch bean*/) { + + } + + @Test + public void saveBenthosBatch(/*BenthosBatch bean*/) { + + } + + @Test + public void deleteBenthosBatch(/*String id*/) { + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/BenthosBatchTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,63 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link Program}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class CruiseTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllCruise(/*String programId*/) { + + } + + @Test + public void getCruise(/*String id*/) { + + } + + @Test + public void createCruise(/*Cruise bean*/) { + + } + + @Test + public void saveCruise(/*Cruise bean*/) { + + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/CruiseTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,190 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfig; +import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfigOption; +import org.apache.commons.io.FileUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.junit.Assume; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; +import org.nuiton.util.ApplicationConfig; +import org.nuiton.util.ArgumentsParserException; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import java.io.File; +import java.io.IOException; + +/** + * To box the persistence service as a test resource. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class DatabaseResource implements TestRule { + + /** Logger. */ + private static final Log log = LogFactory.getLog(DatabaseResource.class); + + public static long BUILD_TIMESTAMP = System.nanoTime(); + + private static ClassLoader oldClassLoader; + + protected TuttiPersistenceAdagioConfig config; + + protected TuttiPersistence driver; + + public TuttiPersistenceAdagioConfig getConfig() { + return config; + } + + public TuttiPersistence getDriver() { + return driver; + } + + @Override + public Statement apply(final Statement base, final Description description) { + + return new Statement() { + @Override + public void evaluate() throws Throwable { + before(description); + try { + base.evaluate(); + } finally { + after(description); + } + } + }; + } + + protected void before(Description description) throws Throwable { + Class<?> testClass = description.getTestClass(); + + File db = new File("src/test/db"); + if (!db.exists()) { + + if (log.isWarnEnabled()) { + log.warn("Could not find db at " + db + ", test [" + + testClass + "] is skipped."); + } + Assume.assumeTrue(false); + } + + if (log.isInfoEnabled()) { + log.info("Prepare test " + testClass); + } + + config = createConfig(testClass, ""); + + if (log.isDebugEnabled()) { + log.debug("Use conf.properties at " + config.getDbConfigurationPath()); + } + ApplicationContext context = new ClassPathXmlApplicationContext( + "applicationContext-conf.xml", + "applicationContext-dataSource-local.xml", + "applicationContext-entities.xml", + "applicationContext-service-tutti.xml"); + + driver = (TuttiPersistence) context.getBean("adagioPersistenceService"); + + driver.setEnumerations(config.getDbEnumerations()); + + driver.open(); + } + + protected void after(Description description) throws IOException { + Class<?> testClass = description.getTestClass(); + if (log.isInfoEnabled()) { + log.info("After test " + testClass); + } + // push back old classLoader + if (oldClassLoader != null) { + Thread.currentThread().setContextClassLoader(oldClassLoader); + } + + // close hibernate session if was used + if (driver != null) { + driver.close(); + } + } + + + public static TuttiPersistenceAdagioConfig createConfig(Class<?> testClass, + String name) throws ArgumentsParserException, IOException { + + File resourceDirectory = getTestSpecificDirectory(testClass, name); + + RessourceClassLoader loader = + new RessourceClassLoader(testClass.getClassLoader()); + + oldClassLoader = Thread.currentThread().getContextClassLoader(); + Thread.currentThread().setContextClassLoader(loader); + + ApplicationConfig applicationConfig = + new ApplicationConfig("tutti-test.properties"); + applicationConfig.loadDefaultOptions( + TuttiPersistenceAdagioConfigOption.values()); + applicationConfig.setDefaultOption("tutti.data.directory", + resourceDirectory.getAbsolutePath()); + applicationConfig.parse(); + + TuttiPersistenceAdagioConfig result = + new TuttiPersistenceAdagioConfig(applicationConfig); + + result.initConfig(loader); + return result; + } + + public static File getTestSpecificDirectory(Class<?> testClass, + String name) throws IOException { + // Trying to look for the temporary folder to store data for the test + String tempDirPath = System.getProperty("java.io.tmpdir"); + if (tempDirPath == null) { + // can this really occur ? + tempDirPath = ""; + if (log.isWarnEnabled()) { + log.warn("'\"java.io.tmpdir\" not defined"); + } + } + File tempDirFile = new File(tempDirPath); + + // create the directory to store database data + String dataBasePath = testClass.getName() + + File.separator // a directory with the test class name + + name // a sub-directory with the method name + + '_' + + BUILD_TIMESTAMP; // and a timestamp + File databaseFile = new File(tempDirFile, dataBasePath); + FileUtils.forceMkdir(databaseFile); + + return databaseFile; + } + +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/DatabaseResource.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/FishingOperationTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/FishingOperationTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/FishingOperationTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,63 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link FishingOperation}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class FishingOperationTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllFishingOperation(/*String cruiseId*/) { + + } + + @Test + public void getFishingOperation(/*String id*/) { + + } + + @Test + public void createFishingOperation(/*FishingOperation bean*/) { + + } + + @Test + public void saveFishingOperation(/*FishingOperation bean*/) { + + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/FishingOperationTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/MacroWasteBatchTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/MacroWasteBatchTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/MacroWasteBatchTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,67 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link Program}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class MacroWasteBatchTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllMacroWasteBatch(/*String fishingOperationId*/) { + + } + + @Test + public void getMacroWasteBatch(/*String id*/) { + + } + + @Test + public void createMacroWasteBatch(/*MacroWasteBatch bean*/) { + + } + + @Test + public void saveMacroWasteBatch(/*MacroWasteBatch bean*/) { + + } + + @Test + public void deleteMacroWasteBatch(/*String id*/) { + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/MacroWasteBatchTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/PlanktonBatchTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/PlanktonBatchTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/PlanktonBatchTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,67 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link Program}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class PlanktonBatchTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllPlanktonBatch(/*String fishingOperationId*/) { + + } + + @Test + public void getPlanktonBatch(/*String id*/) { + + } + + @Test + public void createPlanktonBatch(/*PlanktonBatch bean*/) { + + } + + @Test + public void savePlanktonBatch(/*PlanktonBatch bean*/) { + + } + + @Test + public void deletePlanktonBatch(/*String id*/) { + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/PlanktonBatchTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramDaoTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramDaoTest.java 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramDaoTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -1,67 +0,0 @@ -package fr.ifremer.tutti.persistence; - -/* - * #%L - * Tutti :: Persistence Adagio (impl) - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.adagio.core.dao.administration.programStrategy.Program; -import fr.ifremer.adagio.core.dao.administration.programStrategy.ProgramDao; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.hibernate.Query; -import org.hibernate.classic.Session; -import org.junit.Assert; -import org.junit.Test; - -import javax.annotation.Resource; -import java.util.List; - - -public class ProgramDaoTest extends BaseDaoTest { - - /** Logger. */ - private static final Log log = LogFactory.getLog(ProgramDaoTest.class); - - @Resource(name = "programDao") - private ProgramDao dao; - - @Test - public void getAllProgramFromHibernate() { - Session sess = getSession(); - Query query = sess.createQuery("from ProgramImpl"); - List actual = query.list(); - Assert.assertNotNull(actual); - - if (log.isInfoEnabled()) { - log.info("Nb program: " + actual.size()); - } - } - - public void getProgram() { - String programCode = "OTB"; - Program actual = dao.load(programCode); - Assert.assertNotNull(actual); - Assert.assertEquals(programCode, actual.getCode()); - } - -} Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,75 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; +import org.junit.Assert; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +import java.util.List; + +/** + * To test operations around {@link Program}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +public class ProgramTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllProgram() { + List<Program> result = dbResource.getDriver().getAllProgram(); + Assert.assertNotNull(result); + Assert.assertEquals(1, result.size()); + } + + @Test + public void getProgram(/*String id*/) { + String programCode = "CAM-CGFS"; + Program actual = dbResource.getDriver().getProgram(programCode); + Assert.assertNotNull(actual); + Assert.assertNotNull(actual.getId()); + Assert.assertNotNull(actual.getName()); + Assert.assertNotNull(actual.getZone()); + Assert.assertEquals(programCode, actual.getId()); + } + + @Test + @Ignore + public void createProgram(/*Program bean*/) { + + } + + @Test + @Ignore + public void saveProgram(/*Program bean*/) { + + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProgramTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProtocolTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProtocolTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProtocolTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,63 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link TuttiProtocol}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class ProtocolTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllProtocol() { + + } + + @Test + public void getProtocol(/*String id*/) { + + } + + @Test + public void createProtocol(/*TuttiProtocol bean*/) { + + } + + @Test + public void saveProtocol(/*TuttiProtocol bean*/) { + + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ProtocolTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ReferentialTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ReferentialTest.java 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ReferentialTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -1,6 +1,30 @@ package fr.ifremer.tutti.persistence; -import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfig; +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Country; import fr.ifremer.tutti.persistence.entities.referential.Gear; @@ -8,17 +32,11 @@ import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.persistence.entities.referential.Vessel; import fr.ifremer.tutti.persistence.entities.referential.Zone; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.AfterClass; import org.junit.Assert; -import org.junit.BeforeClass; +import org.junit.ClassRule; import org.junit.Ignore; import org.junit.Test; -import org.nuiton.util.ArgumentsParserException; -import org.springframework.context.ApplicationContext; -import java.io.IOException; import java.util.List; /** @@ -29,61 +47,28 @@ */ public class ReferentialTest { - /** Logger. */ - private static final Log log = LogFactory.getLog(ReferentialTest.class); + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); - protected static TuttiPersistenceAdagioConfig config; - protected static TuttiPersistence driver; - @BeforeClass - public static void beforeClass() throws IOException, ArgumentsParserException { - - TestUtil.checkDbExists(); - - config = TestUtil.createConfig(ReferentialTest.class, ""); - - if (log.isDebugEnabled()) { - log.debug("Use conf.properties at " + config.getDbConfigurationPath()); - } - ApplicationContext context = TestUtil.createSpringContext(); - - driver = (TuttiPersistence) context.getBean("adagioPersistenceService"); - - driver.setEnumerations(config.getDbEnumerations()); - - driver.open(); - } - - @AfterClass - public static void afterClass() throws Exception { - - // push back old classLoader - TestUtil.resetClassLoader(); - - // close hibernate session if was used - if (driver != null) { - driver.close(); - } - } - @Test public void getAllProgramZone() { - List<Zone> result = driver.getAllProgramZone(); + List<Zone> result = dbResource.getDriver().getAllProgramZone(); Assert.assertNotNull(result); Assert.assertEquals(0, result.size()); } @Test public void getAllCountry() { - List<Country> result = driver.getAllCountry(); + List<Country> result = dbResource.getDriver().getAllCountry(); Assert.assertNotNull(result); Assert.assertEquals(240, result.size()); } @Test public void getAllScientificVessel() { - List<Vessel> result = driver.getAllScientificVessel(); + List<Vessel> result = dbResource.getDriver().getAllScientificVessel(); Assert.assertNotNull(result); Assert.assertEquals(1, result.size()); } @@ -92,28 +77,28 @@ @Test @Ignore public void getAllFishingVessel() { - List<Vessel> result = driver.getAllFishingVessel(); + List<Vessel> result = dbResource.getDriver().getAllFishingVessel(); Assert.assertNotNull(result); Assert.assertEquals(187, result.size()); } @Test public void getAllScientificGear() { - List<Gear> result = driver.getAllScientificGear(); + List<Gear> result = dbResource.getDriver().getAllScientificGear(); Assert.assertNotNull(result); Assert.assertEquals(2, result.size()); } @Test public void getAllFishingGear() { - List<Gear> result = driver.getAllFishingGear(); + List<Gear> result = dbResource.getDriver().getAllFishingGear(); Assert.assertNotNull(result); Assert.assertEquals(75, result.size()); } @Test public void getAllPerson() { - List<Person> result = driver.getAllPerson(); + List<Person> result = dbResource.getDriver().getAllPerson(); Assert.assertNotNull(result); Assert.assertEquals(226, result.size()); } @@ -121,21 +106,21 @@ @Test public void getAllSpecies() { - List<Species> result = driver.getAllSpecies(); + List<Species> result = dbResource.getDriver().getAllSpecies(); Assert.assertNotNull(result); Assert.assertEquals(156, result.size()); } @Test public void getAllBenthosSpecies() { - List<Species> result = driver.getAllBenthosSpecies(); + List<Species> result = dbResource.getDriver().getAllBenthosSpecies(); Assert.assertNotNull(result); Assert.assertEquals(156, result.size()); } @Test public void getAllPlanktonSpecies() { - List<Species> result = driver.getAllPlanktonSpecies(); + List<Species> result = dbResource.getDriver().getAllPlanktonSpecies(); Assert.assertNotNull(result); Assert.assertEquals(156, result.size()); } @@ -158,35 +143,35 @@ @Test public void getAllFishingOperationEnvironmentCaracteristic() { - List<Caracteristic> result = driver.getAllFishingOperationEnvironmentCaracteristic(); + List<Caracteristic> result = dbResource.getDriver().getAllFishingOperationEnvironmentCaracteristic(); Assert.assertNotNull(result); Assert.assertEquals(40, result.size()); } @Test public void getAllFishingOperationGearCaracteristic() { - List<Caracteristic> result = driver.getAllFishingOperationGearCaracteristic(); + List<Caracteristic> result = dbResource.getDriver().getAllFishingOperationGearCaracteristic(); Assert.assertNotNull(result); Assert.assertEquals(155, result.size()); } @Test public void getAllFishingOperationHydrologicCaracteristic() { - List<Caracteristic> result = driver.getAllFishingOperationHydrologicCaracteristic(); + List<Caracteristic> result = dbResource.getDriver().getAllFishingOperationHydrologicCaracteristic(); Assert.assertNotNull(result); Assert.assertEquals(40, result.size()); } @Test public void getAllSpeciesLengthStepCaracteristic() { - List<Caracteristic> result = driver.getAllSpeciesLengthStepCaracteristic(); + List<Caracteristic> result = dbResource.getDriver().getAllSpeciesLengthStepCaracteristic(); Assert.assertNotNull(result); Assert.assertEquals(0, result.size()); } @Test public void getSizeCategoryCaracteristic() { - Caracteristic result = driver.getSizeCategoryCaracteristic(); + Caracteristic result = dbResource.getDriver().getSizeCategoryCaracteristic(); Assert.assertNotNull(result); Assert.assertTrue(result.isQualitativeType()); Assert.assertNotNull(result.getQualitativeValue()); @@ -195,7 +180,7 @@ @Test public void getSexCaracteristic() { - Caracteristic result = driver.getSexCaracteristic(); + Caracteristic result = dbResource.getDriver().getSexCaracteristic(); Assert.assertNotNull(result); Assert.assertTrue(result.isQualitativeType()); Assert.assertNotNull(result.getQualitativeValue()); @@ -204,7 +189,7 @@ @Test public void getSortedUnsortedCaracteristic() { - Caracteristic result = driver.getSortedUnsortedCaracteristic(); + Caracteristic result = dbResource.getDriver().getSortedUnsortedCaracteristic(); Assert.assertNotNull(result); Assert.assertTrue(result.isQualitativeType()); Assert.assertNotNull(result.getQualitativeValue()); @@ -213,7 +198,7 @@ @Test public void getMaturityCaracteristic() { - Caracteristic result = driver.getMaturityCaracteristic(); + Caracteristic result = dbResource.getDriver().getMaturityCaracteristic(); Assert.assertNotNull(result); Assert.assertTrue(result.isQualitativeType()); Assert.assertNotNull(result.getQualitativeValue()); @@ -222,7 +207,7 @@ @Test public void getMacroWasteCategoryCaracteristic() { - Caracteristic result = driver.getMacroWasteCategoryCaracteristic(); + Caracteristic result = dbResource.getDriver().getMacroWasteCategoryCaracteristic(); Assert.assertNotNull(result); Assert.assertTrue(result.isQualitativeType()); Assert.assertNotNull(result.getQualitativeValue()); @@ -231,7 +216,7 @@ @Test public void getMacroWasteSizeCategoryCaracteristic() { - Caracteristic result = driver.getMacroWasteSizeCategoryCaracteristic(); + Caracteristic result = dbResource.getDriver().getMacroWasteSizeCategoryCaracteristic(); Assert.assertNotNull(result); Assert.assertTrue(result.isQualitativeType()); Assert.assertNotNull(result.getQualitativeValue()); Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/ReferentialTest.java ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Added: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/SpeciesBatchTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/SpeciesBatchTest.java (rev 0) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/SpeciesBatchTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -0,0 +1,82 @@ +package fr.ifremer.tutti.persistence; + +/* + * #%L + * Tutti :: Persistence Adagio (impl) + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.Program; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import org.junit.ClassRule; +import org.junit.Ignore; +import org.junit.Test; + +/** + * To test operations around {@link SpeciesBatch}. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.3 + */ +@Ignore +public class SpeciesBatchTest { + + @ClassRule + public static final DatabaseResource dbResource = new DatabaseResource(); + + @Test + public void getAllRootSpeciesBatch(/*String fishingOperationId*/) { + + } + + @Test + public void getAllSpeciesBatch(/*String fishingOperationId*/) { + + } + + @Test + public void getSpeciesBatch(/*String id*/) { + + } + + @Test + public void createSpeciesBatch(/*SpeciesBatch bean, String parentBatchId*/) { + + } + + @Test + public void saveSpeciesBatch(/*SpeciesBatch bean*/) { + + } + + @Test + public void deleteSpeciesBatch(/*String id*/) { + } + + @Test + public void deleteSpeciesSubBatch(/*String id*/) { + } + + @Test + public void getAllSpeciesBatchFrequency(/*String speciesBatchId*/) { + + } +} Property changes on: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/SpeciesBatchTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TestUtil.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TestUtil.java 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TestUtil.java 2013-01-10 09:10:19 UTC (rev 163) @@ -1,136 +0,0 @@ -package fr.ifremer.tutti.persistence; - -/* - * #%L - * Tutti :: Persistence Adagio (impl) - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfig; -import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfigOption; -import org.apache.commons.io.FileUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.Assume; -import org.nuiton.util.ApplicationConfig; -import org.nuiton.util.ArgumentsParserException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import java.io.File; -import java.io.IOException; - -/** - * TODO - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -public final class TestUtil { - - /** Logger. */ - private static final Log log = LogFactory.getLog(TestUtil.class); - - public static long BUILD_TIMESTAMP = System.nanoTime(); - - private static ClassLoader oldClassLoader; - - public static TuttiPersistenceAdagioConfig createConfig(Class<?> klass, - String name) throws ArgumentsParserException, IOException { - - File resourceDirectory = TestUtil.getTestSpecificDirectory(klass, name); - - RessourceClassLoader loader = - new RessourceClassLoader(klass.getClassLoader()); - - oldClassLoader = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(loader); - - ApplicationConfig applicationConfig = - new ApplicationConfig("tutti-test.properties"); - applicationConfig.loadDefaultOptions( - TuttiPersistenceAdagioConfigOption.values()); - applicationConfig.setDefaultOption("tutti.data.directory", - resourceDirectory.getAbsolutePath()); - applicationConfig.parse(); - - TuttiPersistenceAdagioConfig config = - new TuttiPersistenceAdagioConfig(applicationConfig); - - config.initConfig(loader); - return config; - } - - public static void resetClassLoader() { - if (oldClassLoader != null) { - Thread.currentThread().setContextClassLoader(oldClassLoader); - } - } - - public static void checkDbExists() { - File db = new File("src/test/db"); - if (!db.exists()) { - - if (log.isWarnEnabled()) { - log.warn("Could not find db at " + db + ", test is skipped."); - } - Assume.assumeTrue(false); - } - } - - public static File getTestSpecificDirectory(Class<?> klass, - String name) throws IOException { - // Trying to look for the temporary folder to store data for the test - String tempDirPath = System.getProperty("java.io.tmpdir"); - if (tempDirPath == null) { - // can this really occur ? - tempDirPath = ""; - if (log.isWarnEnabled()) { - log.warn("'\"java.io.tmpdir\" not defined"); - } - } - File tempDirFile = new File(tempDirPath); - - // create the directory to store database data - String dataBasePath = klass.getName() - + File.separator // a directory with the test class name - + name // a sub-directory with the method name - + '_' - + BUILD_TIMESTAMP; // and a timestamp - File databaseFile = new File(tempDirFile, dataBasePath); - FileUtils.forceMkdir(databaseFile); - - return databaseFile; - } - - public static ApplicationContext createSpringContext() { - return new ClassPathXmlApplicationContext( - "applicationContext-conf.xml", - "applicationContext-dataSource-local.xml", - "applicationContext-entities.xml", - "applicationContext-service-tutti.xml"); - } - - private TestUtil() { - } - - -} Deleted: trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImplTest.java =================================================================== --- trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImplTest.java 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/test/java/fr/ifremer/tutti/persistence/TuttiPersistenceAdagioImplTest.java 2013-01-10 09:10:19 UTC (rev 163) @@ -1,357 +0,0 @@ -package fr.ifremer.tutti.persistence; - -/* - * #%L - * Tutti :: Persistence Adagio (impl) - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import fr.ifremer.tutti.persistence.config.TuttiPersistenceAdagioConfig; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.springframework.context.ApplicationContext; - -/** - * To test the {@link TuttiPersistenceAdagioImpl} service. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.3 - */ -@Ignore -public class TuttiPersistenceAdagioImplTest { - - /** Logger. */ - private static final Log log = - LogFactory.getLog(TuttiPersistenceAdagioImplTest.class); - - @Rule - public TestName name = new TestName(); - - protected TuttiPersistenceAdagioConfig config; - - protected TuttiPersistence driver; - - @BeforeClass - public static void beforeClass() { - - TestUtil.checkDbExists(); - } - - @Before - public void setUp() throws Exception { - - config = TestUtil.createConfig(getClass(), name.getMethodName()); - - if (log.isDebugEnabled()) { - log.debug("Use conf.properties at " + config.getDbConfigurationPath()); - } - ApplicationContext context = TestUtil.createSpringContext(); - - driver = (TuttiPersistence) context.getBean("adagioPersistenceService"); - - driver.setEnumerations(config.getDbEnumerations()); - - driver.open(); - } - - @After - public void tearDown() throws Exception { - - // push back old classLoader - TestUtil.resetClassLoader(); - - // close hibernate session if was used - if (driver != null) { - driver.close(); - } - } - - //------------------------------------------------------------------------// - //-- Referential methods --// - //------------------------------------------------------------------------// - - - @Test - @Ignore - public void getAllProgram() { - - } - - @Test - @Ignore - public void getProgram(/*String id*/) { - - } - - @Test - @Ignore - public void createProgram(/*Program bean*/) { - - } - - @Test - @Ignore - public void saveProgram(/*Program bean*/) { - - } - - @Test - @Ignore - public void getAllCruise(/*String programId*/) { - - } - - @Test - @Ignore - public void getCruise(/*String id*/) { - - } - - @Test - @Ignore - public void createCruise(/*Cruise bean*/) { - - } - - @Test - @Ignore - public void saveCruise(/*Cruise bean*/) { - - } - - @Test - @Ignore - public void getAllProtocol() { - - } - - @Test - @Ignore - public void getProtocol(/*String id*/) { - - } - - @Test - @Ignore - public void createProtocol(/*TuttiProtocol bean*/) { - - } - - @Test - @Ignore - public void saveProtocol(/*TuttiProtocol bean*/) { - - } - - @Test - @Ignore - public void getAllFishingOperation(/*String cruiseId*/) { - - } - - @Test - @Ignore - public void getFishingOperation(/*String id*/) { - - } - - @Test - @Ignore - public void createFishingOperation(/*FishingOperation bean*/) { - - } - - @Test - @Ignore - public void saveFishingOperation(/*FishingOperation bean*/) { - - } - - @Test - @Ignore - public void getAllRootSpeciesBatch(/*String fishingOperationId*/) { - - } - - @Test - @Ignore - public void getAllSpeciesBatch(/*String fishingOperationId*/) { - - } - - @Test - @Ignore - public void getSpeciesBatch(/*String id*/) { - - } - - @Test - @Ignore - public void createSpeciesBatch(/*SpeciesBatch bean, String parentBatchId*/) { - - } - - @Test - @Ignore - public void saveSpeciesBatch(/*SpeciesBatch bean*/) { - - } - - @Test - @Ignore - public void deleteSpeciesBatch(/*String id*/) { - } - - @Test - @Ignore - public void deleteSpeciesSubBatch(/*String id*/) { - } - - @Test - @Ignore - public void getAllSpeciesBatchFrequency(/*String speciesBatchId*/) { - - } - - @Test - @Ignore - public void getAllBenthosBatch(/*String fishingOperationId*/) { - - } - - @Test - @Ignore - public void getBenthosBatch(/*String id*/) { - - } - - @Test - @Ignore - public void createBenthosBatch(/*BenthosBatch bean*/) { - - } - - @Test - @Ignore - public void saveBenthosBatch(/*BenthosBatch bean*/) { - - } - - @Test - @Ignore - public void deleteBenthosBatch(/*String id*/) { - } - - @Test - @Ignore - public void getAllPlanktonBatch(/*String fishingOperationId*/) { - - } - - @Test - @Ignore - public void getPlanktonBatch(/*String id*/) { - - } - - @Test - @Ignore - public void createPlanktonBatch(/*PlanktonBatch bean*/) { - - } - - @Test - @Ignore - public void savePlanktonBatch(/*PlanktonBatch bean*/) { - - } - - @Test - @Ignore - public void deletePlanktonBatch(/*String id*/) { - } - - @Test - @Ignore - public void getAllMacroWasteBatch(/*String fishingOperationId*/) { - - } - - @Test - @Ignore - public void getMacroWasteBatch(/*String id*/) { - - } - - @Test - @Ignore - public void createMacroWasteBatch(/*MacroWasteBatch bean*/) { - - } - - @Test - @Ignore - public void saveMacroWasteBatch(/*MacroWasteBatch bean*/) { - - } - - @Test - @Ignore - public void deleteMacroWasteBatch(/*String id*/) { - } - - @Test - @Ignore - public void getAllAccidentalBatch(/*String fishingOperationId*/) { - - } - - @Test - @Ignore - public void getAccidentalBatch(/*String id*/) { - - } - - @Test - @Ignore - public void createAccidentalBatch(/*AccidentalBatch bean*/) { - - } - - @Test - @Ignore - public void saveAccidentalBatch(/*AccidentalBatch bean*/) { - - } - - @Test - @Ignore - public void deleteAccidentalBatch(/*String id*/) { - } - -} Modified: trunk/tutti-persistence-adagio/src/test/server.properties =================================================================== --- trunk/tutti-persistence-adagio/src/test/server.properties 2013-01-09 20:38:38 UTC (rev 162) +++ trunk/tutti-persistence-adagio/src/test/server.properties 2013-01-10 09:10:19 UTC (rev 163) @@ -1,2 +1,25 @@ +### +# #%L +# Tutti :: Persistence Adagio (impl) +# $Id$ +# $HeadURL$ +# %% +# Copyright (C) 2012 - 2013 Ifremer +# %% +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/gpl-3.0.html>. +# #L% +### server.database.0=file:db/allegro server.dbname.0=allegro \ No newline at end of file Property changes on: trunk/tutti-persistence-adagio/src/test/server.properties ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL Property changes on: trunk/tutti-persistence-adagio/src/test/startServer.sh ___________________________________________________________________ Modified: svn:keywords - Author Date Id Revision + Author Date Id Revision HeadURL
participants (1)
-
tchemit@users.forge.codelutin.com