001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: package org.netbeans.jellytools.modules.javacvs;
042:
043: import java.io.ByteArrayInputStream;
044: import java.io.IOException;
045: import java.io.InputStream;
046: import junit.framework.Test;
047: import junit.framework.TestSuite;
048: import junit.textui.TestRunner;
049: import org.netbeans.jellytools.JellyTestCase;
050: import org.netbeans.jellytools.OptionsOperator;
051: import org.netbeans.jellytools.ProjectsTabOperator;
052: import org.netbeans.jemmy.JemmyException;
053: import org.netbeans.jemmy.operators.JFileChooserOperator;
054: import org.netbeans.junit.NbTestSuite;
055:
056: /**
057: * Test of org.netbeans.jellytools.modules.javacvs.ImportWizardOperator,
058: * BrowseRepositoryFolderOperator, FolderToImportStepOperator.
059: *
060: * @author Jiri.Skrivanek@sun.com
061: */
062: public class ImportWizardOperatorTest extends JellyTestCase {
063:
064: /** Use for internal test execution inside IDE
065: * @param args command line arguments
066: */
067: public static void main(java.lang.String[] args) {
068: TestRunner.run(suite());
069: }
070:
071: /** Method used for explicit testsuite definition
072: * @return created suite
073: */
074: public static Test suite() {
075: TestSuite suite = new NbTestSuite();
076: suite.addTest(new ImportWizardOperatorTest("testInvoke"));
077: suite.addTest(new ImportWizardOperatorTest("testSetCVSRoot"));
078: suite
079: .addTest(new ImportWizardOperatorTest(
080: "testFolderToImport"));
081: suite.addTest(new ImportWizardOperatorTest("testFinish"));
082: return suite;
083: }
084:
085: /** Set up executed before each test case. */
086: protected void setUp() {
087: System.out.println("### " + getName() + " ###");
088: }
089:
090: /** Constructor required by JUnit.
091: * @param testName method name to be used as testcase
092: */
093: public ImportWizardOperatorTest(String testName) {
094: super (testName);
095: }
096:
097: /** Test of invoke method.*/
098: public void testInvoke() {
099: ImportWizardOperator.invoke(ProjectsTabOperator.invoke()
100: .getProjectRootNode("SampleProject")); //NOI18N
101: }
102:
103: private static PseudoCvsServer cvss;
104:
105: /** Tests CVS root customizer. */
106: public void testSetCVSRoot() throws Exception {
107: CVSRootStepOperator cvsRootOper = new CVSRootStepOperator();
108: InputStream in = new ByteArrayInputStream(new byte[] { 'I',
109: ' ', 'L', 'O', 'V', 'E', ' ', 'Y', 'O', 'U', '\n' });
110: try {
111: cvss = new PseudoCvsServer(in);
112: } catch (IOException ioe) {
113: throw new JemmyException(
114: "Error initializing PseudoCvsServer: " + ioe);
115: }
116: cvss.ignoreProbe();
117: new Thread(cvss).start();
118: cvsRootOper.setCVSRoot(cvss.getCvsRoot());
119: OptionsOperator proxyOper = cvsRootOper.proxyConfiguration();
120: proxyOper.close();
121: cvsRootOper.next();
122: }
123:
124: /** Test Folder to Import panel of wizard. */
125: public void testFolderToImport() throws Exception {
126: FolderToImportStepOperator folderToImportOper = new FolderToImportStepOperator();
127: folderToImportOper.setFolderToImport(getWorkDirPath());
128: JFileChooserOperator browseFolder = folderToImportOper
129: .browseFolderToImport();
130: assertEquals(
131: "Directory set in wizard not propagated to file chooser:",
132: getWorkDir().getAbsolutePath(), browseFolder
133: .getCurrentDirectory().getAbsolutePath()); // NOI18N
134: browseFolder.cancel();
135: folderToImportOper.setImportMessage("Import message"); //NOI18N
136: folderToImportOper.setRepositoryFolder("folder");
137: BrowseRepositoryFolderOperator browseRepositoryOper = folderToImportOper
138: .browseRepositoryFolder();
139: browseRepositoryOper.selectFolder(""); // NOI18N
140: browseRepositoryOper.ok();
141: folderToImportOper.checkCheckoutAfterImport(false);
142: }
143:
144: /** Test finish wizard. */
145: public void testFinish() throws Exception {
146: cvss.stop();
147: // Cancel wizard (finish is possible but causes an error because
148: // of use of pseudo pserver.
149: new ImportWizardOperator().cancel();
150: }
151: }
|