Author: bpoussin Date: 2008-08-19 18:37:13 +0000 (Tue, 19 Aug 2008) New Revision: 1305 Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/RegionStorage.java trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java trunk/isis-fish/src/test/fr/ifremer/isisfish/vcs/VCSSVNTest.java Log: Nouvelle implantation de vcs fonctionne avec les tests unitaires pour: - checkout - update - delete - setTag - isTag Par contre svn+ssh n'arrive pas a s'authentifier Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -80,19 +80,37 @@ protected final static VersionNumber version = new VersionNumber(3, 2, 0, 0); protected final static VersionNumber databaseVersion = new VersionNumber( version.getNumber(0), version.getNumber(1)); + protected final static VersionNumber apiVersion = new VersionNumber( + version.getNumber(0), version.getNumber(1), version.getNumber(2)); public static VersionNumber getVersionNumber() { return version; } + /** + * le nombre global ex: 3.2.0.0 + * @return + */ static public String getVersion() { String result = version.toString(); return result; } + /** + * La version de la base ex: 3.2 + * @return + */ public static VersionNumber getDatabaseVersion() { return databaseVersion; } + + /** + * La version de l'api de programmation ex: 3.2.0 + * @return + */ + public static VersionNumber getApiVersion() { + return apiVersion; + } static final public String COPYRIGHT_TEXT = "Version " + getVersion() + " IFREMER-MAERHA © 2000-2008"; static final public String CONFIG_FILENAME = "isis-config-" + version.getNumber(0); @@ -572,7 +590,7 @@ VCS_USER_PASSWORD(VCS.VCS_USER_PASSWORD, _("isisfish.config.vcs.userPassword.description"), ""), VCS_HOST_NAME(VCS.VCS_HOST_NAME, _("isisfish.config.vcs.hostName.description"), "labs.libre-entreprise.org"), VCS_PATH(VCS.VCS_PATH, _("isisfish.config.vcs.remotePath.description"), "/svnroot/isis-fish-data"), - VCS_TAG(VCS.VCS_TAG, _("isisfish.config.vcs.remoteDatabase.description"), "/trunk"), +// VCS_TAG(VCS.VCS_TAG, _("isisfish.config.vcs.remoteDatabase.description"), "/trunk"), // TYPE_REPO_PROPERTY_KEY = newConfigPropertyKey("typeRepo", VCSTypeRepo.class, 9, n_("isisfish.config.vcs.typeRepo.description"), "TAG"), // PROJECT_NAME_PROPERTY_KEY = newConfigPropertyKey("projectName", String.class, 11, n_("isisfish.config.main.projectName.description"), "Isis-Fish"), Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -33,6 +33,7 @@ import com.sun.tools.internal.xjc.generator.util.ExistingBlockReference; import fr.ifremer.isisfish.datastore.AnalysePlanStorage; +import fr.ifremer.isisfish.datastore.ExportStorage; import fr.ifremer.isisfish.datastore.FormuleStorage; import fr.ifremer.isisfish.datastore.RegionStorage; import fr.ifremer.isisfish.datastore.RuleStorage; @@ -51,8 +52,10 @@ import fr.ifremer.isisfish.util.StringConverter; import fr.ifremer.isisfish.util.TimeUnitConverter; import fr.ifremer.isisfish.vcs.VCS; +import fr.ifremer.isisfish.vcs.VCSException; import fr.ifremer.isisfish.vcs.VCSFactory; import java.io.File; +import java.text.SimpleDateFormat; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.logging.LogFactory; import static org.codelutin.i18n.I18nf._; @@ -66,7 +69,9 @@ import org.swixml.ConverterLibrary; import org.codelutin.i18n.I18n; +import org.codelutin.topia.TopiaException; import org.codelutin.util.LocaleConverter; +import org.codelutin.util.VersionNumber; import static javax.swing.JOptionPane.showOptionDialog; @@ -196,16 +201,77 @@ * Initialise le VCSNone et check s'il y a des mises a jour pour prevenir * l'utilisateur */ - static public void initVCS() { + static public void initVCS() throws VCSException { // init vcs vcs = VCSFactory.createVCS(config); - // check connection status + // Si le repo local exist mais n'est pas du bon type, on renome ce repertoire + File local = config.getDatabaseDirectory(); + if (local.exists()) { + if(!vcs.isValidLocalRepository()) { + File localBackup = new File(local.getParentFile(), + local.getName() + "-" + + new SimpleDateFormat().format(new Date())); + if (!local.renameTo(localBackup)) { + throw new IsisFishRuntimeException( + "Can rename local repository that don't use svn"); + } + } + } + + // Si le repo local n'existe pas on fait un check out complet + if (!local.exists()) { + // Si on utilise pas le bon tag on change de tag + VersionNumber tag = IsisConfig.getApiVersion(); + if (!vcs.isTag(tag)) { + // pas de tag pour cette version, on checkout le trunk + tag = null; + } + + vcs.checkout(tag, false); + + AnalysePlanStorage.checkout(); + ExportStorage.checkout(); + FormuleStorage.checkout(); + RuleStorage.checkout(); + ScriptStorage.checkout(); + SimulatorStorage.checkout(); + + vcs.update(new File(local, SimulationStorage.SIMULATION_PATH), false); + vcs.update(new File(local, RegionStorage.REGION_PATH), false); + try { + RegionStorage.checkout("DemoRegion"); + } catch (TopiaException eee) { + log.warn("Can't checkout DemoRegion", eee); + } + } + + if (!local.exists()) { + throw new IsisFishRuntimeException("Can't find local repository"); + } + + // check protocol, user, host vcs.checkProtocol(); - // check release - vcs.checkRelease(); + // Suivant la version du logiciel et les versions de base disponible + // il est possiblement obligatoire de ne plus etre sur le trunk, ou + // de migrer sur un autre tag + // si on est sur une branche, on est en developpement, on ne fait donc rien + if (!vcs.getTag().startsWith("branches")) { + + // Si on utilise pas le bon tag on change de tag + VersionNumber tag = IsisConfig.getApiVersion(); + if (vcs.isTag(tag)) { + // un tag dispo, on a donc pas la derniere version, on switch + vcs.setTag(tag); + } else { + // pas de tag dispo on retourne sur le trunk + vcs.setTag(null); + } + } + + // check file status vcs.checkFileStatus(); } Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -57,7 +57,7 @@ File dest = config.getDatabaseDirectory(); File file = new File(dest, "pom.xml"); log.info(_("Checkout pom.xml to %s", file)); - vcs.update(Arrays.asList(file)); + vcs.update(file, false); } Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/RegionStorage.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/RegionStorage.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/RegionStorage.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -199,7 +199,7 @@ * @return le sotrage après checkout */ static public RegionStorage checkout(String name) throws VCSException, TopiaException { - checkout(IsisFish.config.getDatabaseDirectory(), REGION_PATH + "/" + name); + checkout(IsisFish.config.getDatabaseDirectory(), REGION_PATH + File.separator + name); RegionStorage region = getRegion(name); if (region != null) { File file = region.getDataBackupFile(); Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -31,6 +31,7 @@ package fr.ifremer.isisfish.datastore; +import fr.ifremer.isisfish.IsisConfig; import fr.ifremer.isisfish.IsisFish; import fr.ifremer.isisfish.vcs.VCS; import fr.ifremer.isisfish.vcs.VCSException; @@ -46,6 +47,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.codelutin.util.VersionNumber; /** * Classe permettant de géré l'interaction avec le cvs @@ -231,7 +233,7 @@ */ public void update() throws VCSException { prepare(); - getVCS().update(Arrays.asList(getFile())); + getVCS().update(getFile(), true); } public boolean isUpToDate() throws VCSException { @@ -240,7 +242,7 @@ } /** - * Permet de ramener tout un répertoire du VCSNone. Utile seulement pour le + * Permet de ramener tout un répertoire du VCS. Utile seulement pour le * premier lancement pour scipts et exports. * * @param destDir le repertoire parent @@ -249,7 +251,15 @@ * */ static public void checkout(File destDir, String module) throws VCSException { - getVCS().checkout(destDir, module, true); + // Si on utilise pas le bon tag on change de tag + VersionNumber tag = IsisConfig.getApiVersion(); + if (!getVCS().isTag(tag)) { + // pas de tag pour cette version, on checkout le trunk + tag = null; + } + + File file = new File(destDir, module); + getVCS().update(file, true); } /** Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -37,6 +37,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.topia.TopiaException; +import org.codelutin.util.VersionNumber; /** * @@ -55,19 +56,17 @@ protected String protocol; protected String host; protected String path; - protected String tag; protected File sshKeyFile; protected String login; protected String password; public AbstractVCS(File localRepository, - String protocol, String host, String path, String tag, + String protocol, String host, String path, File sshKeyFile, String login, String password) { this.localRepository = localRepository; this.protocol = protocol; this.host = host; this.path = path; - this.tag = tag; this.sshKeyFile = sshKeyFile; this.login = login; this.password = password; @@ -85,34 +84,41 @@ return protocol; } - public void setProtocol(String protocol) { + /** + * checkProtocol is automaticaly done + * @param path + */ + public void setProtocol(String protocol) throws VCSException { this.protocol = protocol; + checkProtocol(); } public String getHost() { return host; } - public void setHost(String host) { + /** + * checkProtocol is automaticaly done + * @param path + */ + public void setHost(String host) throws VCSException { this.host = host; + checkProtocol(); } public String getPath() { return path; } - public void setPath(String path) { + /** + * checkProtocol is automaticaly done + * @param path + */ + public void setPath(String path) throws VCSException { this.path = path; + checkProtocol(); } - public String getTag() { - return tag; - } - - public void setTag(String tag) { - this.tag = tag; - } - public File getSshKeyFile() { return sshKeyFile; } @@ -125,8 +131,13 @@ return login; } - public void setLogin(String login) { + /** + * checkProtocol is automaticaly done + * @param path + */ + public void setLogin(String login) throws VCSException { this.login = login; + checkProtocol(); } public String getPassword() { @@ -143,74 +154,13 @@ public boolean isVersionnableAbleFile(File file) { String filename = file.getName(); - return !".svn".equals(filename) && !"CVS".equals(filename) && !filename.endsWith("~"); + return !".svn".equals(filename) && !"CVS".equals(filename) && + !filename.endsWith("~") && + // si le fichier n'appartient pas a loca repository, il ne pourra pas etre versionne + file.getAbsolutePath().startsWith(getLocalRepository().getAbsolutePath()); } /** - * Verifie la connexion et si le protocole a change, switch le repository - * pour utiliser le nouveau protocole. Si on est en mode interface (mode - * graphique) et que le switch se passe mal, demande a l'utilisateur - * de nouvelle valeur pour le protocole (+ identifiant, ...) - */ - public void checkProtocol() throws VCSException { - if (isConnected()) { - // Si le repo local exist mais n'est pas en svn, on renome ce repertoire - // FIXME a faire - File local = getLocalRepository(); - if(local.exists()) { - File svn = new File(local, ".svn"); - if (!svn.exists()) { - File localBackup = new File(local.getParentFile(), - local.getName() + "-" + - new SimpleDateFormat().format(new Date())); - if(!local.renameTo(localBackup)) { - throw new IsisFishRuntimeException("Can rename local repository that don't use svn"); - } - } - } - - // Si le repo local n'existe pas on fait un check out complet - if (!local.exists()) { - // On modifie la version a a checkouter pour etre sur d'avoir la bonne - - AnalysePlanStorage.checkout(); - ExportStorage.checkout(); - FormuleStorage.checkout(); - RuleStorage.checkout(); - ScriptStorage.checkout(); - SimulatorStorage.checkout(); - - checkout(getLocalRepository(), SimulationStorage.SIMULATION_PATH, false); - checkout(getLocalRepository(), RegionStorage.REGION_PATH, false); - try { - RegionStorage.checkout("DemoRegion"); - } catch (TopiaException eee) { - log.warn("Can't checkout DemoRegion", eee); - } - } - - if (!local.exists()) { - throw new IsisFishRuntimeException("Can't find local repository"); - } - // si le protocole a change on le change -// if (getLocalTag() != ) - // FIXME a faire - } - } - - /** - * Verifie que l'utilisateur utilise la bonne version de script en fonction - * de sa version de logiciel. Si ce n'est pas le cas et que l'on est en - * interactif (mode graphique), on lui demande ce qu'il souhaite faire. - */ - public void checkRelease() throws VCSException { - if (isConnected()) { - // Si on utilise pas la bonne branche on change de branche - // FIXME a faire - } - } - - /** * Verifie si tous les fichiers du repository local sont les dernieres * version par rapport au serveur. Si ce n'est pas le cas et que l'on est * en mode interactif (mode graphique), on lui propose de mettre a jour Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -58,10 +58,6 @@ */ public static final String VCS_PATH = "vcs.path"; /** - * repository tag to used ex: "/branches/3.2" or "HEAD", "/trunk" or "" - */ - public static final String VCS_TAG = "vcs.tag"; - /** * user login to access vcs ex: bpoussin */ public static final String VCS_USER_NAME = "vcs.username"; @@ -74,33 +70,39 @@ * Get local repository directory */ public File getLocalRepository(); - + /** - * Get the server address of the local file - * ex: svn+ssh://bpoussin at labs.libre-entreprise.org/svnroot/isis-fish/trunk/isis-fish/pom.xml - * - * @param f file that we want to know the source + * Return true, if local repository is valid repository for actuel vcs * @return */ - public String getLocalRepositorySource(File f) throws VCSException; + public boolean isValidLocalRepository(); /** - * Get the root server address of the local repository - * ex: svn+ssh://bpoussin at labs.libre-entreprise.org/svnroot/isis-fish - * + * Return true, if local repository is writeable + * (use trunk and is not anonymous) * @return */ - public String getLocalRepositoryRoot() throws VCSException; + public boolean isWriteable() throws VCSException; +// /** +// * Get the server address of the local file +// * ex: svn+ssh://bpoussin at labs.libre-entreprise.org/svnroot/isis-fish/trunk/isis-fish/pom.xml +// * +// * @param f file that we want to know the source +// * @return +// */ +// public String getLocalRepositorySource(File f) throws VCSException; +// +// /** +// * Get the root server address of the local repository +// * ex: svn+ssh://bpoussin at labs.libre-entreprise.org/svnroot/isis-fish +// * +// * @return +// */ +// public String getLocalRepositoryRoot() throws VCSException; + /** - * Usefull to permit to use VCSNone as filter - * @param pathname - * @return - */ - public boolean accept(File pathname); - - /** - * Commit specified files + * Commit specified files, if files is null, all files are commited * @param files files to commit * @param msg message used to commit * @throws fr.ifremer.isisfish.vcs.VCSException @@ -116,32 +118,22 @@ public void add(List<File> files, String msg) throws VCSException; /** - * get repository module on server and put it in destDir - * @param destDir destination directory - * @param module module name + * get repository on server and put it in localdir + * @param tag tag to used, null = /trunk other is tags/[tag] * @param recurse if file is directory checkout sub file * @throws fr.ifremer.isisfish.vcs.VCSException */ - public void checkout(File destDir, String module, boolean recurse) throws VCSException; + public void checkout(VersionNumber tag, boolean recurse) throws VCSException; +// /** +// * switch to new protocole, can be used to switch between anonymous and +// * authenticate protocole +// * @param protocoleType +// * @throws fr.ifremer.isisfish.vcs.VCSException +// */ +// public void switchProtocole(String protocoleType) throws VCSException; + /** - * Change repository tag, used when we use some tag and we want to go to - * trunk. - * @param version version to go, if null trunk is used, otherwize - * tags/version is used - * @throws fr.ifremer.isisfish.vcs.VCSException - */ - public void switchTag(VersionNumber version) throws VCSException; - - /** - * switch to new protocole, can be used to switch between anonymous and - * authenticate protocole - * @param protocoleType - * @throws fr.ifremer.isisfish.vcs.VCSException - */ - public void switchProtocole(String protocoleType) throws VCSException; - - /** * Delete and commit files in server repository * @param files file to delete * @param msg message for commit @@ -155,7 +147,7 @@ * @param files * @return changelog for each file */ - public Map<File, String> getChanglog(List<File> files); + public Map<File, String> getChanglog(List<File> files) throws VCSException; /** * show diff between local file and repository file @@ -176,13 +168,13 @@ * get list of new or modified files on server * @return list of modified or new files */ - public List<File> getUpdatedFile(); + public List<File> getUpdatedFile() throws VCSException; /** * Ask if there are some new or modified files on server * @return true if new file available */ - public boolean haveUpdate(); + public boolean haveUpdate() throws VCSException; /** * Get connection state. @@ -203,7 +195,7 @@ * @param version version number like 3.2 * @return true if tag found with this name */ - public boolean isTag(VersionNumber version); + public boolean isTag(VersionNumber version) throws VCSException; /** * Check if file is uptodate @@ -231,7 +223,7 @@ * @return true if there are some merging conflict, false otherwize * @throws fr.ifremer.isisfish.vcs.VCSException */ - public boolean update(List<File> files) throws VCSException; + public boolean update(File file, boolean recurse) throws VCSException; /** * Verifie la connexion et si le protocole a change, switch le repository @@ -250,11 +242,69 @@ */ void checkFileStatus() throws VCSException; +// /** +// * Verifie que l'utilisateur utilise la bonne version de script en fonction +// * de sa version de logiciel. Si ce n'est pas le cas et que l'on est en +// * interactif (mode graphique), on lui demande ce qu'il souhaite faire. +// */ +// void checkRelease(VersionNumber version) throws VCSException; + + String getHost(); + + String getLogin(); + + String getPassword(); + + String getPath(); + + String getProtocol(); + + File getSshKeyFile(); + /** - * Verifie que l'utilisateur utilise la bonne version de script en fonction - * de sa version de logiciel. Si ce n'est pas le cas et que l'on est en - * interactif (mode graphique), on lui demande ce qu'il souhaite faire. + * retourne le tag reellement utilise, par exemple si on a fait un + * setTag(3.2.0) cette methode retourne "/tags/3.2.0", pour setTag(null) + * on retourne "/trunk" + * @return + * @throws fr.ifremer.isisfish.vcs.VCSException */ - void checkRelease() throws VCSException; + String getTag() throws VCSException; + /** + * Change repository tag, used when we use some tag and we want to go to + * trunk. + * @param version version to go, if null trunk is used, otherwize + * tags/version is used + * @throws fr.ifremer.isisfish.vcs.VCSException + */ + public void setTag(VersionNumber version) throws VCSException; + + /** + * checkProtocol is automaticaly done + * @param path + */ + void setHost(String host) throws VCSException; + + /** + * checkProtocol is automaticaly done + * @param path + */ + void setLogin(String login) throws VCSException; + + void setPassword(String password); + + /** + * checkProtocol is automaticaly done + * @param path + */ + void setPath(String path) throws VCSException; + + /** + * checkProtocol is automaticaly done + * @param path + */ + void setProtocol(String protocol) throws VCSException; + + void setSshKeyFile(File sshKeyFile); + } Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -69,7 +69,6 @@ String protocol = config.getOption(VCS.VCS_PROTOCOLE); String host = config.getOption(VCS.VCS_HOST_NAME); String path = config.getOption(VCS.VCS_PATH); - String tag = config.getOption(VCS.VCS_TAG); File sshKeyFile = config.getOptionAsFile(VCS.VCS_SSH_KEY_FILE); String login = config.getOption(VCS.VCS_USER_NAME); String password = config.getOption(VCS.VCS_USER_PASSWORD); @@ -77,11 +76,11 @@ try { Class clazz = (Class) ConvertUtils.convert(classname, Class.class); result = (VCSNone) ConstructorUtils.invokeConstructor(clazz, - new Object[]{dataDir, protocol, host, path, tag, sshKeyFile, login, password}); + new Object[]{dataDir, protocol, host, path, sshKeyFile, login, password}); } catch (Exception eee) { log.error(_("Can't instanciate wanted VCS (%s), use default", config.getOption(VCS.VCS_TYPE)), eee); - result = new VCSNone(dataDir, protocol, host, path, tag, sshKeyFile, login, password); + result = new VCSNone(dataDir, protocol, host, path, sshKeyFile, login, password); } return result; } Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -47,17 +47,22 @@ static private Log log = LogFactory.getLog(VCSNone.class); public VCSNone(File localRepository, - String protocol, String host, String path, String tag, + String protocol, String host, String path, File sshKeyFile, String login, String password) { - super(localRepository, protocol, host, path, tag, sshKeyFile, login, password); + super(localRepository, protocol, host, path, sshKeyFile, login, password); } + public boolean isValidLocalRepository() { + return true; + } + + /** * look on server if version is tag repository * @param version version number like 3.2 * @return true if tag found with this name */ - public boolean isTag(VersionNumber version) { + public boolean isTag(VersionNumber version) throws VCSException { return false; } @@ -65,7 +70,7 @@ * Ask if there are some new or modified files on server * @return true if new file available */ - public boolean haveUpdate() { + public boolean haveUpdate() throws VCSException { return false; } @@ -73,7 +78,7 @@ * get list of new or modified files on server * @return list of modified or new files */ - public List<File> getUpdatedFile() { + public List<File> getUpdatedFile() throws VCSException { return new ArrayList<File>(); } @@ -108,7 +113,7 @@ * @param b // FIXME * @throws fr.ifremer.isisfish.vcs.VCSException */ - public void checkout(File destDir, String module, boolean b) throws VCSException { + public void checkout(VersionNumber tag, boolean b) throws VCSException { throw new VCSException("Can't checkout with dummy VCS"); } @@ -176,25 +181,35 @@ * @return true if there are some merging conflict, false otherwize * @throws fr.ifremer.isisfish.vcs.VCSException */ - public boolean update(List<File> files) throws VCSException { + public boolean update(File file, boolean recurse) throws VCSException { throw new VCSException("Can't update file with dummy VCS"); } - public void switchTag(VersionNumber version) throws VCSException { - // do nothing +// public String getLocalRepositorySource(File f) throws VCSException { +// throw new VCSException("Not supported."); +// } +// +// public String getLocalRepositoryRoot() throws VCSException { +// throw new VCSException("Not supported."); +// } +// +// public String getLocalRepositoryTag() throws VCSException { +// throw new VCSException("Not supported."); +// } + + public void checkProtocol() throws VCSException { + // nothing to do } - public void switchProtocole(String protocoleType) throws VCSException { - // do nothing + public boolean isWriteable() throws VCSException { + return false; } - public String getLocalRepositorySource(File f) throws VCSException { - throw new VCSException("Not supported."); + public void setTag(VersionNumber version) throws VCSException { + // do nothing } - public String getLocalRepositoryRoot() throws VCSException { - throw new VCSException("Not supported."); + public String getTag() throws VCSException { + return null; } - - } Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java =================================================================== --- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -19,12 +19,10 @@ package fr.ifremer.isisfish.vcs; -import java.util.logging.Level; -import java.util.logging.Logger; import static org.codelutin.i18n.I18nf._; -import fr.ifremer.isisfish.IsisConfig; import java.io.File; +import java.util.Arrays; import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; @@ -33,6 +31,10 @@ import org.tmatesoft.svn.core.SVNCommitInfo; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; +import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; +import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory; +import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; import org.tmatesoft.svn.core.wc.ISVNOptions; import org.tmatesoft.svn.core.wc.SVNClientManager; import org.tmatesoft.svn.core.wc.SVNInfo; @@ -51,21 +53,21 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(VCSSVN.class); - - protected String protocol; - protected String host; - protected String path; - protected String tag; - protected File sshKeyFile; - protected String login; - protected String password; - + protected SVNClientManager svnManager = null; public VCSSVN(File localRepository, - String protocol, String host, String path, String tag, + String protocol, String host, String path, File sshKeyFile, String login, String password) { - super(localRepository, protocol, host, path, tag, sshKeyFile, login, password); + super(localRepository, protocol, host, path, sshKeyFile, login, password); + if (protocol.startsWith("file")) { + FSRepositoryFactory.setup(); + } else if (protocol.startsWith("http")) { + DAVRepositoryFactory.setup(); + } else { + //svn://, svn+xxx:// (svn+ssh:// in particular) + SVNRepositoryFactoryImpl.setup(); + } } protected SVNClientManager getSVNManager() { @@ -75,12 +77,16 @@ if (getProtocol().contains("ssh")) { ISVNOptions options = SVNWCUtil.createDefaultOptions(true); - options.setPropertyValue("svnkit.ssh2.key", getSshKeyFile().getAbsolutePath()); - options.setPropertyValue("svnkit.ssh2.username", login); - if (passwd != null && !"".equals(passwd)) { - options.setPropertyValue("svnkit.ssh2.passphrase", passwd); - } - svnManager = SVNClientManager.newInstance(options); +// options.setPropertyValue("svnkit.ssh2.key", getSshKeyFile().getAbsolutePath()); +// options.setPropertyValue("svnkit.ssh2.username", login); +// if (passwd != null && !"".equals(passwd)) { +// options.setPropertyValue("svnkit.ssh2.passphrase", passwd); +// } + ISVNAuthenticationManager auth = + SVNWCUtil.createDefaultAuthenticationManager( + SVNWCUtil.getDefaultConfigurationDirectory(), + login, passwd, sshKeyFile, passwd, false); + svnManager = SVNClientManager.newInstance(options, auth); } else { ISVNOptions options = SVNWCUtil.createDefaultOptions(true); svnManager = SVNClientManager.newInstance(options, login, passwd); @@ -89,34 +95,81 @@ return svnManager; } - protected SVNURL getRemoteURL() throws SVNException { - SVNURL remoteURL = SVNURL.parseURIEncoded(getRemoteRepository()); - return remoteURL; + public boolean isValidLocalRepository() { + File local = getLocalRepository(); + File svn = new File(local, ".svn"); + boolean result = svn.exists(); + return result; } - - public String getLocalRepositoryRoot() throws VCSException { + + @Override + public void checkProtocol() throws VCSException { try { File localRoot = getLocalRepository(); SVNInfo info = getSVNManager().getWCClient().doInfo(localRoot, SVNRevision.WORKING); - SVNURL url = info.getCopyFromURL(); - String result = url.toDecodedString(); - return result; + SVNURL url = info.getURL(); + + // si un des constituants de l'url a change on fait un switch relocate + boolean mustSwitch = false; + if (!url.getProtocol().equals(getProtocol())) { + log.info(_("repository protocol change from %s to %s", + url.getProtocol(), getProtocol())); + mustSwitch = true; + } + if (!url.getUserInfo().equals(getLogin())) { + log.info(_("repository user change from %s to %s", + url.getUserInfo(), getLogin())); + mustSwitch = true; + } + if (!url.getHost().equals(getHost())) { + log.info(_("repository host change from %s to %s", + url.getHost(), getHost())); + mustSwitch = true; + } + + if (mustSwitch) { + String path = url.getPath(); + int port = url.getPort(); + SVNURL newUrl = SVNURL.create(getProtocol(), getLogin(), + getHost(), port, path, true); + getSVNManager().getUpdateClient().doRelocate(localRoot, url, newUrl, true); + } } catch (SVNException eee) { throw new VCSException(_("Can't get address on serveur of local repository"), eee); } + } - public String getLocalRepositorySource(File f) throws VCSException { - try { - // TODO perhaps, check if file is in getLocalRepository() file ? - SVNInfo info = getSVNManager().getWCClient().doInfo(f, SVNRevision.WORKING); - SVNURL url = info.getURL(); - String result = url.toDecodedString(); - return result; - } catch (SVNException eee) { - throw new VCSException(_("Can't get address on serveur of local repository"), eee); - } + + + protected SVNURL getRemoteURL() throws SVNException { + SVNURL remoteURL = SVNURL.parseURIEncoded(getRemoteRepository()); + return remoteURL; } + +// public String getLocalRepositoryRoot() throws VCSException { +// try { +// File localRoot = getLocalRepository(); +// SVNInfo info = getSVNManager().getWCClient().doInfo(localRoot, SVNRevision.WORKING); +// SVNURL url = info.getCopyFromURL(); +// String result = url.toDecodedString(); +// return result; +// } catch (SVNException eee) { +// throw new VCSException(_("Can't get address on serveur of local repository"), eee); +// } +// } +// +// public String getLocalRepositorySource(File f) throws VCSException { +// try { +// // TODO perhaps, check if file is in getLocalRepository() file ? +// SVNInfo info = getSVNManager().getWCClient().doInfo(f, SVNRevision.WORKING); +// SVNURL url = info.getURL(); +// String result = url.toDecodedString(); +// return result; +// } catch (SVNException eee) { +// throw new VCSException(_("Can't get address on serveur of local repository"), eee); +// } +// } /** * Retourne l'url du repository distant @@ -125,15 +178,23 @@ */ public String getRemoteRepository() { String proto = getProtocol(); + String user = getLogin(); String host = getHost(); String path = getPath(); - String tag = getTag(); - if (tag == null && "".equals(tag)) { - tag = "/trunk"; + String result = null; + + if (proto.startsWith("file")) { + result = proto + "://" + path; + } else { + if (user == null) { + user = ""; + } else if (!"".equals(user)) { + user = user + "@"; + } + + result = proto + "://" + user + host + path; } - - String result = proto + "://" + host + path + tag; return result; } @@ -146,9 +207,15 @@ public void commit(List<File> files, String msg) throws VCSException { try { + if (files == null) { + files = Arrays.asList(getLocalRepository()); + } SVNCommitInfo commitInfo = getSVNManager().getCommitClient() .doCommit(files.toArray(new File[files.size()]), - false, msg, false, true); + false, // keep lock + msg, + false, // force + true); // recurse log.debug("to revision " + commitInfo.getNewRevision()); } catch (SVNException eee) { throw new VCSException("Can't commit files", eee); @@ -158,7 +225,7 @@ public void add(List<File> files, String msg) throws VCSException { try { for (File file : files) { - // FIXME check argument in documentation + // FIXME ajoute dans le ignore les fichiers regions/<region>/data/* getSVNManager().getWCClient().doAdd(file, true, // force add to allready added file (no error) false, // don't create dir if not exist @@ -172,14 +239,22 @@ } } - public void checkout(File destDir, String module, boolean recurse) throws VCSException { + public void checkout(VersionNumber tag, boolean recurse) throws VCSException { try { - SVNURL source = getRemoteURL().appendPath(module, false); - File destination = new File(destDir, module); - getSVNManager().getUpdateClient().doCheckout(source, destination, null, + String tagPath = "/trunk/"; + if (tag != null) { + tagPath = "/tags/" + tag + "/"; + } + + SVNURL source = getRemoteURL().appendPath(tagPath, false); + + File destDir = getLocalRepository(); + destDir.mkdirs(); + + getSVNManager().getUpdateClient().doCheckout(source, destDir, null, SVNRevision.HEAD, recurse); } catch (SVNException eee) { - throw new VCSException(_("Can't checkout file %s", module), eee); + throw new VCSException(_("Can't checkout"), eee); } } @@ -223,32 +298,81 @@ throw new UnsupportedOperationException("Not supported yet."); } - public boolean isTag(VersionNumber version) { + public boolean isUpToDate(File file) throws VCSException { throw new UnsupportedOperationException("Not supported yet."); } - public boolean isUpToDate(File file) throws VCSException { - throw new UnsupportedOperationException("Not supported yet."); + public boolean update(File file, boolean recurse) throws VCSException { + try { + if (!accept(file)) { + throw new VCSException("Can't update file that not in local repository"); + } + while (!file.getParentFile().exists()) { + update(file.getParentFile(), false); + } + getSVNManager().getUpdateClient().doUpdate(file, SVNRevision.HEAD, recurse); + } catch (SVNException eee) { + throw new VCSException("Can't update files", eee); + } + return false; // FIXME rechercher s'il y a eu des conflits dans les fichiers } - public boolean update(List<File> files) throws VCSException { - for (File file : files) { + public boolean isWriteable() throws VCSException { + String login = getLogin(); + String tag = getTag(); + + boolean result = login != null && !"".equals(login) && !"anonymous".equals(login); + result = result && !tag.startsWith("/tags"); + + return result; + } + + public boolean isTag(VersionNumber version) throws VCSException { + boolean result = version == null; // le trunk exist toujours + if (!result) { try { - getSVNManager().getUpdateClient().doUpdate(file, SVNRevision.HEAD, true); + SVNURL url = getRemoteURL(); + url = url.appendPath("tags/" + version, true); + SVNInfo info = getSVNManager().getWCClient().doInfo(url, null, SVNRevision.HEAD); + // si le tag n'existe pas, on n'arrive pas ici car une exception + // est leve, et donc result reste a faux + result = info != null; } catch (SVNException eee) { - throw new VCSException("Can't update files", eee); + log.debug(_("Tag %s don't exist", version)); } } - return false; // FIXME rechercher s'il y a eu des conflits dans les fichiers + return result; } - public void switchTag(VersionNumber version) throws VCSException { - throw new UnsupportedOperationException("Not supported yet."); + public String getTag() throws VCSException { + try { + File localRoot = getLocalRepository(); + SVNInfo info = getSVNManager().getWCClient().doInfo(localRoot, SVNRevision.WORKING); + String root = info.getCopyFromURL().toDecodedString(); + String url = info.getURL().toDecodedString(); + String result = url.substring(root.length()); + return result; + } catch (SVNException eee) { + throw new VCSException(_("Can't get address on serveur of local repository"), eee); + } } - public void switchProtocole(String protocoleType) throws VCSException { - throw new UnsupportedOperationException("Not supported yet."); + public void setTag(VersionNumber version) throws VCSException { + try { + String tag = "/trunk"; + if (version != null) { + tag = "/tags/" + version; + } + + File localRoot = getLocalRepository(); + + SVNURL newUrl = getRemoteURL(); + newUrl = newUrl.appendPath(tag, true); + + getSVNManager().getUpdateClient().doSwitch(localRoot, newUrl, SVNRevision.HEAD, true); + } catch (SVNException eee) { + throw new VCSException(_("Can't get address on serveur of local repository"), eee); + } } - } Modified: trunk/isis-fish/src/test/fr/ifremer/isisfish/vcs/VCSSVNTest.java =================================================================== --- trunk/isis-fish/src/test/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2008-08-19 13:30:52 UTC (rev 1304) +++ trunk/isis-fish/src/test/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2008-08-19 18:37:13 UTC (rev 1305) @@ -20,355 +20,340 @@ package fr.ifremer.isisfish.vcs; import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; +import junit.framework.TestCase; +import org.codelutin.util.FileUtil; import org.codelutin.util.VersionNumber; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import static org.junit.Assert.*; import org.tmatesoft.svn.core.SVNURL; +import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.wc.SVNClientManager; +import org.tmatesoft.svn.core.wc.SVNRevision; /** * * @author poussin */ -public class VCSSVNTest { +public class VCSSVNTest extends TestCase { - VCSSVN instance = null; + static VCSSVN instance = null; public VCSSVNTest() { } - @BeforeClass - public static void setUpClass() throws Exception { - } + static final String fileContentTag = "Version 3.1.0"; + static final String fileContentTrunk = "Version 3.2.0"; + + static File template = new File("/tmp/testsvn-template"); + static File remoteRepo = new File("/tmp/testsvn-repo"); + static File localRepo = new File("/tmp/testsvn-local"); - @AfterClass - public static void tearDownClass() throws Exception { + static { + try { + // un peu de nettoyage + if (template.exists()) { + FileUtil.deleteRecursively(template); + } + if (remoteRepo.exists()) { + FileUtil.deleteRecursively(remoteRepo); + } + if (localRepo.exists()) { + FileUtil.deleteRecursively(localRepo); + } + + // 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 + // par la classe elle meme et ainsi tester que ca marche + instance = new VCSSVN( + localRepo, + "file", + "", + remoteRepo.getAbsolutePath() + "/" + "isis-fish-data", + null, + "", ""); + + + /////////////////////////////////////////////////////////////////// + // + // Creation d'un repo local avec un trunk et un tag + // durant le test, on modifie version.txt pour utiliser + // fileContentTrunk et modifier le contenu. On peut alors tester + // le changement de tag en fonction du contenu du fichier + /////////////////////////////////////////////////////////////////// + + // creation d'un template de directory + new File(template, "regions" + File.separator + "DemoRegion" + File.separator + "data").mkdirs(); + new File(template, "simulations" + File.separator + "simu1" + File.separator + "data").mkdirs(); + new File(template, "scripts").mkdirs(); + FileUtil.writeString(new File(template, "scripts" + File.separator + "version.txt"), fileContentTag); + + // creation du repo pour les tests + SVNRepositoryFactory.createLocalRepository(remoteRepo, false, true); + + // ajout de source dans le repo + SVNURL svnURL = SVNURL.parseURIDecoded("file://" + remoteRepo.getAbsolutePath()); + SVNURL svnRoot = svnURL.appendPath("isis-fish-data", false); + SVNURL svnTrunk = svnRoot.appendPath("trunk", false); + SVNURL svnTags = svnRoot.appendPath("tags", false); + + SVNClientManager svnManager = SVNClientManager.newInstance(); + // creation de l'arborescence + svnManager.getCommitClient().doMkDir(new SVNURL[]{svnRoot, svnTrunk, svnTags}, "add dir"); + svnManager.getCommitClient().doImport(template, svnTrunk, "initial import", true, true); + + svnManager.getCopyClient().doCopy(svnTrunk, SVNRevision.HEAD, svnTags.appendPath("3.1.0", false), false, true, "Create tag"); + + + +// instance = new VCSSVN( +// new File("/tmp/testsvn"), +//// "svn+ssh", +// "file", +// "localhost", +// "/tmp/svnkit/repos/isis-fish-data", +// new File("/home/poussin/.ssh/id_dsa"), +// "poussin", ""); + +// instance = new VCSSVN( +// new File("/tmp/testsvn"), +// "svn", +// "labs.libre-entreprise.org", +// "/svnroot/isis-fish-data", +// null, +// "anonymous", "anonymous"); + +// instance = new VCSSVN( +// new File("/tmp/testsvn"), +// "svn+ssh", +// "labs.libre-entreprise.org", +// "/svnroot/isis-fish-data", +// null, +// "anonymous", "anonymous"); + } catch (Exception eee) { + throw new RuntimeException(eee); + } } - @Before - public void setUp() { -// instance = new VCSSVN(config); + @Override + protected void tearDown() throws Exception { } /** * Test of getSVNManager method, of class VCSSVN. */ @Test - public void getSVNManager() { + public void testgetSVNManager() { System.out.println("getSVNManager"); - VCSSVN instance = null; - SVNClientManager expResult = null; SVNClientManager result = instance.getSVNManager(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + assertNotNull(result); } /** * Test of getRemoteURL method, of class VCSSVN. */ @Test - public void getRemoteURL() throws Exception { + public void testgetRemoteURL() throws Exception { System.out.println("getRemoteURL"); - VCSSVN instance = null; - SVNURL expResult = null; + SVNURL expResult = SVNURL.create("file", null, "", -1, + remoteRepo.getAbsolutePath() + "/" + "isis-fish-data", true); SVNURL result = instance.getRemoteURL(); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } - + /** - * Test of getLocalRepositoryRoot method, of class VCSSVN. - */ - @Test - public void getLocalRepositoryRoot() throws Exception { - System.out.println("getLocalRepositoryRoot"); - VCSSVN instance = null; - String expResult = ""; - String result = instance.getLocalRepositoryRoot(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - - /** - * Test of getLocalRepositorySource method, of class VCSSVN. - */ - @Test - public void getLocalRepositorySource() throws Exception { - System.out.println("getLocalRepositorySource"); - File f = null; - VCSSVN instance = null; - String expResult = ""; - String result = instance.getLocalRepositorySource(f); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - - /** - * Test of getRemoteRepository method, of class VCSSVN. - */ - @Test - public void getRemoteRepository() { - System.out.println("getRemoteRepository"); - VCSSVN instance = null; - String expResult = ""; - String result = instance.getRemoteRepository(); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - - /** * Test of isVersionnableAbleFile method, of class VCSSVN. */ @Test - public void isVersionnableAbleFile() { + public void testisVersionnableAbleFile() { System.out.println("isVersionnableAbleFile"); - File file = null; - VCSSVN instance = null; - boolean expResult = false; - boolean result = instance.isVersionnableAbleFile(file); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + { + // un fichier special, on refuse + File file = new File(".svn"); + boolean expResult = false; + boolean result = instance.isVersionnableAbleFile(file); + assertEquals(expResult, result); + } + { + // Pas dans le repository local, on refuse + File file = new File("Toto.java"); + boolean expResult = false; + boolean result = instance.isVersionnableAbleFile(file); + assertEquals(expResult, result); + } + { + // enfin un bout fichier :) + File file = new File(instance.getLocalRepository(), "Toto.java"); + boolean expResult = true; + boolean result = instance.isVersionnableAbleFile(file); + assertEquals(expResult, result); + } } - + /** - * Test of commit method, of class VCSSVN. + * Test of checkout method, of class VCSSVN. */ @Test - public void commit() throws Exception { - System.out.println("commit"); - List<File> files = null; - String msg = ""; - VCSSVN instance = null; - instance.commit(files, msg); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + public void testAll() throws Exception { + System.out.println("checkout"); + // on ne checkout rien juste le .svn dans le repertoire racine + instance.checkout(null, false); + assertTrue(instance.getLocalRepository().exists()); + + // update scripts dir + instance.update(new File(instance.getLocalRepository(), "scripts"), true); + File version = new File(instance.getLocalRepository(), "scripts" + File.separator + "version.txt"); + assertTrue(version.exists()); + assertEquals(fileContentTag, FileUtil.readAsString(version)); + + // modification du fichier version.txt + FileUtil.writeString(version, fileContentTrunk); + instance.commit(null, "modif du fichier version"); + assertEquals(fileContentTrunk, FileUtil.readAsString(version)); + + // recuperation de DemoRegion + File demo = new File(instance.getLocalRepository(), "regions" + File.separator + "DemoRegion"); + instance.update(demo, true); + assertTrue(demo.exists()); + + // suppression de DemoRegion + instance.delete(Arrays.asList(demo), "suppression d'une region"); + assertFalse(demo.exists()); + + // test switchTag + instance.setTag(new VersionNumber(3, 1, 0)); + assertEquals(fileContentTag, FileUtil.readAsString(version)); + assertTrue(demo.exists()); + } + /** * Test of add method, of class VCSSVN. */ @Test - public void add() throws Exception { + public void testadd() throws Exception { System.out.println("add"); - List<File> files = null; + List<File> files = new ArrayList<File>(); String msg = ""; - VCSSVN instance = null; instance.add(files, msg); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** - * Test of checkout method, of class VCSSVN. - */ - @Test - public void checkout() throws Exception { - System.out.println("checkout"); - File destDir = null; - String module = ""; - boolean recurse = false; - VCSSVN instance = null; - instance.checkout(destDir, module, recurse); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - - /** - * Test of delete method, of class VCSSVN. - */ - @Test - public void delete() throws Exception { - System.out.println("delete"); - List<File> files = null; - String msg = ""; - VCSSVN instance = null; - instance.delete(files, msg); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - - /** * Test of getChanglog method, of class VCSSVN. */ @Test - public void getChanglog() { + public void testgetChanglog() { System.out.println("getChanglog"); - List<File> files = null; - VCSSVN instance = null; - Map<File, String> expResult = null; + List<File> files = new ArrayList<File>(); + Map<File, String> expResult = new HashMap<File, String>(); Map<File, String> result = instance.getChanglog(files); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** * Test of getDiff method, of class VCSSVN. */ @Test - public void getDiff() throws Exception { + public void testgetDiff() throws Exception { System.out.println("getDiff"); File file = null; - VCSSVN instance = null; String expResult = ""; String result = instance.getDiff(file); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** * Test of getFileList method, of class VCSSVN. */ @Test - public void getFileList() throws Exception { + public void testgetFileList() throws Exception { System.out.println("getFileList"); File directory = null; - VCSSVN instance = null; List<String> expResult = null; List<String> result = instance.getFileList(directory); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** * Test of getUpdatedFile method, of class VCSSVN. */ @Test - public void getUpdatedFile() { + public void testgetUpdatedFile() { System.out.println("getUpdatedFile"); - VCSSVN instance = null; List<File> expResult = null; List<File> result = instance.getUpdatedFile(); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** * Test of haveUpdate method, of class VCSSVN. */ @Test - public void haveUpdate() { + public void testhaveUpdate() { System.out.println("haveUpdate"); - VCSSVN instance = null; boolean expResult = false; boolean result = instance.haveUpdate(); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** * Test of isConnected method, of class VCSSVN. */ @Test - public void isConnected() { + public void testisConnected() { System.out.println("isConnected"); - VCSSVN instance = null; - boolean expResult = false; + boolean expResult = true; boolean result = instance.isConnected(); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** * Test of isOnRemote method, of class VCSSVN. */ @Test - public void isOnRemote() throws Exception { + public void testisOnRemote() throws Exception { System.out.println("isOnRemote"); File file = null; - VCSSVN instance = null; boolean expResult = false; boolean result = instance.isOnRemote(file); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } /** * Test of isTag method, of class VCSSVN. */ @Test - public void isTag() { + public void testisTag() throws Exception { System.out.println("isTag"); - VersionNumber version = null; - VCSSVN instance = null; - boolean expResult = false; - boolean result = instance.isTag(version); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + { + VersionNumber version = new VersionNumber(3,1,0); + boolean expResult = true; + boolean result = instance.isTag(version); + assertEquals(expResult, result); + } + { + VersionNumber version = new VersionNumber(3,2,0); + boolean expResult = false; + boolean result = instance.isTag(version); + assertEquals(expResult, result); + } } /** * Test of isUpToDate method, of class VCSSVN. */ @Test - public void isUpToDate() throws Exception { + public void testisUpToDate() throws Exception { System.out.println("isUpToDate"); File file = null; - VCSSVN instance = null; boolean expResult = false; boolean result = instance.isUpToDate(file); assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); } - /** - * Test of update method, of class VCSSVN. - */ - @Test - public void update() throws Exception { - System.out.println("update"); - List<File> files = null; - VCSSVN instance = null; - boolean expResult = false; - boolean result = instance.update(files); - assertEquals(expResult, result); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - - /** - * Test of switchTag method, of class VCSSVN. - */ - @Test - public void switchTag() throws Exception { - System.out.println("switchTag"); - VersionNumber version = null; - VCSSVN instance = null; - instance.switchTag(version); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - - /** - * Test of switchProtocole method, of class VCSSVN. - */ - @Test - public void switchProtocole() throws Exception { - System.out.println("switchProtocole"); - String protocoleType = ""; - VCSSVN instance = null; - instance.switchProtocole(protocoleType); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); - } - } \ No newline at end of file