Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
May 2009
- 5 participants
- 134 discussions
r2236 - in isis-fish/trunk/src/main: java/fr/ifremer/isisfish java/fr/ifremer/isisfish/ui java/fr/ifremer/isisfish/ui/simulator java/fr/ifremer/isisfish/ui/simulator/launcher resources/i18n
by chatellier@users.labs.libre-entreprise.org 18 May '09
by chatellier@users.labs.libre-entreprise.org 18 May '09
18 May '09
Author: chatellier
Date: 2009-05-18 15:23:12 +0000 (Mon, 18 May 2009)
New Revision: 2236
Added:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/launcher/
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/launcher/SSHLauncherConfigUI.jaxx
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties
isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties
Log:
Add caparmor configuration frame
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-05-18 14:37:36 UTC (rev 2235)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-05-18 15:23:12 UTC (rev 2236)
@@ -191,13 +191,13 @@
File result = getOptionAsFile(Option.DATABASE_DIRECTORY.key);
return result;
}
-
+
/**
* Retourne le lock a utiliser pour la base h2.
*
* Par defaut la base utilise 'file'.
*
- * Les valeur acceptées sont :
+ * Les valeurs acceptées sont :
* - file
* - socket
* - no
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2009-05-18 14:37:36 UTC (rev 2235)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeUI.jaxx 2009-05-18 15:23:12 UTC (rev 2236)
@@ -17,38 +17,28 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*##%*/
-
-/**
- * WelcomeUI.
- *
- * Created: 1 aout 2005 18:37:25 CEST
- *
- * @author Benjamin POUSSIN <poussin at codelutin.com>
- * @version $Revision: 1312 $
- *
- * Last update: $Date: 2008-08-28 10:21:07 +0200 (jeu, 28 aoû 2008) $
- * by : $Author: sletellier $
- */
-->
<JFrame id='isisfishFrame' title="isisfish.welcome.title" width='874' height='736' resizable="true" location='{new Point(0,23)}' layout='{new BorderLayout()}'>
<script><![CDATA[
import static org.codelutin.i18n.I18n._;
+ import javax.swing.JFrame;
+
+ import fr.ifremer.isisfish.IsisFish;
+ import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.ui.simulator.SimulAction;
import fr.ifremer.isisfish.ui.input.InputUI;
import fr.ifremer.isisfish.ui.input.InputAction;
+ import fr.ifremer.isisfish.ui.input.InputSaveVerifier;
import fr.ifremer.isisfish.ui.sensitivity.SensitivityUI;
import fr.ifremer.isisfish.ui.result.ResultAction;
import fr.ifremer.isisfish.ui.result.ResultView;
import fr.ifremer.isisfish.ui.script.ScriptUI;
import fr.ifremer.isisfish.ui.simulator.SimulUI;
import fr.ifremer.isisfish.ui.simulator.QueueUI;
- import jaxx.runtime.DefaultJAXXContext;
- import fr.ifremer.isisfish.IsisFish;
- import fr.ifremer.isisfish.IsisConfig;
- import javax.swing.JFrame;
+ import fr.ifremer.isisfish.ui.simulator.launcher.SSHLauncherConfigUI;
import org.codelutin.widget.AboutFrame;
import jaxx.runtime.JAXXInitialContext;
- import fr.ifremer.isisfish.ui.input.InputSaveVerifier;
+ import jaxx.runtime.DefaultJAXXContext;
Map<JFrame, WelcomePanelUI> allFrameOpened;
WelcomeSaveVerifier verifier = new WelcomeSaveVerifier();
@@ -127,6 +117,15 @@
// FIXME a reimplanter
// fr.ifremer.isisfish.versionning.ui.VCSConfigUI.doLaunch()
}
+
+ protected void configurationSSHLauncher() {
+ SSHLauncherConfigUI configUI = new SSHLauncherConfigUI();
+ configUI.pack();
+ configUI.setSize(600, configUI.getHeight());
+ org.codelutin.widget.SwingUtil.center(configUI);
+ configUI.setVisible(true);
+ }
+
protected void help(String urlAlias) {
Help.showURL(urlAlias);
}
@@ -143,8 +142,7 @@
// center frame
Dimension dim = getToolkit().getScreenSize();
about.setSize(640, 520);
- about.setLocation((dim.width - about.getSize().width) / 2,
- (dim.height - about.getSize().height) / 2);
+ org.codelutin.widget.SwingUtil.center(about);
about.setVisible(true);
}
]]>
@@ -166,7 +164,8 @@
<JSeparator/>
<JMenu text="isisfish.welcome.menu.configuration">
<JMenuItem text="isisfish.welcome.menu.configuration" enabled='false' onActionPerformed='config()'/>
- <JMenuItem text="isisfish.welcome.menu.vcs.configuration" enabled='false' onActionPerformed='configVCS()'/>
+ <JMenuItem text="isisfish.welcome.menu.configuration.vcs" enabled='false' onActionPerformed='configVCS()'/>
+ <JMenuItem text="isisfish.welcome.menu.configuration.sshlauncher" onActionPerformed='configurationSSHLauncher()'/>
</JMenu>
</JMenu>
<JMenu text="isisfish.welcome.menu.help">
Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/launcher/SSHLauncherConfigUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/launcher/SSHLauncherConfigUI.jaxx (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/launcher/SSHLauncherConfigUI.jaxx 2009-05-18 15:23:12 UTC (rev 2236)
@@ -0,0 +1,278 @@
+<!-- ##%
+Copyright (C) 2009 Ifremer, 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.
+##% -->
+<JDialog resizable="false" title="isisfish.simulator.ssh.configuration.title" layout="{new BoxLayout(this.getContentPane(), BoxLayout.PAGE_AXIS)}">
+ <script><![CDATA[
+
+ import fr.ifremer.isisfish.IsisFish;
+
+ protected String currentSSHserver;
+ protected String currentSSHUsername;
+ protected String currentSSHKey;
+ protected String currentSSHDatapath;
+ protected String currentSSHIsisHome;
+ protected String currentSSHTempPath;
+ protected String currentSSHScriptCommand;
+ protected String currentSSHControlInterval;
+ protected String currentSSHSimultaneousSimulation;
+
+ // fill default values
+ resetSSHConfiguration();
+
+ /**
+ * Reset values with default configuration values.
+ */
+ protected void resetSSHConfiguration() {
+ // server config
+ sshServerField.setText(IsisFish.config.getSimulatorSshServer());
+ usernameField.setText(IsisFish.config.getSimulatorSshUsername());
+ sshKeyField.setText(IsisFish.config.getSSHPrivateKeyFilePath().getAbsolutePath());
+
+ // caparmor config
+ sshDatapathField.setText(IsisFish.config.getSimulatorSshDataPath());
+ sshIsisHomeField.setText(IsisFish.config.getSimulatorSshIsisHome());
+ sshTemppathField.setText(IsisFish.config.getSimulatorSshTmpPath());
+ sshScriptQueueCommandField.setText(IsisFish.config.getSimulatorSshAddToQueueCommand());
+ sshControlIntervalField.setText(String.valueOf(IsisFish.config.getSimulatorSshControlCheckInterval()));
+ sshSimultaneousSimulationField.setText(String.valueOf(IsisFish.config.getSimulatorSshMaxSimultaneousSimulation()));
+
+ doCheck();
+ }
+
+ protected void doCheck() {
+
+ boolean configurationValid = true;
+
+ // copy values
+ currentSSHserver = sshServerField.getText().trim();
+ if (currentSSHserver.isEmpty()) {
+ configurationValid = false;
+ setColor(true, sshServerField);
+ }
+ else {
+ setColor(false, sshServerField);
+ }
+
+ currentSSHUsername = usernameField.getText().trim();
+ if (!currentSSHUsername.matches("\\w+")) {
+ configurationValid = false;
+ setColor(true, usernameField);
+ }
+ else {
+ setColor(false, usernameField);
+ }
+
+ //currentSSHKey
+
+ currentSSHDatapath = sshDatapathField.getText().trim();
+ if (currentSSHDatapath.isEmpty()) {
+ configurationValid = false;
+ setColor(true, sshDatapathField);
+ }
+ else {
+ setColor(false, sshDatapathField);
+ }
+
+ currentSSHIsisHome = sshIsisHomeField.getText().trim();
+ if (currentSSHIsisHome.isEmpty()) {
+ configurationValid = false;
+ setColor(true, sshIsisHomeField);
+ }
+ else {
+ setColor(false, sshIsisHomeField);
+ }
+
+ currentSSHTempPath = sshTemppathField.getText().trim();
+ if (!currentSSHTempPath.startsWith("/")) {
+ configurationValid = false;
+ setColor(true, sshTemppathField);
+ }
+ else {
+ setColor(false, sshTemppathField);
+ }
+
+ currentSSHScriptCommand = sshScriptQueueCommandField.getText().trim();
+ if (currentSSHScriptCommand.isEmpty()) {
+ configurationValid = false;
+ setColor(true, sshScriptQueueCommandField);
+ }
+ else {
+ setColor(false, sshScriptQueueCommandField);
+ }
+
+ currentSSHControlInterval = sshControlIntervalField.getText().trim();
+ if (!currentSSHControlInterval.matches("\\d+")) {
+ configurationValid = false;
+ setColor(true, sshControlIntervalField);
+ }
+ else {
+ setColor(false, sshControlIntervalField);
+ }
+
+ currentSSHSimultaneousSimulation = sshSimultaneousSimulationField.getText().trim();
+ if (!currentSSHSimultaneousSimulation.matches("\\d+")) {
+ configurationValid = false;
+ setColor(true, sshSimultaneousSimulationField);
+ }
+ else {
+ setColor(false, sshSimultaneousSimulationField);
+ }
+
+ okButton.setEnabled(configurationValid);
+ }
+
+ /**
+ * Set values in config and force configuration save.
+ */
+ protected void saveSSHConfiguration() {
+ IsisFish.config.setSimulatorSshServer(currentSSHserver);
+ IsisFish.config.setSimulatorSshUsername(currentSSHUsername);
+
+ IsisFish.config.setSimulatorSshDataPath(currentSSHDatapath);
+ IsisFish.config.setSimuatorShhIsisHome(currentSSHIsisHome);
+ IsisFish.config.setSimulatorSshTmpPath(currentSSHTempPath);
+ IsisFish.config.setSimulatorSshAddToQueueCommand(currentSSHScriptCommand);
+ IsisFish.config.setSimulatorSshControlCheckInterval(Long.parseLong(currentSSHControlInterval));
+ IsisFish.config.setSimulatorSshMaxSimultaneousSimulation(Integer.parseInt(currentSSHSimultaneousSimulation));
+
+ IsisFish.config.saveForUser();
+ dispose();
+ }
+
+ /**
+ * Close frame.
+ */
+ protected void cancelSSHConfiguration() {
+ dispose();
+ }
+
+ protected void setColor(boolean invalid, JComponent component) {
+ component.setForeground(invalid ? Color.RED: Color.BLACK);
+ }
+ ]]></script>
+
+ <Table border='{BorderFactory.createTitledBorder(_("isisfish.simulator.ssh.configuration.connection"))}'
+ fill='horizontal'>
+ <row>
+ <cell>
+ <JLabel id='sshServerLabel' text='isisfish.config.main.simulation.ssh.server'
+ toolTipText='isisfish.config.main.simulation.ssh.login.description' />
+ </cell>
+ <cell fill='horizontal' weightx="2.0">
+ <JTextField id='sshServerField' toolTipText='isisfish.config.main.simulation.ssh.login.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='usernameLabel' text='isisfish.config.main.simulation.ssh.login'
+ toolTipText='isisfish.config.main.simulation.ssh.login.description' />
+ </cell>
+ <cell>
+ <JTextField id='usernameField' toolTipText='isisfish.config.main.simulation.ssh.login.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='sshKeyLabel' text='isisfish.config.ssh.key.file' toolTipText='isisfish.config.ssh.key.file.description' />
+ </cell>
+ <cell>
+ <JTextField id='sshKeyField' enabled='false' toolTipText='isisfish.config.ssh.key.file.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ </Table>
+ <Table border='{BorderFactory.createTitledBorder(_("isisfish.simulator.ssh.configuration.environment"))}'>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='sshDatapathLabel' text='isisfish.config.main.simulation.ssh.datapath'
+ toolTipText='isisfish.config.main.simulation.ssh.datapath.description' />
+ </cell>
+ <cell weightx="1.0">
+ <JTextField id='sshDatapathField' toolTipText='isisfish.config.main.simulation.ssh.datapath.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='sshIsisHomeLabel' text='isisfish.config.main.simulation.ssh.isis.home'
+ toolTipText='isisfish.config.main.simulation.ssh.isis.home.description' />
+ </cell>
+ <cell>
+ <JTextField id='sshIsisHomeField' toolTipText='isisfish.config.main.simulation.ssh.isis.home.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='sshTemppathLabel' text='isisfish.config.main.simulation.ssh.tmppath'
+ toolTipText='isisfish.config.main.simulation.ssh.tmppath.description' />
+ </cell>
+ <cell>
+ <JTextField id='sshTemppathField' toolTipText='isisfish.config.main.simulation.ssh.tmppath.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='sshScriptQueueCommandLabel' text='isisfish.config.main.simulation.ssh.addscripttoqueuecommand'
+ toolTipText='isisfish.config.main.simulation.ssh.addscripttoqueuecommand.description' />
+ </cell>
+ <cell>
+ <JTextField id='sshScriptQueueCommandField'
+ toolTipText='isisfish.config.main.simulation.ssh.addscripttoqueuecommand.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='sshControlIntervalLabel' text='isisfish.config.main.simulation.ssh.control.check.interval'
+ toolTipText='isisfish.config.main.simulation.ssh.control.check.interval.description' />
+ </cell>
+ <cell>
+ <JTextField id='sshControlIntervalField'
+ toolTipText='isisfish.config.main.simulation.ssh.control.check.interval.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ <row fill='horizontal'>
+ <cell>
+ <JLabel id='sshSimultaneousSimulationLabel' text='isisfish.config.main.simulation.max.simultaneous.simulation'
+ toolTipText='isisfish.config.main.simulation.max.simultaneous.simulation.description' />
+ </cell>
+ <cell>
+ <JTextField id='sshSimultaneousSimulationField'
+ toolTipText='isisfish.config.main.simulation.max.simultaneous.simulation.description'
+ onKeyReleased="doCheck()" />
+ </cell>
+ </row>
+ </Table>
+ <Table>
+ <row fill='horizontal'>
+ <cell fill='horizontal'>
+ <JButton id='okButton' text='isisfish.common.ok' onActionPerformed="saveSSHConfiguration()" />
+ </cell>
+ <cell fill='horizontal'>
+ <JButton id='resetButton' text='isisfish.common.reset' onActionPerformed="resetSSHConfiguration()" />
+ </cell>
+ <cell fill='horizontal'>
+ <JButton id='cancelButton' text='isisfish.common.cancel' onActionPerformed="cancelSSHConfiguration()" />
+ </cell>
+ </row>
+ </Table>
+</JDialog>
Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties
===================================================================
--- isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-05-18 14:37:36 UTC (rev 2235)
+++ isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-05-18 15:23:12 UTC (rev 2236)
@@ -29,7 +29,6 @@
Create\ a\ new\ script=
Cut\ current\ selection\ (Ctrl-x)=
Error\ during\ vcs\ initialisation=
-Error\ while\ downloading\ file\ \:\ %s=
Error\ while\ uploading\ public\ key\ to\ remote\ serveur\ authorized_keys=
Export\ selected\ script(s)\ to\ zip\ archive=
Generate\ next\ simulation=
@@ -170,14 +169,22 @@
isisfish.config.main.regionMap.description=
isisfish.config.main.remoteCaparmor.description=
isisfish.config.main.resultExport.description=
-isisfish.config.main.simulation.max.simultaneous.simulation.description=
-isisfish.config.main.simulation.ssh.addscripttoqueuecommand.description=
-isisfish.config.main.simulation.ssh.control.check.interval.description=
-isisfish.config.main.simulation.ssh.datapath.description=
-isisfish.config.main.simulation.ssh.isis.home.description=
-isisfish.config.main.simulation.ssh.login.description=
-isisfish.config.main.simulation.ssh.server.description=
-isisfish.config.main.simulation.ssh.tmppath.description=
+isisfish.config.main.simulation.max.simultaneous.simulation=Simultaneous simulation
+isisfish.config.main.simulation.max.simultaneous.simulation.description=Simultaneous simulation to do on Caparmor
+isisfish.config.main.simulation.ssh.addscripttoqueuecommand=Qsub command
+isisfish.config.main.simulation.ssh.addscripttoqueuecommand.description=Qsub command path
+isisfish.config.main.simulation.ssh.control.check.interval=Control check interval (seconds)
+isisfish.config.main.simulation.ssh.control.check.interval.description=Control check interval (seconds)
+isisfish.config.main.simulation.ssh.datapath=Isis-Fish database
+isisfish.config.main.simulation.ssh.datapath.description=Isis-Fish database path
+isisfish.config.main.simulation.ssh.isis.home=Isis-Fish home
+isisfish.config.main.simulation.ssh.isis.home.description=Isis-Fish installation directory
+isisfish.config.main.simulation.ssh.login=SSH identifier
+isisfish.config.main.simulation.ssh.login.description=SSH identifier
+isisfish.config.main.simulation.ssh.server=Server address
+isisfish.config.main.simulation.ssh.server.description=Server adress
+isisfish.config.main.simulation.ssh.tmppath=Server temp directory
+isisfish.config.main.simulation.ssh.tmppath.description=Server temp directory (must start with /)
isisfish.config.main.simulationServer.description=
isisfish.config.main.simulationShowOnlyError.description=
isisfish.config.main.simulationShowOnlyQueue.description=
@@ -185,6 +192,8 @@
isisfish.config.main.subSimulator.description=
isisfish.config.main.userMail.description=
isisfish.config.main.userName.description=
+isisfish.config.ssh.key.file=SSH key
+isisfish.config.ssh.key.file.description=Private SSH key path
isisfish.config.vcs.hostName.description=
isisfish.config.vcs.keyFile.description=
isisfish.config.vcs.localDatabasePath.description=
@@ -235,8 +244,6 @@
isisfish.error.delete.database=Can't delete database
isisfish.error.delete.file=could not delete file %1$s
isisfish.error.delete.vcs.files=Can't delete vcs files
-isisfish.error.dialog.message=Some errors have been detected
-isisfish.error.dialog.title=Error
isisfish.error.during.simulation=Error during simulation
isisfish.error.emigration.negative=emigration negative
isisfish.error.empty.code.rubbin=rubbin's code is empty
@@ -911,6 +918,9 @@
isisfish.simulator.launcher.remote=on Caparmor server
isisfish.simulator.launcher.subprocess=in subprocess
isisfish.simulator.simulaction.badid=Can't start simulation, bad id\: %s
+isisfish.simulator.ssh.configuration.connection=Connection information
+isisfish.simulator.ssh.configuration.environment=Caparmor configuration
+isisfish.simulator.ssh.configuration.title=Caparmor launcher configuration
isisfish.simulator.subprocess.readoutput.error=
isisfish.species.age=Age
isisfish.species.cee=CEE
@@ -1022,6 +1032,8 @@
isisfish.welcome.menu.about=About
isisfish.welcome.menu.close=Close
isisfish.welcome.menu.configuration=Configuration
+isisfish.welcome.menu.configuration.sshlauncher=
+isisfish.welcome.menu.configuration.vcs=
isisfish.welcome.menu.file=File
isisfish.welcome.menu.frame=Frame
isisfish.welcome.menu.help=Help
@@ -1037,7 +1049,6 @@
isisfish.welcome.menu.script=Script
isisfish.welcome.menu.simulation=Simulation Launcher
isisfish.welcome.menu.synchro=Server Synchronisation
-isisfish.welcome.menu.vcs.configuration=Configuration vcs
isisfish.welcome.title=Ifremer Simulation
isisfish.wizardGroupCreation.allGroupsSameSize=All groups have the same size
isisfish.wizardGroupCreation.allValues=Input all the values
Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties
===================================================================
--- isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-05-18 14:37:36 UTC (rev 2235)
+++ isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-05-18 15:23:12 UTC (rev 2236)
@@ -29,7 +29,6 @@
Create\ a\ new\ script=
Cut\ current\ selection\ (Ctrl-x)=
Error\ during\ vcs\ initialisation=
-Error\ while\ downloading\ file\ \:\ %s=
Error\ while\ uploading\ public\ key\ to\ remote\ serveur\ authorized_keys=
Export\ selected\ script(s)\ to\ zip\ archive=
Generate\ next\ simulation=
@@ -131,7 +130,7 @@
isisfish.common.prev=Pr\u00E9c\u00E9dent
isisfish.common.region=R\u00E9gion
isisfish.common.remove=Supprimer
-isisfish.common.reset=reset
+isisfish.common.reset=R\u00E9initialiser
isisfish.common.rules=R\u00E8gles
isisfish.common.save=Sauver
isisfish.common.saveModel=Sauver comme mod\u00E8le
@@ -170,14 +169,22 @@
isisfish.config.main.regionMap.description=le nom du r\u00E9pertoire contenant les maps d'une r\u00E9gion
isisfish.config.main.remoteCaparmor.description=lance les simulations sur un serveur distant
isisfish.config.main.resultExport.description=TODO
-isisfish.config.main.simulation.max.simultaneous.simulation.description=
-isisfish.config.main.simulation.ssh.addscripttoqueuecommand.description=
-isisfish.config.main.simulation.ssh.control.check.interval.description=
-isisfish.config.main.simulation.ssh.datapath.description=
-isisfish.config.main.simulation.ssh.isis.home.description=
-isisfish.config.main.simulation.ssh.login.description=
-isisfish.config.main.simulation.ssh.server.description=
-isisfish.config.main.simulation.ssh.tmppath.description=
+isisfish.config.main.simulation.max.simultaneous.simulation=Nombre de simulations simultan\u00E9es
+isisfish.config.main.simulation.max.simultaneous.simulation.description=Nombre maximum de simulations pouvant \u00EAtre envoy\u00E9es au serveur
+isisfish.config.main.simulation.ssh.addscripttoqueuecommand=Commande 'qsub'
+isisfish.config.main.simulation.ssh.addscripttoqueuecommand.description=Emplacemement de la commande 'qsub'
+isisfish.config.main.simulation.ssh.control.check.interval=V\u00E9rification de la progression (secondes)
+isisfish.config.main.simulation.ssh.control.check.interval.description=Temps d'attente en secondes entre deux v\u00E9rifications de progression
+isisfish.config.main.simulation.ssh.datapath=Base de donn\u00E9es
+isisfish.config.main.simulation.ssh.datapath.description=Emplacement de la base de donn\u00E9es (isis-database)
+isisfish.config.main.simulation.ssh.isis.home=Installation d'Isis-Fish
+isisfish.config.main.simulation.ssh.isis.home.description=Emplacement d'installation d'Isis-Fish sur le serveur
+isisfish.config.main.simulation.ssh.login=Identifiant
+isisfish.config.main.simulation.ssh.login.description=Identifiant SSH pour se connecter au serveur
+isisfish.config.main.simulation.ssh.server=Adresse du serveur
+isisfish.config.main.simulation.ssh.server.description=Adresse du serveur
+isisfish.config.main.simulation.ssh.tmppath=Dossier temporaire
+isisfish.config.main.simulation.ssh.tmppath.description=Emplacement du dossier temporaire (le chemin doit commencer par /)
isisfish.config.main.simulationServer.description=l'url du serveur de simulations distant
isisfish.config.main.simulationShowOnlyError.description=pour indiquer si l'on doit conserver dans l'UI des simulations termin\u00E9es uniquement celles avec erreur
isisfish.config.main.simulationShowOnlyQueue.description=pour indiquer si l'on doit conserver dans l'UI des simulations termin\u00E9es uniquement celles effectu\u00E9es localement
@@ -185,6 +192,8 @@
isisfish.config.main.subSimulator.description=pour indiquer si les simulations sont \u00E0 effectuer localement dans un sous process
isisfish.config.main.userMail.description=le courriel de l'utilisateur
isisfish.config.main.userName.description=le nom - pr\u00E9nom de l'utilisateur
+isisfish.config.ssh.key.file=Cl\u00E9 SSH
+isisfish.config.ssh.key.file.description=Emplacement de la cl\u00E9 priv\u00E9e SSH
isisfish.config.vcs.hostName.description=le nom du serveur vcs \u00E0 utiliser
isisfish.config.vcs.keyFile.description=le chemin complet du fichier de clef priv\u00E9e ssh2 \u00E0 utiliser lors d'une connexion s\u00E9curis\u00E9e
isisfish.config.vcs.localDatabasePath.description=
@@ -235,8 +244,6 @@
isisfish.error.delete.database=Can't delete database
isisfish.error.delete.file=could not delete file %1$s
isisfish.error.delete.vcs.files=Can't delete vcs files
-isisfish.error.dialog.message=Une erreur a \u00E9t\u00E9 d\u00E9tect\u00E9e
-isisfish.error.dialog.title=Erreur
isisfish.error.during.simulation=Error during simulation
isisfish.error.emigration.negative=emigration negative
isisfish.error.empty.code.rubbin=le code rubbin est vide
@@ -911,6 +918,9 @@
isisfish.simulator.launcher.remote=sur le serveur Caparmor
isisfish.simulator.launcher.subprocess=dans un sous processus
isisfish.simulator.simulaction.badid=Impossible de lancer la simulation '%s' \: l'identifiant existe d\u00E9j\u00E0 \!
+isisfish.simulator.ssh.configuration.connection=Information de connexion
+isisfish.simulator.ssh.configuration.environment=Configuration sur Caparmor
+isisfish.simulator.ssh.configuration.title=Configuration du lanceur Caparmor
isisfish.simulator.subprocess.readoutput.error=
isisfish.species.age=Age
isisfish.species.cee=CEE
@@ -1022,6 +1032,8 @@
isisfish.welcome.menu.about=\u00C0 propos
isisfish.welcome.menu.close=Fermer
isisfish.welcome.menu.configuration=Configuration
+isisfish.welcome.menu.configuration.sshlauncher=Configuration Caparmor
+isisfish.welcome.menu.configuration.vcs=Configuration vcs
isisfish.welcome.menu.file=Fichier
isisfish.welcome.menu.frame=Fen\u00EAtre
isisfish.welcome.menu.help=Aide
@@ -1037,7 +1049,6 @@
isisfish.welcome.menu.script=Script
isisfish.welcome.menu.simulation=Lanceur de simulations
isisfish.welcome.menu.synchro=Synchronisation Serveur
-isisfish.welcome.menu.vcs.configuration=Configuration vcs
isisfish.welcome.title=Simulation Ifremer
isisfish.wizardGroupCreation.allGroupsSameSize=Tous les groupes ont la m\u00EAme taille
isisfish.wizardGroupCreation.allValues=Input all the values
1
0
r2235 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish
by chatellier@users.labs.libre-entreprise.org 18 May '09
by chatellier@users.labs.libre-entreprise.org 18 May '09
18 May '09
Author: chatellier
Date: 2009-05-18 14:37:36 +0000 (Mon, 18 May 2009)
New Revision: 2235
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java
Log:
I18N was used before his own init.
Center main frame.
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2009-05-18 09:53:47 UTC (rev 2234)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2009-05-18 14:37:36 UTC (rev 2235)
@@ -46,6 +46,7 @@
import org.codelutin.topia.TopiaException;
import org.codelutin.util.LocaleConverter;
import org.codelutin.util.VersionNumber;
+import org.codelutin.widget.SwingUtil;
import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
import fr.ifremer.isisfish.datastore.ExportStorage;
@@ -188,27 +189,30 @@
* @param args main args
* @throws Exception if any exception while build configuration
*/
- static public void init(String ... args) throws Exception {
- log.info(_("isisfish.launch.start", java.util.Arrays.toString(args)));
- StringBuilder builder = new StringBuilder();
- builder.append(java.text.SimpleDateFormat.getInstance().format(new java.util.Date()));
- builder.append(" Java version: ").append(System.getProperty("java.runtime.version"));
- builder.append(" Isis-fish version: ").append(IsisConfig.getVersion());
- log.info(builder.toString());
- log.debug(_("isisfish.launch.debugMode"));
+ public static void init(String... args) throws Exception {
+ // i18n is not inited here
+ if (log.isInfoEnabled()) {
+ log.info("Starting Isis-Fish with args : " + java.util.Arrays.toString(args));
+ StringBuilder builder = new StringBuilder();
+ builder.append(SimpleDateFormat.getInstance().format(new java.util.Date()));
+ builder.append(" Java version: ").append(System.getProperty("java.runtime.version"));
+ builder.append(" Isis-fish version: ").append(IsisConfig.getVersion());
+ log.info(builder.toString());
+ }
+
// first load converter and matrixFactory
initConvertersAndMatrixFactory();
+
// after init shutdown hook
Runtime.getRuntime().addShutdownHook(new IsisQuitHook());
+ // parsing des options à partir des arguments passés
config = new IsisConfig();
-
- // parsing des options à partir des arguments passés
config.parse(args);
+ // init i18n
I18n.init(config.getLocale());
-
}
/**
@@ -439,7 +443,7 @@
/**
* initialise et lance l'interface graphique si elle est demandee
*/
- static public void launchUI() {
+ public static void launchUI() {
if (config.isLaunchUI()) {
// init simulater manager
SimulationService.getService();
@@ -451,13 +455,12 @@
// Set to exit on close
welcome.setDefaultCloseOperation(WelcomeUI.DO_NOTHING_ON_CLOSE);
welcome.addWindowListener(new WindowAdapter() {
-
@Override
public void windowClosing(WindowEvent e) {
((WelcomeUI)e.getSource()).close();
}
});
- // add context
+ SwingUtil.center(welcome);
welcome.setVisible(true);
}
else {
1
0
r2234 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish
by chatellier@users.labs.libre-entreprise.org 18 May '09
by chatellier@users.labs.libre-entreprise.org 18 May '09
18 May '09
Author: chatellier
Date: 2009-05-18 09:53:47 +0000 (Mon, 18 May 2009)
New Revision: 2234
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
Log:
Add setter method for change caparmor configuration by UI
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-05-15 16:59:52 UTC (rev 2233)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2009-05-18 09:53:47 UTC (rev 2234)
@@ -333,8 +333,17 @@
String result = getOption(Option.SIMULATOR_SSH_SERVER.key);
return result;
}
-
+
/**
+ * Change ssh server url value.
+ *
+ * @param sshServer
+ */
+ public void setSimulatorSshServer(String sshServer) {
+ setOption(Option.SIMULATOR_SSH_SERVER.key, sshServer);
+ }
+
+ /**
* Retourne le login pour acceder au serveur de simulation accessible via SSH.
*
* @return simulator username
@@ -343,19 +352,36 @@
String result = getOption(Option.SIMULATOR_SSH_USER_NAME.key);
return result;
}
-
+
/**
- * Retourne le chemin relatif ou abs du repertoire
- * root des données d'isis.
+ * Change ssh username.
*
+ * @param username username
+ */
+ public void setSimulatorSshUsername(String username ) {
+ setOption(Option.SIMULATOR_SSH_USER_NAME.key, username);
+ }
+
+ /**
+ * Retourne le chemin relatif ou abs du repertoire root des données d'isis.
+ *
* @return simulator data path
*/
public String getSimulatorSshDataPath() {
String result = getOption(Option.SIMULATOR_SSH_DATAPATH.key);
return result;
}
-
+
/**
+ * Change remote datapath.
+ *
+ * @param datapath datapath
+ */
+ public void setSimulatorSshDataPath(String datapath) {
+ setOption(Option.SIMULATOR_SSH_DATAPATH.key, datapath);
+ }
+
+ /**
* Retourne le chemin distant ou est installé isis.
*
* @return remote isis home
@@ -364,8 +390,17 @@
String result = getOption(Option.SIMULATOR_SSH_ISIS_HOME.key);
return result;
}
-
+
/**
+ * Change isis home on ssh server.
+ *
+ * @param isishome isis home
+ */
+ public void setSimuatorShhIsisHome(String isishome) {
+ setOption(Option.SIMULATOR_SSH_ISIS_HOME.key, isishome);
+ }
+
+ /**
* Retourne l'emplacement du dossier temporaire distant.
*
* Ce dossier doit être ABSOLUT.
@@ -376,8 +411,17 @@
String result = getOption(Option.SIMULATOR_SSH_TMPPATH.key);
return result;
}
-
+
/**
+ * Change ssh temp path.
+ *
+ * @param sshtemppath temp path
+ */
+ public void setSimulatorSshTmpPath(String sshtemppath) {
+ setOption(Option.SIMULATOR_SSH_TMPPATH.key, sshtemppath);
+ }
+
+ /**
* Retourne la commande a utiliser pour ajouter
* le script à la queue des simulation.
*
@@ -387,8 +431,17 @@
String result = getOption(Option.SIMULATOR_SSH_ADDSCRIPTTOQUEUECOMMAND.key);
return result;
}
-
+
/**
+ * Change qsub command.
+ *
+ * @param command new command
+ */
+ public void setSimulatorSshAddToQueueCommand(String command) {
+ setOption(Option.SIMULATOR_SSH_ADDSCRIPTTOQUEUECOMMAND.key, command);
+ }
+
+ /**
* Retourne l'interval de temps a utiliser
* pour recuperer le fichier de control.
*
@@ -398,8 +451,17 @@
int result = getOptionAsInt(Option.SIMULATOR_SSH_CONTROLCHECKINTERVAL.key);
return result;
}
-
+
/**
+ * Change control check interval.
+ *
+ * @param interval interval
+ */
+ public void setSimulatorSshControlCheckInterval(long interval) {
+ setOption(Option.SIMULATOR_SSH_CONTROLCHECKINTERVAL.key, String.valueOf(interval));
+ }
+
+ /**
* Retourne le nombre simultané de simulations authorisées sur
* caparmor.
*
@@ -413,6 +475,15 @@
}
/**
+ * Change max simultaneous simulation at a time.
+ *
+ * @param max max
+ */
+ public void setSimulatorSshMaxSimultaneousSimulation(int max) {
+ setOption(Option.SIMULATOR_SSH_MAX_SIMULTANEOUS_SIMULATION.key, String.valueOf(max));
+ }
+
+ /**
* Retourne la clé privée de l'utilisteur courant.
*
* @return private ssh key path
@@ -421,7 +492,7 @@
File result = getOptionAsFile(Option.SSH_KEY_FILE.key);
return result;
}
-
+
/*
* Le type de simulation par defaut a utiliser (local, remote, ...)
* @return
@@ -798,7 +869,7 @@
DATABASE_LOCK_MODE("database.lockmode", _("isisfish.config.database.lockmode.description"), "file"),
// TODO remove duplicated ssh key configuration
- SSH_KEY_FILE("ssh.key.file", _("isisfish.config.vcs.keyFile.description"), getUserHome() + File.separator + ".ssh" + File.separator + "isis_rsa"),
+ SSH_KEY_FILE("ssh.key.file", _("isisfish.config.ssh.key.file.description"), getUserHome() + File.separator + ".ssh" + File.separator + "isis_rsa"),
SSH_PASSPHRASE_ENABLED("ssh.passphrase.enabled", _("isisfish.config.vcs.noPassPhrase.description"), "false"),
SSH_PASSPHRASE("ssh.passphrase", _("isisfish.config.vcs.passphrase.description"), ""),
1
0
Author: chatellier
Date: 2009-05-15 16:59:52 +0000 (Fri, 15 May 2009)
New Revision: 2233
Modified:
isis-fish/trunk/pom.xml
Log:
Add lutinwidget as snapshot for rsyntax editor use
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2009-05-15 14:13:58 UTC (rev 2232)
+++ isis-fish/trunk/pom.xml 2009-05-15 16:59:52 UTC (rev 2233)
@@ -188,6 +188,13 @@
</dependency>
<dependency>
+ <groupId>org.fife</groupId>
+ <artifactId>rsyntaxtextarea</artifactId>
+ <version>1.3.3</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.41</version>
@@ -341,9 +348,9 @@
<topia.version>2.1.4</topia.version>
<topia.service.version>1.0.2</topia.service.version>
<lutinmatrix.version>1.3</lutinmatrix.version>
- <lutinutil.version>1.0.5</lutinutil.version>
+ <lutinutil.version>1.0.6</lutinutil.version>
<i18n.version>0.9</i18n.version>
- <lutinwidget.version>0.14</lutinwidget.version>
+ <lutinwidget.version>0.15-SNAPSHOT</lutinwidget.version>
<generator.version>0.64</generator.version>
<lutinj2r.version>0.4</lutinj2r.version>
<jrst.version>0.8.4</jrst.version>
@@ -351,7 +358,7 @@
<openmap.version>4.6.4</openmap.version>
<aspectwerkz.version>2.0</aspectwerkz.version>
<xmlrpc.version>3.1.2</xmlrpc.version>
-
+
<!-- for compilation test to run -->
<maven.test.forkMode>once</maven.test.forkMode>
1
0
r2232 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script
by chatellier@users.labs.libre-entreprise.org 15 May '09
by chatellier@users.labs.libre-entreprise.org 15 May '09
15 May '09
Author: chatellier
Date: 2009-05-15 14:13:58 +0000 (Fri, 15 May 2009)
New Revision: 2232
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
Log:
Use 'validate' to refresh editor
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2009-05-14 18:09:51 UTC (rev 2231)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptUI.jaxx 2009-05-15 14:13:58 UTC (rev 2232)
@@ -17,26 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*##%*/
-
-/**
- * ScriptUI.
- *
- * Created: 1 aout 2005 18:37:25 CEST
- *
- * @author Benjamin POUSSIN <poussin at codelutin.com>
- * @version $Revision: 1312 $
- *
- * Last update: $Date: 2008-08-28 10:21:07 +0200 (jeu, 28 aoû 2008) $
- * by : $Author: sletellier $
- */
-->
<JPanel id="script" layout='{new BorderLayout()}'>
<script><![CDATA[
- import static org.codelutin.i18n.I18n._;
- import jaxx.runtime.swing.Item;
import javax.swing.event.TreeSelectionListener;
- import jaxx.runtime.swing.JAXXTree;
import javax.swing.tree.TreePath;
import fr.ifremer.isisfish.ui.widget.editor.GenericCell;
import javax.swing.tree.DefaultTreeModel;
@@ -81,7 +66,7 @@
}
else {
editor.close();
- editor.repaint();
+ editor.validate();
}
actionLogArea.setText("");
}
@@ -130,7 +115,7 @@
}
protected void setEditor(File f){
editor.open(f);
- editor.repaint();
+ editor.validate();
}
protected DefaultMutableTreeNode findNode(DefaultMutableTreeNode root, String value){
DefaultMutableTreeNode result= null;
1
0
r2231 - in isis-fish/trunk/src: main/java/fr/ifremer/isisfish/actions main/java/fr/ifremer/isisfish/ui/versionning test/java/fr/ifremer/isisfish/actions
by chatellier@users.labs.libre-entreprise.org 14 May '09
by chatellier@users.labs.libre-entreprise.org 14 May '09
14 May '09
Author: chatellier
Date: 2009-05-14 18:09:51 +0000 (Thu, 14 May 2009)
New Revision: 2231
Added:
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/actions/VCSActionTest.java
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/VCSAction.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx
Log:
Add a test on VCS action (ssk key creation)
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/VCSAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/VCSAction.java 2009-05-14 18:09:22 UTC (rev 2230)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/VCSAction.java 2009-05-14 18:09:51 UTC (rev 2231)
@@ -59,10 +59,10 @@
}
// bug #1623, le dossier parent n'existe pas
- if (f.getParentFile() != null && f.getParentFile().isDirectory()) {
- f.mkdirs();
+ if (f.getParentFile() != null && !f.getParentFile().exists()) {
+ f.getParentFile().mkdirs();
}
-
+
if (log.isInfoEnabled()) {
log.info("Generate ssh key to " + f);
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx 2009-05-14 18:09:22 UTC (rev 2230)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx 2009-05-14 18:09:51 UTC (rev 2231)
@@ -52,8 +52,8 @@
File publicKeyFile = new File(serverPublicKeyFile.getText());
// bug #1623, le dossier parent n'existe pas
- if (privateKeyFile.getParentFile() != null && privateKeyFile.getParentFile().isDirectory()) {
- privateKeyFile.mkdirs();
+ if (privateKeyFile.getParentFile() != null && !privateKeyFile.getParentFile().exists()) {
+ privateKeyFile.getParentFile().mkdirs();
}
try {
Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/actions/VCSActionTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/actions/VCSActionTest.java (rev 0)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/actions/VCSActionTest.java 2009-05-14 18:09:51 UTC (rev 2231)
@@ -0,0 +1,58 @@
+/* *##%
+ * 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.actions;
+
+import java.io.File;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import fr.ifremer.isisfish.AbstractIsisFishTest;
+import fr.ifremer.isisfish.IsisFish;
+
+/**
+ * Test class for VCS action.
+ *
+ * @author chatellier
+ * @version $Revision: 1.0 $
+ *
+ * Last update : $Date: 14 mai 2009 $
+ * By : $Author: chatellier $
+ */
+public class VCSActionTest extends AbstractIsisFishTest {
+
+ /**
+ * Test ssh key creation action.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testSshCreateKey() throws Exception {
+ VCSAction action = new VCSAction(IsisFish.config);
+ action.sshCreateKey(false);
+
+ File sshKeyFile = new File(getCurrentDatabaseDirectory(), "ssh"
+ + File.separator + "isis_test_dsa");
+ File sshKeyFilePub = new File(getCurrentDatabaseDirectory(), "ssh"
+ + File.separator + "isis_test_dsa.pub");
+ Assert.assertTrue(sshKeyFile.isFile());
+ Assert.assertTrue(sshKeyFilePub.isFile());
+ }
+}
1
0
r2230 - in isis-fish/trunk/src/test/java/fr/ifremer: . isisfish isisfish/datastore isisfish/entity isisfish/logging isisfish/logging/io isisfish/mexico isisfish/simulator isisfish/simulator/launcher isisfish/simulator/sensitivity isisfish/ui/sensitivity isisfish/ui/widget/filter isisfish/util isisfish/vcs
by chatellier@users.labs.libre-entreprise.org 14 May '09
by chatellier@users.labs.libre-entreprise.org 14 May '09
14 May '09
Author: chatellier
Date: 2009-05-14 18:09:22 +0000 (Thu, 14 May 2009)
New Revision: 2230
Added:
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/DataStorageTestHelper.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PersistenceTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/LoggerHelper.java
Removed:
isis-fish/trunk/src/test/java/fr/ifremer/TestUtils.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/PersistenceTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/TestUtil.java
Modified:
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/AnalysePlanStorageTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ExportStorageTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/FormuleStorageTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/RuleStorageTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ScriptStorageTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SensitivityStorageTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SimulatorStorageTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PopulationSeasonInfoTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderUtilTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationHelperTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/FactorTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculatorRandomMock.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeModelTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/widget/filter/FilterDialogModelMock.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java
Log:
Refactor all tests.
Now all test must inherit abtract test that build a test environment with a proper isolated database.
Deleted: isis-fish/trunk/src/test/java/fr/ifremer/TestUtils.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/TestUtils.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/TestUtils.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -1,133 +0,0 @@
-/* *##%
- * 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;
-
-import java.io.File;
-import java.io.FileFilter;
-
-import org.apache.commons.io.FileUtils;
-import org.codelutin.util.FileUtil;
-
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.util.ClasspathTemplateLoader;
-import freemarker.cache.TemplateLoader;
-import freemarker.ext.beans.BeansWrapper;
-import freemarker.template.Configuration;
-
-/**
- * Une classe pour avoir des choses utiles pour tous les tests d'isis
- *
- * @author chemit
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-public abstract class TestUtils {
-
- protected static File basedir;
-
- protected static File targetdir;
-
- protected static File dirDatabase;
-
- public static File getBasedir() {
- if (basedir == null) {
- String base = System.getProperty("basedir");
- if (base == null || base.isEmpty()) {
- base = new File("").getAbsolutePath();
- }
- basedir = new File(base);
- //System.out.println("basedir for test " + basedir);
- }
- return basedir;
- }
-
- public static File getTargetdir() {
- if (targetdir == null) {
- targetdir = new File(getBasedir(), "target");
- //System.out.println("targetdir for test " + targetdir);
- }
- return targetdir;
- }
-
- /**
- * Toujours appeler cette method pour les test d'isis.
- * (sinon,il ira ecrire dans le isis-database-3 officiel).
- *
- * Create a temp dir and init isis with that temp dir as database.
- *
- * @throws Exception
- */
- public static void init() throws Exception {
-
- File mavenTestDir = new File(getTargetdir() + File.separator + "surefire-workdir");
- dirDatabase = FileUtil.createTempDirectory("isisdbtest", "", mavenTestDir);
-
- System.setProperty("database.directory", dirDatabase.getAbsolutePath());
- System.setProperty("launch.ui", "false");
- System.setProperty("user.home", dirDatabase.getAbsolutePath());
-
- IsisFish.init();
- IsisFish.initVCS();
-
- FileUtils.copyDirectory(new File("src/test/resources/test-database"), dirDatabase, new FileFilter() {
- @Override
- public boolean accept(File pathname) {
- boolean result = true;
- if(pathname.getAbsolutePath().indexOf(File.separator + ".svn") != -1) {
- result = false;
- }
- return result;
- }
- });
- }
-
- /**
- * Delete created temp directory.
- */
- public static void clean() {
- System.setProperty("user.home", "");
- if(dirDatabase != null) {
- FileUtil.deleteRecursively(dirDatabase);
- dirDatabase = null;
- }
- }
-
- /**
- * Return common script freemarker configuration.
- *
- * @return freemarker {@link Configuration}
- */
- public static Configuration getFreemarkerConfiguration() {
- Configuration freemarkerConfiguration = new Configuration();
-
- // needed to overwrite "Defaults to default system encoding."
- // fix encoding issue on some systems
- freemarkerConfiguration.setDefaultEncoding("utf-8");
-
- // specific template loader to get template from jars (classpath)
- TemplateLoader templateLoader = new ClasspathTemplateLoader();
- freemarkerConfiguration.setTemplateLoader(templateLoader);
-
- freemarkerConfiguration.setObjectWrapper(new BeansWrapper());
-
- return freemarkerConfiguration;
- }
-}
Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java (rev 0)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/AbstractIsisFishTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -0,0 +1,149 @@
+/* *##%
+ * 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;
+
+import java.io.File;
+import java.io.FileFilter;
+
+import org.apache.commons.io.FileUtils;
+import org.codelutin.util.FileUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import fr.ifremer.isisfish.util.ClasspathTemplateLoader;
+import freemarker.cache.TemplateLoader;
+import freemarker.ext.beans.BeansWrapper;
+import freemarker.template.Configuration;
+
+/**
+ * Abtract test case for isis fish.
+ *
+ * Contains BeforeClass and AfterClass method to proper init cases.
+ *
+ * @author chatellier
+ * @version $Revision: 1.0 $
+ *
+ * Last update : $Date: 14 mai 2009 $
+ * By : $Author: chatellier $
+ */
+public abstract class AbstractIsisFishTest {
+
+ protected static File basedir;
+
+ protected static File targetdir;
+
+ protected static File dirDatabase;
+
+ protected static File getBasedir() {
+ if (basedir == null) {
+ String base = System.getProperty("basedir");
+ if (base == null || base.isEmpty()) {
+ base = new File("").getAbsolutePath();
+ }
+ basedir = new File(base);
+ }
+ return basedir;
+ }
+
+ protected static File getTargetdir() {
+ if (targetdir == null) {
+ targetdir = new File(getBasedir(), "target");
+ }
+ return targetdir;
+ }
+
+ /**
+ * Toujours appeler cette method pour les test d'isis.
+ * (sinon,il ira ecrire dans le isis-database-3 officiel).
+ *
+ * Create a temp dir and init isis with that temp dir as database.
+ *
+ * @throws Exception
+ */
+ @BeforeClass
+ public static void init() throws Exception {
+
+ File mavenTestDir = new File(getTargetdir() + File.separator + "surefire-workdir");
+ dirDatabase = FileUtil.createTempDirectory("isisdbtest", "", mavenTestDir);
+
+ System.setProperty("user.home", dirDatabase.getAbsolutePath());
+ System.setProperty(IsisConfig.Option.LAUNCH_UI.key, "false");
+ System.setProperty(IsisConfig.Option.DATABASE_DIRECTORY.key, dirDatabase.getAbsolutePath());
+ System.setProperty(IsisConfig.Option.SSH_KEY_FILE.key, dirDatabase.getAbsolutePath() + File.separator + "ssh" + File.separator + "isis_test_dsa");
+ System.setProperty(IsisConfig.Option.VCS_SSH_KEY_FILE.key, dirDatabase.getAbsolutePath() + File.separator + "ssh" + File.separator + "isis_test_rsa");
+
+ IsisFish.init();
+ IsisFish.initVCS();
+
+ FileUtils.copyDirectory(new File("src/test/resources/test-database"),
+ dirDatabase, new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ boolean result = true;
+ if (pathname.getAbsolutePath().indexOf(
+ File.separator + ".svn") != -1) {
+ result = false;
+ }
+ return result;
+ }
+ });
+ }
+
+ /**
+ * Return current database directory.
+ *
+ * @return current database directory
+ */
+ protected static File getCurrentDatabaseDirectory() {
+ return dirDatabase;
+ }
+
+ /**
+ * Delete created temp directory.
+ */
+ @AfterClass
+ public static void clean() {
+ System.clearProperty("user.home");
+ if (dirDatabase != null) {
+ FileUtil.deleteRecursively(dirDatabase);
+ dirDatabase = null;
+ }
+ }
+
+ /**
+ * Return common script freemarker configuration.
+ *
+ * @return freemarker {@link Configuration}
+ */
+ protected static Configuration getFreemarkerConfiguration() {
+ Configuration freemarkerConfiguration = new Configuration();
+
+ // needed to overwrite "Defaults to default system encoding."
+ // fix encoding issue on some systems
+ freemarkerConfiguration.setDefaultEncoding("utf-8");
+
+ // specific template loader to get template from jars (classpath)
+ TemplateLoader templateLoader = new ClasspathTemplateLoader();
+ freemarkerConfiguration.setTemplateLoader(templateLoader);
+
+ freemarkerConfiguration.setObjectWrapper(new BeansWrapper());
+
+ return freemarkerConfiguration;
+ }
+}
Deleted: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/PersistenceTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/PersistenceTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/PersistenceTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -1,770 +0,0 @@
-/* *##%
-* Copyright (C) 2002, 2009 Code Lutin, Cédric Pineau, Benjamin Poussin
-*
-* 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;
-
-import java.util.Collection;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.topia.TopiaContext;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import fr.ifremer.TestUtils;
-import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.entities.Cell;
-import fr.ifremer.isisfish.entities.CellDAO;
-import fr.ifremer.isisfish.entities.EffortDescription;
-import fr.ifremer.isisfish.entities.EffortDescriptionDAO;
-import fr.ifremer.isisfish.entities.FisheryRegion;
-import fr.ifremer.isisfish.entities.FisheryRegionDAO;
-import fr.ifremer.isisfish.entities.Gear;
-import fr.ifremer.isisfish.entities.GearDAO;
-import fr.ifremer.isisfish.entities.Metier;
-import fr.ifremer.isisfish.entities.MetierDAO;
-import fr.ifremer.isisfish.entities.MetierSeasonInfo;
-import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO;
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationDAO;
-import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.entities.PopulationGroupDAO;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfoDAO;
-import fr.ifremer.isisfish.entities.Port;
-import fr.ifremer.isisfish.entities.PortDAO;
-import fr.ifremer.isisfish.entities.Result;
-import fr.ifremer.isisfish.entities.ResultDAO;
-import fr.ifremer.isisfish.entities.Season;
-import fr.ifremer.isisfish.entities.SeasonDAO;
-import fr.ifremer.isisfish.entities.Selectivity;
-import fr.ifremer.isisfish.entities.SelectivityDAO;
-import fr.ifremer.isisfish.entities.SetOfVessels;
-import fr.ifremer.isisfish.entities.SetOfVesselsDAO;
-import fr.ifremer.isisfish.entities.Species;
-import fr.ifremer.isisfish.entities.SpeciesDAO;
-import fr.ifremer.isisfish.entities.Strategy;
-import fr.ifremer.isisfish.entities.StrategyDAO;
-import fr.ifremer.isisfish.entities.StrategyMonthInfo;
-import fr.ifremer.isisfish.entities.StrategyMonthInfoDAO;
-import fr.ifremer.isisfish.entities.TargetSpecies;
-import fr.ifremer.isisfish.entities.TargetSpeciesDAO;
-import fr.ifremer.isisfish.entities.TripType;
-import fr.ifremer.isisfish.entities.TripTypeDAO;
-import fr.ifremer.isisfish.entities.VesselType;
-import fr.ifremer.isisfish.entities.VesselTypeDAO;
-import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.entities.ZoneDAO;
-
-/**
- * PersistenceTest.
- *
- * Created: 3 août 2004
- *
- * @author Benjamin Poussin <poussin at codelutin.com>
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class PersistenceTest {
-
- /**
- * Logger for this class
- */
- private static final Log log = LogFactory.getLog(PersistenceTest.class);
-
- // Persistence
- protected TopiaContext context = null;
- protected RegionStorage rs;
-
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- }
-
- @AfterClass
- public static void clean() {
- TestUtils.clean();
- }
-
- @Before
- public void setUp() throws Exception {
- rs = RegionStorage.create("test");
- context = rs.getStorage();
- }
-
- @After
- public void tearDown() throws Exception {
- rs.delete(false);
- }
-
- @Test
- public void testInstanciate() throws Exception {
- TopiaContext context = this.context.beginTransaction();
-
- FisheryRegionDAO fisheryRegionDAO = IsisFishDAOHelper.getFisheryRegionDAO(context);
- FisheryRegion fisheryRegion = fisheryRegionDAO.create();
- log.debug(fisheryRegion + " - " + fisheryRegion.getClass().getName());
-
- EffortDescriptionDAO effortDescriptionDAO = IsisFishDAOHelper.getEffortDescriptionDAO(context);
- EffortDescription effortDescription = effortDescriptionDAO.create();
- log.debug(effortDescription + " - " + effortDescription.getClass().getName());
-
- GearDAO gearDAO = IsisFishDAOHelper.getGearDAO(context);
- Gear gear = gearDAO.create();
- log.debug(gear + " - " + gear.getClass().getName());
-
- CellDAO cellDAO = IsisFishDAOHelper.getCellDAO(context);
- Cell cell = cellDAO.create();
- log.debug(cell + " - " + cell.getClass().getName());
-
- SpeciesDAO speciesDAO = IsisFishDAOHelper.getSpeciesDAO(context);
- Species species = speciesDAO.create();
- log.debug(species + " - " + species.getClass().getName());
-
- MetierDAO metierDAO = IsisFishDAOHelper.getMetierDAO(context);
- Metier metier = metierDAO.create();
- log.debug(metier + " - " + metier.getClass().getName());
-
- MetierSeasonInfoDAO metierSeasonInfoDAO = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
- MetierSeasonInfo metierSeasonInfo = metierSeasonInfoDAO.create();
- log.debug(metierSeasonInfo + " - " +metierSeasonInfo.getClass().getName());
-
- PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(context);
- PopulationGroup populationGroup = populationGroupDAO.create();
- log.debug(populationGroup + " - " + populationGroup.getClass().getName());
-
- PopulationDAO populationDAO = IsisFishDAOHelper.getPopulationDAO(context);
- Population population = populationDAO.create();
- log.debug(population + " - " + population.getClass().getName());
-
- PortDAO portDAO = IsisFishDAOHelper.getPortDAO(context);
- Port port = portDAO.create();
- log.debug(port + " - " + port.getClass().getName());
-
- ResultDAO resultDAO = IsisFishDAOHelper.getResultDAO(context);
- Result result = resultDAO.create();
- log.debug(result + " - " + result.getClass().getName());
-
- SeasonDAO seasonDAO = IsisFishDAOHelper.getSeasonDAO(context);
- Season season = seasonDAO.create();
- log.debug(season + " - " + season.getClass().getName());
-
- PopulationSeasonInfoDAO PopulationSeasonInfoDAO = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
- PopulationSeasonInfo PopulationSeasonInfo = PopulationSeasonInfoDAO.create();
- log.debug(PopulationSeasonInfo + " - " + PopulationSeasonInfo.getClass().getName());
-
- SelectivityDAO selectivityDAO = IsisFishDAOHelper.getSelectivityDAO(context);
- Selectivity selectivity = selectivityDAO.create();
- log.debug(selectivity + " - " + selectivity.getClass().getName());
-
- SetOfVesselsDAO setOfVesselsDAO = IsisFishDAOHelper.getSetOfVesselsDAO(context);
- SetOfVessels setOfVessels = setOfVesselsDAO.create();
- log.debug(setOfVessels + " - " + setOfVessels.getClass().getName());
-
- StrategyMonthInfoDAO strategyMonthInfoDAO = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
- StrategyMonthInfo strategyMonthInfo = strategyMonthInfoDAO.create();
- log.debug(strategyMonthInfo + " - " + strategyMonthInfo.getClass().getName());
-
- StrategyDAO strategyDAO = IsisFishDAOHelper.getStrategyDAO(context);
- Strategy strategy = strategyDAO.create();
- log.debug(strategy + " - " + strategy.getClass().getName());
-
- TargetSpeciesDAO targetSpeciesDAO = IsisFishDAOHelper.getTargetSpeciesDAO(context);
- TargetSpecies targetSpecies = targetSpeciesDAO.create();
- log.debug(targetSpecies + " - " + targetSpecies.getClass().getName());
-
- TripTypeDAO tripTypeDAO = IsisFishDAOHelper.getTripTypeDAO(context);
- TripType tripType = tripTypeDAO.create();
- log.debug(tripType + " - " + tripType.getClass().getName());
-
- VesselTypeDAO vesselTypeDAO = IsisFishDAOHelper.getVesselTypeDAO(context);
- VesselType vesselType = vesselTypeDAO.create();
- log.debug(vesselType + " - " + vesselType.getClass().getName());
-
- ZoneDAO zoneDAO = IsisFishDAOHelper.getZoneDAO(context);
- Zone zone = zoneDAO.create();
- log.debug(zone + " - " + zone.getClass().getName());
-
- context.rollbackTransaction();
- }
-
-
- @Test
- public void testMakePersistence() throws Exception {
- TopiaContext context = this.context.beginTransaction();
-// {
-// AgeGroupDAO ps = IsisFishDAOHelper.getAgeGroupDAO(context);
-// AgeGroup o = ps.create();
-// o = ps.update(o);
-// }
- {
- FisheryRegionDAO ps = IsisFishDAOHelper.getFisheryRegionDAO(context);
- FisheryRegion o = ps.create();
- o = ps.update(o);
- }
-// {
-// CompositeZoneDAO ps = IsisFishDAOHelper.getCompositeZoneDAO(context);
-// CompositeZone o = ps.create();
-// o = ps.update(o);
-// }
- {
- EffortDescriptionDAO ps = IsisFishDAOHelper.getEffortDescriptionDAO(context);
- EffortDescription o = ps.create();
- o = ps.update(o);
- }
-// {
-// EmigrationDAO ps = IsisFishDAOHelper.getEmigrationDAO(context);
-// Emigration o = ps.create();
-// o = ps.update(o);
-// }
-// {
-// EquationDAO ps = IsisFishDAOHelper.getEquationDAO(context);
-// Equation o = ps.create();
-// o = ps.update(o);
-// }
- {
- GearDAO ps = IsisFishDAOHelper.getGearDAO(context);
- Gear o = ps.create();
- o = ps.update(o);
- }
-// {
-// ImmigrationDAO ps = IsisFishDAOHelper.getImmigrationDAO(context);
-// Immigration o = ps.create();
-// o = ps.update(o);
-// }
-// {
-// LengthGroupDAO ps = IsisFishDAOHelper.getLengthGroupDAO(context);
-// LengthGroup o = ps.create();
-// o = ps.update(o);
-// }
-// {
-// MappingZoneReproZoneRecruDAO ps = IsisFishDAOHelper.getMappingZoneReproZoneRecruDAO(context);
-// MappingZoneReproZoneRecru o = ps.create();
-// o = ps.update(o);
-// }
- {
- CellDAO ps = IsisFishDAOHelper.getCellDAO(context);
- Cell o = ps.create();
- o = ps.update(o);
- }
- {
- SpeciesDAO ps = IsisFishDAOHelper.getSpeciesDAO(context);
- Species o = ps.create();
- o = ps.update(o);
- }
- {
- MetierDAO ps = IsisFishDAOHelper.getMetierDAO(context);
- Metier o = ps.create();
- o = ps.update(o);
- }
- {
- MetierSeasonInfoDAO ps = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
- MetierSeasonInfo o = ps.create();
- o = ps.update(o);
- }
-// {
-// MigrationDAO ps = IsisFishDAOHelper.getMigrationDAO(context);
-// Migration o = ps.create();
-// o = ps.update(o);
-// }
- {
-// try{
- PopulationGroupDAO ps = IsisFishDAOHelper.getPopulationGroupDAO(context);
- PopulationGroup o = ps.create();
- o = ps.update(o);
-// assertTrue(false); // normalement on a pas le droit d'instancier une entity abstraite
-// }catch(TopiaException eee){
-// assertTrue(true);
-// }
- }
- {
- PopulationDAO ps = IsisFishDAOHelper.getPopulationDAO(context);
- Population o = ps.create();
- o = ps.update(o);
- }
- {
- PortDAO ps = IsisFishDAOHelper.getPortDAO(context);
- Port o = ps.create();
- o = ps.update(o);
- }
- {
- ResultDAO ps = IsisFishDAOHelper.getResultDAO(context);
- Result o = ps.create();
- o = ps.update(o);
- }
- {
- PopulationSeasonInfoDAO ps = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
- PopulationSeasonInfo o = ps.create();
- o = ps.update(o);
- }
- {
- SelectivityDAO ps = IsisFishDAOHelper.getSelectivityDAO(context);
- Selectivity o = ps.create();
- o = ps.update(o);
- }
- {
- SetOfVesselsDAO ps = IsisFishDAOHelper.getSetOfVesselsDAO(context);
- SetOfVessels o = ps.create();
- o = ps.update(o);
- }
-// {
-// SimpleZoneDAO ps = IsisFishDAOHelper.getSimpleZoneDAO(context);
-// SimpleZone o = ps.create();
-// o = ps.update(o);
-// }
- {
- StrategyMonthInfoDAO ps = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
- StrategyMonthInfo o = ps.create();
- o = ps.update(o);
- }
- {
- StrategyDAO ps = IsisFishDAOHelper.getStrategyDAO(context);
- Strategy o = ps.create();
- o = ps.update(o);
- }
- {
- TargetSpeciesDAO ps = IsisFishDAOHelper.getTargetSpeciesDAO(context);
- TargetSpecies o = ps.create();
- o = ps.update(o);
- }
- {
- TripTypeDAO ps = IsisFishDAOHelper.getTripTypeDAO(context);
- TripType o = ps.create();
- o = ps.update(o);
- }
- {
- VesselTypeDAO ps = IsisFishDAOHelper.getVesselTypeDAO(context);
- VesselType o = ps.create();
- o = ps.update(o);
- }
- {
- ZoneDAO ps = IsisFishDAOHelper.getZoneDAO(context);
- Zone o = ps.create();
- o = ps.update(o);
- }
- context.rollbackTransaction();
- }
-
- @Test
- public void testFindAll() throws Exception {
- TopiaContext context = this.context.beginTransaction();
-// {
-// AgeGroupDAO ps = IsisFishDAOHelper.getAgeGroupDAO(context);
-// Collection<AgeGroup> list = ps.findAll();
-// log.debug(list + " - " +ps.getClass().getName());
-// }
- {
- FisheryRegionDAO ps = IsisFishDAOHelper.getFisheryRegionDAO(context);
- Collection<FisheryRegion> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
-// {
-// CompositeZoneDAO ps = IsisFishDAOHelper.getCompositeZoneDAO(context);
-// Collection list<CompositeZone> = ps.findAll();
-// }
- {
- EffortDescriptionDAO ps = IsisFishDAOHelper.getEffortDescriptionDAO(context);
- Collection<EffortDescription> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
-// {
-// EmigrationDAO ps = IsisFishDAOHelper.getEmigrationDAO(context);
-// Collection<Emigration> list = ps.findAll();
-// log.debug(list + " - " +ps.getClass().getName());
-// }
- {
- GearDAO ps = IsisFishDAOHelper.getGearDAO(context);
- Collection<Gear> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
-// {
-// ImmigrationDAO ps = IsisFishDAOHelper.getImmigrationDAO(context);
-// Collection<Immigration> list = ps.findAll();
-// log.debug(list + " - " +ps.getClass().getName());
-// }
-// {
-// LengthGroupDAO ps = IsisFishDAOHelper.getLengthGroupDAO(context);
-// Collection<LengthGroup> list = ps.findAll();
-// log.debug(list + " - " +ps.getClass().getName());
-// }
-// {
-// MappingZoneReproZoneRecruDAO ps = IsisFishDAOHelper.getMappingZoneReproZoneRecruDAO(context);
-// Collection<MappingZoneReproZoneRecru> list = ps.findAll();
-// log.debug(list + " - " +ps.getClass().getName());
-// }
- {
- CellDAO ps = IsisFishDAOHelper.getCellDAO(context);
- Collection<Cell> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- SpeciesDAO ps = IsisFishDAOHelper.getSpeciesDAO(context);
- Collection<Species> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- MetierDAO ps = IsisFishDAOHelper.getMetierDAO(context);
- Collection<Metier> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- MetierSeasonInfoDAO ps = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
- Collection<MetierSeasonInfo> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
-// {
-// MigrationDAO ps = IsisFishDAOHelper.getMigrationDAO(context);
-// Collection<Migration> list = ps.findAll();
-// log.debug(list + " - " +ps.getClass().getName());
-// }
- {
- PopulationGroupDAO ps = IsisFishDAOHelper.getPopulationGroupDAO(context);
- Collection<PopulationGroup> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- PopulationDAO ps = IsisFishDAOHelper.getPopulationDAO(context);
- Collection<Population> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- PortDAO ps = IsisFishDAOHelper.getPortDAO(context);
- Collection<Port> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- ResultDAO ps = IsisFishDAOHelper.getResultDAO(context);
- Collection<Result> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- PopulationSeasonInfoDAO ps = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
- Collection<PopulationSeasonInfo> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- SelectivityDAO ps = IsisFishDAOHelper.getSelectivityDAO(context);
- Collection<Selectivity> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- SetOfVesselsDAO ps = IsisFishDAOHelper.getSetOfVesselsDAO(context);
- Collection<SetOfVessels> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
-// {
-// SimpleZoneDAO ps = IsisFishDAOHelper.getSimpleZoneDAO(context);
-// Collection<SimpleZone> list = ps.findAll();
-// }
- {
- StrategyMonthInfoDAO ps = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
- Collection<StrategyMonthInfo> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- StrategyDAO ps = IsisFishDAOHelper.getStrategyDAO(context);
- Collection<Strategy> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- TargetSpeciesDAO ps = IsisFishDAOHelper.getTargetSpeciesDAO(context);
- Collection<TargetSpecies> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- TripTypeDAO ps = IsisFishDAOHelper.getTripTypeDAO(context);
- Collection<TripType> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- VesselTypeDAO ps = IsisFishDAOHelper.getVesselTypeDAO(context);
- Collection<VesselType> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- {
- ZoneDAO ps = IsisFishDAOHelper.getZoneDAO(context);
- Collection<Zone> list = ps.findAll();
- log.debug(list + " - " +ps.getClass().getName());
- }
- context.rollbackTransaction();
- }
-/*
- public void testDelete() throws Exception {
- TopiaContext context = this.context.beginTransaction();
- {
- AgeGroupDAO ps = IsisFishDAOHelper.getAgeGroupDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- AgeGroup o = (AgeGroup)i.next();
- ps.delete(o);
- }
- }
- {
- RegionDAO ps = IsisFishDAOHelper.getRegionDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Region o = (Region)i.next();
- ps.delete(o);
- }
- }
- {
- CompositeZoneDAO ps = IsisFishDAOHelper.getCompositeZoneDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- CompositeZone o = (CompositeZone)i.next();
- ps.delete(o);
- }
- }
- {
- EffortDescriptionDAO ps = IsisFishDAOHelper.getEffortDescriptionDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- EffortDescription o = (EffortDescription)i.next();
- ps.delete(o);
- }
- }
- {
- EmigrationDAO ps = IsisFishDAOHelper.getEmigrationDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Emigration o = (Emigration)i.next();
- ps.delete(o);
- }
- }
- {
- EquationDAO ps = IsisFishDAOHelper.getEquationDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Equation o = (Equation)i.next();
- ps.delete(o);
- }
- }
- {
- GearDAO ps = IsisFishDAOHelper.getGearDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Gear o = (Gear)i.next();
- ps.delete(o);
- }
- }
- {
- ImmigrationDAO ps = IsisFishDAOHelper.getImmigrationDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Immigration o = (Immigration)i.next();
- ps.delete(o);
- }
- }
- {
- LengthGroupDAO ps = IsisFishDAOHelper.getLengthGroupDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- LengthGroup o = (LengthGroup)i.next();
- ps.delete(o);
- }
- }
- {
- MappingZoneReproZoneRecruDAO ps = IsisFishDAOHelper.getMappingZoneReproZoneRecruDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- MappingZoneReproZoneRecru o = (MappingZoneReproZoneRecru)i.next();
- ps.delete(o);
- }
- }
- {
- CellDAO ps = IsisFishDAOHelper.getCellDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Cell o = (Cell)i.next();
- ps.delete(o);
- }
- }
- {
- SpeciesDAO ps = IsisFishDAOHelper.getSpeciesDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Species o = (Species)i.next();
- ps.delete(o);
- }
- }
- {
- MetierDAO ps = IsisFishDAOHelper.getMetierDAO(context);
- Metier o = ps.create();
- }
- {
- MetierSeasonInfoDAO ps = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- MetierSeasonInfo o = (MetierSeasonInfo)i.next();
- ps.delete(o);
- }
- }
- {
- MigrationDAO ps = IsisFishDAOHelper.getMigrationDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Migration o = (Migration)i.next();
- ps.delete(o);
- }
- }
- {
- MonthDAO ps = IsisFishDAOHelper.getMonthDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Month o = (Month)i.next();
- ps.delete(o);
- }
- }
- {
- PopulationGroupDAO ps = IsisFishDAOHelper.getPopulationGroupDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- PopulationGroup o = (PopulationGroup)i.next();
- ps.delete(o);
- }
- }
- {
- PopulationDAO ps = IsisFishDAOHelper.getPopulationDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Population o = (Population)i.next();
- ps.delete(o);
- }
- }
- {
- PortDAO ps = IsisFishDAOHelper.getPortDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Port o = (Port)i.next();
- ps.delete(o);
- }
- }
- {
- ResultManagerDAO ps = IsisFishDAOHelper.getResultManagerDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- ResultStorage o = (ResultStorage)i.next();
- ps.delete(o);
- }
- }
- {
- SeasonDAO ps = IsisFishDAOHelper.getSeasonDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Season o = (Season)i.next();
- ps.delete(o);
- }
- }
- {
- PopulationSeasonInfoDAO ps = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- PopulationSeasonInfo o = (PopulationSeasonInfo)i.next();
- ps.delete(o);
- }
- }
- {
- SelectivityDAO ps = IsisFishDAOHelper.getSelectivityDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Selectivity o = (Selectivity)i.next();
- ps.delete(o);
- }
- }
- {
- SetOfVesselsDAO ps = IsisFishDAOHelper.getSetOfVesselsDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- SetOfVessels o = (SetOfVessels)i.next();
- ps.delete(o);
- }
- }
- {
- SimpleZoneDAO ps = IsisFishDAOHelper.getSimpleZoneDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- SimpleZone o = (SimpleZone)i.next();
- ps.delete(o);
- }
- }
- {
- StrategyMonthInfoDAO ps = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- StrategyMonthInfo o = (StrategyMonthInfo)i.next();
- ps.delete(o);
- }
- }
- {
- StrategyDAO ps = IsisFishDAOHelper.getStrategyDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Strategy o = (Strategy)i.next();
- ps.delete(o);
- }
- }
- {
- TargetSpeciesDAO ps = IsisFishDAOHelper.getTargetSpeciesDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- TargetSpecies o = (TargetSpecies)i.next();
- ps.delete(o);
- }
- }
- {
- TimeUnitDAO ps = IsisFishDAOHelper.getTimeUnitDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- TimeUnit o = (TimeUnit)i.next();
- ps.delete(o);
- }
- }
- {
- TripTypeDAO ps = IsisFishDAOHelper.getTripTypeDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- TripType o = (TripType)i.next();
- ps.delete(o);
- }
- }
- {
- VesselTypeDAO ps = IsisFishDAOHelper.getVesselTypeDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- VesselType o = (VesselType)i.next();
- ps.delete(o);
- }
- }
- {
- ZoneDAO ps = IsisFishDAOHelper.getZoneDAO(context);
- Collection list = ps.findAll();
- for(Iterator i=list.iterator(); i.hasNext();){
- Zone o = (Zone)i.next();
- ps.delete(o);
- }
- }
- context.rollbackTransaction();
- }
- */
-} // Persistence
-
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/AnalysePlanStorageTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/AnalysePlanStorageTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/AnalysePlanStorageTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -26,10 +26,10 @@
import java.util.Map;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.Configuration;
import freemarker.template.Template;
@@ -45,14 +45,13 @@
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $
* by : $Author: tchemit $
*/
-public class AnalysePlanStorageTest {
+public class AnalysePlanStorageTest extends AbstractIsisFishTest {
- protected static Configuration freemarkerConfiguration;
+ protected Configuration freemarkerConfiguration;
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
+ @Before
+ public void setUp() throws Exception {
+ freemarkerConfiguration = getFreemarkerConfiguration();
}
@Test
@@ -81,11 +80,11 @@
template.process(root, out);
out.flush();
String content = out.toString();
-
+
// remove it to compile, it's in isis fish data project
Assert.assertTrue(content.indexOf("import scripts.ResultName;") > 0);
content = content.replaceFirst("import scripts.ResultName;", "");
-
+
analysePlanStorage.setContent(content);
// 0 = compile success
Added: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/DataStorageTestHelper.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/DataStorageTestHelper.java (rev 0)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/DataStorageTestHelper.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -0,0 +1,56 @@
+/* *##%
+ * 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.datastore;
+
+import org.junit.Ignore;
+
+/**
+ * Helper to acces protected static cache objects.
+ *
+ * @author chatellier
+ * @version $Revision: 1.0 $
+ *
+ * Last update : $Date: 14 mai 2009 $
+ * By : $Author: chatellier $
+ */
+ at Ignore
+public class DataStorageTestHelper {
+
+ /**
+ * Clear static simulation cache.
+ */
+ public static void clearSimulationCache() {
+ SimulationStorage.simulations.clear();
+ }
+
+ /**
+ * Clear static region cache.
+ */
+ public static void clearRegionCache() {
+ RegionStorage.regions.clear();
+ }
+
+ /**
+ * Clear all static cache.
+ */
+ public static void clearAllCache() {
+ clearSimulationCache();
+ clearRegionCache();
+ }
+}
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ExportStorageTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ExportStorageTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ExportStorageTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -26,10 +26,10 @@
import java.util.Map;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.Configuration;
import freemarker.template.Template;
@@ -45,14 +45,13 @@
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $
* by : $Author: tchemit $
*/
-public class ExportStorageTest {
+public class ExportStorageTest extends AbstractIsisFishTest {
- protected static Configuration freemarkerConfiguration;
+ protected Configuration freemarkerConfiguration;
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
+ @Before
+ public void setUp() throws Exception {
+ freemarkerConfiguration = getFreemarkerConfiguration();
}
@Test
@@ -60,8 +59,7 @@
String fileName = "TestExport1";
- ExportStorage exportStorage = ExportStorage
- .getExport(fileName);
+ ExportStorage exportStorage = ExportStorage.getExport(fileName);
// get template
Template template = freemarkerConfiguration
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/FormuleStorageTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/FormuleStorageTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/FormuleStorageTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -25,10 +25,10 @@
import java.util.HashMap;
import java.util.Map;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.Configuration;
import freemarker.template.Template;
@@ -44,14 +44,13 @@
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $
* by : $Author: tchemit $
*/
-public class FormuleStorageTest {
+public class FormuleStorageTest extends AbstractIsisFishTest {
- protected static Configuration freemarkerConfiguration;
+ protected Configuration freemarkerConfiguration;
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
+ @Before
+ public void setUp() throws Exception {
+ freemarkerConfiguration = getFreemarkerConfiguration();
}
@Test
@@ -59,8 +58,8 @@
String fileName = "TestFormule1";
- FormuleStorage formuleStorage = FormuleStorage
- .getFormule("test", fileName);
+ FormuleStorage formuleStorage = FormuleStorage.getFormule("test",
+ fileName);
// get template
Template template = freemarkerConfiguration
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/RuleStorageTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/RuleStorageTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/RuleStorageTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -26,10 +26,10 @@
import java.util.Map;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.Configuration;
import freemarker.template.Template;
@@ -45,14 +45,13 @@
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $
* by : $Author: tchemit $
*/
-public class RuleStorageTest {
+public class RuleStorageTest extends AbstractIsisFishTest {
- protected static Configuration freemarkerConfiguration;
+ protected Configuration freemarkerConfiguration;
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
+ @Before
+ public void setUp() throws Exception {
+ freemarkerConfiguration = getFreemarkerConfiguration();
}
@Test
@@ -60,8 +59,7 @@
String fileName = "TestRule1";
- RuleStorage ruleStorage = RuleStorage
- .getRule(fileName);
+ RuleStorage ruleStorage = RuleStorage.getRule(fileName);
// get template
Template template = freemarkerConfiguration
@@ -81,11 +79,11 @@
template.process(root, out);
out.flush();
String content = out.toString();
-
+
// remove it to compile, it's in isis fish data project
Assert.assertTrue(content.indexOf("import scripts.ResultName;") > 0);
content = content.replaceFirst("import scripts.ResultName;", "");
-
+
ruleStorage.setContent(content);
// 0 = compile success
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ScriptStorageTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ScriptStorageTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/ScriptStorageTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -27,10 +27,10 @@
import org.codelutin.util.FileUtil;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.Configuration;
import freemarker.template.Template;
@@ -46,17 +46,13 @@
* Last update: $Date$
* by : $Author$
*/
-public class ScriptStorageTest {
+public class ScriptStorageTest extends AbstractIsisFishTest {
- protected static Configuration freemarkerConfiguration;
-
- /*
- * @see TestCase#setUp()
- */
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
+ protected Configuration freemarkerConfiguration;
+
+ @Before
+ public void setUp() throws Exception {
+ freemarkerConfiguration = getFreemarkerConfiguration();
}
/*
@@ -95,8 +91,7 @@
String fileName = "TestScript1";
- ScriptStorage scriptStorage = ScriptStorage
- .getScript(fileName);
+ ScriptStorage scriptStorage = ScriptStorage.getScript(fileName);
// get template
Template template = freemarkerConfiguration
@@ -116,11 +111,11 @@
template.process(root, out);
out.flush();
String content = out.toString();
-
+
// remove it to compile, it's in isis fish data project
Assert.assertTrue(content.indexOf("import scripts.ResultName;") > 0);
content = content.replaceFirst("import scripts.ResultName;", "");
-
+
scriptStorage.setContent(content);
// 0 = compile success
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SensitivityStorageTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SensitivityStorageTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SensitivityStorageTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -26,10 +26,10 @@
import java.util.Map;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.Configuration;
import freemarker.template.Template;
@@ -45,14 +45,13 @@
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $
* by : $Author: tchemit $
*/
-public class SensitivityStorageTest {
+public class SensitivityStorageTest extends AbstractIsisFishTest {
- protected static Configuration freemarkerConfiguration;
+ protected Configuration freemarkerConfiguration;
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
+ @Before
+ public void setUp() throws Exception {
+ freemarkerConfiguration = getFreemarkerConfiguration();
}
@Test
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SimulatorStorageTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SimulatorStorageTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/datastore/SimulatorStorageTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -26,10 +26,10 @@
import java.util.Map;
import org.junit.Assert;
-import org.junit.BeforeClass;
+import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.Configuration;
import freemarker.template.Template;
@@ -45,14 +45,13 @@
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $
* by : $Author: tchemit $
*/
-public class SimulatorStorageTest {
+public class SimulatorStorageTest extends AbstractIsisFishTest {
- protected static Configuration freemarkerConfiguration;
+ protected Configuration freemarkerConfiguration;
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
+ @Before
+ public void setUp() throws Exception {
+ freemarkerConfiguration = getFreemarkerConfiguration();
}
@Test
Copied: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PersistenceTest.java (from rev 2214, isis-fish/trunk/src/test/java/fr/ifremer/isisfish/PersistenceTest.java)
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PersistenceTest.java (rev 0)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PersistenceTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -0,0 +1,759 @@
+/* *##%
+* Copyright (C) 2002, 2009 Code Lutin, Cédric Pineau, Benjamin Poussin
+*
+* 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.entity;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.topia.TopiaContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import fr.ifremer.isisfish.AbstractIsisFishTest;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.entities.Cell;
+import fr.ifremer.isisfish.entities.CellDAO;
+import fr.ifremer.isisfish.entities.EffortDescription;
+import fr.ifremer.isisfish.entities.EffortDescriptionDAO;
+import fr.ifremer.isisfish.entities.FisheryRegion;
+import fr.ifremer.isisfish.entities.FisheryRegionDAO;
+import fr.ifremer.isisfish.entities.Gear;
+import fr.ifremer.isisfish.entities.GearDAO;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.entities.MetierDAO;
+import fr.ifremer.isisfish.entities.MetierSeasonInfo;
+import fr.ifremer.isisfish.entities.MetierSeasonInfoDAO;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationDAO;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationGroupDAO;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfoDAO;
+import fr.ifremer.isisfish.entities.Port;
+import fr.ifremer.isisfish.entities.PortDAO;
+import fr.ifremer.isisfish.entities.Result;
+import fr.ifremer.isisfish.entities.ResultDAO;
+import fr.ifremer.isisfish.entities.Season;
+import fr.ifremer.isisfish.entities.SeasonDAO;
+import fr.ifremer.isisfish.entities.Selectivity;
+import fr.ifremer.isisfish.entities.SelectivityDAO;
+import fr.ifremer.isisfish.entities.SetOfVessels;
+import fr.ifremer.isisfish.entities.SetOfVesselsDAO;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.entities.SpeciesDAO;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.StrategyDAO;
+import fr.ifremer.isisfish.entities.StrategyMonthInfo;
+import fr.ifremer.isisfish.entities.StrategyMonthInfoDAO;
+import fr.ifremer.isisfish.entities.TargetSpecies;
+import fr.ifremer.isisfish.entities.TargetSpeciesDAO;
+import fr.ifremer.isisfish.entities.TripType;
+import fr.ifremer.isisfish.entities.TripTypeDAO;
+import fr.ifremer.isisfish.entities.VesselType;
+import fr.ifremer.isisfish.entities.VesselTypeDAO;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.entities.ZoneDAO;
+
+/**
+ * PersistenceTest.
+ *
+ * Created: 3 août 2004
+ *
+ * @author Benjamin Poussin <poussin at codelutin.com>
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class PersistenceTest extends AbstractIsisFishTest {
+
+ /**
+ * Logger for this class
+ */
+ private static final Log log = LogFactory.getLog(PersistenceTest.class);
+
+ // Persistence
+ protected TopiaContext context = null;
+ protected RegionStorage rs;
+
+ @Before
+ public void setUp() throws Exception {
+ rs = RegionStorage.create("test");
+ context = rs.getStorage();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ rs.delete(false);
+ }
+
+ @Test
+ public void testInstanciate() throws Exception {
+ TopiaContext context = this.context.beginTransaction();
+
+ FisheryRegionDAO fisheryRegionDAO = IsisFishDAOHelper.getFisheryRegionDAO(context);
+ FisheryRegion fisheryRegion = fisheryRegionDAO.create();
+ log.debug(fisheryRegion + " - " + fisheryRegion.getClass().getName());
+
+ EffortDescriptionDAO effortDescriptionDAO = IsisFishDAOHelper.getEffortDescriptionDAO(context);
+ EffortDescription effortDescription = effortDescriptionDAO.create();
+ log.debug(effortDescription + " - " + effortDescription.getClass().getName());
+
+ GearDAO gearDAO = IsisFishDAOHelper.getGearDAO(context);
+ Gear gear = gearDAO.create();
+ log.debug(gear + " - " + gear.getClass().getName());
+
+ CellDAO cellDAO = IsisFishDAOHelper.getCellDAO(context);
+ Cell cell = cellDAO.create();
+ log.debug(cell + " - " + cell.getClass().getName());
+
+ SpeciesDAO speciesDAO = IsisFishDAOHelper.getSpeciesDAO(context);
+ Species species = speciesDAO.create();
+ log.debug(species + " - " + species.getClass().getName());
+
+ MetierDAO metierDAO = IsisFishDAOHelper.getMetierDAO(context);
+ Metier metier = metierDAO.create();
+ log.debug(metier + " - " + metier.getClass().getName());
+
+ MetierSeasonInfoDAO metierSeasonInfoDAO = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
+ MetierSeasonInfo metierSeasonInfo = metierSeasonInfoDAO.create();
+ log.debug(metierSeasonInfo + " - " +metierSeasonInfo.getClass().getName());
+
+ PopulationGroupDAO populationGroupDAO = IsisFishDAOHelper.getPopulationGroupDAO(context);
+ PopulationGroup populationGroup = populationGroupDAO.create();
+ log.debug(populationGroup + " - " + populationGroup.getClass().getName());
+
+ PopulationDAO populationDAO = IsisFishDAOHelper.getPopulationDAO(context);
+ Population population = populationDAO.create();
+ log.debug(population + " - " + population.getClass().getName());
+
+ PortDAO portDAO = IsisFishDAOHelper.getPortDAO(context);
+ Port port = portDAO.create();
+ log.debug(port + " - " + port.getClass().getName());
+
+ ResultDAO resultDAO = IsisFishDAOHelper.getResultDAO(context);
+ Result result = resultDAO.create();
+ log.debug(result + " - " + result.getClass().getName());
+
+ SeasonDAO seasonDAO = IsisFishDAOHelper.getSeasonDAO(context);
+ Season season = seasonDAO.create();
+ log.debug(season + " - " + season.getClass().getName());
+
+ PopulationSeasonInfoDAO PopulationSeasonInfoDAO = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
+ PopulationSeasonInfo PopulationSeasonInfo = PopulationSeasonInfoDAO.create();
+ log.debug(PopulationSeasonInfo + " - " + PopulationSeasonInfo.getClass().getName());
+
+ SelectivityDAO selectivityDAO = IsisFishDAOHelper.getSelectivityDAO(context);
+ Selectivity selectivity = selectivityDAO.create();
+ log.debug(selectivity + " - " + selectivity.getClass().getName());
+
+ SetOfVesselsDAO setOfVesselsDAO = IsisFishDAOHelper.getSetOfVesselsDAO(context);
+ SetOfVessels setOfVessels = setOfVesselsDAO.create();
+ log.debug(setOfVessels + " - " + setOfVessels.getClass().getName());
+
+ StrategyMonthInfoDAO strategyMonthInfoDAO = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
+ StrategyMonthInfo strategyMonthInfo = strategyMonthInfoDAO.create();
+ log.debug(strategyMonthInfo + " - " + strategyMonthInfo.getClass().getName());
+
+ StrategyDAO strategyDAO = IsisFishDAOHelper.getStrategyDAO(context);
+ Strategy strategy = strategyDAO.create();
+ log.debug(strategy + " - " + strategy.getClass().getName());
+
+ TargetSpeciesDAO targetSpeciesDAO = IsisFishDAOHelper.getTargetSpeciesDAO(context);
+ TargetSpecies targetSpecies = targetSpeciesDAO.create();
+ log.debug(targetSpecies + " - " + targetSpecies.getClass().getName());
+
+ TripTypeDAO tripTypeDAO = IsisFishDAOHelper.getTripTypeDAO(context);
+ TripType tripType = tripTypeDAO.create();
+ log.debug(tripType + " - " + tripType.getClass().getName());
+
+ VesselTypeDAO vesselTypeDAO = IsisFishDAOHelper.getVesselTypeDAO(context);
+ VesselType vesselType = vesselTypeDAO.create();
+ log.debug(vesselType + " - " + vesselType.getClass().getName());
+
+ ZoneDAO zoneDAO = IsisFishDAOHelper.getZoneDAO(context);
+ Zone zone = zoneDAO.create();
+ log.debug(zone + " - " + zone.getClass().getName());
+
+ context.rollbackTransaction();
+ }
+
+
+ @Test
+ public void testMakePersistence() throws Exception {
+ TopiaContext context = this.context.beginTransaction();
+// {
+// AgeGroupDAO ps = IsisFishDAOHelper.getAgeGroupDAO(context);
+// AgeGroup o = ps.create();
+// o = ps.update(o);
+// }
+ {
+ FisheryRegionDAO ps = IsisFishDAOHelper.getFisheryRegionDAO(context);
+ FisheryRegion o = ps.create();
+ o = ps.update(o);
+ }
+// {
+// CompositeZoneDAO ps = IsisFishDAOHelper.getCompositeZoneDAO(context);
+// CompositeZone o = ps.create();
+// o = ps.update(o);
+// }
+ {
+ EffortDescriptionDAO ps = IsisFishDAOHelper.getEffortDescriptionDAO(context);
+ EffortDescription o = ps.create();
+ o = ps.update(o);
+ }
+// {
+// EmigrationDAO ps = IsisFishDAOHelper.getEmigrationDAO(context);
+// Emigration o = ps.create();
+// o = ps.update(o);
+// }
+// {
+// EquationDAO ps = IsisFishDAOHelper.getEquationDAO(context);
+// Equation o = ps.create();
+// o = ps.update(o);
+// }
+ {
+ GearDAO ps = IsisFishDAOHelper.getGearDAO(context);
+ Gear o = ps.create();
+ o = ps.update(o);
+ }
+// {
+// ImmigrationDAO ps = IsisFishDAOHelper.getImmigrationDAO(context);
+// Immigration o = ps.create();
+// o = ps.update(o);
+// }
+// {
+// LengthGroupDAO ps = IsisFishDAOHelper.getLengthGroupDAO(context);
+// LengthGroup o = ps.create();
+// o = ps.update(o);
+// }
+// {
+// MappingZoneReproZoneRecruDAO ps = IsisFishDAOHelper.getMappingZoneReproZoneRecruDAO(context);
+// MappingZoneReproZoneRecru o = ps.create();
+// o = ps.update(o);
+// }
+ {
+ CellDAO ps = IsisFishDAOHelper.getCellDAO(context);
+ Cell o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ SpeciesDAO ps = IsisFishDAOHelper.getSpeciesDAO(context);
+ Species o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ MetierDAO ps = IsisFishDAOHelper.getMetierDAO(context);
+ Metier o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ MetierSeasonInfoDAO ps = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
+ MetierSeasonInfo o = ps.create();
+ o = ps.update(o);
+ }
+// {
+// MigrationDAO ps = IsisFishDAOHelper.getMigrationDAO(context);
+// Migration o = ps.create();
+// o = ps.update(o);
+// }
+ {
+// try{
+ PopulationGroupDAO ps = IsisFishDAOHelper.getPopulationGroupDAO(context);
+ PopulationGroup o = ps.create();
+ o = ps.update(o);
+// assertTrue(false); // normalement on a pas le droit d'instancier une entity abstraite
+// }catch(TopiaException eee){
+// assertTrue(true);
+// }
+ }
+ {
+ PopulationDAO ps = IsisFishDAOHelper.getPopulationDAO(context);
+ Population o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ PortDAO ps = IsisFishDAOHelper.getPortDAO(context);
+ Port o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ ResultDAO ps = IsisFishDAOHelper.getResultDAO(context);
+ Result o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ PopulationSeasonInfoDAO ps = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
+ PopulationSeasonInfo o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ SelectivityDAO ps = IsisFishDAOHelper.getSelectivityDAO(context);
+ Selectivity o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ SetOfVesselsDAO ps = IsisFishDAOHelper.getSetOfVesselsDAO(context);
+ SetOfVessels o = ps.create();
+ o = ps.update(o);
+ }
+// {
+// SimpleZoneDAO ps = IsisFishDAOHelper.getSimpleZoneDAO(context);
+// SimpleZone o = ps.create();
+// o = ps.update(o);
+// }
+ {
+ StrategyMonthInfoDAO ps = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
+ StrategyMonthInfo o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ StrategyDAO ps = IsisFishDAOHelper.getStrategyDAO(context);
+ Strategy o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ TargetSpeciesDAO ps = IsisFishDAOHelper.getTargetSpeciesDAO(context);
+ TargetSpecies o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ TripTypeDAO ps = IsisFishDAOHelper.getTripTypeDAO(context);
+ TripType o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ VesselTypeDAO ps = IsisFishDAOHelper.getVesselTypeDAO(context);
+ VesselType o = ps.create();
+ o = ps.update(o);
+ }
+ {
+ ZoneDAO ps = IsisFishDAOHelper.getZoneDAO(context);
+ Zone o = ps.create();
+ o = ps.update(o);
+ }
+ context.rollbackTransaction();
+ }
+
+ @Test
+ public void testFindAll() throws Exception {
+ TopiaContext context = this.context.beginTransaction();
+// {
+// AgeGroupDAO ps = IsisFishDAOHelper.getAgeGroupDAO(context);
+// Collection<AgeGroup> list = ps.findAll();
+// log.debug(list + " - " +ps.getClass().getName());
+// }
+ {
+ FisheryRegionDAO ps = IsisFishDAOHelper.getFisheryRegionDAO(context);
+ Collection<FisheryRegion> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+// {
+// CompositeZoneDAO ps = IsisFishDAOHelper.getCompositeZoneDAO(context);
+// Collection list<CompositeZone> = ps.findAll();
+// }
+ {
+ EffortDescriptionDAO ps = IsisFishDAOHelper.getEffortDescriptionDAO(context);
+ Collection<EffortDescription> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+// {
+// EmigrationDAO ps = IsisFishDAOHelper.getEmigrationDAO(context);
+// Collection<Emigration> list = ps.findAll();
+// log.debug(list + " - " +ps.getClass().getName());
+// }
+ {
+ GearDAO ps = IsisFishDAOHelper.getGearDAO(context);
+ Collection<Gear> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+// {
+// ImmigrationDAO ps = IsisFishDAOHelper.getImmigrationDAO(context);
+// Collection<Immigration> list = ps.findAll();
+// log.debug(list + " - " +ps.getClass().getName());
+// }
+// {
+// LengthGroupDAO ps = IsisFishDAOHelper.getLengthGroupDAO(context);
+// Collection<LengthGroup> list = ps.findAll();
+// log.debug(list + " - " +ps.getClass().getName());
+// }
+// {
+// MappingZoneReproZoneRecruDAO ps = IsisFishDAOHelper.getMappingZoneReproZoneRecruDAO(context);
+// Collection<MappingZoneReproZoneRecru> list = ps.findAll();
+// log.debug(list + " - " +ps.getClass().getName());
+// }
+ {
+ CellDAO ps = IsisFishDAOHelper.getCellDAO(context);
+ Collection<Cell> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ SpeciesDAO ps = IsisFishDAOHelper.getSpeciesDAO(context);
+ Collection<Species> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ MetierDAO ps = IsisFishDAOHelper.getMetierDAO(context);
+ Collection<Metier> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ MetierSeasonInfoDAO ps = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
+ Collection<MetierSeasonInfo> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+// {
+// MigrationDAO ps = IsisFishDAOHelper.getMigrationDAO(context);
+// Collection<Migration> list = ps.findAll();
+// log.debug(list + " - " +ps.getClass().getName());
+// }
+ {
+ PopulationGroupDAO ps = IsisFishDAOHelper.getPopulationGroupDAO(context);
+ Collection<PopulationGroup> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ PopulationDAO ps = IsisFishDAOHelper.getPopulationDAO(context);
+ Collection<Population> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ PortDAO ps = IsisFishDAOHelper.getPortDAO(context);
+ Collection<Port> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ ResultDAO ps = IsisFishDAOHelper.getResultDAO(context);
+ Collection<Result> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ PopulationSeasonInfoDAO ps = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
+ Collection<PopulationSeasonInfo> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ SelectivityDAO ps = IsisFishDAOHelper.getSelectivityDAO(context);
+ Collection<Selectivity> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ SetOfVesselsDAO ps = IsisFishDAOHelper.getSetOfVesselsDAO(context);
+ Collection<SetOfVessels> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+// {
+// SimpleZoneDAO ps = IsisFishDAOHelper.getSimpleZoneDAO(context);
+// Collection<SimpleZone> list = ps.findAll();
+// }
+ {
+ StrategyMonthInfoDAO ps = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
+ Collection<StrategyMonthInfo> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ StrategyDAO ps = IsisFishDAOHelper.getStrategyDAO(context);
+ Collection<Strategy> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ TargetSpeciesDAO ps = IsisFishDAOHelper.getTargetSpeciesDAO(context);
+ Collection<TargetSpecies> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ TripTypeDAO ps = IsisFishDAOHelper.getTripTypeDAO(context);
+ Collection<TripType> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ VesselTypeDAO ps = IsisFishDAOHelper.getVesselTypeDAO(context);
+ Collection<VesselType> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ {
+ ZoneDAO ps = IsisFishDAOHelper.getZoneDAO(context);
+ Collection<Zone> list = ps.findAll();
+ log.debug(list + " - " +ps.getClass().getName());
+ }
+ context.rollbackTransaction();
+ }
+/*
+ public void testDelete() throws Exception {
+ TopiaContext context = this.context.beginTransaction();
+ {
+ AgeGroupDAO ps = IsisFishDAOHelper.getAgeGroupDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ AgeGroup o = (AgeGroup)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ RegionDAO ps = IsisFishDAOHelper.getRegionDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Region o = (Region)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ CompositeZoneDAO ps = IsisFishDAOHelper.getCompositeZoneDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ CompositeZone o = (CompositeZone)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ EffortDescriptionDAO ps = IsisFishDAOHelper.getEffortDescriptionDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ EffortDescription o = (EffortDescription)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ EmigrationDAO ps = IsisFishDAOHelper.getEmigrationDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Emigration o = (Emigration)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ EquationDAO ps = IsisFishDAOHelper.getEquationDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Equation o = (Equation)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ GearDAO ps = IsisFishDAOHelper.getGearDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Gear o = (Gear)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ ImmigrationDAO ps = IsisFishDAOHelper.getImmigrationDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Immigration o = (Immigration)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ LengthGroupDAO ps = IsisFishDAOHelper.getLengthGroupDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ LengthGroup o = (LengthGroup)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ MappingZoneReproZoneRecruDAO ps = IsisFishDAOHelper.getMappingZoneReproZoneRecruDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ MappingZoneReproZoneRecru o = (MappingZoneReproZoneRecru)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ CellDAO ps = IsisFishDAOHelper.getCellDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Cell o = (Cell)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ SpeciesDAO ps = IsisFishDAOHelper.getSpeciesDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Species o = (Species)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ MetierDAO ps = IsisFishDAOHelper.getMetierDAO(context);
+ Metier o = ps.create();
+ }
+ {
+ MetierSeasonInfoDAO ps = IsisFishDAOHelper.getMetierSeasonInfoDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ MetierSeasonInfo o = (MetierSeasonInfo)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ MigrationDAO ps = IsisFishDAOHelper.getMigrationDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Migration o = (Migration)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ MonthDAO ps = IsisFishDAOHelper.getMonthDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Month o = (Month)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ PopulationGroupDAO ps = IsisFishDAOHelper.getPopulationGroupDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ PopulationGroup o = (PopulationGroup)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ PopulationDAO ps = IsisFishDAOHelper.getPopulationDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Population o = (Population)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ PortDAO ps = IsisFishDAOHelper.getPortDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Port o = (Port)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ ResultManagerDAO ps = IsisFishDAOHelper.getResultManagerDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ ResultStorage o = (ResultStorage)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ SeasonDAO ps = IsisFishDAOHelper.getSeasonDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Season o = (Season)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ PopulationSeasonInfoDAO ps = IsisFishDAOHelper.getPopulationSeasonInfoDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ PopulationSeasonInfo o = (PopulationSeasonInfo)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ SelectivityDAO ps = IsisFishDAOHelper.getSelectivityDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Selectivity o = (Selectivity)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ SetOfVesselsDAO ps = IsisFishDAOHelper.getSetOfVesselsDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ SetOfVessels o = (SetOfVessels)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ SimpleZoneDAO ps = IsisFishDAOHelper.getSimpleZoneDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ SimpleZone o = (SimpleZone)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ StrategyMonthInfoDAO ps = IsisFishDAOHelper.getStrategyMonthInfoDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ StrategyMonthInfo o = (StrategyMonthInfo)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ StrategyDAO ps = IsisFishDAOHelper.getStrategyDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Strategy o = (Strategy)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ TargetSpeciesDAO ps = IsisFishDAOHelper.getTargetSpeciesDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ TargetSpecies o = (TargetSpecies)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ TimeUnitDAO ps = IsisFishDAOHelper.getTimeUnitDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ TimeUnit o = (TimeUnit)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ TripTypeDAO ps = IsisFishDAOHelper.getTripTypeDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ TripType o = (TripType)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ VesselTypeDAO ps = IsisFishDAOHelper.getVesselTypeDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ VesselType o = (VesselType)i.next();
+ ps.delete(o);
+ }
+ }
+ {
+ ZoneDAO ps = IsisFishDAOHelper.getZoneDAO(context);
+ Collection list = ps.findAll();
+ for(Iterator i=list.iterator(); i.hasNext();){
+ Zone o = (Zone)i.next();
+ ps.delete(o);
+ }
+ }
+ context.rollbackTransaction();
+ }
+ */
+} // Persistence
+
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PopulationSeasonInfoTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PopulationSeasonInfoTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/entity/PopulationSeasonInfoTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -39,6 +39,8 @@
import org.codelutin.math.matrix.gui.MatrixPanelEditor;
import org.junit.Test;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
+
/**
* PopulationSeasonInfoTest.
*
@@ -50,14 +52,15 @@
* Last update: $Date$
* by : $Author$
*/
-public class PopulationSeasonInfoTest{
-
+public class PopulationSeasonInfoTest extends AbstractIsisFishTest {
+
/** Logger for this class */
- private static final Log log = LogFactory.getLog(PopulationSeasonInfoTest.class);
-
+ private static final Log log = LogFactory
+ .getLog(PopulationSeasonInfoTest.class);
+
@Test
public void testToString() {
- String [] s = new String[]{"toto", "titi", "tutu"};
+ String[] s = new String[] { "toto", "titi", "tutu" };
System.out.println(Arrays.toString(s));
}
@@ -73,28 +76,27 @@
List<String> sem = new ArrayList<String>();
- for (int i=0; i<nbrAge; i++) {
- for (int j=0; j<nbrZone; j++) {
+ for (int i = 0; i < nbrAge; i++) {
+ for (int j = 0; j < nbrZone; j++) {
sem.add("g" + i + "/z" + j);
}
}
- MatrixND mat = MatrixFactory.getInstance().create(new List[]{sem, sem});
- for(MatrixIterator mi=mat.iterator(); mi.next();){
- int [] dim = mi.getCoordinates();
+ MatrixND mat = MatrixFactory.getInstance().create(
+ new List[] { sem, sem });
+ for (MatrixIterator mi = mat.iterator(); mi.next();) {
+ int[] dim = mi.getCoordinates();
int i = dim[0];
int j = dim[1];
- if(
- // un element de la diagonale dans le block choisi
- (i+nbrZone == j)
- || // calcul pour savoir s'il y a le groupe plus
+ if (
+ // un element de la diagonale dans le block choisi
+ (i + nbrZone == j) || // calcul pour savoir s'il y a le groupe plus
(groupplus
// regarde si on est bien dans le dernier block
- && (nbrAge-1 == i/nbrZone)
+ && (nbrAge - 1 == i / nbrZone)
// regarde si on est bien sur la diagonal
- && (i == j))
- ){
+ && (i == j))) {
mi.setValue(1);
}
}
@@ -106,12 +108,14 @@
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
-
- JOptionPane.showMessageDialog(dialog, panel,_("Spacialized visualisation"), JOptionPane.INFORMATION_MESSAGE);
-
+
+ JOptionPane.showMessageDialog(dialog, panel,
+ _("Spacialized visualisation"),
+ JOptionPane.INFORMATION_MESSAGE);
+
}
});
-
+
Thread t = new Thread(new Runnable() {
public void run() {
try {
@@ -123,12 +127,12 @@
}
});
t.start();
-
+
// it would really be nice to wait the thread, otherwise the test
// means nothing!!!
t.join();
} catch (HeadlessException he) {
- if(log.isErrorEnabled()) {
+ if (log.isErrorEnabled()) {
log.error("No X11 display available", he);
}
}
@@ -142,31 +146,34 @@
@Test
public void testSpacializeLengthChangeMatrix() throws InterruptedException {
-
int nbsecteurs = 2;
int nbclasses = 3;
- MatrixND mat = MatrixFactory.getInstance().create(new int[]{nbclasses, nbclasses});
- int i=1;
- for (MatrixIterator mi=mat.iterator(); mi.next();) {
+ MatrixND mat = MatrixFactory.getInstance().create(
+ new int[] { nbclasses, nbclasses });
+ int i = 1;
+ for (MatrixIterator mi = mat.iterator(); mi.next();) {
mi.setValue(i++);
}
List<String> sem = new ArrayList<String>();
- for (i=0; i<nbclasses; i++) {
- for (int j=0; j<nbsecteurs; j++) {
+ for (i = 0; i < nbclasses; i++) {
+ for (int j = 0; j < nbsecteurs; j++) {
sem.add("g" + i + "/z" + j);
}
}
- MatrixND bigmat = MatrixFactory.getInstance().create(new List[]{sem, sem});
+ MatrixND bigmat = MatrixFactory.getInstance().create(
+ new List[] { sem, sem });
- for(i=0; i<nbclasses; i++){
- for(int j=0; j<nbclasses; j++){
- MatrixND matId = MatrixFactory.getInstance().matrixId(nbsecteurs);
- matId.mults(mat.getValue(i,j));
- bigmat.paste(new int[]{i*nbsecteurs, j*nbsecteurs}, matId);
+ for (i = 0; i < nbclasses; i++) {
+ for (int j = 0; j < nbclasses; j++) {
+ MatrixND matId = MatrixFactory.getInstance().matrixId(
+ nbsecteurs);
+ matId.mults(mat.getValue(i, j));
+ bigmat.paste(new int[] { i * nbsecteurs, j * nbsecteurs },
+ matId);
}
}
@@ -184,12 +191,14 @@
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
-
- JOptionPane.showMessageDialog(dialog, box, _("Spacialized visualisation"), JOptionPane.INFORMATION_MESSAGE);
-
+
+ JOptionPane.showMessageDialog(dialog, box,
+ _("Spacialized visualisation"),
+ JOptionPane.INFORMATION_MESSAGE);
+
}
});
-
+
Thread t = new Thread(new Runnable() {
public void run() {
try {
@@ -201,12 +210,12 @@
}
});
t.start();
-
+
// it would really be nice to wait the thread, otherwise the test
// means nothing!!!
t.join();
} catch (HeadlessException he) {
- if(log.isErrorEnabled()) {
+ if (log.isErrorEnabled()) {
log.error("No X11 display available", he);
}
}
Copied: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/LoggerHelper.java (from rev 2214, isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/TestUtil.java)
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/LoggerHelper.java (rev 0)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/LoggerHelper.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -0,0 +1,413 @@
+/* *##%
+ * 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.logging;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.StringUtil;
+
+/**
+ * Usefull methods for tests.
+ *
+ * @author chemit
+ */
+public abstract class LoggerHelper {
+
+ public static String filename;
+ public static long MEGA_STREAM_SIZE = 6 * 100000;
+ private static long totalPause;
+
+ protected static final Log log = LogFactory.getLog(LoggerHelper.class);
+
+ public static void createMock(File testDir, String filename, int i) throws IOException, InterruptedException {
+ LoggerHelper.MEGA_STREAM_SIZE = 6 * i;
+ LoggerHelper.filename = new File(testDir, filename).getAbsolutePath();
+ File file = new File(testDir, filename);
+ long t0 = System.nanoTime();
+ mockLogFile();
+ long t1;
+
+ t1 = System.nanoTime();
+ log.info("create [" + LoggerHelper.MEGA_STREAM_SIZE + "] in " + StringUtil.convertTime(t1 - t0) + " [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "]");
+ System.gc();
+ }
+
+ static void pause(long time) throws InterruptedException {
+ Thread.sleep(time);
+ totalPause += time;
+ System.gc();
+ }
+
+ /**
+ * create a mock of logEvents
+ *
+ * @throws java.io.IOException todo
+ * @throws InterruptedException todo
+ */
+ public static void mockLogFile() throws IOException, InterruptedException {
+ File f = new File(filename);
+ if (f.exists()) {
+ f.delete();
+ }
+ BufferedWriter s = new BufferedWriter(new FileWriter(f));
+ int MAX_0 = (int) (MEGA_STREAM_SIZE / 6);
+ int i = 0;
+ long t0, t00;
+ long t1;
+ totalPause = 0;
+ t00 = System.currentTimeMillis();
+ t0 = System.currentTimeMillis();
+ try {
+
+ for (i = 0; i < MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.FATAL, 0, i + "debug ", "ioreiovrio veuio vreupo xz xe opiu tep uxr u ", "xeoiujoiz xpo puoi rui hp", i, new String[0]);
+ s.write(record.toString() + '\n');
+ s.flush();
+ }
+
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+
+ for (i = MAX_0; i < 2 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.WARN, 0, i + " warn", "jkljfdjkl fdkjlkj lkjdlkfjl dfkljl dflkfdj lfdjlk fjdlkj fdl", "vmfof o rieipk?prj,anklvndfkljn gmlrtsoijrmoig", i, new String[0]);
+ s.write(record.toString() + '\n');
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 2 * MAX_0; i < 3 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.INFO, 0, i + " info", "grlgjlrmgr jglerj mgrjm gre pjkogremoiqp jgpo rejopigjrej,m", "grkgherjfezoprjgbpdofajhlbnb;k nfkfjgmjmsg", i, new String[0]);
+ s.write(record.toString() + '\n');
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 3 * MAX_0; i < 4 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.DEBUG, 0, i + " debug", "grmgjueroijiorehjnjodj j gn mbr,nhltrhjjdo jp joi jreio j", "gezoeteroiyerphehkzb,fgbd bcmsherkgheiusbcjkdvberb ", i, new String[0]);
+ s.write(record.toString() + '\n');
+ s.flush();
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 4 * MAX_0; i < 5 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " trace", "ffgkdhvlsdknjk eriopgejo ipjiropj i io poi opijgr pe jupoieruj ga geigerihpi oeop erp ", "griofeioteogbbekjbnrjemk prejrlmekhgrehivbn rekhgrhi ", i, new String[0]);
+ s.write(record.toString() + '\n');
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 5 * MAX_0; i < 6 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " user", "grekgrhze t e re klgre ge rgre gre gfer g rjyukj yujty reez ze fz", "gekfhezh zhrze hgerhglkrej ljbvkxdfn df,ekgrrnvkmn", i, new String[0]);
+ s.write(record.toString() + '\n');
+ s.flush();
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ } catch (OutOfMemoryError e) {
+ t1 = System.currentTimeMillis();
+ log.info("failed after | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ e.printStackTrace();
+ } finally {
+ if (s != null) {
+ s.flush();
+ s.close();
+ }
+ }
+ }
+
+ /**
+ * create a mock of logEvents
+ *
+ * @throws java.io.IOException todo
+ * @throws InterruptedException todo
+ */
+ public static void mockLogFile2() throws IOException, InterruptedException {
+ File f = new File(filename);
+ if (f.exists()) {
+ f.delete();
+ }
+ BufferedWriter s = new BufferedWriter(new FileWriter(f));
+ int MAX_0 = (int) (MEGA_STREAM_SIZE / 6);
+ int i = 0;
+ long t0, t00;
+ long t1;
+ totalPause = 0;
+ t00 = System.currentTimeMillis();
+ t0 = System.currentTimeMillis();
+ try {
+
+ for (i = 0; i < MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.FATAL, 0, i + "debug ", "ioreiovrio veuio vreupo xz xe opiu tep uxr u ", "xeoiujoiz xpo puoi rui hp", i, new String[0]);
+ s.write(record.toString() + '\n');
+ s.flush();
+ }
+
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+
+ for (i = MAX_0; i < 2 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.WARN, 0, i + " warn", "jkljfdjkl fdkjlkj lkjdlkfjl dfkljl dflkfdj lfdjlk fjdlkj fdl", "vmfof o rieipk?prj,ùnklvndfkljn gmlrtsoîjrmoig", i, new String[0]);
+ s.write(record.toString() + '\n');
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 2 * MAX_0; i < 3 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.INFO, 0, i + " info", "grlgjlrmgr jglerj mgrjm gre pjkogremoiqp jgpo rejopigjrej,m", "grkgherjfezoprjgbpdofùjhlbnb;k nfkfjgmjmsg", i, new String[0]);
+ s.write(record.toString() + '\n');
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 3 * MAX_0; i < 4 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.DEBUG, 0, i + " debug", "grmgjueroijiorehjnjodj j gn mbr,nhltrhjjdo jp joi jreio j", "gezoeteroiyerphehkzb,fgbd bcmsherkgheiusbcjkdvberb ", i, new String[0]);
+ s.write(record.toString() + '\n');
+ s.flush();
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 4 * MAX_0; i < 5 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " trace", "ffgkdhvlsdknjk eriopgejo ipjiropj i io poi opijgr pe jupoieruj g'^ geigerihpi oeop erp ", "griofeioteogbbekjbnrjemk çprejrlmekhgrehivbn rekhgrhi ", i, new String[0]);
+ s.write(record.toString() + '\n');
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ //pause(500);
+ t0 = System.currentTimeMillis();
+ for (i = 5 * MAX_0; i < 6 * MAX_0; i++) {
+ LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " user", "grekgrhze t e re klgre ge rgre gre gfer g rjyukj yujty reez ze fz", "gekfhezh zhrze hgerhglkrej ljbvkxdfn df,ekgrrnvkmn", i, new String[0]);
+ s.write(record.toString() + '\n');
+ s.flush();
+ }
+ t1 = System.currentTimeMillis();
+ log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ } catch (OutOfMemoryError e) {
+ t1 = System.currentTimeMillis();
+ log.info("failed after | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
+ e.printStackTrace();
+ } finally {
+ if (s != null) {
+ s.flush();
+ s.close();
+ }
+ }
+ }
+
+ /**
+ * This is a log record (says an entry of a log file). This is abstracted from any
+ * logging implementation.
+ * <p/>
+ * To deal with log, we don't use string version stored in original log file,
+ * prefer use serialized form of a LogRecord : we keep a lot of time when using
+ * them to display them in ui, and for filtering process too.
+ * <p/>
+ * The LogRecord unicity is base on two properties :
+ * <ul>
+ * <li>timestamp</li>
+ * <li>message</li>
+ * </ul>
+ * <p/>
+ * We can not use only timestamp, more than one event could appear in a same
+ * timestamp.
+ * <p/>
+ * TODO Put this code in lutinLog ?
+ *
+ * @author chemit
+ */
+ public static class LogRecord implements java.io.Serializable {
+
+ /** the time of the event */
+ protected long timeStamp;
+
+ /** the msg for the event */
+ protected String message;
+
+ /** the severity of the event */
+ protected int level;
+
+ /** the throwable details the event */
+ protected String[] throwableStrRep;
+
+ /** origin filename of the event */
+ //protected transient String filename;
+
+ /** origin method name of the event */
+ //protected transient String methodName;
+
+ /** origin line number of the event */
+ //protected transient int lineNumber;
+
+ /**
+ * the string represention of logEvent, transient since we use a lazy getter
+ * we don't need to store it.
+ * <p/>
+ * <b>(if not transient : double the size of serialized form...)</b>
+ */
+ protected transient String text;
+
+ /**
+ * the offset of logRecord in stream.
+ * <p/>
+ * This is a transient property, since we compute this value when getting
+ * the LogRecord from stream
+ */
+ protected transient long offset;
+
+ private static final long serialVersionUID = 1335077740059488080L;
+
+ public static LogRecord newInstance(LogLevel level,
+ long timestamp,
+ String message,
+ String fileName,
+ String methodName,
+ int lineNumber,
+ String[] errors) throws UnsupportedEncodingException {
+ return new LogRecord(
+ level == null ? LogLevel.DEBUG.ordinal() : level.ordinal(),
+ timestamp,
+ message,
+ fileName,
+ methodName,
+ lineNumber,
+ errors
+ );
+ }
+
+ protected LogRecord(int level,
+ long timestamp,
+ String message,
+ String filename,
+ String methodName,
+ int lineNumber,
+ String[] throwableStrRep) throws UnsupportedEncodingException {
+ this.level = level;
+ this.timeStamp = timestamp;
+ //this.message = message;
+ this.message = new String((filename + ":" + lineNumber + " - " + methodName + " - " + message).getBytes("utf-8"));
+ //this.filename = filename;
+ //this.methodName = methodName;
+ //this.lineNumber = lineNumber;
+ this.throwableStrRep = throwableStrRep;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public String[] getThrowableStrRep() {
+ return throwableStrRep;
+ }
+
+ public long getTimeStamp() {
+ return timeStamp;
+ }
+
+ public int getLineNumber() {
+ return 0;
+ //return lineNumber;
+ }
+
+ public String getMethodName() {
+ return "";
+ //return methodName;
+ }
+
+ public long getOffset() {
+ return offset;
+ }
+
+ public void setOffset(long offset) {
+ this.offset = offset;
+ }
+
+ /**
+ * We use a cache for the representation since we will use a lots of time.
+ *
+ * @return the String representation used to display logEvent in ui.
+ */
+ @Override
+ public String toString() {
+ if (text == null) {
+ text = new StringBuilder(LogLevel.getLogLevel(level).toString()).
+ append(' ').append(message).toString();
+ }
+ /*if (text == null) {
+ text = new StringBuilder().append(LogLevel.getSimulLogLevel(level)).
+ append(' ').append(filename).append(':').
+ append(lineNumber).append(" - ").
+ append(methodName).append(" - ").append(message).toString();
+ }*/
+ return text;
+ }
+
+ /**
+ * We base the identiy of a LogEvent on the message, level and timestamp
+ *
+ * @param o object to compare
+ * @return <code>true</code> if same object
+ */
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ LogRecord event = (LogRecord) o;
+ return timeStamp == event.timeStamp &&
+ !(message != null ? !message.equals(event.message) :
+ event.message != null);
+ }
+
+ @Override
+ public int hashCode() {
+ int result;
+ result = (int) (timeStamp ^ (timeStamp >>> 32));
+ result = 31 * result + (message != null ? message.hashCode() : 0);
+ return result;
+ }
+
+ }
+}
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -1,20 +1,39 @@
+/* *##%
+ * 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.logging;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
-import fr.ifremer.TestUtils;
import junit.framework.Assert;
-import junit.framework.TestCase;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.codelutin.util.FileUtil;
+import org.junit.Test;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
-public class SimulationLoggerUtilTest extends TestCase {
+public class SimulationLoggerUtilTest extends AbstractIsisFishTest {
static private final String category = "fr.ifremer.isisfish.logging";
@@ -22,10 +41,9 @@
static private Log log = LogFactory.getLog(category);
+ @Test
public void testSimulationLoggerInfo() throws Exception {
- TestUtil.IsisStart();
-
Log logInit = LogFactory.getLog(appenderId);
Log logInit2 = LogFactory.getLog(appenderId + ".hip");
@@ -44,7 +62,7 @@
Level hibernateLogLevel = hibernatelog.getLevel();
- String loggerFile = new File(TestUtils.getTargetdir(), SimulationLoggerUtilTest.class.getSimpleName() + "_" + System.nanoTime() + ".log").getAbsolutePath();
+ String loggerFile = new File(getTargetdir(), SimulationLoggerUtilTest.class.getSimpleName() + "_" + System.nanoTime() + ".log").getAbsolutePath();
System.out.println(">>>> loggerFile " + loggerFile);
// todo do a test for addSimulationAppender too!
@@ -58,7 +76,7 @@
);
// check hibernate level was not changed
- assertEquals(hibernateLogLevel, Logger.getLogger("org.hibernate").getLevel());
+ Assert.assertEquals(hibernateLogLevel, Logger.getLogger("org.hibernate").getLevel());
final Log logger = LogFactory.getLog(appenderId);
@@ -92,7 +110,7 @@
// it would really be nice to wait the thread, otherwise the test
// means nothing!!!
t.join();
- assertTrue(!t.isAlive());
+ Assert.assertTrue(!t.isAlive());
SimulationLoggerUtil.removeSimulationAppender(appenderId);
message = "appender was destoyed WE MUST NOT SEE this message in simulation log file!!!";
@@ -128,10 +146,9 @@
}
+ @Test
public void testSimulationLoggerDebug() throws Exception {
- TestUtil.IsisStart();
-
Log logInit = LogFactory.getLog(appenderId);
Log logInit2 = LogFactory.getLog(appenderId + ".hip");
@@ -162,7 +179,7 @@
);
// check hibernate level was not changed
- assertEquals(hibernateLogLevel, Logger.getLogger("org.hibernate").getLevel());
+ Assert.assertEquals(hibernateLogLevel, Logger.getLogger("org.hibernate").getLevel());
final Log logger = LogFactory.getLog(appenderId);
@@ -196,7 +213,7 @@
// it would really be nice to wait the thread, otherwise the test
// means nothing!!!
t.join();
- assertTrue(!t.isAlive());
+ Assert.assertTrue(!t.isAlive());
SimulationLoggerUtil.removeSimulationAppender(appenderId);
message = "appender was destoyed WE MUST NOT SEE this message in simulation log file!!!";
Deleted: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/TestUtil.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/TestUtil.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/TestUtil.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -1,408 +0,0 @@
-package fr.ifremer.isisfish.logging;
-
-import fr.ifremer.TestUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.log.LutinLogFactory;
-import org.codelutin.util.StringUtil;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-/**
- * Usefull methods for tests.
- *
- * @author chemit
- */
-
-public abstract class TestUtil {
-
- public static String filename;
- public static long MEGA_STREAM_SIZE = 6 * 100000;
- private static long totalPause;
-
- protected static final Log log = LogFactory.getLog(TestUtil.class);
-
- public static void createMock(File testDir, String filename, int i) throws IOException, InterruptedException {
- TestUtil.MEGA_STREAM_SIZE = 6 * i;
- TestUtil.filename = new File(testDir, filename).getAbsolutePath();
- File file = new File(testDir, filename);
- long t0 = System.nanoTime();
- mockLogFile();
- long t1;
-
- t1 = System.nanoTime();
- log.info("create [" + TestUtil.MEGA_STREAM_SIZE + "] in " + StringUtil.convertTime(t1 - t0) + " [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "]");
- System.gc();
- }
-
- static void pause(long time) throws InterruptedException {
- Thread.sleep(time);
- totalPause += time;
- System.gc();
- }
-
- /**
- * create a mock of logEvents
- *
- * @throws java.io.IOException todo
- * @throws InterruptedException todo
- */
- public static void mockLogFile() throws IOException, InterruptedException {
- File f = new File(filename);
- if (f.exists()) {
- f.delete();
- }
- BufferedWriter s = new BufferedWriter(new FileWriter(f));
- int MAX_0 = (int) (MEGA_STREAM_SIZE / 6);
- int i = 0;
- long t0, t00;
- long t1;
- totalPause = 0;
- t00 = System.currentTimeMillis();
- t0 = System.currentTimeMillis();
- try {
-
- for (i = 0; i < MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.FATAL, 0, i + "debug ", "ioreiovrio veuio vreupo xz xe opiu tep uxr u ", "xeoiujoiz xpo puoi rui hp", i, new String[0]);
- s.write(record.toString() + '\n');
- s.flush();
- }
-
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
-
- for (i = MAX_0; i < 2 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.WARN, 0, i + " warn", "jkljfdjkl fdkjlkj lkjdlkfjl dfkljl dflkfdj lfdjlk fjdlkj fdl", "vmfof o rieipk?prj,anklvndfkljn gmlrtsoijrmoig", i, new String[0]);
- s.write(record.toString() + '\n');
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 2 * MAX_0; i < 3 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.INFO, 0, i + " info", "grlgjlrmgr jglerj mgrjm gre pjkogremoiqp jgpo rejopigjrej,m", "grkgherjfezoprjgbpdofajhlbnb;k nfkfjgmjmsg", i, new String[0]);
- s.write(record.toString() + '\n');
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 3 * MAX_0; i < 4 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.DEBUG, 0, i + " debug", "grmgjueroijiorehjnjodj j gn mbr,nhltrhjjdo jp joi jreio j", "gezoeteroiyerphehkzb,fgbd bcmsherkgheiusbcjkdvberb ", i, new String[0]);
- s.write(record.toString() + '\n');
- s.flush();
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 4 * MAX_0; i < 5 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " trace", "ffgkdhvlsdknjk eriopgejo ipjiropj i io poi opijgr pe jupoieruj ga geigerihpi oeop erp ", "griofeioteogbbekjbnrjemk prejrlmekhgrehivbn rekhgrhi ", i, new String[0]);
- s.write(record.toString() + '\n');
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 5 * MAX_0; i < 6 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " user", "grekgrhze t e re klgre ge rgre gre gfer g rjyukj yujty reez ze fz", "gekfhezh zhrze hgerhglkrej ljbvkxdfn df,ekgrrnvkmn", i, new String[0]);
- s.write(record.toString() + '\n');
- s.flush();
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- } catch (OutOfMemoryError e) {
- t1 = System.currentTimeMillis();
- log.info("failed after | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- e.printStackTrace();
- } finally {
- if (s != null) {
- s.flush();
- s.close();
- }
- }
- }
-
- /**
- * create a mock of logEvents
- *
- * @throws java.io.IOException todo
- * @throws InterruptedException todo
- */
- public static void mockLogFile2() throws IOException, InterruptedException {
- File f = new File(filename);
- if (f.exists()) {
- f.delete();
- }
- BufferedWriter s = new BufferedWriter(new FileWriter(f));
- int MAX_0 = (int) (MEGA_STREAM_SIZE / 6);
- int i = 0;
- long t0, t00;
- long t1;
- totalPause = 0;
- t00 = System.currentTimeMillis();
- t0 = System.currentTimeMillis();
- try {
-
- for (i = 0; i < MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.FATAL, 0, i + "debug ", "ioreiovrio veuio vreupo xz xe opiu tep uxr u ", "xeoiujoiz xpo puoi rui hp", i, new String[0]);
- s.write(record.toString() + '\n');
- s.flush();
- }
-
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
-
- for (i = MAX_0; i < 2 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.WARN, 0, i + " warn", "jkljfdjkl fdkjlkj lkjdlkfjl dfkljl dflkfdj lfdjlk fjdlkj fdl", "vmfof o rieipk?prj,ùnklvndfkljn gmlrtsoîjrmoig", i, new String[0]);
- s.write(record.toString() + '\n');
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 2 * MAX_0; i < 3 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.INFO, 0, i + " info", "grlgjlrmgr jglerj mgrjm gre pjkogremoiqp jgpo rejopigjrej,m", "grkgherjfezoprjgbpdofùjhlbnb;k nfkfjgmjmsg", i, new String[0]);
- s.write(record.toString() + '\n');
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 3 * MAX_0; i < 4 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.DEBUG, 0, i + " debug", "grmgjueroijiorehjnjodj j gn mbr,nhltrhjjdo jp joi jreio j", "gezoeteroiyerphehkzb,fgbd bcmsherkgheiusbcjkdvberb ", i, new String[0]);
- s.write(record.toString() + '\n');
- s.flush();
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 4 * MAX_0; i < 5 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " trace", "ffgkdhvlsdknjk eriopgejo ipjiropj i io poi opijgr pe jupoieruj g'^ geigerihpi oeop erp ", "griofeioteogbbekjbnrjemk çprejrlmekhgrehivbn rekhgrhi ", i, new String[0]);
- s.write(record.toString() + '\n');
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- //pause(500);
- t0 = System.currentTimeMillis();
- for (i = 5 * MAX_0; i < 6 * MAX_0; i++) {
- LogRecord record = LogRecord.newInstance(LogLevel.TRACE, 0, i + " user", "grekgrhze t e re klgre ge rgre gre gfer g rjyukj yujty reez ze fz", "gekfhezh zhrze hgerhglkrej ljbvkxdfn df,ekgrrnvkmn", i, new String[0]);
- s.write(record.toString() + '\n');
- s.flush();
- }
- t1 = System.currentTimeMillis();
- log.debug("create next [" + MAX_0 + "] in " + StringUtil.convertTime(t1 - t0) + " | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- } catch (OutOfMemoryError e) {
- t1 = System.currentTimeMillis();
- log.info("failed after | total " + i + " in " + StringUtil.convertTime(t1 - totalPause - t00));
- e.printStackTrace();
- } finally {
- if (s != null) {
- s.flush();
- s.close();
- }
- }
- }
-
- public static void IsisStart() {
- System.setProperty("org.apache.commons.logging.LogFactory",
- LutinLogFactory.class.getName());
- try {
- TestUtils.init();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * This is a log record (says an entry of a log file). This is abstracted from any
- * logging implementation.
- * <p/>
- * To deal with log, we don't use string version stored in original log file,
- * prefer use serialized form of a LogRecord : we keep a lot of time when using
- * them to display them in ui, and for filtering process too.
- * <p/>
- * The LogRecord unicity is base on two properties :
- * <ul>
- * <li>timestamp</li>
- * <li>message</li>
- * </ul>
- * <p/>
- * We can not use only timestamp, more than one event could appear in a same
- * timestamp.
- * <p/>
- * TODO Put this code in lutinLog ?
- *
- * @author chemit
- */
- public static class LogRecord implements java.io.Serializable {
-
- /** the time of the event */
- protected long timeStamp;
-
- /** the msg for the event */
- protected String message;
-
- /** the severity of the event */
- protected int level;
-
- /** the throwable details the event */
- protected String[] throwableStrRep;
-
- /** origin filename of the event */
- //protected transient String filename;
-
- /** origin method name of the event */
- //protected transient String methodName;
-
- /** origin line number of the event */
- //protected transient int lineNumber;
-
- /**
- * the string represention of logEvent, transient since we use a lazy getter
- * we don't need to store it.
- * <p/>
- * <b>(if not transient : double the size of serialized form...)</b>
- */
- protected transient String text;
-
- /**
- * the offset of logRecord in stream.
- * <p/>
- * This is a transient property, since we compute this value when getting
- * the LogRecord from stream
- */
- protected transient long offset;
-
- private static final long serialVersionUID = 1335077740059488080L;
-
- public static LogRecord newInstance(LogLevel level,
- long timestamp,
- String message,
- String fileName,
- String methodName,
- int lineNumber,
- String[] errors) throws UnsupportedEncodingException {
- return new LogRecord(
- level == null ? LogLevel.DEBUG.ordinal() : level.ordinal(),
- timestamp,
- message,
- fileName,
- methodName,
- lineNumber,
- errors
- );
- }
-
- protected LogRecord(int level,
- long timestamp,
- String message,
- String filename,
- String methodName,
- int lineNumber,
- String[] throwableStrRep) throws UnsupportedEncodingException {
- this.level = level;
- this.timeStamp = timestamp;
- //this.message = message;
- this.message = new String((filename + ":" + lineNumber + " - " + methodName + " - " + message).getBytes("utf-8"));
- //this.filename = filename;
- //this.methodName = methodName;
- //this.lineNumber = lineNumber;
- this.throwableStrRep = throwableStrRep;
- }
-
- public String getMessage() {
- return message;
- }
-
- public int getLevel() {
- return level;
- }
-
- public String[] getThrowableStrRep() {
- return throwableStrRep;
- }
-
- public long getTimeStamp() {
- return timeStamp;
- }
-
- public int getLineNumber() {
- return 0;
- //return lineNumber;
- }
-
- public String getMethodName() {
- return "";
- //return methodName;
- }
-
- public long getOffset() {
- return offset;
- }
-
- public void setOffset(long offset) {
- this.offset = offset;
- }
-
- /**
- * We use a cache for the representation since we will use a lots of time.
- *
- * @return the String representation used to display logEvent in ui.
- */
- @Override
- public String toString() {
- if (text == null) {
- text = new StringBuilder(LogLevel.getLogLevel(level).toString()).
- append(' ').append(message).toString();
- }
- /*if (text == null) {
- text = new StringBuilder().append(LogLevel.getSimulLogLevel(level)).
- append(' ').append(filename).append(':').
- append(lineNumber).append(" - ").
- append(methodName).append(" - ").append(message).toString();
- }*/
- return text;
- }
-
- /**
- * We base the identiy of a LogEvent on the message, level and timestamp
- *
- * @param o object to compare
- * @return <code>true</code> if same object
- */
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- LogRecord event = (LogRecord) o;
- return timeStamp == event.timeStamp &&
- !(message != null ? !message.equals(event.message) :
- event.message != null);
- }
-
- @Override
- public int hashCode() {
- int result;
- result = (int) (timeStamp ^ (timeStamp >>> 32));
- result = 31 * result + (message != null ? message.hashCode() : 0);
- return result;
- }
-
- }
-}
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -1,15 +1,36 @@
+/* *##%
+ * 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.logging.io;
-import fr.ifremer.TestUtils;
-import fr.ifremer.isisfish.logging.TestUtil;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.util.StringUtil;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
+import fr.ifremer.isisfish.logging.LoggerHelper;
/**
* User: tony
@@ -17,11 +38,11 @@
* Time: 21:41:53
*/
-public class LineReaderTest extends TestCase {
+public class LineReaderTest extends AbstractIsisFishTest {
protected static final Log log = LogFactory.getLog(LineReaderTest.class);
- File testDir;
+ protected File testDir;
final static int[] sizes = new int[]{
10,
@@ -39,51 +60,49 @@
//2000000
};
- protected void setUp() throws Exception {
- super.setUp();
-
- testDir = new File(TestUtils.getTargetdir(), "bench_" + System.nanoTime());
+ @Before
+ public void setUp() throws Exception {
+ testDir = new File(getTargetdir(), "bench_" + System.nanoTime());
testDir.mkdirs();
System.out.println("benchdir " + testDir);
}
protected static void createMock(File testDir, int i) throws IOException, InterruptedException {
- TestUtil.MEGA_STREAM_SIZE = 6 * i;
- TestUtil.filename = new File(testDir, LineReaderTest.class.getSimpleName() + "_" + 6 * i + ".log").getAbsolutePath();
- File file = new File(testDir, TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = 6 * i;
+ LoggerHelper.filename = new File(testDir, LineReaderTest.class.getSimpleName() + "_" + 6 * i + ".log").getAbsolutePath();
+ File file = new File(testDir, LoggerHelper.filename);
long t0 = System.nanoTime();
- TestUtil.mockLogFile();
+ LoggerHelper.mockLogFile();
long t1;
t1 = System.nanoTime();
- log.info("create [" + TestUtil.MEGA_STREAM_SIZE + "] in " + StringUtil.convertTime(t1 - t0) + " [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "]");
+ log.info("create [" + LoggerHelper.MEGA_STREAM_SIZE + "] in " + StringUtil.convertTime(t1 - t0) + " [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "]");
System.gc();
}
+ public void testMakeMock() throws Exception {
- public void estMakeMock() throws Exception {
-
for (int size : sizes) {
createMock(testDir, size);
}
}
- public void estCreateOffsets() throws Exception {
+ public void testCreateOffsets() throws Exception {
for (int size : sizes) {
createOffset(size);
}
}
- public void estGetNbLines() throws Exception {
+ public void testGetNbLines() throws Exception {
for (int size : sizes) {
getNbLines(size);
}
}
- public void estScanAllLines() throws Exception {
+ public void testScanAllLines() throws Exception {
for (int size : sizes) {
scanAllLines(size * 6);
@@ -94,7 +113,7 @@
}
- public void estScanReverseAllLines() throws Exception {
+ public void testScanReverseAllLines() throws Exception {
for (int size : sizes) {
scanReverseAllLines(size * 6);
@@ -104,7 +123,7 @@
}
}
- public void estScanThenReverseAllLines() throws Exception {
+ public void testScanThenReverseAllLines() throws Exception {
for (int size : sizes) {
scanThenReverseAllLines(size * 6);
@@ -121,13 +140,13 @@
}
protected void scanAllLines(int size) throws IOException {
- TestUtil.MEGA_STREAM_SIZE = size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + TestUtil.MEGA_STREAM_SIZE + ".log";
- File file = new File(TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + LoggerHelper.MEGA_STREAM_SIZE + ".log";
+ File file = new File(LoggerHelper.filename);
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
t.open();
- assertEquals(TestUtil.MEGA_STREAM_SIZE, t.getNbLines());
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, t.getNbLines());
for (int i = 0; i < t.getNbLines(); i++) {
long offset = t.getOffsetReader().getOffset(i);
//assertEquals(i,offset);
@@ -148,13 +167,13 @@
}
protected void scanAllLines(int size, int length) throws IOException {
- TestUtil.MEGA_STREAM_SIZE = size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + TestUtil.MEGA_STREAM_SIZE + ".log";
- File file = new File(TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + LoggerHelper.MEGA_STREAM_SIZE + ".log";
+ File file = new File(LoggerHelper.filename);
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
t.open();
- assertEquals(TestUtil.MEGA_STREAM_SIZE, t.getNbLines());
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, t.getNbLines());
for (int i = 0; i < t.getNbLines(); i += length) {
long offset = t.getOffsetReader().getOffset(i);
//assertEquals(i,offset);
@@ -175,13 +194,13 @@
}
protected void scanReverseAllLines(int size) throws IOException {
- TestUtil.MEGA_STREAM_SIZE = size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + TestUtil.MEGA_STREAM_SIZE + ".log";
- File file = new File(TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + LoggerHelper.MEGA_STREAM_SIZE + ".log";
+ File file = new File(LoggerHelper.filename);
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
t.open();
- assertEquals(TestUtil.MEGA_STREAM_SIZE, t.getNbLines());
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, t.getNbLines());
for (int i = 0; i < t.getNbLines(); i += 10) {
long offset = t.getOffsetReader().getOffset(i);
//assertEquals(i,offset);
@@ -202,13 +221,13 @@
}
protected void scanReverseAllLines(int size, int length) throws IOException {
- TestUtil.MEGA_STREAM_SIZE = size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + TestUtil.MEGA_STREAM_SIZE + ".log";
- File file = new File(TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + LoggerHelper.MEGA_STREAM_SIZE + ".log";
+ File file = new File(LoggerHelper.filename);
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
t.open();
- assertEquals(TestUtil.MEGA_STREAM_SIZE, t.getNbLines());
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, t.getNbLines());
for (int i = 0; i < t.getNbLines(); i += length) {
long offset = t.getOffsetReader().getOffset(i);
//assertEquals(i,offset);
@@ -229,13 +248,13 @@
}
protected void scanThenReverseAllLines(int size) throws IOException {
- TestUtil.MEGA_STREAM_SIZE = size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + TestUtil.MEGA_STREAM_SIZE + ".log";
- File file = new File(TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + LoggerHelper.MEGA_STREAM_SIZE + ".log";
+ File file = new File(LoggerHelper.filename);
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
t.open();
- assertEquals(TestUtil.MEGA_STREAM_SIZE, t.getNbLines());
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, t.getNbLines());
for (int i = 0; i < t.getNbLines(); i += 10) {
long offset = t.getOffsetReader().getOffset(i);
//assertEquals(i,offset);
@@ -254,13 +273,13 @@
}
protected void scanThenReverseAllLines(int size, int length) throws IOException {
- TestUtil.MEGA_STREAM_SIZE = size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + TestUtil.MEGA_STREAM_SIZE + ".log";
- File file = new File(TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + LoggerHelper.MEGA_STREAM_SIZE + ".log";
+ File file = new File(LoggerHelper.filename);
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
t.open();
- assertEquals(TestUtil.MEGA_STREAM_SIZE, t.getNbLines());
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, t.getNbLines());
for (int i = 0; i < t.getNbLines(); i += length) {
long offset = t.getOffsetReader().getOffset(i);
//assertEquals(i,offset);
@@ -279,35 +298,35 @@
}
protected void getNbLines(int size) throws IOException, InterruptedException {
- TestUtil.MEGA_STREAM_SIZE = 6 * size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + 6 * size + ".log";
- File file = new File(TestUtil.filename);
+ LoggerHelper.MEGA_STREAM_SIZE = 6 * size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + 6 * size + ".log";
+ File file = new File(LoggerHelper.filename);
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
t.open();
long nbLines = t.getNbLines();
- assertEquals(TestUtil.MEGA_STREAM_SIZE, nbLines);
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, nbLines);
t.close();
long t1 = System.currentTimeMillis();
- log.info("(" + nbLines + ") [" + TestUtil.MEGA_STREAM_SIZE + "] in " + time(t0, t1) + " [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "]");
+ log.info("(" + nbLines + ") [" + LoggerHelper.MEGA_STREAM_SIZE + "] in " + time(t0, t1) + " [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "]");
}
protected void createOffset(int size) throws IOException, InterruptedException {
- TestUtil.MEGA_STREAM_SIZE = 6 * size;
- TestUtil.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + 6 * size + ".log";
- File file = new File(TestUtil.filename);
- File offsetfile = new File(TestUtil.filename + ".offsets");
+ LoggerHelper.MEGA_STREAM_SIZE = 6 * size;
+ LoggerHelper.filename = "bench/" + LineReaderTest.class.getSimpleName() + "_" + 6 * size + ".log";
+ File file = new File(LoggerHelper.filename);
+ File offsetfile = new File(LoggerHelper.filename + ".offsets");
if (offsetfile.exists()) {
if (!offsetfile.delete()) {
- fail("could not delete file " + offsetfile);
+ Assert.fail("could not delete file " + offsetfile);
}
}
long t0 = System.currentTimeMillis();
LineReader t = createReader(file, "offsets");
- assertEquals(TestUtil.MEGA_STREAM_SIZE, t.getNbLines());
+ Assert.assertEquals(LoggerHelper.MEGA_STREAM_SIZE, t.getNbLines());
t.close();
long t1 = System.currentTimeMillis();
- log.info("time (" + time(t0, t1) + ") [" + TestUtil.MEGA_STREAM_SIZE + "] [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "] [offsetfile: " + offsetfile + ", length: " + StringUtil.convertMemory(offsetfile.length()) + "]");
+ log.info("time (" + time(t0, t1) + ") [" + LoggerHelper.MEGA_STREAM_SIZE + "] [file: " + file + ", length: " + StringUtil.convertMemory(file.length()) + "] [offsetfile: " + offsetfile + ", length: " + StringUtil.convertMemory(offsetfile.length()) + "]");
}
public static String time(long t0, long t1) {
@@ -328,10 +347,11 @@
sb.append(secondes).append("s ");
}
sb.append(total).append("ms ");
- sb.append(" ~ ").append((float) (t1 - t0) / TestUtil.MEGA_STREAM_SIZE);
+ sb.append(" ~ ").append((float) (t1 - t0) / LoggerHelper.MEGA_STREAM_SIZE);
return sb.toString();
}
+ @Test
public void testSimple() throws Exception {
String filename = "bench/LineReaderTest_30.log";
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderUtilTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderUtilTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/logging/io/LineReaderUtilTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -1,14 +1,35 @@
+/* *##%
+ * 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.logging.io;
-import fr.ifremer.TestUtils;
-import fr.ifremer.isisfish.logging.LogLevel;
-import fr.ifremer.isisfish.logging.LogLevelUtil;
-import fr.ifremer.isisfish.logging.TestUtil;
-import junit.framework.TestCase;
+import java.io.File;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
-import java.io.File;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
+import fr.ifremer.isisfish.logging.LogLevel;
+import fr.ifremer.isisfish.logging.LogLevelUtil;
+import fr.ifremer.isisfish.logging.LoggerHelper;
/**
* Tests unitaires sur les implantations de LineReader
@@ -16,15 +37,15 @@
* @author chemit
*/
-public class LineReaderUtilTest extends TestCase {
+public class LineReaderUtilTest extends AbstractIsisFishTest {
protected static final Log log = LogFactory.getLog(LineReaderUtilTest.class);
- static File testDir;
+ protected static File testDir;
public static File getTestDir() {
if (testDir == null) {
- testDir = new File(TestUtils.getTargetdir(), "bench_" + System.nanoTime());
+ testDir = new File(getTargetdir(), "bench_" + System.nanoTime());
if (!testDir.mkdirs()) {
throw new IllegalStateException("could not create directory " + testDir);
}
@@ -49,19 +70,18 @@
};
File f;
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
System.out.println("benchdir " + getTestDir());
String filename = "LineReaderTest_30.log";
f = new File(testDir, filename);
if (!f.exists()) {
- TestUtil.createMock(testDir, filename, 5);
+ LoggerHelper.createMock(testDir, filename, 5);
}
}
-
+ @Test
public void testLevelReader() throws Exception {
long nbLines;
@@ -71,7 +91,7 @@
reader.getOffsetReader().deleteOffsetFile();
reader.open();
nbLines = reader.getNbLines();
- assertEquals(30, nbLines);
+ Assert.assertEquals(30, nbLines);
log.info("found " + nbLines + " in reader " + reader);
reader2 = new LineReaderUtil.LevelLineReader(reader, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + LogLevel.DEBUG.mask())), LogLevel.FATAL);
@@ -79,7 +99,7 @@
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(5, nbLines);
+ Assert.assertEquals(5, nbLines);
reader2.close();
reader2 = new LineReaderUtil.LevelLineReader(reader, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + LogLevel.DEBUG.mask())), LogLevel.DEBUG);
@@ -87,7 +107,7 @@
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(5, nbLines);
+ Assert.assertEquals(5, nbLines);
reader2.close();
reader2 = new LineReaderUtil.LevelLineReader(reader, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + LogLevel.INFO.mask())), LogLevel.INFO);
@@ -95,7 +115,7 @@
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(5, nbLines);
+ Assert.assertEquals(5, nbLines);
reader2.getOffsetReader().deleteOffsetFile();
reader2.close();
@@ -103,6 +123,7 @@
reader.close();
}
+ @Test
public void testLevelsReader() throws Exception {
LineReader reader, reader2, reader3;
@@ -113,7 +134,7 @@
reader.getOffsetReader().deleteOffsetFile();
reader.open();
nbLines = reader.getNbLines();
- assertEquals(30, nbLines);
+ Assert.assertEquals(30, nbLines);
log.info("found " + nbLines + " in reader " + reader);
levels = LogLevelUtil.createSet(LogLevel.DEBUG, LogLevel.INFO);
@@ -122,57 +143,57 @@
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(10, nbLines);
+ Assert.assertEquals(10, nbLines);
reader2.getOffsetReader().deleteOffsetFile();
reader2.close();
levels = LogLevelUtil.createSet(LogLevel.WARN, LogLevel.INFO);
reader2 = new LineReaderUtil.LevelsLineReader(reader, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + levels)), LogLevel.INFO, LogLevel.WARN);
reader2.getOffsetReader().deleteOffsetFile();
- assertTrue(reader2.getOffsetReader().needCreate());
+ Assert.assertTrue(reader2.getOffsetReader().needCreate());
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(10, nbLines);
+ Assert.assertEquals(10, nbLines);
levels = LogLevelUtil.createSet(LogLevel.INFO);
reader3 = new LineReaderUtil.LevelsLineReader(reader2, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + levels)), LogLevel.INFO);
reader3.getOffsetReader().deleteOffsetFile();
- assertTrue(reader3.getOffsetReader().needCreate());
+ Assert.assertTrue(reader3.getOffsetReader().needCreate());
reader3.open();
nbLines = reader3.getNbLines();
log.info("found " + nbLines + " in reader " + reader3);
- assertEquals(5, nbLines);
+ Assert.assertEquals(5, nbLines);
reader2.close();
reader3.close();
levels = LogLevelUtil.createSet(LogLevel.INFO, LogLevel.WARN);
reader2 = new LineReaderUtil.LevelsLineReader(reader, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + levels)), LogLevel.WARN, LogLevel.INFO);
- assertFalse(reader2.getOffsetReader().needCreate());
+ Assert.assertFalse(reader2.getOffsetReader().needCreate());
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(10, nbLines);
+ Assert.assertEquals(10, nbLines);
reader2.getOffsetReader().deleteOffsetFile();
reader2.close();
levels = LogLevelUtil.createSet(LogLevel.DEBUG);
reader2 = new LineReaderUtil.LevelsLineReader(reader, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + levels)), LogLevel.DEBUG);
- assertFalse(reader2.getOffsetReader().needCreate());
+ Assert.assertFalse(reader2.getOffsetReader().needCreate());
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(5, nbLines);
+ Assert.assertEquals(5, nbLines);
reader2.close();
levels = LogLevelUtil.createSet(LogLevel.DEBUG, LogLevel.DEBUG);
reader2 = new LineReaderUtil.LevelsLineReader(reader, new FileOffsetReader(new File(reader.getFile().getParentFile(), "leveloffsets_" + levels)), LogLevel.DEBUG, LogLevel.DEBUG);
- assertFalse(reader2.getOffsetReader().needCreate());
+ Assert.assertFalse(reader2.getOffsetReader().needCreate());
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(5, nbLines);
+ Assert.assertEquals(5, nbLines);
reader2.getOffsetReader().deleteOffsetFile();
reader2.close();
@@ -181,6 +202,7 @@
reader.close();
}
+ @Test
public void testPatternReader() throws Exception {
LineReader reader, reader2;
@@ -190,7 +212,7 @@
reader.getOffsetReader().deleteOffsetFile();
reader.open();
nbLines = reader.getNbLines();
- assertEquals(30, nbLines);
+ Assert.assertEquals(30, nbLines);
log.info("found " + nbLines + " in reader " + reader);
reader2 = new LineReaderUtil.PatternLineReader(reader, new MemoryOffsetReader(100), "DEBUG.*", 0);
@@ -198,7 +220,7 @@
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(5, nbLines);
+ Assert.assertEquals(5, nbLines);
reader2.close();
reader2 = new LineReaderUtil.PatternLineReader(reader, new MemoryOffsetReader(100), "ADEBUG.*", 0);
@@ -206,7 +228,7 @@
reader2.open();
nbLines = reader2.getNbLines();
log.info("found " + nbLines + " in reader " + reader2);
- assertEquals(0, nbLines);
+ Assert.assertEquals(0, nbLines);
reader2.close();
reader.getOffsetReader().deleteOffsetFile();
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/mexico/MexicoHelperTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -31,7 +31,7 @@
import org.codelutin.util.FileUtil;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
@@ -48,7 +48,7 @@
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $ by :
* $Author: tchemit $
*/
-public class MexicoHelperTest {
+public class MexicoHelperTest extends AbstractIsisFishTest {
/** Commons logging log. */
private static Log log = LogFactory.getLog(MexicoHelperTest.class);
@@ -67,9 +67,9 @@
matrix1.setValue(new int[] { 2, 1 }, -1);
// factor 1
- Factor<Double,Double> factorContinuous = new Factor<Double,Double>(
+ Factor<Double, Double> factorContinuous = new Factor<Double, Double>(
"factor 1 (double continuous)");
- ContinuousDomain<Double,Double> domain1 = new ContinuousDomain<Double,Double>();
+ ContinuousDomain<Double, Double> domain1 = new ContinuousDomain<Double, Double>();
domain1.setMinBound(0.0);
domain1.setMaxBound(50.0);
factorContinuous.setDomain(domain1);
@@ -77,8 +77,9 @@
.setPath("fr.ifremer.isisfish.entities.PopulationGroup#1156461521013#0.1715620681984218#maxLength");
// factor 2
- Factor<Double,Double> factorDiscrete = new Factor<Double,Double>("factor 2 (double discrete)");
- DiscreteDomain<Double,Double> domain2 = new DiscreteDomain<Double,Double>();
+ Factor<Double, Double> factorDiscrete = new Factor<Double, Double>(
+ "factor 2 (double discrete)");
+ DiscreteDomain<Double, Double> domain2 = new DiscreteDomain<Double, Double>();
domain2.getValues().put(0.0, 12.3);
domain2.getValues().put(1.0, 70.9);
domain2.getValues().put(2.0, 21.0);
@@ -90,8 +91,9 @@
factorDiscrete.setValue(3.0);
// factor 3
- Factor<Integer,Double> factorContinuous2 = new Factor<Integer,Double>("factor 3 (integer discrete)");
- DiscreteDomain<Integer,Double> domain3 = new DiscreteDomain<Integer,Double>();
+ Factor<Integer, Double> factorContinuous2 = new Factor<Integer, Double>(
+ "factor 3 (integer discrete)");
+ DiscreteDomain<Integer, Double> domain3 = new DiscreteDomain<Integer, Double>();
domain3.getValues().put(0.0, 13);
domain3.getValues().put(0.0, 14);
domain3.getValues().put(0.0, 15);
@@ -100,7 +102,7 @@
.setPath("fr.ifremer.isisfish.entities.PopulationGroup#1156461521076#0.6526656643346673#minLength");
// factor 4
- Factor<MatrixND,Double> factorMatrixContinuous = new Factor<MatrixND,Double>(
+ Factor<MatrixND, Double> factorMatrixContinuous = new Factor<MatrixND, Double>(
"factor 4 (MatrixContinuous)");
MatrixContinuousDomain domain4 = new MatrixContinuousDomain();
domain4.setCoefficient(0.1);
@@ -111,7 +113,7 @@
.setPath("fr.ifremer.isisfish.entities.PopulationGroup#1156461521076#0.6526656643346673#minLength");
// factor 5
- Factor<Double,Double> factorEquationContinuous = new Factor<Double,Double>(
+ Factor<Double, Double> factorEquationContinuous = new Factor<Double, Double>(
"factor 5 (EquationContinuous)");
EquationContinuousDomain domain5 = new EquationContinuousDomain();
domain5.setCoefficient(0.1);
@@ -144,13 +146,14 @@
// test xml export
String xml = MexicoHelper.getDesignPlanAsXML(testDesignPlan);
- Assert.assertTrue(xml.indexOf("<factor name=\"factor 2 (double discrete)\"") != -1);
+ Assert.assertTrue(xml
+ .indexOf("<factor name=\"factor 2 (double discrete)\"") != -1);
//Assert.assertTrue(xml.indexOf("<range min=\"12.0\" max=\"99.0\" />") != -1);
Assert.assertTrue(xml.indexOf("<value>70.9</value>") != -1);
if (log.isDebugEnabled()) {
xml = xml.replaceAll(">", ">\n");
- FileUtil.writeString(new File(TestUtils.getTargetdir(),
+ FileUtil.writeString(new File(getTargetdir(),
"mexicohelper_designplan.xml"), xml);
log.info("testGetDesignPlanAsXML xml = " + xml);
}
@@ -163,8 +166,9 @@
*/
@Test
public void testGetDesignPlanFromXML() throws IOException {
-
- File testFile = new File("src/test/resources/mexico/mexicohelper_designplan.xml");
+
+ File testFile = new File(
+ "src/test/resources/mexico/mexicohelper_designplan.xml");
// topia context can be null in tests
DesignPlan plan = MexicoHelper.getDesignPlanFromXML(testFile, null);
@@ -174,7 +178,7 @@
xml = xml.replaceAll(">", ">\n");
log.info("testGetDesignPlanFromXML xml = " + xml);
}
-
+
/**
* Test que l'export XML de l'import XML produise le meme xml.
*
@@ -187,14 +191,15 @@
DesignPlan testDesignPlan = getTestDesignPlan();
String xml1 = MexicoHelper.getDesignPlanAsXML(testDesignPlan);
log.debug("xml 1 = " + xml1);
-
+
// export
- File testFile = new File("src/test/resources/mexico/mexicohelper_designplan.xml");
+ File testFile = new File(
+ "src/test/resources/mexico/mexicohelper_designplan.xml");
// topia context can be null in tests
DesignPlan plan = MexicoHelper.getDesignPlanFromXML(testFile, null);
String xml2 = MexicoHelper.getDesignPlanAsXML(plan);
log.debug("xml 2 = " + xml2);
-
+
Assert.assertEquals(xml1, xml2);
}
}
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationHelperTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationHelperTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationHelperTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -27,12 +27,10 @@
import org.codelutin.math.matrix.DoubleBigVector;
import org.codelutin.math.matrix.MatrixFactory;
import org.codelutin.topia.TopiaContext;
-import org.junit.AfterClass;
import org.junit.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.datastore.ResultStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.entities.Result;
@@ -50,7 +48,7 @@
* Last update: $Date$
* by : $Author$
*/
-public class SimulationHelperTest {
+public class SimulationHelperTest extends AbstractIsisFishTest {
/** Commons logging log. */
private static Log log = LogFactory.getLog(SimulationHelperTest.class);
@@ -59,16 +57,6 @@
"src" + File.separator + "test" + File.separator + "resources" + File.separator + "simulations" + File.separator + "test-nonregression-20090203.zip",
// put here other zip simulation test
};
-
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- }
-
- @AfterClass
- public static void clean() {
- TestUtils.clean();
- }
// public void testVerifResult() throws Exception {
// try {
@@ -140,7 +128,7 @@
for (String zipName : SIMULATION_ZIP_FILE) {
// recuperation du fichier zip de la simulation de test
- File zip = new File(TestUtils.getBasedir(), zipName);
+ File zip = new File(getBasedir(), zipName);
// import de cette simulation
String name = "simulation-test-" + System.currentTimeMillis();
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -22,14 +22,12 @@
import junit.framework.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
/**
- * TODO COMMENT ME.
+ * Simulation parameter test class.
*
* @author chatellier
* @version $Revision: 1.0 $
@@ -37,14 +35,8 @@
* Last update : $Date: 19 mars 2009 $
* By : $Author: chatellier $
*/
- at Ignore
-public class SimulationParameterTest {
+public class SimulationParameterTest extends AbstractIsisFishTest {
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- }
-
/**
* Test to build one simulation parameters.
*
@@ -53,19 +45,18 @@
*/
@Test
public void testToPropertiesFromPropertties() {
-
+
SimulationParameter params = new SimulationParameter();
params.setIsisFishVersion("3.2.0.4");
params.setDescription("desc");
-
+
// make transform
Properties props = params.toProperties();
SimulationParameter params2 = new SimulationParameter();
params2.fromProperties(null, props);
-
+
Assert.assertEquals("3.2.0.4", params2.getIsisFishVersion());
Assert.assertEquals("desc", params2.getDescription());
}
-
-
+
}
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -36,10 +36,9 @@
import org.codelutin.topia.TopiaException;
import org.junit.After;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.StorageException;
@@ -70,31 +69,27 @@
* Last update : $Date: 24 févr. 2009 $
* By : $Author: chatellier $
*/
-public class SimulationPreScriptTest {
+public class SimulationPreScriptTest extends AbstractIsisFishTest {
- /** Commons logging log. */
+ /** log. */
private static Log log = LogFactory.getLog(SimulationPreScriptTest.class);
- //protected TopiaContext rootContext;
-
protected static Configuration freemarkerConfiguration;
-
- @BeforeClass
- public static void init() throws Exception {
- freemarkerConfiguration = TestUtils.getFreemarkerConfiguration();
- }
-
+
@Before
public void setUp() throws Exception {
// not do it in @BeforeClass
// test will fail !
- TestUtils.init();
- System.setProperty("hibernate.hbm2ddl.auto", "create");
+ init();
+ freemarkerConfiguration = getFreemarkerConfiguration();
+ // very important , other test wil fail with that
+ //System.setProperty("hibernate.hbm2ddl.auto", "create");
}
@After
public void tearDown() {
- System.setProperty("hibernate.hbm2ddl.auto", "");
+ // very important , other test wil fail with that
+ //System.clearProperty("hibernate.hbm2ddl.auto");
}
/**
@@ -165,6 +160,7 @@
context.setSimulationStorage(simulation);
// FIXME here is the error, getDb throw exception
//simulationPreScript.beforeSimulation(context);
+ SimulationContext.remove();
// try to find previous entity
vesselType = vesselTypeDAO.findByTopiaId(topiaId);
@@ -270,6 +266,7 @@
context.setSimulationStorage(simulation);
// FIXME here is the error, getDb throw exception
//simulationPreScript.beforeSimulation(context);
+ SimulationContext.remove();
// try to find previous entity
populationSeasonInfo = populationSeasonInfoDAO.findByTopiaId(topiaId);
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -28,7 +28,7 @@
import org.junit.Before;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationGroup;
import fr.ifremer.isisfish.entities.PopulationImpl;
@@ -51,7 +51,7 @@
*
* Last update : $Date: 24 févr. 2009 $ By : $Author: chatellier $
*/
-public class SimulationServiceTest {
+public class SimulationServiceTest extends AbstractIsisFishTest {
/** Commons logging log. */
private static Log log = LogFactory.getLog(SimulationServiceTest.class);
@@ -60,7 +60,7 @@
public void setUp() throws Exception {
// not do it in @BeforeClass
// test will fail !
- TestUtils.init();
+ AbstractIsisFishTest.init();
}
/**
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SshSimulatorLauncherTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -22,10 +22,9 @@
import junit.framework.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.IsisFish;
import freemarker.template.TemplateException;
@@ -39,13 +38,8 @@
* Last update : $Date: 22 janv. 2009 $
* By : $Author: chatellier $
*/
-public class SshSimulatorLauncherTest {
+public class SshSimulatorLauncherTest extends AbstractIsisFishTest {
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- }
-
/**
* Test l'instantiation du script qsub (caparmor).
*
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/FactorTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/FactorTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/FactorTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -25,7 +25,6 @@
import org.junit.Assert;
import org.junit.Test;
-import fr.ifremer.isisfish.entities.Equation;
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.EquationContinuousDomain;
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculatorRandomMock.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculatorRandomMock.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/sensitivity/SensitivityCalculatorRandomMock.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -24,7 +24,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixND;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.simulator.launcher.SimulationServiceTest;
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeModelTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeModelTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/sensitivity/FactorTreeModelTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -21,7 +21,6 @@
import static org.codelutin.i18n.I18n._;
import java.awt.HeadlessException;
-import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -38,6 +37,7 @@
import org.codelutin.math.matrix.MatrixND;
import org.junit.Test;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.domain.ContinuousDomain;
import fr.ifremer.isisfish.simulator.sensitivity.domain.DiscreteDomain;
@@ -53,8 +53,8 @@
* Last update: $Date: 2009-02-03 17:44:23 +0100 (mar 03 fév 2009) $
* by : $Author: chatellier $
*/
-public class FactorTreeModelTest{
-
+public class FactorTreeModelTest extends AbstractIsisFishTest {
+
/** Logger for this class */
private static final Log log = LogFactory.getLog(FactorTreeModelTest.class);
@@ -65,8 +65,9 @@
*/
protected List<Factor> getFactors() {
- Factor<Integer,Integer> factor1 = new Factor<Integer,Integer>("testint");
- ContinuousDomain<Integer,Integer> domain1 = new ContinuousDomain<Integer,Integer>();
+ Factor<Integer, Integer> factor1 = new Factor<Integer, Integer>(
+ "testint");
+ ContinuousDomain<Integer, Integer> domain1 = new ContinuousDomain<Integer, Integer>();
domain1.setMinBound(0);
domain1.setMaxBound(50);
factor1.setDomain(domain1);
@@ -94,14 +95,16 @@
matrix2.setValue(new int[] { 1, 2 }, -13000);
// factor
- Factor<MatrixND,String> factor2 = new Factor<MatrixND,String>("testmatrix");
- DiscreteDomain<MatrixND,String> domain2 = new DiscreteDomain<MatrixND,String>();
+ Factor<MatrixND, String> factor2 = new Factor<MatrixND, String>(
+ "testmatrix");
+ DiscreteDomain<MatrixND, String> domain2 = new DiscreteDomain<MatrixND, String>();
domain2.getValues().put("m1", matrix1);
domain2.getValues().put("m2", matrix2);
factor2.setDomain(domain2);
- factor2.setPath("org.codelutin.math.matrix.MatrixND#563456293453#2.456347646#dim");
+ factor2
+ .setPath("org.codelutin.math.matrix.MatrixND#563456293453#2.456347646#dim");
factor2.setValueForIdentifier("m2");
-
+
List<Factor> factors1 = new ArrayList<Factor>();
factors1.add(factor1);
factors1.add(factor2);
@@ -114,7 +117,7 @@
*/
@Test
public void testJTreeModel() throws InterruptedException {
-
+
TreeNode root = new DefaultMutableTreeNode(getFactors());
final JTree tree = new JTree(root);
tree.setRootVisible(true);
@@ -127,10 +130,12 @@
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
- JOptionPane.showMessageDialog(dialog, tree,_("Tree factor model"), JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showMessageDialog(dialog, tree,
+ _("Tree factor model"),
+ JOptionPane.INFORMATION_MESSAGE);
}
});
-
+
Thread t = new Thread(new Runnable() {
public void run() {
try {
@@ -142,12 +147,12 @@
}
});
t.start();
-
+
// it would really be nice to wait the thread, otherwise the test
// means nothing!!!
t.join();
} catch (HeadlessException he) {
- if(log.isErrorEnabled()) {
+ if (log.isErrorEnabled()) {
log.error("No X11 display available", he);
}
}
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/widget/filter/FilterDialogModelMock.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/widget/filter/FilterDialogModelMock.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/ui/widget/filter/FilterDialogModelMock.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -13,6 +13,8 @@
* A simple mock of filter to test Filter operations.
* <p/>
* To be used in unit tests
+ *
+ * @deprecated on 20090514 never used
*/
public class FilterDialogModelMock extends FilterModel<FilterDialogModelMock.ModelMock, FilterDialogModelMock.ModelMock> {
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/CompileHelperTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -29,10 +29,9 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.util.FileUtil;
import org.junit.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
/**
* CompileHelperTest.
@@ -46,21 +45,12 @@
* Last update: $Date$
* by : $Author$
*/
-public class CompileHelperTest {
+public class CompileHelperTest extends AbstractIsisFishTest {
/** Class logger */
private static Log log = LogFactory.getLog(CompileHelperTest.class);
/**
- * Called once before all class tests.
- * @throws Exception
- */
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- }
-
- /**
* Return a Java code content in Java 6.
*
* @param name Class name
@@ -77,7 +67,7 @@
content.append("}");
return content.toString();
}
-
+
/**
* Return a Java code content in Java 6 that extends a class.
*
@@ -87,7 +77,8 @@
*/
protected String getSecondClassContent(String name, String extendsName) {
StringBuffer content = new StringBuffer();
- content.append("public class " + name + " extends " + extendsName + " {");
+ content.append("public class " + name + " extends " + extendsName
+ + " {");
content.append(" @Override");
content.append(" public boolean isEmpty(String s) {");
content.append(" return false;");
@@ -95,7 +86,7 @@
content.append("}");
return content.toString();
}
-
+
/**
* Test une compilation de classe et une
* instantiation de la classe compilée.
@@ -105,7 +96,7 @@
*/
@Test
public void testCompile() throws IOException, ClassNotFoundException {
- File f = File.createTempFile("testCompile", ".java", TestUtils.getTargetdir());
+ File f = File.createTempFile("testCompile", ".java", getTargetdir());
String filename = FileUtil.basename(f, ".java");
String code = getFirstClassContent(filename);
FileUtil.writeString(f, code);
@@ -122,7 +113,7 @@
Class<?> c = cl.loadClass(filename);
log.info("class name: " + c.getName());
Assert.assertEquals(filename, c.getName());
-
+
// delete
File fclass = new File(f.getAbsolutePath().replaceAll("java$", "class"));
fclass.delete();
@@ -138,12 +129,12 @@
@Test
public void testCompileDepend() throws IOException, ClassNotFoundException {
- File fA = File.createTempFile("testCompileA", ".java", TestUtils.getTargetdir());
+ File fA = File.createTempFile("testCompileA", ".java", getTargetdir());
String filenameA = FileUtil.basename(fA, ".java");
String codeA = getFirstClassContent(filenameA);
FileUtil.writeString(fA, codeA);
- File fB = File.createTempFile("testCompileB", ".java", TestUtils.getTargetdir());
+ File fB = File.createTempFile("testCompileB", ".java", getTargetdir());
String filenameB = FileUtil.basename(fB, ".java");
String codeB = getSecondClassContent(filenameB, filenameA);
FileUtil.writeString(fB, codeB);
@@ -152,8 +143,8 @@
List<File> classpath = new ArrayList<File>();
classpath.add(fB.getParentFile());
- CompileHelper.compile(classpath, Collections.singletonList(fB),
- dest, null);
+ CompileHelper.compile(classpath, Collections.singletonList(fB), dest,
+ null);
// essai de chargement de la classe
URL[] cp = new URL[] { dest.toURI().toURL() };
@@ -169,11 +160,13 @@
c = cl.loadClass(filenameA);
log.info("class name: " + c.getName());
Assert.assertEquals(filenameA, c.getName());
-
+
// delete
- File fclassA = new File(fA.getAbsolutePath().replaceAll("java$", "class"));
+ File fclassA = new File(fA.getAbsolutePath().replaceAll("java$",
+ "class"));
fclassA.delete();
- File fclassB = new File(fB.getAbsolutePath().replaceAll("java$", "class"));
+ File fclassB = new File(fB.getAbsolutePath().replaceAll("java$",
+ "class"));
fclassB.delete();
fA.delete();
fB.delete();
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/EvaluateHelperTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -23,10 +23,9 @@
import junit.framework.Assert;
-import org.junit.BeforeClass;
import org.junit.Test;
-import fr.ifremer.TestUtils;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.equation.EmigrationEquation;
import fr.ifremer.isisfish.equation.PopulationGrowth;
import fr.ifremer.isisfish.equation.PopulationGrowthReverse;
@@ -40,13 +39,8 @@
* Last update : $Date$
* By : $Author$
*/
-public class EvaluateHelperTest {
+public class EvaluateHelperTest extends AbstractIsisFishTest {
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
- }
-
/**
* Test #normalizeClassName().
*/
@@ -87,28 +81,30 @@
Assert.assertNotNull(result);
Assert.assertEquals("4.0", result.toString());
}
-
+
/**
* Test #evaluate() but twice to check that previous
* class don't stay in class loader.
*/
@Test
public void testDoubleContentEvaluate() {
-
+
Map<String, Object> args = new HashMap<String, Object>();
args.put("context", null);
args.put("length", 2.0);
args.put("group", null);
-
+
String equationContent = "return length * 2.0;";
Object result = EvaluatorHelper.evaluate("org.codelutin.equation",
- "TestDoubleContentEvaluate", PopulationGrowthReverse.class, equationContent, args);
+ "TestDoubleContentEvaluate", PopulationGrowthReverse.class,
+ equationContent, args);
Assert.assertNotNull(result);
Assert.assertEquals("4.0", result.toString());
-
+
equationContent = "return length * 3.0;";
result = EvaluatorHelper.evaluate("org.codelutin.equation",
- "TestDoubleContentEvaluate", PopulationGrowthReverse.class, equationContent, args);
+ "TestDoubleContentEvaluate", PopulationGrowthReverse.class,
+ equationContent, args);
Assert.assertNotNull(result);
Assert.assertEquals("6.0", result.toString());
}
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2009-05-13 17:13:02 UTC (rev 2229)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2009-05-14 18:09:22 UTC (rev 2230)
@@ -32,7 +32,6 @@
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.tmatesoft.svn.core.SVNCommitInfo;
@@ -47,8 +46,7 @@
import org.tmatesoft.svn.core.wc.SVNUpdateClient;
import org.tmatesoft.svn.core.wc.SVNWCClient;
-import fr.ifremer.TestUtils;
-import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.AbstractIsisFishTest;
/**
* Class de test VCS.
@@ -61,12 +59,12 @@
*
* Last update: $Date: 2008-10-07 18:46:13 +0200 (mar 07 oct 2008) $ by : $Author: tchemit $
*/
-public class VCSSVNTest {
+public class VCSSVNTest extends AbstractIsisFishTest {
/** Class logger */
private static Log log = LogFactory.getLog(VCSSVNTest.class);
- public static final File TMPDIR = TestUtils.getTargetdir();
+ public static final File TMPDIR = getTargetdir();
public static final String FILECONTENTTAG = "Version 3.1.0";
public static final String FILECONTENTTRUNK = "Version 3.2.0";
@@ -86,49 +84,19 @@
}
/**
- * Static test init.
- * @throws Exception
- */
- @BeforeClass
- public static void init() throws Exception {
- TestUtils.init();
-
- template = new File(TMPDIR, "testsvn-template");
- remoteRepo = new File(TMPDIR, "testsvn-repo");
- localRepo = new File(TMPDIR, "testsvn-local");
- localRepoTrunk = new File(TMPDIR, "testsvn-localTrunk");
- }
-
- /**
- * Clean repo directories.
- */
- @Ignore
- protected void clean() {
- // un peu de nettoyage
- if (template.exists()) {
- FileUtil.deleteRecursively(template);
- }
- if (remoteRepo.exists()) {
- FileUtil.deleteRecursively(remoteRepo);
- }
- if (localRepo.exists()) {
- FileUtil.deleteRecursively(localRepo);
- }
- if (localRepoTrunk.exists()) {
- FileUtil.deleteRecursively(localRepoTrunk);
- }
- }
-
- /**
* Init call before each test.
* @throws IOException
* @throws SVNException
*/
@Before
public void setUp() throws IOException, SVNException {
+ template = new File(TMPDIR, "testsvn-template");
+ remoteRepo = new File(TMPDIR, "testsvn-repo");
+ localRepo = new File(TMPDIR, "testsvn-local");
+ localRepoTrunk = new File(TMPDIR, "testsvn-localTrunk");
// un peu de nettoyage
- clean();
+ tearDown();
// creation de l'instance de notre VCS pour les tests
// on le fait au debut pour que la l'init de la lib svn soit fait
@@ -182,12 +150,23 @@
}
/**
- * After each test.
+ * Clean repo directories.
*/
@After
public void tearDown() {
// un peu de nettoyage
- //clean();
+ if (template.exists()) {
+ FileUtil.deleteRecursively(template);
+ }
+ if (remoteRepo.exists()) {
+ FileUtil.deleteRecursively(remoteRepo);
+ }
+ if (localRepo.exists()) {
+ FileUtil.deleteRecursively(localRepo);
+ }
+ if (localRepoTrunk.exists()) {
+ FileUtil.deleteRecursively(localRepoTrunk);
+ }
}
/**
@@ -434,7 +413,7 @@
vcs.checkProtocol();
}
-
+
/**
* Test cleanup.
*
@@ -1065,9 +1044,10 @@
Map<File, SVNStatus> files = vcs.getRemoteStatus(null, true);
log.info("Will update file = " + files.keySet());
Assert.assertTrue("Must be one file updated", files.size() == 1);
-
+
// try to update...
List<File> filesInConflict = vcs.update(null, true);
- Assert.assertTrue("No file should be in conflit", filesInConflict.isEmpty());
+ Assert.assertTrue("No file should be in conflit", filesInConflict
+ .isEmpty());
}
}
\ No newline at end of file
1
0
r2229 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish: datastore simulator ui/simulator
by sletellier@users.labs.libre-entreprise.org 13 May '09
by sletellier@users.labs.libre-entreprise.org 13 May '09
13 May '09
Author: sletellier
Date: 2009-05-13 17:13:02 +0000 (Wed, 13 May 2009)
New Revision: 2229
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
Log:
Hacked : Rechargement de base ayant le meme nom en AS
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2009-05-13 15:58:31 UTC (rev 2228)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2009-05-13 17:13:02 UTC (rev 2229)
@@ -314,6 +314,17 @@
* @return Parameter property.
*/
public SimulationParameter getParameter() {
+ return getParameter(null);
+ }
+
+ /**
+ * Get parameter property.
+ *
+ * This method open database.
+ *
+ * @return Parameter property.
+ */
+ public SimulationParameter getParameter(File dir) {
if (parameter == null) {
Properties prop = new Properties();
File file = getSimulationParametersFile();
@@ -329,7 +340,7 @@
prop.load(in);
in.close();
parameter = new SimulationParameter();
- parameter.fromProperties(getDirectory(), prop);
+ parameter.fromProperties(dir, prop);
} catch (IOException eee) {
throw new IsisFishRuntimeException(_(
"isisfish.error.read.simulation.parameters", file), eee);
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2009-05-13 15:58:31 UTC (rev 2228)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2009-05-13 17:13:02 UTC (rev 2229)
@@ -350,7 +350,7 @@
"useStatistic", "true"));
// FIXME not good place and code
- if(this.region == null || !region.getName().equals(regionName)) {
+ if(directory != null && (this.region == null || !region.getName().equals(regionName))) {
// ATTENTION: directory pointe sur le repertoire de la simulation et non de la region
this.region = new RegionStorage(directory, regionName); // RegionStorage.getRegion(directory, regionName);
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-05-13 15:58:31 UTC (rev 2228)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-05-13 17:13:02 UTC (rev 2229)
@@ -171,8 +171,7 @@
fos = new FileInputStream(f);
Properties proper = new Properties();
proper.load(fos);
- param.fromProperties(SimulationStorage.getSimulationDirectory(),
- proper);
+ param.fromProperties(null, proper);
} catch (Exception e) {
if (log.isErrorEnabled()) {
log.error("Can't import simulation", e);
1
0
r2228 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: . input sensitivity simulator
by sletellier@users.labs.libre-entreprise.org 13 May '09
by sletellier@users.labs.libre-entreprise.org 13 May '09
13 May '09
Author: sletellier
Date: 2009-05-13 15:58:31 +0000 (Wed, 13 May 2009)
New Revision: 2228
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx
Log:
Region CRUD propaged in UI
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2009-05-13 12:06:18 UTC (rev 2227)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/WelcomeTabUI.jaxx 2009-05-13 15:58:31 UTC (rev 2228)
@@ -43,11 +43,15 @@
public void selTab(int i){
simulTabs.setSelectedIndex(i);
}
+ public void refresh(){
+ simulUI.refresh();
+ sensitivityUI.refresh();
+ }
]]>
</script>
<JTabbedPane id="simulTabs" tabPlacement='{JTabbedPane.LEFT}' constraints="BorderLayout.CENTER">
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/book.gif"))}'>
- <fr.ifremer.isisfish.ui.input.InputUI constructorParams='new JAXXInitialContext().add(getContextValue(WelcomeSaveVerifier.class)).add(new InputAction()).add(new InputSaveVerifier()).add(this)'/>
+ <fr.ifremer.isisfish.ui.input.InputUI id='inputUI' constructorParams='new JAXXInitialContext().add(getContextValue(WelcomeSaveVerifier.class)).add(new InputAction()).add(new InputSaveVerifier()).add(this)'/>
</tab>
<tab title=' ' icon='{new ImageIcon(getClass().getResource("/images/simulation.gif"))}'>
<fr.ifremer.isisfish.ui.simulator.SimulUI id='simulUI' constructorParams='new SimulAction()'/>
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2009-05-13 12:06:18 UTC (rev 2227)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2009-05-13 15:58:31 UTC (rev 2228)
@@ -78,6 +78,7 @@
import org.codelutin.topia.TopiaContext;
import fr.ifremer.isisfish.entities.FisheryRegion;
import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.ui.WelcomeTabUI;
getContextValue(WelcomeSaveVerifier.class).addSaveVerifier(getVerifier());
new fr.ifremer.isisfish.ui.input.InputNavigationTreeSelectionAdapter(this);
@@ -92,6 +93,7 @@
return getContextValue(RegionStorage.class);
}
protected void setFieldCurrentRegionModel(){
+ getParentContainer(WelcomeTabUI.class).refresh();
fieldCurrentRegion.setModel(getFieldCurrentRegionModel());
}
protected DefaultComboBoxModel getFieldCurrentRegionModel(){
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2009-05-13 12:06:18 UTC (rev 2227)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityUI.jaxx 2009-05-13 15:58:31 UTC (rev 2228)
@@ -33,6 +33,9 @@
public void selTab(int i) {
sensitivityTabs.setSelectedIndex(i);
}
+ public void refresh(){
+ paramsUI.refresh();
+ }
]]>
</script>
<JTabbedPane id="sensitivityTabs" constraints="BorderLayout.CENTER">
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2009-05-13 12:06:18 UTC (rev 2227)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2009-05-13 15:58:31 UTC (rev 2228)
@@ -81,6 +81,7 @@
setListSimulParamsStrategiesItems();
setListSimulParamsPopulationsItems();
setRulesItems();
+ fieldSimulParamsRegion.setModel(new DefaultComboBoxModel(Common.getRegionItem()));
fieldSimulParamsRegion.setSelectedItem(getContextValue(SimulAction.class).getSimulationParameter().getRegionName());
}
protected void regionChange(ItemEvent e) {
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx 2009-05-13 12:06:18 UTC (rev 2227)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulUI.jaxx 2009-05-13 15:58:31 UTC (rev 2228)
@@ -58,7 +58,7 @@
protected void selTab(int i) {
simulTabs.setSelectedIndex(i);
}
- protected void refreshAll() {
+ public void refresh() {
paramsUI.refresh();
preSciptUI.refresh();
sensUI.refresh();
@@ -74,7 +74,7 @@
File file = fc.getSelectedFile();
//This is where a real application would open the file.
getContextValue(SimulAction.class).importSimulation(file);
- refreshAll();
+ refresh();
}
}
protected void saveSimulation() {
1
0
r2227 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator
by sletellier@users.labs.libre-entreprise.org 13 May '09
by sletellier@users.labs.libre-entreprise.org 13 May '09
13 May '09
Author: sletellier
Date: 2009-05-13 12:06:18 +0000 (Wed, 13 May 2009)
New Revision: 2227
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
Log:
Clear all exports when loading an old simulation
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-05-12 17:14:55 UTC (rev 2226)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2009-05-13 12:06:18 UTC (rev 2227)
@@ -308,6 +308,7 @@
sensitivityCalculator = param.getSensitivityCalculator();
// Chargement des exports de sensibilites
+ sensitivityExports.clear();
for (SensitivityExport ex : param.getSensitivityExport()){
sensitivityExports.put(ex, ex.getExportFilename());
}
1
0