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()); + } +}