Some test code for org-netbeans-Lib-cvsclient

Source: Internet
Author: User
Tags netbeans

I wrote some test code for cvsclient and recorded it here:

/*** Test cvsclient * @ author linshutao **/import Java. io. file; import Java. io. fileoutputstream; import Java. io. ioexception; import Java. io. printstream; import Org. netbeans. lib. cvsclient. cvsroot; import Org. netbeans. lib. cvsclient. client; import Org. netbeans. lib. cvsclient. admin. entry; import Org. netbeans. lib. cvsclient. admin. standardadminhandler; import Org. netbeans. lib. cvsclient. command. builder; import org. Netbeans. lib. cvsclient. command. commandabortedexception; import Org. netbeans. lib. cvsclient. command. commandexception; import Org. netbeans. lib. cvsclient. command. globaloptions; import Org. netbeans. lib. cvsclient. command. checkout. checkoutcommand; import Org. netbeans. lib. cvsclient. command. commit. commitcommand; import Org. netbeans. lib. cvsclient. command. diff. diffcommand; import Org. netbeans. lib. cvsclient. comman D. diff. diffinformation; import Org. netbeans. lib. cvsclient. command. diff. simplediffbuilder; import Org. netbeans. lib. cvsclient. command. log. logcommand; import Org. netbeans. lib. cvsclient. commandLine. basiclistener; import Org. netbeans. lib. cvsclient. connection. authenticationexception; import Org. netbeans. lib. cvsclient. connection. connection; import Org. netbeans. lib. cvsclient. connection. connectionfactory; import Org. netbeans. lib. cvsclient. event. eventmanager; import JUnit. framework. testcase; public class cvsclienttest extends testcase {/** CVS clinet instance used to communicate with CVS server */Private Static client cvsclient = NULL; /** CVS connect string */Private Static cvsroot = NULL;/** connection instance to keep connect with CVS server */Private Static connection = NULL;/** GL Obal options to store the requied parameter for CVS server */Private Static globaloptions = NULL;/** the local path on ur Local Machine */Private Static string localpath = "D: /cvs_checkout ";/** connection string */Final Static string connection_string =": pserver: linshutao: 123456@168.168.0.77:/home/cvsroot "; public connection openconnection () throws authenticationexception, ioexception, comman Dexception {cvsroot = cvsroot. parse (connection_string); connection = connectionfactory. getconnection (cvsroot); cvsclient = new client (connection, new standardadminhandler (); cvsclient. setlocalpath (localpath); cvsclient. geteventmanager (). addcvslistener (New basiclistener (); connection. open (); globaloptions = new globaloptions (); globaloptions. setcvsroot (cvsroot. parse (connection_string ). getrepository (); Return connection;} public client getcvsclient () throws authenticationexception, ioexception, commandexception {If (cvsclient = NULL) {openconnection ();} return cvsclient ;} public void closeconnection () throws ioexception {If (connection! = NULL) {connection. close () ;}// redirect output stream public static void systemsetout () {try {file test = new file ("D:/test.txt"); test. createnewfile (); printstream out = new printstream (New fileoutputstream (TEST); // printstream out = new printstream (new string (); system. setout (out);} catch (exception e) {}}/** start test... */Public void testlogcommand () throws commandabortedexception, commandexception, authenticationexception, ioexception {openconnection (); logcommand = new logcommand (); logcommand. setfiles (new file [] {New file ("D:/cvs_checkout/im800kbs/src/web/COM/syni/im800/KB/Attendant/webapp/Action/kbsentryaction. java ") Export cutecommand (logcommand, globaloptions); closeconnection ();} public void testcheckoutcommand () throws authenticationexception, ioexception, commandexception {openconnection (); checkoutcommand = new checkoutcommand (); checkoutcommand. setmodule ("im800kbs"); // only output information without output file // checkoutcommand. setpipetooutput (true); checkoutcommand. setrecursive (true); checkoutcommand. setcheckoutbyrevision ("v1-3-1-1000" );cvsclient.exe cutecommand (checkoutcommand, globaloptions); closeconnection ();} public void testcommitcommand () throws authenticationexception, ioexception, commandexception {openconnection (); commitcommand = new commitcommand (); file files [] = {New file ("D: /cvs_checkout/im800kbs/src/web/COM/syni/im800/KB/Attendant/webapp/Action/ABC. java "javascutecommand (commitcommand, globaloptions); closeconnection ();} public void testdiffcommand () throws authenticationexception, ioexception, commandexception {systemsetout (); openconnection (); diffcommand = new diffcommand ();/*** comparison of two different versions of a file * setrevision1: Set a version. If not set, compare it with a local file * setrevision2: set another version ** // diffcommand. setrevision1 ("1.64.2.229"); diffcommand. setrevision2 ("1.64.2.230"); diffcommand. setfiles (new file [] {New file ("D:/cvs_checkout/im800kbs/src/web/COM/syni/im800/KB/Attendant/webapp/Action/kbsentryaction. java "Export cutecommand (diffcommand, globaloptions); closeconnection ();} public void testdiffinformation () throws authenticationexception, ioexception, commandexception {openconnection (); eventmanager em = new eventmanager (cvsclient ); em. addcvslistener (New basiclistener (); diffcommand = new diffcommand (); diffcommand. setfiles (new file [] {New file ("D:/cvs_checkout/im800kbs/src/web/COM/syni/im800/KB/Attendant/webapp/Action/kbsentryaction. java ")}); // diffcommand. setrevision1 ("1.64.2.229"); diffcommand. setrevision2 ("1.64.2.230"); simplediffbuilder SDB = new simplediffbuilder (EM, diffcommand); // cvsclient.exe cutecommand (diffcommand, globaloptions); diffinformation diffinfo = SDB. creatediffinformation (); diffinfo. setrepositoryfilename ("D:/cvs_checkout/im800kbs/src/web/COM/syni/im800/KB/Attendant/webapp/Action/kbsentryaction. java "); diffinfo. setleftrevision ("1.64.2.229"); diffinfo. setrightrevision ("1.64.2.230"); system. out. println (diffinfo. getfirstchange ();/* file difffile = new file ("D:/diff.txt"); difffile. createnewfile (); diffinfo. setbook (difffile); diffinfo. setrepositoryfilename ("D:/cvs_checkout/im800kbs/src/web/COM/syni/im800/KB/Attendant/webapp/Action/kbsentryaction. java "); diffinfo. setleftrevision ("1.64.2.220"); diffinfo. setrightrevision ("1.64.2.230"); */closeconnection ();} public void testentry () throws authenticationexception, ioexception, commandexception {systemsetout (); openconnection (); file file = new file ("D:/cvs_checkout/im800kbs/src/web/COM/syni/im800/KB/Attendant/webapp/form/kbsentryform. java "); entry = cvsclient. getentry (File); system. out. println (entry. getrevision (); closeconnection ();}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.