Author: chatellier Date: 2009-09-28 15:03:06 +0000 (Mon, 28 Sep 2009) New Revision: 2648 Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/types/ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/types/MonthTest.java Modified: isis-fish/trunk/changelog.txt isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Month.java Log: Fix a missing hashCode in month Modified: isis-fish/trunk/changelog.txt =================================================================== --- isis-fish/trunk/changelog.txt 2009-09-28 14:37:45 UTC (rev 2647) +++ isis-fish/trunk/changelog.txt 2009-09-28 15:03:06 UTC (rev 2648) @@ -1,5 +1,6 @@ isis-fish (3.2.0.7) stable; urgency=low + * Fix a missing hashCode() problem in month (cause problem in matrixND) * Add time unit (seconds) in simulation summary * Make compilation directory per simulation (caparmor concurrency problem) * Fix plan generator was not closing database after finishing sub job Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Month.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Month.java 2009-09-28 14:37:45 UTC (rev 2647) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Month.java 2009-09-28 15:03:06 UTC (rev 2648) @@ -108,7 +108,18 @@ return nextMonth; } - /* (non-Javadoc) + /* + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + monthNumber; + return result; + } + + /* * @see org.codelutin.topia.persistence.TopiaEntityAbstract#equals(java.lang.Object) */ @Override @@ -123,9 +134,8 @@ return false; } + /* - * (non-Javadoc) - * * @see java.lang.Object#toString() */ @Override @@ -218,4 +228,5 @@ return result; } + } Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/types/MonthTest.java =================================================================== --- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/types/MonthTest.java (rev 0) +++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/types/MonthTest.java 2009-09-28 15:03:06 UTC (rev 2648) @@ -0,0 +1,83 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package fr.ifremer.isisfish.types; + +import static org.codelutin.i18n.I18n._; + +import java.util.LinkedList; +import java.util.List; + +import org.codelutin.math.matrix.MatrixFactory; +import org.codelutin.math.matrix.MatrixND; +import org.junit.Assert; +import org.junit.Test; + +/** + * TODO add comment here. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class MonthTest { + + /** + * Test that indexOf works on list of month. + */ + @Test + public void listTest() { + + List<Month> monthList = new LinkedList<Month>(); + monthList.add(new Month(0)); + monthList.add(new Month(1)); + monthList.add(new Month(2)); + + Assert.assertTrue(monthList.contains(Month.JANUARY)); + Assert.assertFalse(monthList.contains(Month.AUGUST)); + + Assert.assertEquals(0, monthList.indexOf(Month.JANUARY)); + Assert.assertEquals(-1, monthList.indexOf(Month.AUGUST)); + } + + @Test + public void maxtrixWithMonth() { + + List<Month> monthList = new LinkedList<Month>(); + monthList.add(new Month(0)); + monthList.add(new Month(1)); + monthList.add(new Month(2)); + + List<Month> monthList2 = new LinkedList<Month>(); + monthList2.add(Month.FEBRUARY); + + MatrixND tmp = MatrixFactory.getInstance().create( + "test", + new List[] { monthList }, + new String[] { _("isisfish.populationSeasonInfo.months") }); + + MatrixND result = MatrixFactory.getInstance().create( + "test", + new List[] { monthList2 }, + new String[] { _("isisfish.populationSeasonInfo.months") }); + + tmp.pasteSemantics(result); + } +} Property changes on: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/types/MonthTest.java ___________________________________________________________________ Added: svn:keywords + "Author Date Id Revision HeadURL"