Author: echatellier Date: 2015-04-27 09:22:43 +0000 (Mon, 27 Apr 2015) New Revision: 4207 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4207 Log: Add new test to test compilation and excecution of equations Added: trunk/src/test/java/fr/ifremer/isisfish/equation/ trunk/src/test/java/fr/ifremer/isisfish/equation/EquationTest.java Added: trunk/src/test/java/fr/ifremer/isisfish/equation/EquationTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/equation/EquationTest.java (rev 0) +++ trunk/src/test/java/fr/ifremer/isisfish/equation/EquationTest.java 2015-04-27 09:22:43 UTC (rev 4207) @@ -0,0 +1,81 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, CodeLutin, Chatellier Eric + * %% + * 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% + */ +package fr.ifremer.isisfish.equation; + +import fr.ifremer.isisfish.AbstractIsisFishTest; +import fr.ifremer.isisfish.util.Args; +import fr.ifremer.isisfish.util.EvaluatorHelper; +import java.util.Arrays; +import org.apache.commons.lang3.reflect.MethodUtils; +import org.junit.Assert; +import org.junit.Test; + +/** + * Equation related tests. + * + * @author chatellier + */ +public class EquationTest extends AbstractIsisFishTest { + + /** + * Try to compile all equation with a default content to detect basic + * compile error. + * + * @throws java.lang.ClassNotFoundException + */ + @Test + public void testCompileAllEquations() throws ClassNotFoundException { + test(EmigrationEquation.class, new Object[5]); + test(ImmigrationEquation.class, new Object[5]); + test(MigrationEquation.class, new Object[6]); + test(PopulationCapturabilityEquation.class, new Object[4]); + test(PopulationGrowth.class, null, 0.0, null); + test(PopulationGrowthReverse.class, null, 0.0, null); + test(PopulationMaturityOgiveEquation.class, new Object[2]); + test(PopulationMeanWeight.class, new Object[2]); + test(PopulationNaturalDeathRate.class, new Object[4]); + test(PopulationPrice.class, new Object[2]); + test(PopulationRecruitmentEquation.class, new Object[5]); + test(PopulationReproductionEquation.class, null, null, null, null, 0.0, null, null, null, null); + test(PopulationReproductionRateEquation.class, new Object[2]); + test(SelectivityEquation.class, new Object[4]); + test(SoVTechnicalEfficiencyEquation.class, new Object[3]); + test(StrategyInactivityEquation.class, new Object[3]); + test(TargetSpeciesTargetFactorEquation.class, null, null, null, null, false); + test(VariableEquation.class, new Object[3]); + } + + /** + * Try to set 'return 42.0;' in all equation content and test to get this result. + * + * @param clazz class to test + * @param args equation args + */ + protected void test(Class clazz, Object... args) { + EvaluatorHelper.evaluate("fr.isisfish.equation", + "TestCompileAll", clazz, "return 42.0;", args); + Assert.assertEquals(42, 42, 0.0001); + } +} Property changes on: trunk/src/test/java/fr/ifremer/isisfish/equation/EquationTest.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL