r427 - in trunk/lutinvcs: lutinvcs-all/src/test/java/org/codelutin/vcs/ui lutinvcs-ui-jaxx/src/test/java/org/codelutin/vcs/ui
Author: tchemit Date: 2008-04-06 18:35:04 +0000 (Sun, 06 Apr 2008) New Revision: 427 Added: trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java Removed: trunk/lutinvcs/lutinvcs-ui-jaxx/src/test/java/org/codelutin/vcs/ui/UITest.java Log: create lutinvcs-all module (will be also used to make global tests) Copied: trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java (from rev 423, trunk/lutinvcs/lutinvcs-ui-jaxx/src/test/java/org/codelutin/vcs/ui/UITest.java) =================================================================== --- trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java (rev 0) +++ trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-06 18:35:04 UTC (rev 427) @@ -0,0 +1,95 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * 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 org.codelutin.vcs.ui; + +import org.codelutin.i18n.I18n; +import org.codelutin.vcs.VCSConnexion; +import org.codelutin.vcs.VCSEntry; +import org.codelutin.vcs.VCSFactory; +import org.codelutin.vcs.type.VCSConnexionMode; +import org.codelutin.vcs.type.VCSEntryLocation; +import org.codelutin.vcs.type.VCSState; +import org.codelutin.vcs.ui.model.SynchUIModel; +import org.codelutin.vcs.util.VCSConnexionConfigImpl; +import org.codelutin.vcs.util.VCSEntryImpl; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** @author chemit */ +public class UITest { + + /** The r. */ + static java.util.Random r = new java.util.Random(); + + public static void main(String[] args) { + + I18n.init(); + + VCSConnexion connexion = initVCS(new File(new File("").getAbsolutePath())); + + try { + connexion.open(); + + AbstractSynchUI ui = VCSUIFactory.newSynchUI(); + + fillSynchModel(connexion, ui.getModel(), 20, "trunk", "local/", "remote/"); + + ui.setVisible(true); + + } finally { + connexion.close(); + } + } + + public static VCSConnexion initVCS(File root) { + VCSConnexionConfigImpl config = new VCSConnexionConfigImpl(); + config.setType("MOCK"); + config.setLocalDatabasePath(root); + VCSConnexion connexion = VCSFactory.newConnexion(VCSConnexionMode.ANONYMOUS, config); + connexion.init(config); + return connexion; + } + + protected static void fillSynchModel(VCSConnexion handler, SynchUIModel model, int max, String prefix, String localPRefix, String remotePrefix) { + List<VCSEntry> datas = generateListFileStates(handler, max, prefix, localPRefix, remotePrefix); + model.populate(VCSEntryLocation.UNKNOW, datas.toArray(new VCSEntry[datas.size()])); + } + + protected static List<VCSEntry> generateListFileStates(VCSConnexion handler, int max, String prefix, String localPRefix, String remotePrefix) { + List<VCSEntry> datas = generateLocalFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), localPRefix); + datas.addAll(generateRemoteFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), remotePrefix)); + return datas; + } + + protected static List<VCSEntry> generateLocalFileStates(VCSConnexion handler, int max, File root, String localPRefix) { + return generateFileStates(handler, root, max, localPRefix, VCSState.MODIFIED, VCSState.UNVERSIONNED, VCSState.OUT_OF_DATE_AND_MODIFIED, VCSState.REMOVED); + } + + protected static List<VCSEntry> generateRemoteFileStates(VCSConnexion handler, int max, File root, String remotePRefix) { + return generateFileStates(handler, root, max, remotePRefix, VCSState.MISSING, VCSState.OUT_OF_DATE, VCSState.OUT_OF_DATE_AND_MODIFIED); + } + + protected static List<VCSEntry> generateFileStates(VCSConnexion handler, File root, int max, String prefix, VCSState... states) { + List<VCSEntry> datas = new ArrayList<VCSEntry>(); + for (int i = 0, nbFiles = 1 + r.nextInt(max), size = states.length; i < nbFiles; i++) { + VCSEntry state = new VCSEntryImpl(handler, root.getName() + File.separator + prefix + "file" + i); + state.setState(states[r.nextInt(size)]); + datas.add(state); + } + return datas; + } +} Deleted: trunk/lutinvcs/lutinvcs-ui-jaxx/src/test/java/org/codelutin/vcs/ui/UITest.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-jaxx/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-06 18:34:25 UTC (rev 426) +++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-06 18:35:04 UTC (rev 427) @@ -1,95 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * 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 org.codelutin.vcs.ui; - -import org.codelutin.i18n.I18n; -import org.codelutin.vcs.VCSConnexion; -import org.codelutin.vcs.VCSEntry; -import org.codelutin.vcs.VCSFactory; -import org.codelutin.vcs.type.VCSConnexionMode; -import org.codelutin.vcs.type.VCSEntryLocation; -import org.codelutin.vcs.type.VCSState; -import org.codelutin.vcs.ui.model.SynchUIModel; -import org.codelutin.vcs.util.VCSConnexionConfigImpl; -import org.codelutin.vcs.util.VCSEntryImpl; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** @author chemit */ -public class UITest { - - /** The r. */ - static java.util.Random r = new java.util.Random(); - - public static void main(String[] args) { - - I18n.init(); - - VCSConnexion connexion = initVCS(new File(new File("").getAbsolutePath())); - - try { - connexion.open(); - - AbstractSynchUI ui = VCSUIFactory.newSynchUI(); - - fillSynchModel(connexion, ui.getModel(), 20, "trunk", "local/", "remote/"); - - ui.setVisible(true); - - } finally { - connexion.close(); - } - } - - public static VCSConnexion initVCS(File root) { - VCSConnexionConfigImpl config = new VCSConnexionConfigImpl(); - config.setType("MOCK"); - config.setLocalDatabasePath(root); - VCSConnexion connexion = VCSFactory.newConnexion(VCSConnexionMode.ANONYMOUS, config); - connexion.init(config); - return connexion; - } - - protected static void fillSynchModel(VCSConnexion handler, SynchUIModel model, int max, String prefix, String localPRefix, String remotePrefix) { - List<VCSEntry> datas = generateListFileStates(handler, max, prefix, localPRefix, remotePrefix); - model.populate(VCSEntryLocation.UNKNOW, datas.toArray(new VCSEntry[datas.size()])); - } - - protected static List<VCSEntry> generateListFileStates(VCSConnexion handler, int max, String prefix, String localPRefix, String remotePrefix) { - List<VCSEntry> datas = generateLocalFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), localPRefix); - datas.addAll(generateRemoteFileStates(handler, max, new File(handler.getConfig().getLocalDatabasePath(), prefix), remotePrefix)); - return datas; - } - - protected static List<VCSEntry> generateLocalFileStates(VCSConnexion handler, int max, File root, String localPRefix) { - return generateFileStates(handler, root, max, localPRefix, VCSState.MODIFIED, VCSState.UNVERSIONNED, VCSState.OUT_OF_DATE_AND_MODIFIED, VCSState.REMOVED); - } - - protected static List<VCSEntry> generateRemoteFileStates(VCSConnexion handler, int max, File root, String remotePRefix) { - return generateFileStates(handler, root, max, remotePRefix, VCSState.MISSING, VCSState.OUT_OF_DATE, VCSState.OUT_OF_DATE_AND_MODIFIED); - } - - protected static List<VCSEntry> generateFileStates(VCSConnexion handler, File root, int max, String prefix, VCSState... states) { - List<VCSEntry> datas = new ArrayList<VCSEntry>(); - for (int i = 0, nbFiles = 1 + r.nextInt(max), size = states.length; i < nbFiles; i++) { - VCSEntry state = new VCSEntryImpl(handler, root.getName() + File.separator + prefix + "file" + i); - state.setState(states[r.nextInt(size)]); - datas.add(state); - } - return datas; - } -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org