|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package complete.pvcs_profile;
import java.io.*;
import junit.framework.*;
import org.netbeans.junit.*;
import org.netbeans.test.oo.gui.jelly.*;
import org.netbeans.jemmy.JemmyProperties;
import org.netbeans.jemmy.TestOut;
import org.netbeans.jemmy.util.PNGEncoder;
import org.netbeans.jemmy.TimeoutExpiredException;
import org.netbeans.jemmy.operators.*;
import org.netbeans.jellytools.modules.vcsgeneric.wizard.*;
import org.netbeans.jellytools.modules.vcsgeneric.pvcs.*;
import org.netbeans.jellytools.modules.vcscore.*;
import org.openide.util.Utilities;
import org.netbeans.jellytools.*;
import org.netbeans.jellytools.nodes.*;
import org.netbeans.jellytools.actions.*;
import org.netbeans.jellytools.properties.*;
import javax.swing.text.*;
import java.awt.Color;
import java.util.Date;
/** XTest / JUnit test class performing regular development testing on PVCS filesystem.
* @author Jiri Kovalsky
* @version 1.0
*/
public class RegularDevelopment extends NbTestCase {
public static String VERSIONING_MENU = "Versioning";
public static String MOUNT_MENU = VERSIONING_MENU + "|Mount Version Control|Generic VCS";
public static String REFRESH = "PVCS|Refresh";
public static String RECURSIVE_REFRESH = "PVCS|Refresh Recursively";
public static String GET = "PVCS|Get";
public static String DIFF = "PVCS|Diff";
public static String PUT = "PVCS|Put";
public static String HISTORY = "PVCS|History";
public static String UNLOCK = "PVCS|Unlock";
public static String REMOVE_REVISION = "PVCS|Remove Revision";
public static String LOCK = "PVCS|Lock";
public static String VERSIONING_EXPLORER = "Versioning Explorer";
public static String workingDirectory;
public static String userName;
private static final Color MODIFIED_COLOR = new Color(160, 200, 255);
private static final Color NEW_COLOR = new Color(180, 255, 180);
private static final Color REMOVED_COLOR = new Color(255, 160, 180);
/** Constructor required by JUnit.
* @param testName Method name to be used as testcase.
*/
public RegularDevelopment(String testName) {
super(testName);
}
/** Method used for explicit test suite definition.
* @return RegularDevelopment test suite.
*/
public static junit.framework.Test suite() {
TestSuite suite = new NbTestSuite();
String exec = Utilities.isUnix() ? "sh -c \"vlog\"" : "cmd /x /c \"vlog\"";
try { if (Runtime.getRuntime().exec(exec).waitFor() != 0 ) return suite; }
catch (Exception e) {}
suite.addTest(new RegularDevelopment("testCheckoutFile"));
suite.addTest(new RegularDevelopment("testModifyFile"));
suite.addTest(new RegularDevelopment("testViewDifferences"));
suite.addTest(new RegularDevelopment("testCheckinFile"));
suite.addTest(new RegularDevelopment("testViewHistory"));
suite.addTest(new RegularDevelopment("testUnlockFile"));
suite.addTest(new RegularDevelopment("testGetMissingFile"));
suite.addTest(new RegularDevelopment("testRemoveRevision"));
suite.addTest(new RegularDevelopment("testCreateOwnRevision"));
suite.addTest(new RegularDevelopment("testCheckoutRevision"));
suite.addTest(new RegularDevelopment("testLockFile"));
suite.addTest(new RegularDevelopment("testCreateBranch"));
suite.addTest(new RegularDevelopment("testVersioningExplorer"));
return suite;
}
/** Use for internal test execution inside IDE.
* @param args Command line arguments.
*/
public static void main(java.lang.String[] args) {
junit.textui.TestRunner.run(suite());
}
/** Method called before each testcase. Sets default timeouts, redirects system
* output and maps main components.
*/
protected void setUp() throws Exception {
String workingDir = getWorkDirPath();
new java.io.File(workingDir).mkdirs();
java.io.File outputFile = new java.io.File(workingDir + "/output.txt");
outputFile.createNewFile();
java.io.File errorFile = new java.io.File(workingDir + "/error.txt");
errorFile.createNewFile();
java.io.PrintWriter outputWriter = new java.io.PrintWriter(new java.io.FileWriter(outputFile));
java.io.PrintWriter errorWriter = new java.io.PrintWriter(new java.io.FileWriter(errorFile));
org.netbeans.jemmy.JemmyProperties.setCurrentOutput(new org.netbeans.jemmy.TestOut(System.in, outputWriter, errorWriter));
}
/** Method will create a file and capture the screen.
*/
private void captureScreen(String reason) throws Exception {
File file;
try {
file = new File(getWorkDirPath() + "/dump.png");
file.getParentFile().mkdirs();
file.createNewFile();
} catch(IOException e) { throw new Exception("Error: Can't create dump file."); }
PNGEncoder.captureScreen(file.getAbsolutePath());
throw new Exception(reason);
}
/** Tries to checkout a file from PVCS project database.
* @throws Exception any unexpected exception thrown during test.
*/
public void testCheckoutFile() throws Exception {
System.out.print(".. Testing checking out a file ..");
String workingPath = getWorkDirPath();
workingDirectory = workingPath.substring(0, workingPath.indexOf("RegularDevelopment")) + "RepositoryCreation" + File.separator + "testCreateDatabase";
String filesystem = "PVCS " + workingDirectory + File.separator + "Work";
Node filesystemNode = null;
try { filesystemNode = new Node(new ExplorerOperator().repositoryTab().getRootNode(), filesystem); }
catch (TimeoutExpiredException e) { captureScreen("Error: Can't find " + filesystem + " filesystem node."); }
Node A_FileNode = null;
try { A_FileNode = new Node( filesystemNode, "A_File [Current]"); }
catch (TimeoutExpiredException e) { captureScreen("Error: Can't find A_File [Current] node."); }
filesystemNode.select();
new ComboBoxProperty(new PropertySheetOperator(), "Advanced Options").setValue("False");
new Action(VERSIONING_MENU + "|" + GET, GET).perform(A_FileNode);
GetCommandOperator getCommand = new GetCommandOperator("A_File.java");
getCommand.checkLockForTheCurrentUser(true);
getCommand.checkCheckOutWritableWorkfile(true);
getCommand.ok();
MainWindowOperator.getDefault().waitStatusText("Command Refresh finished.");
String children[] = filesystemNode.getChildren();
int count = children.length;
boolean found = false;
for(int i=0; i
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.